]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
vsock: add netns to vsock core
authorBobby Eshleman <bobbyeshleman@meta.com>
Wed, 21 Jan 2026 22:11:41 +0000 (14:11 -0800)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 27 Jan 2026 09:45:38 +0000 (10:45 +0100)
commiteafb64f40ca49c79f0769aab25d0fae5c9d3becb
treee6cb38ba5bbe87c0140a940a0482d93c8d0ff757
parent3eef6c061f97ab2a942dc98291bcdae9a16e5bda
vsock: add netns to vsock core

Add netns logic to vsock core. Additionally, modify transport hook
prototypes to be used by later transport-specific patches (e.g.,
*_seqpacket_allow()).

Namespaces are supported primarily by changing socket lookup functions
(e.g., vsock_find_connected_socket()) to take into account the socket
namespace and the namespace mode before considering a candidate socket a
"match".

This patch also introduces the sysctl /proc/sys/net/vsock/ns_mode to
report the mode and /proc/sys/net/vsock/child_ns_mode to set the mode
for new namespaces.

Add netns functionality (initialization, passing to transports, procfs,
etc...) to the af_vsock socket layer. Later patches that add netns
support to transports depend on this patch.

This patch changes the allocation of random ports for connectible vsocks
in order to avoid leaking the random port range starting point to other
namespaces.

dgram_allow(), stream_allow(), and seqpacket_allow() callbacks are
modified to take a vsk in order to perform logic on namespace modes. In
future patches, the net will also be used for socket
lookups in these functions.

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Bobby Eshleman <bobbyeshleman@meta.com>
Link: https://patch.msgid.link/20260121-vsock-vmtest-v16-1-2859a7512097@meta.com
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
12 files changed:
MAINTAINERS
drivers/vhost/vsock.c
include/linux/virtio_vsock.h
include/net/af_vsock.h
include/net/net_namespace.h
include/net/netns/vsock.h [new file with mode: 0644]
net/vmw_vsock/af_vsock.c
net/vmw_vsock/hyperv_transport.c
net/vmw_vsock/virtio_transport.c
net/vmw_vsock/virtio_transport_common.c
net/vmw_vsock/vmci_transport.c
net/vmw_vsock/vsock_loopback.c