From: "[PATCH 1/2]"@fess.ebiederm.org, "net:In"@fess.ebiederm.org, unregister_netdevice_notifier@fess.ebiederm.org, unregister@fess.ebiederm.org, the@fess.ebiederm.org, "netdevices."@fess.ebiederm.org
To: David Miller <davem@davemloft.net>
Cc: "Eric Dumazet" <eric.dumazet@gmail.com>,
"Eric Van Hensbergen" <ericvh@gmail.com>,
"Dave Jones" <davej@redhat.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
netdev <netdev@vger.kernel.org>,
"Rémi Denis-Courmont" <remi.denis-courmont@nokia.com>,
"Sasha Levin" <levinsasha928@gmail.com>
Subject: Re: net: kernel BUG() in net/netns/generic.h:45
Date: Fri, 06 Apr 2012 18:31:14 -0700 [thread overview]
Message-ID: <m1iphctjj1.fsf@fess.ebiederm.org> (raw)
In-Reply-To: <m1mx6otk85.fsf@fess.ebiederm.org> (Eric W. Biederman's message of "Fri, 06 Apr 2012 18:16:10 -0700")
We already synthesize events in register_netdevice_notifier and synthesizing
events in unregister_netdevice_notifier allows to us remove the need for
special case cleanup code.
This change should be trivially safe as it adds no new cases for
existing callers of unregister_netdevice_notifier to handle.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
---
net/core/dev.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index 452db70..77c0a87 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1410,14 +1410,34 @@ EXPORT_SYMBOL(register_netdevice_notifier);
* register_netdevice_notifier(). The notifier is unlinked into the
* kernel structures and may then be reused. A negative errno code
* is returned on a failure.
+ *
+ * After unregistering unregister and down device events are synthesized
+ * for all devices on the device list to the removed notifier to remove
+ * the need for special case cleanup code.
*/
int unregister_netdevice_notifier(struct notifier_block *nb)
{
+ struct net_device *dev;
+ struct net *net;
int err;
rtnl_lock();
err = raw_notifier_chain_unregister(&netdev_chain, nb);
+ if (err)
+ goto unlock;
+
+ for_each_net(net) {
+ for_each_netdev(net, dev) {
+ if (dev->flags & IFF_UP) {
+ nb->notifier_call(nb, NETDEV_GOING_DOWN, dev);
+ nb->notifier_call(nb, NETDEV_DOWN, dev);
+ }
+ nb->notifier_call(nb, NETDEV_UNREGISTER, dev);
+ nb->notifier_call(nb, NETDEV_UNREGISTER_BATCH, dev);
+ }
+ }
+unlock:
rtnl_unlock();
return err;
}
--
1.7.2.5
next prev parent reply other threads:[~2012-04-07 1:27 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-05 22:20 net: kernel BUG() in net/netns/generic.h:45 Sasha Levin
2012-04-05 23:53 ` Eric W. Biederman
2012-04-06 9:04 ` Sasha Levin
2012-04-07 1:16 ` Eric W. Biederman
2012-04-07 1:31 ` [PATCH 1/2], net:In, unregister_netdevice_notifier, unregister, the, netdevices. [this message]
2012-04-07 1:33 ` [PATCH 1/2] net: In unregister_netdevice_notifier unregister the netdevices Eric W. Biederman
2012-04-07 1:35 ` [PATCH 2/2] phonet: Sort out initiailziation and cleanup code Eric W. Biederman
2012-04-10 6:39 ` Rémi Denis-Courmont
2012-04-10 10:47 ` Sasha Levin
2012-04-13 15:05 ` David Miller
2012-04-13 15:05 ` [PATCH 1/2] net: In unregister_netdevice_notifier unregister the netdevices David Miller
2012-04-14 0:03 ` Eric W. Biederman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m1iphctjj1.fsf@fess.ebiederm.org \
--to="[patch 1/2]"@fess.ebiederm.org \
--cc="net:In"@fess.ebiederm.org \
--cc="netdevices."@fess.ebiederm.org \
--cc=davej@redhat.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=ericvh@gmail.com \
--cc=levinsasha928@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=remi.denis-courmont@nokia.com \
--cc=the@fess.ebiederm.org \
--cc=unregister@fess.ebiederm.org \
--cc=unregister_netdevice_notifier@fess.ebiederm.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.