aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/progs/sock_iter_batch.c
diff options
context:
space:
mode:
authorJordan Rife <[email protected]>2025-07-14 18:09:11 +0000
committerMartin KaFai Lau <[email protected]>2025-07-14 19:09:09 +0000
commit346066c3278f3baa61b1abc8a03721ed2684efe7 (patch)
tree8c4a2de740d5215fdd6ceb72f5f0148ea4a3e7ef /tools/testing/selftests/bpf/progs/sock_iter_batch.c
parentselftests/bpf: Add tests for bucket resume logic in listening sockets (diff)
downloadkernel-346066c3278f3baa61b1abc8a03721ed2684efe7.tar.gz
kernel-346066c3278f3baa61b1abc8a03721ed2684efe7.zip
selftests/bpf: Allow for iteration over multiple ports
Prepare to test TCP socket iteration over both listening and established sockets by allowing the BPF iterator programs to skip the port check. Signed-off-by: Jordan Rife <[email protected]> Signed-off-by: Martin KaFai Lau <[email protected]> Acked-by: Stanislav Fomichev <[email protected]>
Diffstat (limited to 'tools/testing/selftests/bpf/progs/sock_iter_batch.c')
-rw-r--r--tools/testing/selftests/bpf/progs/sock_iter_batch.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/sock_iter_batch.c b/tools/testing/selftests/bpf/progs/sock_iter_batch.c
index 8f483337e103..40dce6a38c30 100644
--- a/tools/testing/selftests/bpf/progs/sock_iter_batch.c
+++ b/tools/testing/selftests/bpf/progs/sock_iter_batch.c
@@ -52,6 +52,8 @@ int iter_tcp_soreuse(struct bpf_iter__tcp *ctx)
idx = 0;
else if (sk->sk_num == ports[1])
idx = 1;
+ else if (!ports[0] && !ports[1])
+ idx = 0;
else
return 0;
@@ -92,6 +94,8 @@ int iter_udp_soreuse(struct bpf_iter__udp *ctx)
idx = 0;
else if (sk->sk_num == ports[1])
idx = 1;
+ else if (!ports[0] && !ports[1])
+ idx = 0;
else
return 0;