vswitchd: Delete 'ifaces' pointer to interface when deleting interface.
authorBen Pfaff <blp@nicira.com>
Fri, 9 Jan 2009 23:18:36 +0000 (15:18 -0800)
committerBen Pfaff <blp@nicira.com>
Fri, 9 Jan 2009 23:18:36 +0000 (15:18 -0800)
Otherwise we dereference a dangling pointer to the interface when we
look up the interface by datapath port index, causing a segfault.

Introduced in commit 150ac45, "vswitchd: Eliminate "can't forward to bad
port" when interfaces disappear," which deletes an interface that is known
to be in the datapath port index table.

vswitchd/bridge.c

index 78a83504252452c5a59ed0bf6a4c0912613a7489..f4735c76748ecb8246d46b34118d167568dae534 100644 (file)
@@ -2552,9 +2552,14 @@ iface_destroy(struct iface *iface)
 {
     if (iface) {
         struct port *port = iface->port;
+        struct bridge *br = port->bridge;
         bool del_active = port->active_iface == iface->port_ifidx;
         struct iface *del;
 
+        if (iface->dp_ifidx >= 0) {
+            port_array_set(&br->ifaces, iface->dp_ifidx, NULL);
+        }
+
         del = port->ifaces[iface->port_ifidx] = port->ifaces[--port->n_ifaces];
         del->port_ifidx = iface->port_ifidx;