|
6 | 6 | #include "sock_iter_batch.skel.h"
|
7 | 7 |
|
8 | 8 | #define TEST_NS "sock_iter_batch_netns"
|
| 9 | +#define TEST_CHILD_NS "sock_iter_batch_child_netns" |
9 | 10 |
|
10 | 11 | static const int init_batch_size = 16;
|
11 | 12 | static const int nr_soreuse = 4;
|
@@ -304,6 +305,7 @@ struct test_case {
|
304 | 305 | int *socks, int socks_len, struct sock_count *counts,
|
305 | 306 | int counts_len, struct bpf_link *link, int iter_fd);
|
306 | 307 | const char *description;
|
| 308 | + int ehash_buckets; |
307 | 309 | int init_socks;
|
308 | 310 | int max_socks;
|
309 | 311 | int sock_type;
|
@@ -410,13 +412,25 @@ static struct test_case resume_tests[] = {
|
410 | 412 | static void do_resume_test(struct test_case *tc)
|
411 | 413 | {
|
412 | 414 | struct sock_iter_batch *skel = NULL;
|
| 415 | + struct sock_count *counts = NULL; |
413 | 416 | static const __u16 port = 10001;
|
| 417 | + struct nstoken *nstoken = NULL; |
414 | 418 | struct bpf_link *link = NULL;
|
415 |
| - struct sock_count *counts; |
416 | 419 | int err, iter_fd = -1;
|
417 | 420 | const char *addr;
|
418 | 421 | int *fds = NULL;
|
419 | 422 |
|
| 423 | + if (tc->ehash_buckets) { |
| 424 | + SYS_NOFAIL("ip netns del " TEST_CHILD_NS); |
| 425 | + SYS(done, "sysctl -w net.ipv4.tcp_child_ehash_entries=%d", |
| 426 | + tc->ehash_buckets); |
| 427 | + SYS(done, "ip netns add %s", TEST_CHILD_NS); |
| 428 | + SYS(done, "ip -net %s link set dev lo up", TEST_CHILD_NS); |
| 429 | + nstoken = open_netns(TEST_CHILD_NS); |
| 430 | + if (!ASSERT_OK_PTR(nstoken, "open_child_netns")) |
| 431 | + goto done; |
| 432 | + } |
| 433 | + |
420 | 434 | counts = calloc(tc->max_socks, sizeof(*counts));
|
421 | 435 | if (!ASSERT_OK_PTR(counts, "counts"))
|
422 | 436 | goto done;
|
@@ -453,6 +467,9 @@ static void do_resume_test(struct test_case *tc)
|
453 | 467 | tc->test(tc->family, tc->sock_type, addr, port, fds, tc->init_socks,
|
454 | 468 | counts, tc->max_socks, link, iter_fd);
|
455 | 469 | done:
|
| 470 | + close_netns(nstoken); |
| 471 | + SYS_NOFAIL("ip netns del " TEST_CHILD_NS); |
| 472 | + SYS_NOFAIL("sysctl -w net.ipv4.tcp_child_ehash_entries=0"); |
456 | 473 | free(counts);
|
457 | 474 | free_fds(fds, tc->init_socks);
|
458 | 475 | if (iter_fd >= 0)
|
|
0 commit comments