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.
/* 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++;
}