msleep(10);
rtnl_lock();
+ /* Since we released the RTNL lock, we have to make sure that
+ * our devices still exist. (But as long as they still exist,
+ * there's no point in refreshing 'dp' or 'dp_dev', since
+ * ifindexes are reused very slowly if ever.) */
dev = __dev_get_by_index(&init_net, dev_ifindex);
port = __dev_get_by_index(&init_net, port_ifindex);
if (!dev || !port)
return -ENODEV;
- if (add && port->br_port)
- return port->br_port->dev ? 0 : -EBUSY;
- else if (!add && !port->br_port)
- return 0;
+ if (add) {
+ if (port->br_port)
+ return port->br_port->dp == dp ? 0 : -EBUSY;
+ } else {
+ if (!port->br_port || port->br_port->dp != dp)
+ return 0;
+ }
}
return -ETIMEDOUT;