bridge: Always delete the correct interfaces in port_del_ifaces().
authorBen Pfaff <blp@nicira.com>
Fri, 18 Mar 2011 17:56:28 +0000 (10:56 -0700)
committerBen Pfaff <blp@nicira.com>
Mon, 21 Mar 2011 16:35:35 +0000 (09:35 -0700)
This code was checking a name from cfg->interfaces[i] but using the result
to decide whether to delete port->ifaces[i].  The two arrays aren't
necessarily in the same order so this code could delete the wrong iface.

Found by inspection.  This is probably not a common problem in practice
because I imagine that deleting an interface from a bond, without deleting
the bond itself, is a rare operation.  The problem would also be
intermittent--after a few switch reconfiguration cycles I imagine that
the problem would resolve.

vswitchd/bridge.c

index c082e5d..1bf4148 100644 (file)
@@ -3962,8 +3962,9 @@ port_del_ifaces(struct port *port, const struct ovsrec_port *cfg)
 
     /* Get rid of deleted interfaces. */
     for (i = 0; i < port->n_ifaces; ) {
-        if (!shash_find(&new_ifaces, cfg->interfaces[i]->name)) {
-            iface_destroy(port->ifaces[i]);
+        struct iface *iface = port->ifaces[i];
+        if (!shash_find(&new_ifaces, iface->name)) {
+            iface_destroy(iface);
         } else {
             i++;
         }