summaryrefslogtreecommitdiff
path: root/net/core/net_namespace.c
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2025-06-06 11:45:08 +0200
committerChristian Brauner <brauner@kernel.org>2025-06-11 11:59:08 +0200
commit9b0240b3ccc325c7a96cf362877180bc9e10d546 (patch)
treeeacee4a3fe6794b52a141a1a5f6976f03bea38c7 /net/core/net_namespace.c
parent6a9e2fb1bab53b54d02714a2ee3c6612d19629ce (diff)
netns: use stable inode number for initial mount ns
Apart from the network and mount namespace all other namespaces expose a stable inode number and userspace has been relying on that for a very long time now. It's very much heavily used API. Align the network namespace and use a stable inode number from the reserved procfs inode number space so this is consistent across all namespaces. Link: https://lore.kernel.org/20250606-work-nsfs-v1-2-b8749c9a8844@kernel.org Reviewed-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'net/core/net_namespace.c')
-rw-r--r--net/core/net_namespace.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index ae54f26709ca..03cf87d3b380 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -796,11 +796,19 @@ static __net_init int net_ns_net_init(struct net *net)
#ifdef CONFIG_NET_NS
net->ns.ops = &netns_operations;
#endif
+ if (net == &init_net) {
+ net->ns.inum = PROC_NET_INIT_INO;
+ return 0;
+ }
return ns_alloc_inum(&net->ns);
}
static __net_exit void net_ns_net_exit(struct net *net)
{
+ /*
+ * Initial network namespace doesn't exit so we don't need any
+ * special checks here.
+ */
ns_free_inum(&net->ns);
}