[PATCH bpf-next 0/5] selftests/bpf: Extend sockmap_redir to test no-redir SK_DROP/SK_PASS

Michal Luczaj
2025-09-05T11:12:02Z

sockmap_redir was introduced to comprehensively test the BPF redirection.
This series strives to increase the tested sockmap/sockhash code coverage;
adds support for skipping the actual redirect part, allowing to simply
SK_DROP or SK_PASS the packet.

BPF_MAP_TYPE_SOCKMAP
BPF_MAP_TYPE_SOCKHASH
x
sk_msg-to-egress
sk_msg-to-ingress
sk_skb-to-egress
sk_skb-to-ingress
x
AF_INET, SOCK_STREAM
AF_INET6, SOCK_STREAM
AF_INET, SOCK_DGRAM
AF_INET6, SOCK_DGRAM
AF_UNIX, SOCK_STREAM
AF_UNIX, SOCK_DGRAM
AF_VSOCK, SOCK_STREAM
AF_VSOCK, SOCK_SEQPACKET
x
SK_REDIRECT
SK_DROP
SK_PASS

Patch 5 ("Support no-redirect SK_DROP/SK_PASS") implements the feature.
Patches 3 ("Rename functions") and 4 ("Let test specify skel's
redirect_type") make preparatory changes.

I also took the opportunity to clean up (Patch 1, "Simplify try_recv()")
and improve a bit (Patch 2, "Fix OOB handling").

$ cd tools/testing/selftests/bpf
$ make
$ sudo ./test_progs -t sockmap_redir
...
Summary: 1/720 PASSED, 0 SKIPPED, 0 FAILED

Signed-off-by: Michal Luczaj <mhal@rbox.co>
---
Michal Luczaj (5):
selftests/bpf: sockmap_redir: Simplify try_recv()
selftests/bpf: sockmap_redir: Fix OOB handling
selftests/bpf: sockmap_redir: Rename functions
selftests/bpf: sockmap_redir: Let test specify skel's redirect_type
selftests/bpf: sockmap_redir: Support no-redirect SK_DROP/SK_PASS

.../selftests/bpf/prog_tests/sockmap_redir.c | 143 +++++++++++++++------
1 file changed, 105 insertions(+), 38 deletions(-)
---
base-commit: e8a6a9d3e8cc539d281e77b9df2439f223ec8153
change-id: 20250523-redir-test-pass-drop-2f2a5edca6e1

Best regards,
--
Michal Luczaj <mhal@rbox.co>