Thread (78 messages) 78 messages, 12 authors, 2025-10-24

Re: [PATCH 14/32] net: use ns_common_init()

From: Jan Kara <jack@suse.cz>
Date: 2025-09-10 15:57:56
Also in: cgroups, linux-block, linux-fsdevel, linux-kselftest, linux-nfs, lkml

On Wed 10-09-25 16:36:59, Christian Brauner wrote:
Don't cargo-cult the same thing over and over.

Signed-off-by: Christian Brauner <brauner@kernel.org>
One comment below.
quoted hunk ↗ jump to hunk
@@ -812,17 +828,14 @@ static void net_ns_net_debugfs(struct net *net)
 
 static __net_init int net_ns_net_init(struct net *net)
 {
-#ifdef CONFIG_NET_NS
-	net->ns.ops = &netns_operations;
-#endif
-	net->ns.inum = PROC_NET_INIT_INO;
-	if (net != &init_net) {
-		int ret = ns_alloc_inum(&net->ns);
-		if (ret)
-			return ret;
-	}
+	int ret = 0;
+
+	if (net == &init_net)
+		net->ns.inum = PROC_NET_INIT_INO;
+	else
+		ret = proc_alloc_inum(&to_ns_common(net)->inum);
 	net_ns_net_debugfs(net);
Here you're calling net_ns_net_debugfs() even if proc_alloc_inum() failed
which looks like a bug to me...

								Honza
quoted hunk ↗ jump to hunk
-	return 0;
+	return ret;
 }
 
 static __net_exit void net_ns_net_exit(struct net *net)
@@ -1282,7 +1295,12 @@ void __init net_ns_init(void)
 #ifdef CONFIG_KEYS
 	init_net.key_domain = &init_net_key_domain;
 #endif
-	preinit_net(&init_net, &init_user_ns);
+	/*
+	 * This currently cannot fail as the initial network namespace
+	 * has a static inode number.
+	 */
+	if (preinit_net(&init_net, &init_user_ns))
+		panic("Could not preinitialize the initial network namespace");
 
 	down_write(&pernet_ops_rwsem);
 	if (setup_net(&init_net))
-- 
2.47.3
-- 
Jan Kara [off-list ref]
SUSE Labs, CR
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help