Jan Beulich
2011-Apr-29 07:21 UTC
[Bridge] [PATCH] bridge: Module use count must be updated as bridges are created/destroyed
Otherwise 'modprobe -r' on a module having a dependency on bridge will implicitly unload bridge, bringing down all connectivity that was using bridges. Signed-off-by: Jan Beulich <jbeulich at novell.com> Cc: Jeff Mahoney <jeffm at suse.com> --- net/bridge/br_if.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- 2.6.39-rc5/net/bridge/br_if.c +++ 2.6.39-rc5-bridge-module-get-put/net/bridge/br_if.c @@ -290,6 +290,11 @@ int br_add_bridge(struct net *net, const if (!dev) return -ENOMEM; + if (!try_module_get(THIS_MODULE)) { + free_netdev(dev); + return -ENOENT; + } + rtnl_lock(); if (strchr(dev->name, '%')) { ret = dev_alloc_name(dev, dev->name); @@ -308,6 +313,8 @@ int br_add_bridge(struct net *net, const unregister_netdevice(dev); out: rtnl_unlock(); + if (ret) + module_put(THIS_MODULE); return ret; out_free: @@ -339,6 +346,8 @@ int br_del_bridge(struct net *net, const del_br(netdev_priv(dev), NULL); rtnl_unlock(); + if (ret == 0) + module_put(THIS_MODULE); return ret; }
David Miller
2011-Apr-29 07:25 UTC
[Bridge] [PATCH] bridge: Module use count must be updated as bridges are created/destroyed
From: "Jan Beulich" <JBeulich at novell.com> Date: Fri, 29 Apr 2011 08:21:14 +0100> Otherwise 'modprobe -r' on a module having a dependency on bridge will > implicitly unload bridge, bringing down all connectivity that was using > bridges. > > Signed-off-by: Jan Beulich <jbeulich at novell.com> > Cc: Jeff Mahoney <jeffm at suse.com>All network device drivers behave exactly the same way, when you rmmod the thing we unconfigure all the routes, addresses, etc. going through that device and let you unload it. And this behavior is very much intentional. Don't add an exception here.
Jan Beulich
2011-Apr-29 08:31 UTC
[Bridge] [PATCH] bridge: Module use count must be updated as bridges are created/destroyed
>>> On 29.04.11 at 10:10, David Miller <davem at davemloft.net> wrote: > From: "Jan Beulich" <JBeulich at novell.com> > Date: Fri, 29 Apr 2011 08:41:10 +0100 > >> You talk of rmmod on the very module, but the issue is about >> modprobe -r on a dependent module. I cannot believe you consider >> it correct that *implicit* unloading of bridge.ko should happen when >> bridges are configured. > > Which module in particular depends upon bridge and causes the > problem?The problem was observed (a long time ago) with ebtable_broute, and I cannot see how this would have changed meanwhile. Jan