Commit 04dc7f6b authored by Eric W. Biederman's avatar Eric W. Biederman Committed by David S. Miller

net: Move network device exit batching

Move network device exit batching from a special case in
net_namespace.c to using common mechanisms in dev.c
Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 72ad937a
...@@ -5766,8 +5766,33 @@ static void __net_exit default_device_exit(struct net *net) ...@@ -5766,8 +5766,33 @@ static void __net_exit default_device_exit(struct net *net)
rtnl_unlock(); rtnl_unlock();
} }
static void __net_exit default_device_exit_batch(struct list_head *net_list)
{
/* At exit all network devices most be removed from a network
* namespace. Do this in the reverse order of registeration.
* Do this across as many network namespaces as possible to
* improve batching efficiency.
*/
struct net_device *dev;
struct net *net;
LIST_HEAD(dev_kill_list);
rtnl_lock();
list_for_each_entry(net, net_list, exit_list) {
for_each_netdev_reverse(net, dev) {
if (dev->rtnl_link_ops)
dev->rtnl_link_ops->dellink(dev, &dev_kill_list);
else
unregister_netdevice_queue(dev, &dev_kill_list);
}
}
unregister_netdevice_many(&dev_kill_list);
rtnl_unlock();
}
static struct pernet_operations __net_initdata default_device_ops = { static struct pernet_operations __net_initdata default_device_ops = {
.exit = default_device_exit, .exit = default_device_exit,
.exit_batch = default_device_exit_batch,
}; };
/* /*
......
...@@ -8,10 +8,8 @@ ...@@ -8,10 +8,8 @@
#include <linux/idr.h> #include <linux/idr.h>
#include <linux/rculist.h> #include <linux/rculist.h>
#include <linux/nsproxy.h> #include <linux/nsproxy.h>
#include <linux/netdevice.h>
#include <net/net_namespace.h> #include <net/net_namespace.h>
#include <net/netns/generic.h> #include <net/netns/generic.h>
#include <net/rtnetlink.h>
/* /*
* Our network namespace constructor/destructor lists * Our network namespace constructor/destructor lists
...@@ -29,20 +27,6 @@ EXPORT_SYMBOL(init_net); ...@@ -29,20 +27,6 @@ EXPORT_SYMBOL(init_net);
#define INITIAL_NET_GEN_PTRS 13 /* +1 for len +2 for rcu_head */ #define INITIAL_NET_GEN_PTRS 13 /* +1 for len +2 for rcu_head */
static void unregister_netdevices(struct net *net, struct list_head *list)
{
struct net_device *dev;
/* At exit all network devices most be removed from a network
* namespace. Do this in the reverse order of registeration.
*/
for_each_netdev_reverse(net, dev) {
if (dev->rtnl_link_ops)
dev->rtnl_link_ops->dellink(dev, list);
else
unregister_netdevice_queue(dev, list);
}
}
static int ops_init(const struct pernet_operations *ops, struct net *net) static int ops_init(const struct pernet_operations *ops, struct net *net)
{ {
int err; int err;
...@@ -78,14 +62,6 @@ static void ops_exit_list(const struct pernet_operations *ops, ...@@ -78,14 +62,6 @@ static void ops_exit_list(const struct pernet_operations *ops,
list_for_each_entry(net, net_exit_list, exit_list) list_for_each_entry(net, net_exit_list, exit_list)
ops->exit(net); ops->exit(net);
} }
if (&ops->list == first_device) {
LIST_HEAD(dev_kill_list);
rtnl_lock();
list_for_each_entry(net, net_exit_list, exit_list)
unregister_netdevices(net, &dev_kill_list);
unregister_netdevice_many(&dev_kill_list);
rtnl_unlock();
}
if (ops->exit_batch) if (ops->exit_batch)
ops->exit_batch(net_exit_list); ops->exit_batch(net_exit_list);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment