]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
selftests/bpf: Add tests for bucket resume logic in listening sockets
authorJordan Rife <jordan@jrife.io>
Mon, 14 Jul 2025 18:09:10 +0000 (11:09 -0700)
committerMartin KaFai Lau <martin.lau@kernel.org>
Mon, 14 Jul 2025 19:09:09 +0000 (12:09 -0700)
Replicate the set of test cases used for UDP socket iterators to test
similar scenarios for TCP listening sockets.

Signed-off-by: Jordan Rife <jordan@jrife.io>
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Acked-by: Stanislav Fomichev <sdf@fomichev.me>
tools/testing/selftests/bpf/prog_tests/sock_iter_batch.c

index a4517bee34d5ba5fea37941525d6d40a0db4fd20..2adacd91fdf894b15899b9c86ef94e854147f1e7 100644 (file)
@@ -358,6 +358,53 @@ static struct test_case resume_tests[] = {
                .family = AF_INET6,
                .test = force_realloc,
        },
+       {
+               .description = "tcp: resume after removing a seen socket (listening)",
+               .init_socks = nr_soreuse,
+               .max_socks = nr_soreuse,
+               .sock_type = SOCK_STREAM,
+               .family = AF_INET6,
+               .test = remove_seen,
+       },
+       {
+               .description = "tcp: resume after removing one unseen socket (listening)",
+               .init_socks = nr_soreuse,
+               .max_socks = nr_soreuse,
+               .sock_type = SOCK_STREAM,
+               .family = AF_INET6,
+               .test = remove_unseen,
+       },
+       {
+               .description = "tcp: resume after removing all unseen sockets (listening)",
+               .init_socks = nr_soreuse,
+               .max_socks = nr_soreuse,
+               .sock_type = SOCK_STREAM,
+               .family = AF_INET6,
+               .test = remove_all,
+       },
+       {
+               .description = "tcp: resume after adding a few sockets (listening)",
+               .init_socks = nr_soreuse,
+               .max_socks = nr_soreuse,
+               .sock_type = SOCK_STREAM,
+               /* Use AF_INET so that new sockets are added to the head of the
+                * bucket's list.
+                */
+               .family = AF_INET,
+               .test = add_some,
+       },
+       {
+               .description = "tcp: force a realloc to occur (listening)",
+               .init_socks = init_batch_size,
+               .max_socks = init_batch_size * 2,
+               .sock_type = SOCK_STREAM,
+               /* Use AF_INET6 so that new sockets are added to the tail of the
+                * bucket's list, needing to be added to the next batch to force
+                * a realloc.
+                */
+               .family = AF_INET6,
+               .test = force_realloc,
+       },
 };
 
 static void do_resume_test(struct test_case *tc)