Re: [PATCH v2 net-next 3/7] socket: Restore sock_create_kern().
From: Christoph Hellwig <hch@lst.de>
Date: 2025-05-26 05:34:38
Also in:
linux-nfs, linux-nvme, linux-rdma, mptcp
From: Christoph Hellwig <hch@lst.de>
Date: 2025-05-26 05:34:38
Also in:
linux-nfs, linux-nvme, linux-rdma, mptcp
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. 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?