netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net namespace: wrap for_each_net with rtnl_lock
@ 2013-07-04  6:20 Fan Du
  2013-07-04  7:04 ` Eric W. Biederman
  0 siblings, 1 reply; 3+ messages in thread
From: Fan Du @ 2013-07-04  6:20 UTC (permalink / raw)
  To: ebiederm; +Cc: serge.hallyn, davem, netdev

The read access to net_namespace_list with for_each_net should always
be protected with rtnl_lock agiast any adding/removing operation from
the list.

Signed-off-by: Fan Du <fan.du@windriver.com>
---
 net/core/net_namespace.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index f976520..f3808ff 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -445,12 +445,14 @@ static int __register_pernet_operations(struct list_head *list,
 
 	list_add_tail(&ops->list, list);
 	if (ops->init || (ops->id && ops->size)) {
+		rtnl_lock();
 		for_each_net(net) {
 			error = ops_init(ops, net);
 			if (error)
 				goto out_undo;
 			list_add_tail(&net->exit_list, &net_exit_list);
 		}
+		rtnl_unlock();
 	}
 	return 0;
 
@@ -468,8 +470,10 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
 	LIST_HEAD(net_exit_list);
 
 	list_del(&ops->list);
+	rtnl_lock();
 	for_each_net(net)
 		list_add_tail(&net->exit_list, &net_exit_list);
+	rtnl_unlock();
 	ops_exit_list(ops, &net_exit_list);
 	ops_free_list(ops, &net_exit_list);
 }
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-07-04  7:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-04  6:20 [PATCH] net namespace: wrap for_each_net with rtnl_lock Fan Du
2013-07-04  7:04 ` Eric W. Biederman
2013-07-04  7:57   ` Fan Du

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).