On Mon, Apr 06, 2015 at 11:27:06AM -0400, Russell Bryant wrote: > When ovn-nbd is looking through bindings to figure out if any logical > ports in the northbound DB need to have their 'up' state changed, it > should be using the logical port's name instead of UUID for matching > up to rows in the OVN db. > > The switch to using the name instead of UUID means we don't have a > quick lookup so we use the same approach that's used for handling > updates in the other direction. We start by hashing all of the > logical ports by name. As we iterate through the bindings, we can > then look up ports by name quickly. > > Signed-off-by: Russell Bryant <rbry...@redhat.com>
The following is risky because HMAP_FOR_EACH_WITH_HASH doesn't necessarily leave its first argument ('hash_node' in this case) NULL when the loop finishes. Instead, it will be, in this case, &hash_node->node. Since 'node' is the first member in lport_hash_node, that works out OK here, but reordering members will cause it to blow up, so I try to avoid this kind of construction. HMAP_FOR_EACH_WITH_HASH(hash_node, node, hash_string(binding->logical_port, 0), &lports_hmap) { if (!strcmp(binding->logical_port, hash_node->lport->name)) { break; } } if (!hash_node) { /* The logical port doesn't exist for this binding. This can happen * under normal circumstances when ovn-nbd hasn't gotten around to * pruning the Binding yet. */ continue; } This has caught people out before, so now I've sent out a patch that should make it more obvious: http://openvswitch.org/pipermail/dev/2015-April/053401.html _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev