Skip to content

Sockmap iterator

Lorenz Bauer bpf 5 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest3 patches 3 repliesIn review
  2. v47 patches 1 replySuperseded
  3. v36 patches 6 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v24 patches10 repliesSuperseded
v13 patches7 repliesSuperseded

Changes in v5 from the cover letter

- Drop pointer to struct sock shenanigans

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3net: sockmap: Remove unnecessary sk_fullsock checksnet/core/sock_map.c+2 -20 replies
2/3net: Allow iterating sockmap and sockhashnet/core/sock_map.c+278 -21 reply
3/3selftests: bpf: Test iterating a sockmaptools/testing/selftests/bpf/prog_tests/sockmap_basic.c tools/testing/selftests/bpf/progs/bpf_iter.h tools/testing/selftests/bpf/progs/bpf_iter_sockmap.c +1 more+144 -02 replies

Reviews trailers per patch

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

PatchYonghong Song
1/3
2/3A-b
3/3

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

Read the v5 thread

Cover letter [PATCH bpf-next v5 0/3] Sockmap iterator

I've decided to drop the changes that extend BTF pointers from this series. They are a lot more work than I anticipated, and I don't want to hold this up more.

The context for a sockmap / sockhash iterator contains the key, and a BTF pointer to a socket. Iterating a sockmap will yield a NULL socket if the slot in the array is empty. Iterating a hashmap will never yield a NULL socket.

I'll add support to call map_update_elem from bpf_iter in a follow up to this series.

Changes in v5:
- Drop pointer to struct sock shenanigans

Changes in v4:
- Alias struct sock* to PTR_TO_SOCK_COMMON instead of PTR_TO_SOCKET (Martin)

Changes in v3:
- Use PTR_TO_BTF_ID in iterator context (Yonghong, Martin)
- Use rcu_dereference instead of rcu_dereference_raw (Jakub)
- Fix various test nits (Jakub, Andrii)

Changes in v2:
- Remove unnecessary sk_fullsock checks (Jakub)
- Nits for test output (Jakub)
- Increase number of sockets in tests to 64 (Jakub)
- Handle ENOENT in tests (Jakub)
- Actually test SOCKHASH iteration (myself)
- Fix SOCKHASH iterator initialization (myself)

Lorenz Bauer (3):
net: sockmap: Remove unnecessary sk_fullsock checks
net: Allow iterating sockmap and sockhash
selftests: bpf: Test iterating a sockmap

 net/core/sock_map.c                           | 284 +++++++++++++++++-
 .../selftests/bpf/prog_tests/sockmap_basic.c  |  89 ++++++
 tools/testing/selftests/bpf/progs/bpf_iter.h  |   9 +
 .../selftests/bpf/progs/bpf_iter_sockmap.c    |  43 +++
 .../selftests/bpf/progs/bpf_iter_sockmap.h    |   3 +
 5 files changed, 424 insertions(+), 4 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/progs/bpf_iter_sockmap.c
 create mode 100644 tools/testing/selftests/bpf/progs/bpf_iter_sockmap.h
Signature · 1 line
2.25.1