Skip to content

bpf: Add sock_ops_get_netns helpers

Lingpeng Chen bpf netdev oe-kbuild-all 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 1 replyIn review
  2. v12 patches 1 replySuperseded

Changes in v2 from the cover letter

- Return u64 instead of u32 for sock_ops_get_netns
- Fix build bug when CONFIG_NET_NS not set
- Add selftest for sock_ops_get_netns

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3bpf: Add sock ops get netns helpersinclude/uapi/linux/bpf.h net/core/filter.c+26 -117 replies
2/3bpf: Sync uapi bpf.h to tools/tools/include/uapi/linux/bpf.h+7 -10 replies
3/3selftests/bpf: add selftest for sock_ops_get_netns helpertools/testing/selftests/bpf/progs/test_tcpbpf_kern.c tools/testing/selftests/bpf/test_tcpbpf_user.c+56 -10 replies

Reviews trailers per patch

1 of 3 patches has a Reviewed-by or Acked-by.

PatchSong Liu
1/3A-b A-b A-b A-b A-b
2/3
3/3

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 bpf-next 0/3] bpf: Add sock_ops_get_netns helpers

Currently 5-tuple(sip+dip+sport+dport+proto) can't identify a uniq connection because there may be multi net namespace. For example, there may be a chance that netns a and netns b all listen on 127.0.0.1:8080 and the client with same port 40782 connect to them. Without netns number, sock ops program can't distinguish them.
Using bpf_sock_ops_get_netns helpers to get current connection netns number to distinguish connections.

Changes in v2:
- Return u64 instead of u32 for sock_ops_get_netns
- Fix build bug when CONFIG_NET_NS not set
- Add selftest for sock_ops_get_netns

Lingpeng Chen (3):
bpf: Add sock ops get netns helpers
bpf: Sync uapi bpf.h to tools/
selftests/bpf: add selftest for sock_ops_get_netns helper

 include/uapi/linux/bpf.h                      |  8 +++-
 net/core/filter.c                             | 19 ++++++++
 tools/include/uapi/linux/bpf.h                |  8 +++-
 .../selftests/bpf/progs/test_tcpbpf_kern.c    | 11 +++++
 .../testing/selftests/bpf/test_tcpbpf_user.c  | 46 ++++++++++++++++++-
 5 files changed, 89 insertions(+), 3 deletions(-)

base-commit bb6d3fb354c5 ("Linux 5.6-rc1")

Signature · 1 line
2.20.1