refactor mptcp bpf tests
Subsystems (4)
Geliang Tang
reviewerv9 cover refactor mptcp bpf tests
From: Geliang Tang <[email protected]>
v9:
- extract a new helper test_bpf_sched() from MPTCP_SCHED_TEST() to make the macro simpler as Mat suggested. (thanks)
- squash MPTCP_SCHED_TEST() into "selftests/bpf: Add bpf_first scheduler & test", not "selftests/bpf: Add bpf scheduler test" to avoid a build error "test_bpf_sched is not used".
v8:
- change argument types of send_data_and_verify from strings to booleans as Matt suggested.
v7:
- address Matt's comments in v6 (thanks)
- add more commit logs.
- use WITH_DATA/WITHOUT_DATA instead of 1/0.
- make patch 3 as a squash-to patch.
v6:
- drop patch 1 in v5 and rebased.
v5:
- drop patch 5 in v4:
Squash to "selftests/bpf: Add bpf scheduler test" 4 cleanup
v4:
- add set_nonblock to make BPF tests stable.
- split 'Squash to "selftests/bpf: Add bpf scheduler test"' into 4 patches.
v3:
- part 1, bpf schedulers.
v2:
- add two more helpers, send_single_byte and send_recv_data.
Refactor mptcp bpf tests using newly added macros MPTCP_BASE_TEST, RUN_MPTCP_TEST and MPTCP_SCHED_TEST macro.
Geliang Tang (8):
selftests/bpf: Add RUN_MPTCP_TEST macro
Squash to "selftests/bpf: Add bpf scheduler test" 1 verify Squash to "selftests/bpf: Add bpf scheduler test" 2 time Squash to "selftests/bpf: Add bpf_first scheduler & test" Squash to "selftests/bpf: Add bpf_bkup scheduler & test" Squash to "selftests/bpf: Add bpf_rr scheduler & test" Squash to "selftests/bpf: Add bpf_red scheduler & test" Squash to "selftests/bpf: Add bpf_burst scheduler & test"
.../testing/selftests/bpf/prog_tests/mptcp.c | 249 +++++------------- 1 file changed, 69 insertions(+), 180 deletions(-)
Signature · 1 line
2.40.1
Geliang Tang
reviewerPATCH v9 1/8 selftests/bpf: Add RUN_MPTCP_TEST macro
From: Geliang Tang <[email protected]>
Each MPTCP subtest tests test__start_subtest(suffix), then invokes test_suffix(). It makes sense to add a new macro RUN_MPTCP_TEST to simpolify the code.
--- tools/testing/selftests/bpf/prog_tests/mptcp.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
tools/testing/selftests/bpf/prog_tests/mptcp.c +8 -4
@@ -653,12 +653,16 @@ static void test_burst(void)mptcp_bpf_burst__destroy (burst_skel); } +#define RUN_MPTCP_TEST (suffix) \ +do { \ + if (test__start_subtest(#suffix)) \ + test_##suffix(); \ +} while (0) +void test_mptcp (void ) { -if (test__start_subtest ("base" )) -test_base (); -if (test__start_subtest ("mptcpify" )) -test_mptcpify (); +RUN_MPTCP_TEST (base); +RUN_MPTCP_TEST (mptcpify);if (test__start_subtest ("default" ))test_default ();if (test__start_subtest ("first" ))
Signature · 1 line
2.40.1
Re: [PATCH mptcp-next v9 1/8] selftests/bpf: Add RUN_MPTCP_TEST macro
Quoted 7 lines · Geliang Tang
From: Geliang Tang <[email protected]>
Each MPTCP subtest tests
test__start_subtest(suffix), then invokestest_suffix(). It makes sense to add a new macroRUN_MPTCP_TESTto simpolify the code.Signed-off-by Geliang Tang <[email protected]>
With https://patchwork.kernel.org/project/mptcp/patch/cc01abb2882608ac5f719e0f7960aa2a2d9fca41.1713404174.git.tanggeliang@kylinos.cn/,
v9 of the series looks good to apply.
The rest of the series is all "squash-to" patches, but for this first patch:
Quoted 34 lines
---
tools/testing/selftests/bpf/prog_tests/mptcp.c| 12 ++++++++----1 file changed, 8 insertions(+), 4 deletions(-)tools/testing/selftests/bpf/prog_tests/mptcp.c +8
-4@@ -653,12 +653,16 @@ static void test_burst(void)mptcp_bpf_burst__destroy (burst_skel); } +#define RUN_MPTCP_TEST (suffix) \ +do { \ + if (test__start_subtest(#suffix)) \ + test_##suffix(); \ +} while (0) +void test_mptcp (void ) { -if (test__start_subtest ("base" )) -test_base (); -if (test__start_subtest ("mptcpify" )) -test_mptcpify (); +RUN_MPTCP_TEST (base); +RUN_MPTCP_TEST (mptcpify);if (test__start_subtest ("default" ))test_default ();if (test__start_subtest ("first" ))Signature · 1 line
2.40.1
Geliang Tang
reviewerPATCH v9 2/8 Squash to "selftests/bpf: Add bpf scheduler test" 1 verify
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
Add send_data_and_verify helper to avoid duplicated code.
--- .../testing/selftests/bpf/prog_tests/mptcp.c | 42 ++++++++++++++----- 1 file changed, 32 insertions(+), 10 deletions(-)
tools/testing/selftests/bpf/prog_tests/mptcp.c +32 -10
@@ -17,6 +17,8 @@#include "mptcp_bpf_burst.skel.h" #define NS_TEST "mptcp_ns" +#define WITH_DATA true +#define WITHOUT_DATA false#ifndef IPPROTO_MPTCP #define IPPROTO_MPTCP 262
@@ -457,23 +459,44 @@ static int has_bytes_sent(char *addr)return system (cmd); } -static void test_default (void ) +static void send_data_and_verify (char *sched,bool addr1,bool addr2) {int server_fd, client_fd; -struct nstoken *nstoken; - nstoken =sched_init ("subflow" ,"default" ); -if (!ASSERT_OK_PTR (nstoken,"sched_init:default" )) - goto fail; server_fd =start_mptcp_server (AF_INET ,ADDR_1 ,PORT_1 ,0 ); +if (CHECK (server_fd <0 , sched,"start_mptcp_server: %d\n" , errno)) +return ; + client_fd =connect_to_fd (server_fd,0 ); +if (CHECK (client_fd <0 , sched,"connect_to_fd: %d\n" , errno)) + goto fail; -send_data (server_fd, client_fd,"default" ); -ASSERT_OK (has_bytes_sent (ADDR_1 ),"has_bytes_sent addr_1" ); -ASSERT_OK (has_bytes_sent (ADDR_2 ),"has_bytes_sent addr_2" ); +send_data (server_fd, client_fd, sched); + +if (addr1) +CHECK (has_bytes_sent (ADDR_1 ), sched,"should have bytes_sent on addr1\n" ); +else +CHECK (!has_bytes_sent (ADDR_1 ), sched,"shouldn't have bytes_sent on addr1\n" ); +if (addr2) +CHECK (has_bytes_sent (ADDR_2 ), sched,"should have bytes_sent on addr2\n" ); +else +CHECK (!has_bytes_sent (ADDR_2 ), sched,"shouldn't have bytes_sent on addr2\n" );close (client_fd); +fail:close (server_fd); +} + +static void test_default (void ) +{ +struct nstoken *nstoken; + + nstoken =sched_init ("subflow" ,"default" ); +if (!ASSERT_OK_PTR (nstoken,"sched_init:default" )) + goto fail; + +send_data_and_verify ("default" ,WITH_DATA ,WITH_DATA ); + fail:cleanup_netns (nstoken); }
@@ -663,8 +686,7 @@ void test_mptcp(void) {RUN_MPTCP_TEST (base);RUN_MPTCP_TEST (mptcpify); -if (test__start_subtest ("default" )) -test_default (); +RUN_MPTCP_TEST (default);if (test__start_subtest ("first" ))test_first ();if (test__start_subtest ("bkup" ))
Signature · 1 line
2.40.1
Geliang Tang
reviewerPATCH v9 3/8 Squash to "selftests/bpf: Add bpf scheduler test" 2 time
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
Move time related code from send_data into send_data_and_verify. Then send_data can be exported into network_helpers.h as a public function, reused by mptcp.c and bpf_tcp_ca.c.
Drop duplicate '#include <time.h>', it's included in test_progs.h already.
--- .../testing/selftests/bpf/prog_tests/mptcp.c | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-)
tools/testing/selftests/bpf/prog_tests/mptcp.c +11 -12
@@ -5,7 +5,6 @@#include <linux/const.h> #include <netinet/in.h> #include <test_progs.h> -#include <time.h> #include "cgroup_helpers.h" #include "network_helpers.h" #include "mptcp_sock.skel.h"
@@ -382,16 +381,12 @@ static void *server(void *arg)static void send_data (int lfd,int fd,char *msg) {ssize_t nr_recv =0 , bytes =0 ; -struct timespec start, end; -unsigned int delta_ms;pthread_t srv_thread;void *thread_ret;char batch[1500 ];int err;WRITE_ONCE (stop,0 ); -if (clock_gettime (CLOCK_MONOTONIC , &start) <0 ) -return ; err =pthread_create (&srv_thread,NULL , server, (void *)(long )lfd);if (CHECK (err !=0 ,"pthread_create" ,"err:%d errno:%d\n" , err, errno))
@@ -408,16 +403,9 @@ static void send_data(int lfd, int fd, char *msg) bytes += nr_recv; } -if (clock_gettime (CLOCK_MONOTONIC , &end) <0 ) -return ; - - delta_ms = (end.tv_sec - start.tv_sec) *1000 + (end.tv_nsec - start.tv_nsec) /1000000 ; -CHECK (bytes != total_bytes,"recv" ,"%zd != %u nr_recv:%zd errno:%d\n" , bytes, total_bytes, nr_recv, errno); -printf ("%s: %u ms\n" , msg, delta_ms); -WRITE_ONCE (stop,1 );pthread_join (srv_thread, &thread_ret);
@@ -461,7 +449,9 @@ static int has_bytes_sent(char *addr)static void send_data_and_verify (char *sched,bool addr1,bool addr2) { +struct timespec start, end;int server_fd, client_fd; +unsigned int delta_ms; server_fd =start_mptcp_server (AF_INET ,ADDR_1 ,PORT_1 ,0 );if (CHECK (server_fd <0 , sched,"start_mptcp_server: %d\n" , errno))
@@ -471,8 +461,17 @@ static void send_data_and_verify(char *sched, bool addr1, bool addr2)if (CHECK (client_fd <0 , sched,"connect_to_fd: %d\n" , errno)) goto fail; +if (clock_gettime (CLOCK_MONOTONIC , &start) <0 ) + goto fail; +send_data (server_fd, client_fd, sched); +if (clock_gettime (CLOCK_MONOTONIC , &end) <0 ) + goto fail; + + delta_ms = (end.tv_sec - start.tv_sec) *1000 + (end.tv_nsec - start.tv_nsec) /1000000 ; +printf ("%s: %u ms\n" , sched, delta_ms); +if (addr1)CHECK (has_bytes_sent (ADDR_1 ), sched,"should have bytes_sent on addr1\n" );else
Signature · 1 line
2.40.1
Geliang Tang
reviewerPATCH v9 4/8 Squash to "selftests/bpf: Add bpf_first scheduler & test"
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
After squashing into this change, the patch "selftests/bpf: Add bpf_first test" can be merged into the patch "selftests/bpf: Add bpf_first scheduler" appending the following lines into commit log:
'''
This patch defines MPTCP_SCHED_TEST macro, a template for all scheduler tests. Every scheduler is identified by argument name, and use sysctl to set net.mptcp.scheduler as "bpf_name" to use this sched. Add two veth net devices to simulate the multiple addresses case. Use 'ip mptcp endpoint' command to add the new endpoint ADDR2 to PM netlink. Arguments addr1/add2 means whether the data has been sent on the first/second subflow or not. Send data and check bytes_sent of 'ss' output after it using send_data_and_verify().
Using MPTCP_SCHED_TEST macro to add a new test for this bpf_first scheduler, the arguments "1 0" means data has been only sent on the first subflow ADDR1. Run this test by RUN_MPTCP_TEST macro. '''
And update the subject to "selftests/bpf: Add bpf_first scheduler & test".
--- .../testing/selftests/bpf/prog_tests/mptcp.c | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-)
tools/testing/selftests/bpf/prog_tests/mptcp.c +27 -23
@@ -39,6 +39,7 @@#ifndef TCP_CA_NAME_MAX #define TCP_CA_NAME_MAX 16#endif +#define MPTCP_SCHED_NAME_MAX 16struct __mptcp_info {__u8 mptcpi_subflows;
@@ -500,41 +501,45 @@ static void test_default(void)cleanup_netns (nstoken); } -static void test_first (void ) +static void test_bpf_sched (struct bpf_object *obj,char *sched, +bool addr1,bool addr2) { -struct mptcp_bpf_first *first_skel; -int server_fd, client_fd; +char bpf_sched[MPTCP_SCHED_NAME_MAX ] ="bpf_" ;struct nstoken *nstoken;struct bpf_link *link; +struct bpf_map *map; - first_skel =mptcp_bpf_first__open_and_load (); -if (!ASSERT_OK_PTR (first_skel,"bpf_first__open_and_load" )) + map =bpf_object__find_map_by_name (obj, sched); + link =bpf_map__attach_struct_ops (map); +if (CHECK (!link, sched,"attach_struct_ops: %d\n" , errno))return ; - link =bpf_map__attach_struct_ops (first_skel->maps.first); -if (!ASSERT_OK_PTR (link,"bpf_map__attach_struct_ops" )) { -mptcp_bpf_first__destroy (first_skel); -return ; - } - - nstoken =sched_init ("subflow" ,"bpf_first" ); -if (!ASSERT_OK_PTR (nstoken,"sched_init:bpf_first" )) + nstoken =sched_init ("subflow" ,strcat (bpf_sched, sched)); +if (CHECK (!nstoken, sched,"sched_init: %d\n" , errno)) goto fail; - server_fd =start_mptcp_server (AF_INET ,ADDR_1 ,PORT_1 ,0 ); - client_fd =connect_to_fd (server_fd,0 ); -send_data (server_fd, client_fd,"bpf_first" ); -ASSERT_OK (has_bytes_sent (ADDR_1 ),"has_bytes_sent addr_1" ); -ASSERT_GT (has_bytes_sent (ADDR_2 ),0 ,"has_bytes_sent addr_2" ); +send_data_and_verify (sched, addr1, addr2); -close (client_fd); -close (server_fd); fail:cleanup_netns (nstoken);bpf_link__destroy (link); -mptcp_bpf_first__destroy (first_skel); } +#define MPTCP_SCHED_TEST (sched, addr1, addr2) \ +static void test_##sched(void) \ +{ \ + struct mptcp_bpf_##sched *skel; \ + \ + skel = mptcp_bpf_##sched##__open_and_load(); \ + if (!ASSERT_OK_PTR(skel, "open_and_load:" #sched)) \ + return; \ + \ + test_bpf_sched(skel->obj, #sched, addr1, addr2); \ + mptcp_bpf_##sched##__destroy(skel); \ +} + +MPTCP_SCHED_TEST (first,WITH_DATA ,WITHOUT_DATA ); +static void test_bkup (void ) {struct mptcp_bpf_bkup *bkup_skel;
@@ -686,8 +691,7 @@ void test_mptcp(void)RUN_MPTCP_TEST (base);RUN_MPTCP_TEST (mptcpify);RUN_MPTCP_TEST (default); -if (test__start_subtest ("first" )) -test_first (); +RUN_MPTCP_TEST (first);if (test__start_subtest ("bkup" ))test_bkup ();if (test__start_subtest ("rr" ))
Signature · 1 line
2.40.1
Mat Martineau
maintainerRe: [PATCH mptcp-next v9 4/8] Squash to "selftests/bpf: Add bpf_first scheduler & test"
Quoted 61 lines · Geliang Tang
From: Geliang Tang <[email protected]>
After squashing into this change, the patch "selftests/bpf: Add
bpf_firsttest" can be merged into the patch "selftests/bpf: Addbpf_firstscheduler" appending the following lines into commit log:'''
This patch definesMPTCP_SCHED_TESTmacro, a template for all scheduler tests. Every scheduler is identified by argument name, and use sysctl to set net.mptcp.scheduler as "bpf_name" to use this sched. Add two veth net devices to simulate the multiple addresses case. Use 'ip mptcp endpoint' command to add the new endpoint ADDR2 to PM netlink. Arguments addr1/add2 means whether the data has been sent on the first/second subflow or not. Send data and checkbytes_sentof 'ss' output after it usingsend_data_and_verify().Using
MPTCP_SCHED_TESTmacro to add a new test for thisbpf_firstscheduler, the arguments "1 0" means data has been only sent on the first subflow ADDR1. Run this test byRUN_MPTCP_TESTmacro. '''And update the subject to "selftests/bpf: Add
bpf_firstscheduler & test".Signed-off-by Geliang Tang <[email protected]>---
.../testing/selftests/bpf/prog_tests/mptcp.c| 50 ++++++++++---------1 file changed, 27 insertions(+), 23 deletions(-)tools/testing/selftests/bpf/prog_tests/mptcp.c +8
-5@@ -39,6 +39,7 @@#ifndef TCP_CA_NAME_MAX #define TCP_CA_NAME_MAX 16#endif +#define MPTCP_SCHED_NAME_MAX 16struct __mptcp_info {__u8 mptcpi_subflows;@@ -500,41 +501,45 @@ static void test_default(void)cleanup_netns (nstoken); } -static void test_first (void ) +static void test_bpf_sched (struct bpf_object *obj,char *sched, +bool addr1,bool addr2) { -struct mptcp_bpf_first *first_skel; -int server_fd, client_fd; +char bpf_sched[MPTCP_SCHED_NAME_MAX ] ="bpf_" ;struct nstoken *nstoken;struct bpf_link *link; +struct bpf_map *map; - first_skel =mptcp_bpf_first__open_and_load (); -if (!ASSERT_OK_PTR (first_skel,"bpf_first__open_and_load" )) + map =bpf_object__find_map_by_name (obj, sched); + link =bpf_map__attach_struct_ops (map); +if (CHECK (!link, sched,"attach_struct_ops: %d\n" , errno))return ;
tools/testing/selftests/bpf/prog_tests/mptcp.c static void test_default(void) · line 517
Quoted 10 lines
tools/testing/selftests/bpf/prog_tests/mptcp.c +1
-8- link =bpf_map__attach_struct_ops (first_skel->maps.first); -if (!ASSERT_OK_PTR (link,"bpf_map__attach_struct_ops" )) { -mptcp_bpf_first__destroy (first_skel); -return ; - } - - nstoken =sched_init ("subflow" ,"bpf_first" ); -if (!ASSERT_OK_PTR (nstoken,"sched_init:bpf_first" )) + nstoken =sched_init ("subflow" ,strcat (bpf_sched, sched));
Hi Geliang -
Thanks for the revision, I think the smaller macro containing a call to test_bpf_sched works well.
One last thing to ask: since the line above uses strcat() and MPTCP_SCHED_NAME_MAX==16 is fairly small (especially with the automatic "bpf_" prefix), please add an assert to check the length of the sched string. Otherwise it's pretty easy to accidentally create a buffer overflow with the MPTCP_SCHED_TEST() macro just by using a string over 11 characters.
- Mat
Quoted 51 lines
tools/testing/selftests/bpf/prog_tests/mptcp.c +2
-7+if (CHECK (!nstoken, sched,"sched_init: %d\n" , errno)) goto fail; - server_fd =start_mptcp_server (AF_INET ,ADDR_1 ,PORT_1 ,0 ); - client_fd =connect_to_fd (server_fd,0 ); -send_data (server_fd, client_fd,"bpf_first" ); -ASSERT_OK (has_bytes_sent (ADDR_1 ),"has_bytes_sent addr_1" ); -ASSERT_GT (has_bytes_sent (ADDR_2 ),0 ,"has_bytes_sent addr_2" ); +send_data_and_verify (sched, addr1, addr2); -close (client_fd); -close (server_fd);fail:
cleanup_netns(nstoken); bpf_link__destroy(link);tools/testing/selftests/bpf/prog_tests/mptcp.c +0
-1-mptcp_bpf_first__destroy (first_skel);}
tools/testing/selftests/bpf/prog_tests/mptcp.c +15
-0+#define MPTCP_SCHED_TEST (sched, addr1, addr2) \ +static void test_##sched(void) \ +{ \ + struct mptcp_bpf_##sched *skel; \ + \ + skel = mptcp_bpf_##sched##__open_and_load(); \ + if (!ASSERT_OK_PTR(skel, "open_and_load:" #sched)) \ + return; \ + \ + test_bpf_sched(skel->obj, #sched, addr1, addr2); \ + mptcp_bpf_##sched##__destroy(skel); \ +} + +MPTCP_SCHED_TEST (first,WITH_DATA ,WITHOUT_DATA ); +static void
test_bkup(void){ struct mptcp_bpf_bkup *bkup_skel;tools/testing/selftests/bpf/prog_tests/mptcp.c +1
-2@@ -686,8 +691,7 @@ void test_mptcp(void)RUN_MPTCP_TEST (base);RUN_MPTCP_TEST (mptcpify);RUN_MPTCP_TEST (default); -if (test__start_subtest ("first" )) -test_first (); +RUN_MPTCP_TEST (first);if (test__start_subtest ("bkup" ))test_bkup ();if (test__start_subtest ("rr" ))Signature · 1 line
2.40.1
Geliang Tang
reviewerPATCH v9 5/8 Squash to "selftests/bpf: Add bpf_bkup scheduler & test"
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
After squashing into this change, the patch "selftests/bpf: Add bpf_bkup test" can be merged into the patch "selftests/bpf: Add bpf_bkup scheduler" appending the following lines into commit log:
'''
Using MPTCP_SCHED_TEST macro to add a new test for this bpf_bkup scheduler, the arguments "1 0" means data has been only sent on the first subflow ADDR1. Run this test by RUN_MPTCP_TEST macro. '''
And update the subject to "selftests/bpf: Add bpf_bkup scheduler & test".
--- .../testing/selftests/bpf/prog_tests/mptcp.c | 39 +------------------ 1 file changed, 2 insertions(+), 37 deletions(-)
tools/testing/selftests/bpf/prog_tests/mptcp.c +2 -37
@@ -539,41 +539,7 @@ static void test_##sched(void) \ }MPTCP_SCHED_TEST (first,WITH_DATA ,WITHOUT_DATA ); - -static void test_bkup (void ) -{ -struct mptcp_bpf_bkup *bkup_skel; -int server_fd, client_fd; -struct nstoken *nstoken; -struct bpf_link *link; - - bkup_skel =mptcp_bpf_bkup__open_and_load (); -if (!ASSERT_OK_PTR (bkup_skel,"bpf_bkup__open_and_load" )) -return ; - - link =bpf_map__attach_struct_ops (bkup_skel->maps.bkup); -if (!ASSERT_OK_PTR (link,"bpf_map__attach_struct_ops" )) { -mptcp_bpf_bkup__destroy (bkup_skel); -return ; - } - - nstoken =sched_init ("subflow backup" ,"bpf_bkup" ); -if (!ASSERT_OK_PTR (nstoken,"sched_init:bpf_bkup" )) - goto fail; - server_fd =start_mptcp_server (AF_INET ,ADDR_1 ,PORT_1 ,0 ); - client_fd =connect_to_fd (server_fd,0 ); - -send_data (server_fd, client_fd,"bpf_bkup" ); -ASSERT_OK (has_bytes_sent (ADDR_1 ),"has_bytes_sent addr_1" ); -ASSERT_GT (has_bytes_sent (ADDR_2 ),0 ,"has_bytes_sent addr_2" ); - -close (client_fd); -close (server_fd); -fail: -cleanup_netns (nstoken); -bpf_link__destroy (link); -mptcp_bpf_bkup__destroy (bkup_skel); -} +MPTCP_SCHED_TEST (bkup,WITH_DATA ,WITHOUT_DATA );static void test_rr (void ) {
@@ -692,8 +658,7 @@ void test_mptcp(void)RUN_MPTCP_TEST (mptcpify);RUN_MPTCP_TEST (default);RUN_MPTCP_TEST (first); -if (test__start_subtest ("bkup" )) -test_bkup (); +RUN_MPTCP_TEST (bkup);if (test__start_subtest ("rr" ))test_rr ();if (test__start_subtest ("red" ))
Signature · 1 line
2.40.1
Geliang Tang
reviewerPATCH v9 6/8 Squash to "selftests/bpf: Add bpf_rr scheduler & test"
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
After squashing into this change, the patch "selftests/bpf: Add bpf_rr test" can be merged into the patch "selftests/bpf: Add bpf_rr scheduler" appending the following lines into commit log:
'''
Using MPTCP_SCHED_TEST macro to add a new test for this bpf_rr scheduler, the arguments "1 1" means data has been sent on both net devices. Run this test by RUN_MPTCP_TEST macro. '''
And update the subject to "selftests/bpf: Add bpf_rr scheduler & test".
--- .../testing/selftests/bpf/prog_tests/mptcp.c | 39 +------------------ 1 file changed, 2 insertions(+), 37 deletions(-)
tools/testing/selftests/bpf/prog_tests/mptcp.c +2 -37
@@ -540,41 +540,7 @@ static void test_##sched(void) \MPTCP_SCHED_TEST (first,WITH_DATA ,WITHOUT_DATA );MPTCP_SCHED_TEST (bkup,WITH_DATA ,WITHOUT_DATA ); - -static void test_rr (void ) -{ -struct mptcp_bpf_rr *rr_skel; -int server_fd, client_fd; -struct nstoken *nstoken; -struct bpf_link *link; - - rr_skel =mptcp_bpf_rr__open_and_load (); -if (!ASSERT_OK_PTR (rr_skel,"bpf_rr__open_and_load" )) -return ; - - link =bpf_map__attach_struct_ops (rr_skel->maps.rr); -if (!ASSERT_OK_PTR (link,"bpf_map__attach_struct_ops" )) { -mptcp_bpf_rr__destroy (rr_skel); -return ; - } - - nstoken =sched_init ("subflow" ,"bpf_rr" ); -if (!ASSERT_OK_PTR (nstoken,"sched_init:bpf_rr" )) - goto fail; - server_fd =start_mptcp_server (AF_INET ,ADDR_1 ,PORT_1 ,0 ); - client_fd =connect_to_fd (server_fd,0 ); - -send_data (server_fd, client_fd,"bpf_rr" ); -ASSERT_OK (has_bytes_sent (ADDR_1 ),"has_bytes_sent addr 1" ); -ASSERT_OK (has_bytes_sent (ADDR_2 ),"has_bytes_sent addr 2" ); - -close (client_fd); -close (server_fd); -fail: -cleanup_netns (nstoken); -bpf_link__destroy (link); -mptcp_bpf_rr__destroy (rr_skel); -} +MPTCP_SCHED_TEST (rr,WITH_DATA ,WITH_DATA );static void test_red (void ) {
@@ -659,8 +625,7 @@ void test_mptcp(void)RUN_MPTCP_TEST (default);RUN_MPTCP_TEST (first);RUN_MPTCP_TEST (bkup); -if (test__start_subtest ("rr" )) -test_rr (); +RUN_MPTCP_TEST (rr);if (test__start_subtest ("red" ))test_red ();if (test__start_subtest ("burst" ))
Signature · 1 line
2.40.1
Geliang Tang
reviewerPATCH v9 7/8 Squash to "selftests/bpf: Add bpf_red scheduler & test"
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
After squashing into this change, the patch "selftests/bpf: Add bpf_red test" can be merged into the patch "selftests/bpf: Add bpf_red scheduler" appending the following lines into commit log:
'''
Using MPTCP_SCHED_TEST macro to add a new test for this bpf_red scheduler, the arguments "1 1" means data has been sent on both net devices. Run this test by RUN_MPTCP_TEST macro. '''
And update the subject to "selftests/bpf: Add bpf_red scheduler & test".
--- .../testing/selftests/bpf/prog_tests/mptcp.c | 39 +------------------ 1 file changed, 2 insertions(+), 37 deletions(-)
tools/testing/selftests/bpf/prog_tests/mptcp.c +2 -37
@@ -541,41 +541,7 @@ static void test_##sched(void) \MPTCP_SCHED_TEST (first,WITH_DATA ,WITHOUT_DATA );MPTCP_SCHED_TEST (bkup,WITH_DATA ,WITHOUT_DATA );MPTCP_SCHED_TEST (rr,WITH_DATA ,WITH_DATA ); - -static void test_red (void ) -{ -struct mptcp_bpf_red *red_skel; -int server_fd, client_fd; -struct nstoken *nstoken; -struct bpf_link *link; - - red_skel =mptcp_bpf_red__open_and_load (); -if (!ASSERT_OK_PTR (red_skel,"bpf_red__open_and_load" )) -return ; - - link =bpf_map__attach_struct_ops (red_skel->maps.red); -if (!ASSERT_OK_PTR (link,"bpf_map__attach_struct_ops" )) { -mptcp_bpf_red__destroy (red_skel); -return ; - } - - nstoken =sched_init ("subflow" ,"bpf_red" ); -if (!ASSERT_OK_PTR (nstoken,"sched_init:bpf_red" )) - goto fail; - server_fd =start_mptcp_server (AF_INET ,ADDR_1 ,PORT_1 ,0 ); - client_fd =connect_to_fd (server_fd,0 ); - -send_data (server_fd, client_fd,"bpf_red" ); -ASSERT_OK (has_bytes_sent (ADDR_1 ),"has_bytes_sent addr 1" ); -ASSERT_OK (has_bytes_sent (ADDR_2 ),"has_bytes_sent addr 2" ); - -close (client_fd); -close (server_fd); -fail: -cleanup_netns (nstoken); -bpf_link__destroy (link); -mptcp_bpf_red__destroy (red_skel); -} +MPTCP_SCHED_TEST (red,WITH_DATA ,WITH_DATA );static void test_burst (void ) {
@@ -626,8 +592,7 @@ void test_mptcp(void)RUN_MPTCP_TEST (first);RUN_MPTCP_TEST (bkup);RUN_MPTCP_TEST (rr); -if (test__start_subtest ("red" )) -test_red (); +RUN_MPTCP_TEST (red);if (test__start_subtest ("burst" ))test_burst (); }
Signature · 1 line
2.40.1
Geliang Tang
reviewerPATCH v9 8/8 Squash to "selftests/bpf: Add bpf_burst scheduler & test"
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
After squashing into this change, the patch "selftests/bpf: Add bpf_burst test" can be merged into the patch "selftests/bpf: Add bpf_burst scheduler" appending the following lines into commit log:
'''
Using MPTCP_SCHED_TEST macro to add a new test for this bpf_burst scheduler, the arguments "1 1" means data has been sent on both net devices. Run this test by RUN_MPTCP_TEST macro.
'''
And update the subject to "selftests/bpf: Add bpf_burst scheduler & test".
Drop send_data, using send_recv_data instead.
--- .../testing/selftests/bpf/prog_tests/mptcp.c | 39 +------------------ 1 file changed, 2 insertions(+), 37 deletions(-)
tools/testing/selftests/bpf/prog_tests/mptcp.c +2 -37
@@ -542,41 +542,7 @@ MPTCP_SCHED_TEST(first, WITH_DATA, WITHOUT_DATA);MPTCP_SCHED_TEST (bkup,WITH_DATA ,WITHOUT_DATA );MPTCP_SCHED_TEST (rr,WITH_DATA ,WITH_DATA );MPTCP_SCHED_TEST (red,WITH_DATA ,WITH_DATA ); - -static void test_burst (void ) -{ -struct mptcp_bpf_burst *burst_skel; -int server_fd, client_fd; -struct nstoken *nstoken; -struct bpf_link *link; - - burst_skel =mptcp_bpf_burst__open_and_load (); -if (!ASSERT_OK_PTR (burst_skel,"bpf_burst__open_and_load" )) -return ; - - link =bpf_map__attach_struct_ops (burst_skel->maps.burst); -if (!ASSERT_OK_PTR (link,"bpf_map__attach_struct_ops" )) { -mptcp_bpf_burst__destroy (burst_skel); -return ; - } - - nstoken =sched_init ("subflow" ,"bpf_burst" ); -if (!ASSERT_OK_PTR (nstoken,"sched_init:bpf_burst" )) - goto fail; - server_fd =start_mptcp_server (AF_INET ,ADDR_1 ,PORT_1 ,0 ); - client_fd =connect_to_fd (server_fd,0 ); - -send_data (server_fd, client_fd,"bpf_burst" ); -ASSERT_OK (has_bytes_sent (ADDR_1 ),"has_bytes_sent addr 1" ); -ASSERT_OK (has_bytes_sent (ADDR_2 ),"has_bytes_sent addr 2" ); - -close (client_fd); -close (server_fd); -fail: -cleanup_netns (nstoken); -bpf_link__destroy (link); -mptcp_bpf_burst__destroy (burst_skel); -} +MPTCP_SCHED_TEST (burst,WITH_DATA ,WITH_DATA );#define RUN_MPTCP_TEST (suffix) \ do { \
@@ -593,6 +559,5 @@ void test_mptcp(void)RUN_MPTCP_TEST (bkup);RUN_MPTCP_TEST (rr);RUN_MPTCP_TEST (red); -if (test__start_subtest ("burst" )) -test_burst (); +RUN_MPTCP_TEST (burst); }
Signature · 1 line
2.40.1
Hi Geliang,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal: Success! ✅
- KVM Validation: debug: Success! ✅
- KVM Validation: btf (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/8715586777
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/e8e20b6cee14
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=845257
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-normalFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)
Matthieu Baerts
maintainerHi Geliang, Mat,
Quoted 8 lines · Geliang Tang
From: Geliang Tang <[email protected]>
v9:
- extract a new helpertest_bpf_sched()fromMPTCP_SCHED_TEST()to make the macro simpler as Mat suggested. (thanks)
- squashMPTCP_SCHED_TEST()into "selftests/bpf: Addbpf_firstscheduler & test", not "selftests/bpf: Add bpf scheduler test" to avoid a build error "test_bpf_schedis not used".
Thank you for the v9, and the review!
@Geliang: there were a lot of Git (TopGit) manipulations here, please check that the result is the expected one.
New patch for t/upstream:
- d0432b7d2bb0: selftests/bpf: Add RUN_MPTCP_TEST macro
- 9791281821ba: conflict in t/selftests-bpf-Add-bpf-scheduler-test
- 92efb2a19752: conflict in t/selftests-bpf-add-bpf_first-test
- 78858b124aee: conflict in t/selftests-bpf-Add-bpf_bkup-test
- e25a04564f65: conflict in t/selftests-bpf-Add-bpf_rr-test
- d474c99c9c56: conflict in t/selftests-bpf-Add-bpf_red-test
- 0091786b07e3: conflict in t/selftests-bpf-Add-bpf_burst-test
- Results: eb9a8fbc1cd3..6ad6176a437b (export)
Squash-to patches:
- da0ce2d96df7: "squashed" "1 verify" (with conflicts) in "selftests/bpf: Add bpf scheduler test"
- d08d36c72f3e: "squashed" "2 time" in "selftests/bpf: Add bpf scheduler test"
- f9800e6dbb07: conflict in t/selftests-bpf-add-bpf_first-test
- d910fb60db22: "squashed" (with conflicts) in "selftests/bpf: Add bpf_first test"
- 6723021b9a04: "squashed" "2 strlen" in "selftests/bpf: Add bpf_first test"
- 1bcf273624e6: "squashed" "3 err msg" in "selftests/bpf: Add bpf_first test"
- 20df6c66a4bf: conflict in t/selftests-bpf-Add-bpf_bkup-test
- 6f9d19a73d33: "squashed" (with conflicts) in "selftests/bpf: Add bpf_bkup test"
- 9c86e3027008: conflict in t/selftests-bpf-Add-bpf_rr-test
- 2bbbcc6cc7c1: "squashed" (with conflicts) in "selftests/bpf: Add bpf_rr test"
- 3bdb5c116569: conflict in t/selftests-bpf-Add-bpf_red-test
- 9eb2410e20b4: "squashed" (with conflicts) in "selftests/bpf: Add bpf_red test"
- 55e93f797697: conflict in t/selftests-bpf-Add-bpf_burst-test
- 9004d2b898a4: "squashed" (with conflicts) in "selftests/bpf: Add bpf_burst test"
- Results: 6ad6176a437b..665448084780 (export)
Squash "sched & test":
- 57731e73cc97: tg:squash: bpf_first sched & test
- 45b46aeeb072: tg:msg: update after squash
- a5a572331f7c: tg:squash: bpf_bkup sched & test
- d89c4282bf53: tg:msg: update after squash
- 44155448f992: tg:squash: bpf_rr sched & test
- 702454c6ba93: tg:msg: update after squash
- 71681fc66d24: tg:squash: bpf_red sched & test
- a15a6438bcbd: tg:msg: update after squash
- 297175c89808: tg:squash: bpf_burst sched & test
- c4624cdf779e: tg:msg: update after squash
- Results: 665448084780..c23ad453d8cc (export)
While at it, I also updated your email address:
- dbec7401465d: tg:msg: update Geliang's email address
- facd3cec3d0a: tg:msg: update Geliang's email address
- 59127f756c66: tg:msg: update Geliang's email address
- c20d79792bb2: tg:msg: update Geliang's email address
- 5f3d6b7755a2: tg:msg: update Geliang's email address
- 05efce6832cb: tg:msg: update Geliang's email address
- becd15a77346: tg:msg: update Geliang's email address
- e2b1e31d7720: tg:msg: update Geliang's email address
- a3bcc475f994: tg:msg: update Geliang's email address
- 699e0dbd591c: tg:msg: update Geliang's email address
- 2d5b66a3675f: tg:msg: update Geliang's email address
- 1df821d94ac8: tg:msg: update Geliang's email address
- 7a0adfdb70d0: tg:msg: update Geliang's email address
- cce49572147a: tg:msg: update Geliang's email address
- fff8347933fd: tg:msg: update Geliang's email address
- 6118caa31040: tg:msg: update Geliang's email address
- 6603ca35adf6: tg:msg: remove my SoB
- Results: c23ad453d8cc..f0f388aa6196 (export)
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Geliang Tang
reviewerHi Matt,
Quoted 13 lines · Matthieu Baerts
Hi Geliang, Mat,
Quoted 10 lines · Geliang Tang
From: Geliang Tang <[email protected]>
v9:
- extract a new helpertest_bpf_sched()fromMPTCP_SCHED_TEST()to make
the macro simpler as Mat suggested. (thanks)
- squashMPTCP_SCHED_TEST()into "selftests/bpf: Addbpf_firstscheduler & test", not "selftests/bpf: Add bpf scheduler test" to
avoid a build error "test_bpf_schedis not used".
Quoted 4 lines
Thank you for the v9, and the review!
@Geliang: there were a lot of Git (TopGit) manipulations here, please check that the result is the expected one.
Thank you for applying these patches. I know there must be many conflicts inside. Thank you for updating my email address too. All patches merged well and all tests passed.
Quoted 5 lines
New patch for t/upstream:
-
d0432b7d2bb0: selftests/bpf: AddRUN_MPTCP_TESTmacro
Please insert this commit "selftests/bpf: Add RUN_MPTCP_TEST macro" before "mptcp: add sched_data helpers" so that it can be upstreamed in advance with "setsockopt per subflow: BPF" series being reviewed, without waiting for BPF scheduler APIs to be updated. WDYT?
Regards,
-Geliang
Quoted 86 lines
-
9791281821ba: conflict in t/selftests-bpf-Add-bpf-scheduler-test
-92efb2a19752: conflict in t/selftests-bpf-add-bpf_first-test
-78858b124aee: conflict in t/selftests-bpf-Add-bpf_bkup-test
-e25a04564f65: conflict in t/selftests-bpf-Add-bpf_rr-test
-d474c99c9c56: conflict in t/selftests-bpf-Add-bpf_red-test
-0091786b07e3: conflict in t/selftests-bpf-Add-bpf_burst-test
- Results:eb9a8fbc1cd3..6ad6176a437b(export)Squash-to patches:
-
da0ce2d96df7: "squashed" "1 verify" (with conflicts) in "selftests/bpf: Add bpf scheduler test"-
d08d36c72f3e: "squashed" "2 time" in "selftests/bpf: Add bpf scheduler
test"
-f9800e6dbb07: conflict in t/selftests-bpf-add-bpf_first-test-
d910fb60db22: "squashed" (with conflicts) in "selftests/bpf: Addbpf_firsttest"
-6723021b9a04: "squashed" "2 strlen" in "selftests/bpf: Addbpf_firsttest"
-1bcf273624e6: "squashed" "3 err msg" in "selftests/bpf: Addbpf_first
test"
-20df6c66a4bf: conflict in t/selftests-bpf-Add-bpf_bkup-test-
6f9d19a73d33: "squashed" (with conflicts) in "selftests/bpf: Addbpf_bkuptest"
-9c86e3027008: conflict in t/selftests-bpf-Add-bpf_rr-test-
2bbbcc6cc7c1: "squashed" (with conflicts) in "selftests/bpf: Addbpf_rrtest"
-3bdb5c116569: conflict in t/selftests-bpf-Add-bpf_red-test-
9eb2410e20b4: "squashed" (with conflicts) in "selftests/bpf: Addbpf_redtest"
-55e93f797697: conflict in t/selftests-bpf-Add-bpf_burst-test-
9004d2b898a4: "squashed" (with conflicts) in "selftests/bpf: Addbpf_bursttest"
- Results: 6ad6176a437b..665448084780 (export)Squash "sched & test":
-
57731e73cc97: tg:squash:bpf_firstsched & test
-45b46aeeb072: tg:msg: update after squash-
a5a572331f7c: tg:squash:bpf_bkupsched & test
-d89c4282bf53: tg:msg: update after squash-
44155448f992: tg:squash:bpf_rrsched & test
-702454c6ba93: tg:msg: update after squash-
71681fc66d24: tg:squash:bpf_redsched & test
-a15a6438bcbd: tg:msg: update after squash-
297175c89808: tg:squash:bpf_burstsched & test
-c4624cdf779e: tg:msg: update after squash
- Results: 665448084780..c23ad453d8cc (export)While at it, I also updated your email address:
-dbec7401465d: tg:msg: update Geliang's email address
-facd3cec3d0a: tg:msg: update Geliang's email address
-59127f756c66: tg:msg: update Geliang's email address
-c20d79792bb2: tg:msg: update Geliang's email address
-5f3d6b7755a2: tg:msg: update Geliang's email address
-05efce6832cb: tg:msg: update Geliang's email address
-becd15a77346: tg:msg: update Geliang's email address
-e2b1e31d7720: tg:msg: update Geliang's email address
-a3bcc475f994: tg:msg: update Geliang's email address
-699e0dbd591c: tg:msg: update Geliang's email address
-2d5b66a3675f: tg:msg: update Geliang's email address
-1df821d94ac8: tg:msg: update Geliang's email address
-7a0adfdb70d0: tg:msg: update Geliang's email address
-cce49572147a: tg:msg: update Geliang's email address
-fff8347933fd: tg:msg: update Geliang's email address
-6118caa31040: tg:msg: update Geliang's email address
-6603ca35adf6: tg:msg: remove my SoB
- Results:c23ad453d8cc..f0f388aa6196(export)Cheers,
Matt
Matthieu Baerts
maintainerHi Geliang,
Quoted 16 lines · Geliang Tang
Hi Matt,
Quoted 13 lines · Matthieu Baerts
Hi Geliang, Mat,
Quoted 10 lines · Geliang Tang
From: Geliang Tang <[email protected]>
v9:
- extract a new helpertest_bpf_sched()fromMPTCP_SCHED_TEST()to make
the macro simpler as Mat suggested. (thanks)
- squashMPTCP_SCHED_TEST()into "selftests/bpf: Addbpf_firstscheduler & test", not "selftests/bpf: Add bpf scheduler test" to
avoid a build error "test_bpf_schedis not used".
Quoted 8 lines
Quoted 4 lines
Thank you for the v9, and the review!
@Geliang: there were a lot of Git (TopGit) manipulations here, please check that the result is the expected one.
Thank you for applying these patches. I know there must be many conflicts inside. Thank you for updating my email address too. All patches merged well and all tests passed.
Thank you for having checked!
Quoted 10 lines
Quoted 5 lines
New patch for t/upstream:
-
d0432b7d2bb0: selftests/bpf: AddRUN_MPTCP_TESTmacroPlease insert this commit "selftests/bpf: Add
RUN_MPTCP_TESTmacro" before "mptcp: addsched_datahelpers" so that it can be upstreamed in advance with "setsockopt per subflow: BPF" series being reviewed, without waiting for BPF scheduler APIs to be updated. WDYT?
I don't think we need to move it: there are no other patches modifying the BPF selftests before that one. So we should be safe regarding conflicts.
We can indeed send it with "setsockopt per subflow: BPF" series. These patches can be applied before "selftests/bpf: Add RUN_MPTCP_TEST macro", in the "patches for net-next" section when they will be marked as ready.
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Geliang Tang
reviewerHi Matt,
Quoted 45 lines · Matthieu Baerts
Hi Geliang,
Quoted 20 lines · Geliang Tang
Hi Matt,
Quoted 17 lines · Matthieu Baerts
Hi Geliang, Mat,
Quoted 12 lines · Geliang Tang
From: Geliang Tang <[email protected]>
v9:
- extract a new helpertest_bpf_sched()fromMPTCP_SCHED_TEST()to
make
the macro simpler as Mat suggested. (thanks)
- squashMPTCP_SCHED_TEST()into "selftests/bpf: Addbpf_firstscheduler & test", not "selftests/bpf: Add bpf scheduler test"
to
avoid a build error "test_bpf_schedis not used".Thank you for the v9, and the review!
Quoted 7 lines
Quoted 3 lines
@Geliang: there were a lot of Git (TopGit) manipulations here, please
check that the result is the expected one.Thank you for applying these patches. I know there must be many conflicts inside. Thank you for updating my email address too. All patches merged well and all tests passed.
Thank you for having checked!
Quoted 11 lines
Quoted 5 lines
New patch for t/upstream:
-
d0432b7d2bb0: selftests/bpf: AddRUN_MPTCP_TESTmacroPlease insert this commit "selftests/bpf: Add
RUN_MPTCP_TESTmacro" before "mptcp: addsched_datahelpers" so that it can be upstreamed in advance with "setsockopt per subflow: BPF" series being reviewed,
without waiting for BPF scheduler APIs to be updated. WDYT?
Quoted 4 lines
I don't think we need to move it: there are no other patches modifying
the BPF selftests before that one. So we should be safe regarding conflicts.
Yes, I agree.
Quoted 7 lines
We can indeed send it with "setsockopt per subflow: BPF" series. These
patches can be applied before "selftests/bpf: AddRUN_MPTCP_TESTmacro",
in the "patches for net-next" section when they will be marked as ready.
"setsockopt per subflow: BPF" series could be merged in this order:
1 selftests/bpf: Add mptcp subflow example 2 selftests/bpf: Add RUN_MPTCP_TEST macro 3 selftests/bpf: Add mptcp subflow subtest 4 selftests/bpf: Handle SIGINT when creating netns
Thanks,
-Geliang
Quoted 3 lines
Cheers,
Matt