@@ -37,9 +37,7 @@ static int sk_fds[REUSEPORT_ARRAY_SIZE];
3737static  int  reuseport_array  =  -1 , outer_map  =  -1 ;
3838static  enum  bpf_map_type  inner_map_type ;
3939static  int  select_by_skb_data_prog ;
40- static  int  saved_tcp_syncookie  =  -1 ;
4140static  struct  bpf_object  * obj ;
42- static  int  saved_tcp_fo  =  -1 ;
4341static  __u32  index_zero ;
4442static  int  epfd ;
4543
@@ -193,14 +191,6 @@ static int write_int_sysctl(const char *sysctl, int v)
193191	return  0 ;
194192}
195193
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- 
204194static  int  enable_fastopen (void )
205195{
206196	int  fo ;
@@ -793,6 +783,7 @@ static void test_config(int sotype, sa_family_t family, bool inany)
793783		TEST_INIT (test_pass_on_err ),
794784		TEST_INIT (test_detach_bpf ),
795785	};
786+ 	struct  netns_obj  * netns ;
796787	char  s [MAX_TEST_NAME ];
797788	const  struct  test  * t ;
798789
@@ -808,9 +799,21 @@ static void test_config(int sotype, sa_family_t family, bool inany)
808799		if  (!test__start_subtest (s ))
809800			continue ;
810801
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+ 
811811		setup_per_test (sotype , family , inany , t -> no_inner_map );
812812		t -> fn (sotype , family );
813813		cleanup_per_test (t -> no_inner_map );
814+ 
815+ out :
816+ 		netns_free (netns );
814817	}
815818}
816819
@@ -850,21 +853,7 @@ void test_map_type(enum bpf_map_type mt)
850853
851854void  serial_test_select_reuseport (void )
852855{
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- 
865856	test_map_type (BPF_MAP_TYPE_REUSEPORT_SOCKARRAY );
866857	test_map_type (BPF_MAP_TYPE_SOCKMAP );
867858	test_map_type (BPF_MAP_TYPE_SOCKHASH );
868- out :
869- 	restore_sysctls ();
870859}
0 commit comments