Commit 8d8fc29d authored by Amerigo Wang's avatar Amerigo Wang Committed by David S. Miller

netpoll: disable netpoll when enslave a device

V3: rename NETDEV_ENSLAVE to NETDEV_JOIN

Currently we do nothing when we enslave a net device which is running netconsole.
Neil pointed out that we may get weird results in such case, so let's disable
netpoll on the device being enslaved. I think it is too harsh to prevent
the device being ensalved if it is running netconsole.

By the way, this patch also removes the NETDEV_GOING_DOWN from netconsole
netdev notifier, because netpoll will check if the device is running or not
and we don't handle NETDEV_PRE_UP neither.

This patch is based on net-next-2.6.
Signed-off-by: default avatarWANG Cong <amwang@redhat.com>
Cc: Neil Horman <nhorman@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a37dd333
...@@ -1640,6 +1640,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) ...@@ -1640,6 +1640,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
} }
} }
call_netdevice_notifiers(NETDEV_JOIN, slave_dev);
/* If this is the first slave, then we need to set the master's hardware /* If this is the first slave, then we need to set the master's hardware
* address to be the same as the slave's. */ * address to be the same as the slave's. */
if (is_zero_ether_addr(bond->dev->dev_addr)) if (is_zero_ether_addr(bond->dev->dev_addr))
......
...@@ -621,11 +621,10 @@ static int netconsole_netdev_event(struct notifier_block *this, ...@@ -621,11 +621,10 @@ static int netconsole_netdev_event(struct notifier_block *this,
bool stopped = false; bool stopped = false;
if (!(event == NETDEV_CHANGENAME || event == NETDEV_UNREGISTER || if (!(event == NETDEV_CHANGENAME || event == NETDEV_UNREGISTER ||
event == NETDEV_BONDING_DESLAVE || event == NETDEV_GOING_DOWN)) event == NETDEV_BONDING_DESLAVE || event == NETDEV_JOIN))
goto done; goto done;
spin_lock_irqsave(&target_list_lock, flags); spin_lock_irqsave(&target_list_lock, flags);
restart:
list_for_each_entry(nt, &target_list, list) { list_for_each_entry(nt, &target_list, list) {
netconsole_target_get(nt); netconsole_target_get(nt);
if (nt->np.dev == dev) { if (nt->np.dev == dev) {
...@@ -633,6 +632,8 @@ static int netconsole_netdev_event(struct notifier_block *this, ...@@ -633,6 +632,8 @@ static int netconsole_netdev_event(struct notifier_block *this,
case NETDEV_CHANGENAME: case NETDEV_CHANGENAME:
strlcpy(nt->np.dev_name, dev->name, IFNAMSIZ); strlcpy(nt->np.dev_name, dev->name, IFNAMSIZ);
break; break;
case NETDEV_BONDING_DESLAVE:
case NETDEV_JOIN:
case NETDEV_UNREGISTER: case NETDEV_UNREGISTER:
/* /*
* rtnl_lock already held * rtnl_lock already held
...@@ -647,11 +648,7 @@ static int netconsole_netdev_event(struct notifier_block *this, ...@@ -647,11 +648,7 @@ static int netconsole_netdev_event(struct notifier_block *this,
dev_put(nt->np.dev); dev_put(nt->np.dev);
nt->np.dev = NULL; nt->np.dev = NULL;
netconsole_target_put(nt); netconsole_target_put(nt);
goto restart;
} }
/* Fall through */
case NETDEV_GOING_DOWN:
case NETDEV_BONDING_DESLAVE:
nt->enabled = 0; nt->enabled = 0;
stopped = true; stopped = true;
break; break;
...@@ -660,10 +657,21 @@ static int netconsole_netdev_event(struct notifier_block *this, ...@@ -660,10 +657,21 @@ static int netconsole_netdev_event(struct notifier_block *this,
netconsole_target_put(nt); netconsole_target_put(nt);
} }
spin_unlock_irqrestore(&target_list_lock, flags); spin_unlock_irqrestore(&target_list_lock, flags);
if (stopped && (event == NETDEV_UNREGISTER || event == NETDEV_BONDING_DESLAVE)) if (stopped) {
printk(KERN_INFO "netconsole: network logging stopped on " printk(KERN_INFO "netconsole: network logging stopped on "
"interface %s as it %s\n", dev->name, "interface %s as it ", dev->name);
event == NETDEV_UNREGISTER ? "unregistered" : "released slaves"); switch (event) {
case NETDEV_UNREGISTER:
printk(KERN_CONT "unregistered\n");
break;
case NETDEV_BONDING_DESLAVE:
printk(KERN_CONT "released slaves\n");
break;
case NETDEV_JOIN:
printk(KERN_CONT "is joining a master device\n");
break;
}
}
done: done:
return NOTIFY_DONE; return NOTIFY_DONE;
......
...@@ -211,6 +211,7 @@ static inline int notifier_to_errno(int ret) ...@@ -211,6 +211,7 @@ static inline int notifier_to_errno(int ret)
#define NETDEV_UNREGISTER_BATCH 0x0011 #define NETDEV_UNREGISTER_BATCH 0x0011
#define NETDEV_BONDING_DESLAVE 0x0012 #define NETDEV_BONDING_DESLAVE 0x0012
#define NETDEV_NOTIFY_PEERS 0x0013 #define NETDEV_NOTIFY_PEERS 0x0013
#define NETDEV_JOIN 0x0014
#define SYS_DOWN 0x0001 /* Notify of system down */ #define SYS_DOWN 0x0001 /* Notify of system down */
#define SYS_RESTART SYS_DOWN #define SYS_RESTART SYS_DOWN
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment