diff options
author | Amerigo Wang <amwang@redhat.com> | 2011-05-19 17:39:10 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-05-22 21:01:19 -0400 |
commit | 8d8fc29d02a33e4bd5f4fa47823c1fd386346093 (patch) | |
tree | 822657741aca7297209c28c906f6b8caa43d163b | |
parent | a37dd3332319260cce81ac91ce25fcc3a31de997 (diff) |
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: WANG Cong <amwang@redhat.com>
Cc: Neil Horman <nhorman@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/bonding/bond_main.c | 2 | ||||
-rw-r--r-- | drivers/net/netconsole.c | 26 | ||||
-rw-r--r-- | include/linux/notifier.h | 1 |
3 files changed, 20 insertions, 9 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 088fd845ffdf..f4960f516c39 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -1640,6 +1640,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1640 | } | 1640 | } |
1641 | } | 1641 | } |
1642 | 1642 | ||
1643 | call_netdevice_notifiers(NETDEV_JOIN, slave_dev); | ||
1644 | |||
1643 | /* If this is the first slave, then we need to set the master's hardware | 1645 | /* If this is the first slave, then we need to set the master's hardware |
1644 | * address to be the same as the slave's. */ | 1646 | * address to be the same as the slave's. */ |
1645 | if (is_zero_ether_addr(bond->dev->dev_addr)) | 1647 | if (is_zero_ether_addr(bond->dev->dev_addr)) |
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index a83e101440fd..4190786de403 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c | |||
@@ -621,11 +621,10 @@ static int netconsole_netdev_event(struct notifier_block *this, | |||
621 | bool stopped = false; | 621 | bool stopped = false; |
622 | 622 | ||
623 | if (!(event == NETDEV_CHANGENAME || event == NETDEV_UNREGISTER || | 623 | if (!(event == NETDEV_CHANGENAME || event == NETDEV_UNREGISTER || |
624 | event == NETDEV_BONDING_DESLAVE || event == NETDEV_GOING_DOWN)) | 624 | event == NETDEV_BONDING_DESLAVE || event == NETDEV_JOIN)) |
625 | goto done; | 625 | goto done; |
626 | 626 | ||
627 | spin_lock_irqsave(&target_list_lock, flags); | 627 | spin_lock_irqsave(&target_list_lock, flags); |
628 | restart: | ||
629 | list_for_each_entry(nt, &target_list, list) { | 628 | list_for_each_entry(nt, &target_list, list) { |
630 | netconsole_target_get(nt); | 629 | netconsole_target_get(nt); |
631 | if (nt->np.dev == dev) { | 630 | if (nt->np.dev == dev) { |
@@ -633,6 +632,8 @@ restart: | |||
633 | case NETDEV_CHANGENAME: | 632 | case NETDEV_CHANGENAME: |
634 | strlcpy(nt->np.dev_name, dev->name, IFNAMSIZ); | 633 | strlcpy(nt->np.dev_name, dev->name, IFNAMSIZ); |
635 | break; | 634 | break; |
635 | case NETDEV_BONDING_DESLAVE: | ||
636 | case NETDEV_JOIN: | ||
636 | case NETDEV_UNREGISTER: | 637 | case NETDEV_UNREGISTER: |
637 | /* | 638 | /* |
638 | * rtnl_lock already held | 639 | * rtnl_lock already held |
@@ -647,11 +648,7 @@ restart: | |||
647 | dev_put(nt->np.dev); | 648 | dev_put(nt->np.dev); |
648 | nt->np.dev = NULL; | 649 | nt->np.dev = NULL; |
649 | netconsole_target_put(nt); | 650 | netconsole_target_put(nt); |
650 | goto restart; | ||
651 | } | 651 | } |
652 | /* Fall through */ | ||
653 | case NETDEV_GOING_DOWN: | ||
654 | case NETDEV_BONDING_DESLAVE: | ||
655 | nt->enabled = 0; | 652 | nt->enabled = 0; |
656 | stopped = true; | 653 | stopped = true; |
657 | break; | 654 | break; |
@@ -660,10 +657,21 @@ restart: | |||
660 | netconsole_target_put(nt); | 657 | netconsole_target_put(nt); |
661 | } | 658 | } |
662 | spin_unlock_irqrestore(&target_list_lock, flags); | 659 | spin_unlock_irqrestore(&target_list_lock, flags); |
663 | if (stopped && (event == NETDEV_UNREGISTER || event == NETDEV_BONDING_DESLAVE)) | 660 | if (stopped) { |
664 | printk(KERN_INFO "netconsole: network logging stopped on " | 661 | printk(KERN_INFO "netconsole: network logging stopped on " |
665 | "interface %s as it %s\n", dev->name, | 662 | "interface %s as it ", dev->name); |
666 | event == NETDEV_UNREGISTER ? "unregistered" : "released slaves"); | 663 | switch (event) { |
664 | case NETDEV_UNREGISTER: | ||
665 | printk(KERN_CONT "unregistered\n"); | ||
666 | break; | ||
667 | case NETDEV_BONDING_DESLAVE: | ||
668 | printk(KERN_CONT "released slaves\n"); | ||
669 | break; | ||
670 | case NETDEV_JOIN: | ||
671 | printk(KERN_CONT "is joining a master device\n"); | ||
672 | break; | ||
673 | } | ||
674 | } | ||
667 | 675 | ||
668 | done: | 676 | done: |
669 | return NOTIFY_DONE; | 677 | return NOTIFY_DONE; |
diff --git a/include/linux/notifier.h b/include/linux/notifier.h index 621dfa16acc0..a577762afbe7 100644 --- a/include/linux/notifier.h +++ b/include/linux/notifier.h | |||
@@ -211,6 +211,7 @@ static inline int notifier_to_errno(int ret) | |||
211 | #define NETDEV_UNREGISTER_BATCH 0x0011 | 211 | #define NETDEV_UNREGISTER_BATCH 0x0011 |
212 | #define NETDEV_BONDING_DESLAVE 0x0012 | 212 | #define NETDEV_BONDING_DESLAVE 0x0012 |
213 | #define NETDEV_NOTIFY_PEERS 0x0013 | 213 | #define NETDEV_NOTIFY_PEERS 0x0013 |
214 | #define NETDEV_JOIN 0x0014 | ||
214 | 215 | ||
215 | #define SYS_DOWN 0x0001 /* Notify of system down */ | 216 | #define SYS_DOWN 0x0001 /* Notify of system down */ |
216 | #define SYS_RESTART SYS_DOWN | 217 | #define SYS_RESTART SYS_DOWN |