[PATCH 14/23] net: Add net namespaces into ns_idr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Now they are exposed in /proc/namespace/ directory.

We already wait RCU grace period in cleanup_net()
before pernet_operations exit, so ns_idr_unregister()
works as expected.

Signed-off-by: Kirill Tkhai <ktkhai@xxxxxxxxxxxxx>
---
 net/core/net_namespace.c |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 5f658cbedd34..f78655a670e5 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -701,14 +701,24 @@ EXPORT_SYMBOL_GPL(get_net_ns_by_pid);
 
 static __net_init int net_ns_net_init(struct net *net)
 {
+	int ret;
 #ifdef CONFIG_NET_NS
 	net->ns.ops = &netns_operations;
 #endif
-	return ns_alloc_inum(&net->ns);
+	ret = ns_alloc_inum(&net->ns);
+	if (ret)
+		return ret;
+
+	ret = ns_idr_register(&net->ns);
+	if (ret < 0)
+		ns_free_inum(&net->ns);
+
+	return ret;
 }
 
 static __net_exit void net_ns_net_exit(struct net *net)
 {
+	ns_idr_unregister(&net->ns);
 	ns_free_inum(&net->ns);
 }
 





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux