]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
netconsole: take care of NETDEV_UNREGISTER event
authorBruno Prémont <bonbons@linux-vserver.org>
Wed, 29 Apr 2009 20:45:17 +0000 (20:45 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 1 May 2009 22:24:18 +0000 (15:24 -0700)
When netconsole is loaded and a network interface fades away (e.g. on
rmmod $interface_driver_module) the rmmod remains stuck and some locks
are taken that prevent any additional module loading/unloading as well
as interface up/down changes.
In addition kernel logs (and console) get flooded at 10s interval with

[  122.464065] unregister_netdevice: waiting for eth0 to become free. Usage count = 1
[  132.704059] unregister_netdevice: waiting for eth0 to become free. Usage count = 1

This patch lets netconsole take NETDEV_UNREGISTER event into account
and release the affected interface if it was in use.

Signed-off-by: Bruno Prémont <bonbons@linux-vserver.org>
Acked-by: Matt Mackall <mpm@selenic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/netconsole.c

index eceadf787a67d5762cad157b5104a033f952a063..bf4af5248cb75549a46415f21ab7685c948e1b42 100644 (file)
@@ -664,7 +664,7 @@ static int netconsole_netdev_event(struct notifier_block *this,
        struct netconsole_target *nt;
        struct net_device *dev = ptr;
 
-       if (!(event == NETDEV_CHANGENAME))
+       if (!(event == NETDEV_CHANGENAME || event == NETDEV_UNREGISTER))
                goto done;
 
        spin_lock_irqsave(&target_list_lock, flags);
@@ -675,6 +675,15 @@ static int netconsole_netdev_event(struct notifier_block *this,
                        case NETDEV_CHANGENAME:
                                strlcpy(nt->np.dev_name, dev->name, IFNAMSIZ);
                                break;
+                       case NETDEV_UNREGISTER:
+                               if (!nt->enabled)
+                                       break;
+                               netpoll_cleanup(&nt->np);
+                               nt->enabled = 0;
+                               printk(KERN_INFO "netconsole: network logging stopped"
+                                       ", interface %s unregistered\n",
+                                       dev->name);
+                               break;
                        }
                }
                netconsole_target_put(nt);