Skip to content

Expose network namespace cookies to user space

Lorenz Bauer bpf netdev 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest4 patches 1 replyIn review
  2. v24 patches 3 repliesSuperseded
  3. v14 patches 4 repliesSuperseded

Changes in v3 from the cover letter

- Use sock_net unconditionally
- Fix unused variable in nsfs ioctl
- Be strict about getsockopt value size

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4net: add SO_NETNS_COOKIE socket optionarch/alpha/include/uapi/asm/socket.h arch/mips/include/uapi/asm/socket.h arch/parisc/include/uapi/asm/socket.h +3 more+17 -00 replies
2/4nsfs: add an ioctl to discover the network namespace cookiefs/nsfs.c include/uapi/linux/nsfs.h+9 -00 replies
3/4tools/testing: add test for NS_GET_COOKIEtools/testing/selftests/nsfs/.gitignore tools/testing/selftests/nsfs/Makefile tools/testing/selftests/nsfs/config +1 more+60 -10 replies
4/4tools/testing: add a selftest for SO_NETNS_COOKIEtools/testing/selftests/net/.gitignore tools/testing/selftests/net/Makefile tools/testing/selftests/net/config +1 more+64 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH bpf-next v3 0/4] Expose network namespace cookies to user space

We're working on a user space control plane for the BPF sk_lookup hook [1]. The hook attaches to a network namespace and allows control over which socket receives a new connection / packet.

I'm proposing to add a new getsockopt and a netns ioctl to retrieve netns cookies, which allows identifying which netns a socket belongs to.

1: https://www.kernel.org/doc/html/latest/bpf/prog_sk_lookup.html

Changes in v3:
- Use sock_net unconditionally
- Fix unused variable in nsfs ioctl
- Be strict about getsockopt value size

Changes in v2:
- Rebase on top of Eric Dumazet's netns cookie simplification

Lorenz Bauer (4):
net: add SO_NETNS_COOKIE socket option
nsfs: add an ioctl to discover the network namespace cookie tools/testing: add test for NS_GET_COOKIE tools/testing: add a selftest for SO_NETNS_COOKIE

 arch/alpha/include/uapi/asm/socket.h          |  2 +
 arch/mips/include/uapi/asm/socket.h           |  2 +
 arch/parisc/include/uapi/asm/socket.h         |  2 +
 arch/sparc/include/uapi/asm/socket.h          |  2 +
 fs/nsfs.c                                     |  7 +++
 include/uapi/asm-generic/socket.h             |  2 +
 include/uapi/linux/nsfs.h                     |  2 +
 net/core/sock.c                               |  7 +++
 tools/testing/selftests/net/.gitignore        |  1 +
 tools/testing/selftests/net/Makefile          |  2 +-
 tools/testing/selftests/net/config            |  1 +
 tools/testing/selftests/net/so_netns_cookie.c | 61 +++++++++++++++++++
 tools/testing/selftests/nsfs/.gitignore       |  1 +
 tools/testing/selftests/nsfs/Makefile         |  2 +-
 tools/testing/selftests/nsfs/config           |  1 +
 tools/testing/selftests/nsfs/netns.c          | 57 +++++++++++++++++
 16 files changed, 150 insertions(+), 2 deletions(-)
 create mode 100644 tools/testing/selftests/net/so_netns_cookie.c
 create mode 100644 tools/testing/selftests/nsfs/netns.c
Signature · 1 line
2.27.0