Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/bpf: Monitor traffic for select_reuseport.

Enable traffic monitoring for the subtests of select_reuseport.

Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Signed-off-by: Kui-Feng Lee <thinker.li@gmail.com>
Link: https://lore.kernel.org/r/20240815053254.470944-7-thinker.li@gmail.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>

authored by

Kui-Feng Lee and committed by
Martin KaFai Lau
69354085 b407b52b

+13 -24
+13 -24
tools/testing/selftests/bpf/prog_tests/select_reuseport.c
··· 37 37 static int reuseport_array = -1, outer_map = -1; 38 38 static enum bpf_map_type inner_map_type; 39 39 static int select_by_skb_data_prog; 40 - static int saved_tcp_syncookie = -1; 41 40 static struct bpf_object *obj; 42 - static int saved_tcp_fo = -1; 43 41 static __u32 index_zero; 44 42 static int epfd; 45 43 ··· 189 191 190 192 close(fd); 191 193 return 0; 192 - } 193 - 194 - static void restore_sysctls(void) 195 - { 196 - if (saved_tcp_fo != -1) 197 - write_int_sysctl(TCP_FO_SYSCTL, saved_tcp_fo); 198 - if (saved_tcp_syncookie != -1) 199 - write_int_sysctl(TCP_SYNCOOKIE_SYSCTL, saved_tcp_syncookie); 200 194 } 201 195 202 196 static int enable_fastopen(void) ··· 783 793 TEST_INIT(test_pass_on_err), 784 794 TEST_INIT(test_detach_bpf), 785 795 }; 796 + struct netns_obj *netns; 786 797 char s[MAX_TEST_NAME]; 787 798 const struct test *t; 788 799 ··· 799 808 if (!test__start_subtest(s)) 800 809 continue; 801 810 811 + netns = netns_new("select_reuseport", true); 812 + if (!ASSERT_OK_PTR(netns, "netns_new")) 813 + continue; 814 + 815 + if (CHECK_FAIL(enable_fastopen())) 816 + goto out; 817 + if (CHECK_FAIL(disable_syncookie())) 818 + goto out; 819 + 802 820 setup_per_test(sotype, family, inany, t->no_inner_map); 803 821 t->fn(sotype, family); 804 822 cleanup_per_test(t->no_inner_map); 823 + 824 + out: 825 + netns_free(netns); 805 826 } 806 827 } 807 828 ··· 853 850 854 851 void serial_test_select_reuseport(void) 855 852 { 856 - saved_tcp_fo = read_int_sysctl(TCP_FO_SYSCTL); 857 - if (saved_tcp_fo < 0) 858 - goto out; 859 - saved_tcp_syncookie = read_int_sysctl(TCP_SYNCOOKIE_SYSCTL); 860 - if (saved_tcp_syncookie < 0) 861 - goto out; 862 - 863 - if (enable_fastopen()) 864 - goto out; 865 - if (disable_syncookie()) 866 - goto out; 867 - 868 853 test_map_type(BPF_MAP_TYPE_REUSEPORT_SOCKARRAY); 869 854 test_map_type(BPF_MAP_TYPE_SOCKMAP); 870 855 test_map_type(BPF_MAP_TYPE_SOCKHASH); 871 - out: 872 - restore_sysctls(); 873 856 }