Skip to content

Commit 8d8fc29

Browse files
Amerigo Wangdavem330
authored andcommitted
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>
1 parent a37dd33 commit 8d8fc29

3 files changed

Lines changed: 20 additions & 9 deletions

File tree

‎drivers/net/bonding/bond_main.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,6 +1640,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
16401640
}
16411641
}
16421642

1643+
call_netdevice_notifiers(NETDEV_JOIN, slave_dev);
1644+
16431645
/* If this is the first slave, then we need to set the master's hardware
16441646
* address to be the same as the slave's. */
16451647
if (is_zero_ether_addr(bond->dev->dev_addr))

‎drivers/net/netconsole.c‎

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -621,18 +621,19 @@ static int netconsole_netdev_event(struct notifier_block *this,
621621
bool stopped = false;
622622

623623
if (!(event == NETDEV_CHANGENAME || event == NETDEV_UNREGISTER ||
624-
event == NETDEV_BONDING_DESLAVE || event == NETDEV_GOING_DOWN))
624+
event == NETDEV_BONDING_DESLAVE || event == NETDEV_JOIN))
625625
goto done;
626626

627627
spin_lock_irqsave(&target_list_lock, flags);
628-
restart:
629628
list_for_each_entry(nt, &target_list, list) {
630629
netconsole_target_get(nt);
631630
if (nt->np.dev == dev) {
632631
switch (event) {
633632
case NETDEV_CHANGENAME:
634633
strlcpy(nt->np.dev_name, dev->name, IFNAMSIZ);
635634
break;
635+
case NETDEV_BONDING_DESLAVE:
636+
case NETDEV_JOIN:
636637
case NETDEV_UNREGISTER:
637638
/*
638639
* rtnl_lock already held
@@ -647,11 +648,7 @@ static int netconsole_netdev_event(struct notifier_block *this,
647648
dev_put(nt->np.dev);
648649
nt->np.dev = NULL;
649650
netconsole_target_put(nt);
650-
goto restart;
651651
}
652-
/* Fall through */
653-
case NETDEV_GOING_DOWN:
654-
case NETDEV_BONDING_DESLAVE:
655652
nt->enabled = 0;
656653
stopped = true;
657654
break;
@@ -660,10 +657,21 @@ static int netconsole_netdev_event(struct notifier_block *this,
660657
netconsole_target_put(nt);
661658
}
662659
spin_unlock_irqrestore(&target_list_lock, flags);
663-
if (stopped && (event == NETDEV_UNREGISTER || event == NETDEV_BONDING_DESLAVE))
660+
if (stopped) {
664661
printk(KERN_INFO "netconsole: network logging stopped on "
665-
"interface %s as it %s\n", dev->name,
666-
event == NETDEV_UNREGISTER ? "unregistered" : "released slaves");
662+
"interface %s as it ", dev->name);
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+
}
667675

668676
done:
669677
return NOTIFY_DONE;

‎include/linux/notifier.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ static inline int notifier_to_errno(int ret)
211211
#define NETDEV_UNREGISTER_BATCH 0x0011
212212
#define NETDEV_BONDING_DESLAVE 0x0012
213213
#define NETDEV_NOTIFY_PEERS 0x0013
214+
#define NETDEV_JOIN 0x0014
214215

215216
#define SYS_DOWN 0x0001 /* Notify of system down */
216217
#define SYS_RESTART SYS_DOWN

0 commit comments

Comments
 (0)