From: Christoph Hellwig <hch@xxxxxx> Date: Mon, 26 May 2025 07:32:27 +0200 > On Fri, May 23, 2025 at 11:21:09AM -0700, Kuniyuki Iwashima wrote: > > Let's restore sock_create_kern() that holds a netns reference. > > > > Now, it's the same as the version before commit 26abe14379f8 ("net: > > Modify sk_alloc to not reference count the netns of kernel sockets."). > > > > Back then, after creating a socket in init_net, we used sk_change_net() > > to drop the netns ref and switch to another netns, but now we can > > simply use __sock_create_kern() instead. > > > > $ git blame -L:sk_change_net include/net/sock.h 26abe14379f8~ > > > > DEBUG_NET_WARN_ON_ONCE() is to catch a path calling sock_create_kern() > > from __net_init functions, since doing so would leak the netns as > > __net_exit functions cannot run until the socket is removed. > > Is reusing the name as the old sock_create_kern a good idea? It can > lead to bugs by people used to the old semantics. In the old days, sock_create_kern() did take a ref to netns, but an implicit change that avoids taking the ref has caused a lot of problems for people who used to the old semantics. This series rather rolls back the change, so I think using the same name here is better than leaving the catchy sock_create_kern() error-prone. > It's also > not really an all that descriptive name for either variant. I'm > not really a net stack or namespace expert, but maybe we can come > up with more descriptive version for both this new sock_create_kern > and the old sock_create_kern/__sock_create_kern?