@@ -37,9 +37,7 @@ static int sk_fds[REUSEPORT_ARRAY_SIZE];
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
@@ -193,14 +191,6 @@ static int write_int_sysctl(const char *sysctl, int v)
193
191
return 0 ;
194
192
}
195
193
196
- static void restore_sysctls (void )
197
- {
198
- if (saved_tcp_fo != -1 )
199
- write_int_sysctl (TCP_FO_SYSCTL , saved_tcp_fo );
200
- if (saved_tcp_syncookie != -1 )
201
- write_int_sysctl (TCP_SYNCOOKIE_SYSCTL , saved_tcp_syncookie );
202
- }
203
-
204
194
static int enable_fastopen (void )
205
195
{
206
196
int fo ;
@@ -793,6 +783,7 @@ static void test_config(int sotype, sa_family_t family, bool inany)
793
783
TEST_INIT (test_pass_on_err ),
794
784
TEST_INIT (test_detach_bpf ),
795
785
};
786
+ struct netns_obj * netns ;
796
787
char s [MAX_TEST_NAME ];
797
788
const struct test * t ;
798
789
@@ -808,9 +799,21 @@ static void test_config(int sotype, sa_family_t family, bool inany)
808
799
if (!test__start_subtest (s ))
809
800
continue ;
810
801
802
+ netns = netns_new ("select_reuseport" , true);
803
+ if (!ASSERT_OK_PTR (netns , "netns_new" ))
804
+ continue ;
805
+
806
+ if (CHECK_FAIL (enable_fastopen ()))
807
+ goto out ;
808
+ if (CHECK_FAIL (disable_syncookie ()))
809
+ goto out ;
810
+
811
811
setup_per_test (sotype , family , inany , t -> no_inner_map );
812
812
t -> fn (sotype , family );
813
813
cleanup_per_test (t -> no_inner_map );
814
+
815
+ out :
816
+ netns_free (netns );
814
817
}
815
818
}
816
819
@@ -850,21 +853,7 @@ void test_map_type(enum bpf_map_type mt)
850
853
851
854
void serial_test_select_reuseport (void )
852
855
{
853
- saved_tcp_fo = read_int_sysctl (TCP_FO_SYSCTL );
854
- if (saved_tcp_fo < 0 )
855
- goto out ;
856
- saved_tcp_syncookie = read_int_sysctl (TCP_SYNCOOKIE_SYSCTL );
857
- if (saved_tcp_syncookie < 0 )
858
- goto out ;
859
-
860
- if (enable_fastopen ())
861
- goto out ;
862
- if (disable_syncookie ())
863
- goto out ;
864
-
865
856
test_map_type (BPF_MAP_TYPE_REUSEPORT_SOCKARRAY );
866
857
test_map_type (BPF_MAP_TYPE_SOCKMAP );
867
858
test_map_type (BPF_MAP_TYPE_SOCKHASH );
868
- out :
869
- restore_sysctls ();
870
859
}
0 commit comments