[ovs-dev] openvswitch-2.4 possible bug in hmap_remove

Richurov Kes kesri1234 at rediffmail.com
Mon Oct 5 18:30:31 UTC 2015



Dear Justin,

There appears to be some problem with the mailing list as it formats whatever I cut paste from gdb. I have tried it three times, but it fail each time. It is somewhat captured correctly in your mailing archive below:
http://openvswitch.org/pipermail/dev/2015-October/060884.html
However it is still garbled toward the end. Our main concern is why is hmap_remove picking up bucket 7 instead of 6? Was it because of any resizing of the hmap array? The crash happen randomly, sometime after adding ports or even after sending some basic pings between VMs on the switch.

Also, may not be connected to this problem, but I noticed that hmap_remove is lacking basic NULL pointer check and it can crash if it is called on an empty hmap pointer. Should it not return failure instead of crashing in these situations? We thought it could be modified as follows:
<pre>voidhmap_remove(struct hmap *hmap, struct hmap_node *node){    struct hmap_node *bucket = &hmap->buckets[node->hash & hmap->mask];
    if (!*bucket) {        return;    }    while (bucket && *bucket != node) {        bucket = *bucket ? &(*bucket)->next : NULL;    }    if (!*bucket) {        return;    }    *bucket = node->next;    hmap->n--;}</pre>
Thanking you,Richukov



More information about the dev mailing list