aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/core/dev.c25
-rw-r--r--net/core/net_namespace.c24
2 files changed, 25 insertions, 24 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index e3e18dee0bd3..0913a08a87d6 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5766,8 +5766,33 @@ static void __net_exit default_device_exit(struct net *net)
5766 rtnl_unlock(); 5766 rtnl_unlock();
5767} 5767}
5768 5768
5769static void __net_exit default_device_exit_batch(struct list_head *net_list)
5770{
5771 /* At exit all network devices most be removed from a network
5772 * namespace. Do this in the reverse order of registeration.
5773 * Do this across as many network namespaces as possible to
5774 * improve batching efficiency.
5775 */
5776 struct net_device *dev;
5777 struct net *net;
5778 LIST_HEAD(dev_kill_list);
5779
5780 rtnl_lock();
5781 list_for_each_entry(net, net_list, exit_list) {
5782 for_each_netdev_reverse(net, dev) {
5783 if (dev->rtnl_link_ops)
5784 dev->rtnl_link_ops->dellink(dev, &dev_kill_list);
5785 else
5786 unregister_netdevice_queue(dev, &dev_kill_list);
5787 }
5788 }
5789 unregister_netdevice_many(&dev_kill_list);
5790 rtnl_unlock();
5791}
5792
5769static struct pernet_operations __net_initdata default_device_ops = { 5793static struct pernet_operations __net_initdata default_device_ops = {
5770 .exit = default_device_exit, 5794 .exit = default_device_exit,
5795 .exit_batch = default_device_exit_batch,
5771}; 5796};
5772 5797
5773/* 5798/*
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 6c7f6e04dbbf..4026a4cff93c 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -8,10 +8,8 @@
8#include <linux/idr.h> 8#include <linux/idr.h>
9#include <linux/rculist.h> 9#include <linux/rculist.h>
10#include <linux/nsproxy.h> 10#include <linux/nsproxy.h>
11#include <linux/netdevice.h>
12#include <net/net_namespace.h> 11#include <net/net_namespace.h>
13#include <net/netns/generic.h> 12#include <net/netns/generic.h>
14#include <net/rtnetlink.h>
15 13
16/* 14/*
17 * Our network namespace constructor/destructor lists 15 * Our network namespace constructor/destructor lists
@@ -29,20 +27,6 @@ EXPORT_SYMBOL(init_net);
29 27
30#define INITIAL_NET_GEN_PTRS 13 /* +1 for len +2 for rcu_head */ 28#define INITIAL_NET_GEN_PTRS 13 /* +1 for len +2 for rcu_head */
31 29
32static void unregister_netdevices(struct net *net, struct list_head *list)
33{
34 struct net_device *dev;
35 /* At exit all network devices most be removed from a network
36 * namespace. Do this in the reverse order of registeration.
37 */
38 for_each_netdev_reverse(net, dev) {
39 if (dev->rtnl_link_ops)
40 dev->rtnl_link_ops->dellink(dev, list);
41 else
42 unregister_netdevice_queue(dev, list);
43 }
44}
45
46static int ops_init(const struct pernet_operations *ops, struct net *net) 30static int ops_init(const struct pernet_operations *ops, struct net *net)
47{ 31{
48 int err; 32 int err;
@@ -78,14 +62,6 @@ static void ops_exit_list(const struct pernet_operations *ops,
78 list_for_each_entry(net, net_exit_list, exit_list) 62 list_for_each_entry(net, net_exit_list, exit_list)
79 ops->exit(net); 63 ops->exit(net);
80 } 64 }
81 if (&ops->list == first_device) {
82 LIST_HEAD(dev_kill_list);
83 rtnl_lock();
84 list_for_each_entry(net, net_exit_list, exit_list)
85 unregister_netdevices(net, &dev_kill_list);
86 unregister_netdevice_many(&dev_kill_list);
87 rtnl_unlock();
88 }
89 if (ops->exit_batch) 65 if (ops->exit_batch)
90 ops->exit_batch(net_exit_list); 66 ops->exit_batch(net_exit_list);
91} 67}