[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <159611043578.535980.14525601933828392397.stgit@localhost.localdomain>
Date: Thu, 30 Jul 2020 15:00:35 +0300
From: Kirill Tkhai <ktkhai@...tuozzo.com>
To: viro@...iv.linux.org.uk, adobriyan@...il.com, davem@...emloft.net,
ebiederm@...ssion.com, akpm@...ux-foundation.org,
christian.brauner@...ntu.com, areber@...hat.com, serge@...lyn.com,
linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
ktkhai@...tuozzo.com
Subject: [PATCH 14/23] net: Add net namespaces into ns_idr
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@...tuozzo.com>
---
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);
}
Powered by blists - more mailing lists