From: Bobby Eshleman <bobbyeshle...@meta.com> Add the per-net vsock NS mode state. This only adds the structure for holding the mode necessary and some of the definitions, but does not integrate the functionality yet.
Signed-off-by: Bobby Eshleman <bobbyeshle...@meta.com> --- MAINTAINERS | 1 + include/net/net_namespace.h | 4 ++++ include/net/netns/vsock.h | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 507c5ff6f620..bf9015498854 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -26149,6 +26149,7 @@ L: net...@vger.kernel.org S: Maintained F: drivers/vhost/vsock.c F: include/linux/virtio_vsock.h +F: include/net/netns/vsock.h F: include/uapi/linux/virtio_vsock.h F: net/vmw_vsock/virtio_transport.c F: net/vmw_vsock/virtio_transport_common.c diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index 025a7574b275..005c0da4fb62 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h @@ -37,6 +37,7 @@ #include <net/netns/smc.h> #include <net/netns/bpf.h> #include <net/netns/mctp.h> +#include <net/netns/vsock.h> #include <net/net_trackers.h> #include <linux/ns_common.h> #include <linux/idr.h> @@ -196,6 +197,9 @@ struct net { /* Move to a better place when the config guard is removed. */ struct mutex rtnl_mutex; #endif +#if IS_ENABLED(CONFIG_VSOCKETS) + struct netns_vsock vsock; +#endif } __randomize_layout; #include <linux/seq_file_net.h> diff --git a/include/net/netns/vsock.h b/include/net/netns/vsock.h new file mode 100644 index 000000000000..ea14b46ed437 --- /dev/null +++ b/include/net/netns/vsock.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __NET_NET_NAMESPACE_VSOCK_H +#define __NET_NET_NAMESPACE_VSOCK_H + +#include <linux/types.h> + +// TODO: rename to VSOCK_NET_* ? +#define VSOCK_NS_MODE_GLOBAL 1 +#define VSOCK_NS_MODE_LOCAL (1 << 1) +#define VSOCK_NS_MODE_INVALID (~0) +/* VSOCK_NS_MODE_WRITTEN_ONCE indicates "write-once" write has occurred */ +#define VSOCK_NS_MODE_WRITTEN_ONCE (1 << 7) + +struct netns_vsock { + struct ctl_table_header *vsock_hdr; + spinlock_t lock; + u8 ns_mode; +}; +#endif /* __NET_NET_NAMESPACE_VSOCK_H */ -- 2.47.1