@@ -46,6 +46,7 @@ static struct net_device *failover_get_bymac(u8 *mac, struct failover_ops **ops)
static int failover_slave_register(struct net_device *slave_dev)
{
struct netdev_lag_upper_info lag_upper_info;
+ struct nd_lock *nd_lock, *nd_lock2;
struct net_device *failover_dev;
struct failover_ops *fops;
int err;
@@ -72,8 +73,14 @@ static int failover_slave_register(struct net_device *slave_dev)
}
lag_upper_info.tx_type = NETDEV_LAG_TX_TYPE_ACTIVEBACKUP;
+
+ double_lock_netdev(slave_dev, &nd_lock, failover_dev, &nd_lock2);
+ nd_lock_transfer_devices(&nd_lock, &nd_lock2);
+
err = netdev_master_upper_dev_link(slave_dev, failover_dev, NULL,
&lag_upper_info, NULL);
+ double_unlock_netdev(nd_lock, nd_lock2);
+
if (err) {
netdev_err(slave_dev, "can not set failover device %s (err = %d)\n",
failover_dev->name, err);
@@ -182,6 +189,18 @@ static int failover_slave_name_change(struct net_device *slave_dev)
return NOTIFY_DONE;
}
+static void call_failover_slave_register(struct net_device *dev)
+{
+ rtnl_lock();
+ if (dev->reg_state == NETREG_REGISTERED) {
+ failover_slave_register(dev);
+ failover_slave_link_change(dev);
+ failover_slave_name_change(dev);
+
+ }
+ rtnl_unlock();
+}
+
static int
failover_event(struct notifier_block *this, unsigned long event, void *ptr)
{
@@ -193,7 +212,10 @@ failover_event(struct notifier_block *this, unsigned long event, void *ptr)
switch (event) {
case NETDEV_REGISTER:
- return failover_slave_register(event_dev);
+ if (netdev_is_rx_handler_busy(event_dev))
+ return NOTIFY_DONE;
+ return schedule_delayed_event(event_dev,
+ call_failover_slave_register);
case NETDEV_UNREGISTER:
return failover_slave_unregister(event_dev);
case NETDEV_UP:
We don't want to do this in failover_event(), since we want to call netdevice notifiers with nd_lock already locked in the future. Also see comments in patch introducing schedule_delayed_event() Signed-off-by: Kirill Tkhai <tkhai@ya.ru> --- net/core/failover.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)