cleanups for bpf sched selftests
Subsystems (4)
cover cleanups for bpf sched selftests
do some cleanups for bpf sched selftests:
- add one more veth net device.
- use '10.0.1.1' to send data instead of use default '127.0.0.1'.
- add a new helper has_bytes_sent().
- update commit logs.
Geliang Tang (3):
Squash to "selftests/bpf: Add bpf_first test"
Squash to "selftests/bpf: Add bpf_bkup test"
Squash to "selftests/bpf: Add bpf_rr test"
.../testing/selftests/bpf/prog_tests/mptcp.c | 63 ++++++++++++------- 1 file changed, 41 insertions(+), 22 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/3 Squash to "selftests/bpf: Add bpf_first test"
Please update the commit log:
'''
This patch expends the MPTCP test base to support MPTCP packet scheduler tests. Add the bpf_first scheduler test in it.
In the new helper sched_init(), add two veth net devices to simulate the multiple addresses case. Use 'ip mptcp endpoint' command to add the new endpoint ADDR_2 to PM netlink. Use sysctl to set net.mptcp.scheduler to use the given sched.
Invoke start_mptcp_server() to start the server on ADDR_1, and invoke connect_to_fd() to connect with the server from the client. Then invoke send_data() to send data.
Some code in send_data() is from prog_tests/bpf_tcp_ca.c.
Use the new helper has_bytes_sent() to check the bytes_sent filed of 'ss' output after send_data() to make sure no data has been sent on ADDR_2. All data has been sent on the first subflow.
Invoke the new helper sched_cleanup() to set back net.mptcp.scheduler to default, flush all mptcp endpoints, and delete the veth net devices. '''
--- .../testing/selftests/bpf/prog_tests/mptcp.c | 41 ++++++++++++++----- 1 file changed, 31 insertions(+), 10 deletions(-)
tools/testing/selftests/bpf/prog_tests/mptcp.c +31 -10
@@ -14,6 +14,9 @@#define TCP_CA_NAME_MAX 16#endif +#define ADDR_1 "10.0.1.1" +#define ADDR_2 "10.0.1.2" +struct mptcp_storage {__u32 invoked;__u32 is_mptcp;
@@ -252,20 +255,39 @@ static void send_data(int lfd, int fd) PTR_ERR(thread_ret)); } -static void add_veth (void ) +static void sched_init (char *flags,char *sched) { -system ("ip link add veth1 type veth" ); -system ("ip addr add 10.0.1.1/24 dev veth1" ); +char cmd[64 ]; + +system ("ip link add veth1 type veth peer name veth2" ); +snprintf (cmd,sizeof (cmd),"ip addr add %s/24 dev veth1" ,ADDR_1 ); +system (cmd);system ("ip link set veth1 up" ); +snprintf (cmd,sizeof (cmd),"ip addr add %s/24 dev veth2" ,ADDR_2 ); +system (cmd); +system ("ip link set veth2 up" ); + +snprintf (cmd,sizeof (cmd),"ip mptcp endpoint add %s %s" ,ADDR_2 , flags); +system (cmd); +snprintf (cmd,sizeof (cmd),"sysctl -qw net.mptcp.scheduler=%s" , sched); +system (cmd); } -static void cleanup (void ) +static void sched_cleanup (void ) {system ("sysctl -qw net.mptcp.scheduler=default" );system ("ip mptcp endpoint flush" );system ("ip link del veth1" ); } +static int has_bytes_sent (char *addr) +{ +char cmd[64 ]; + +snprintf (cmd,sizeof (cmd),"ss -it dst %s | grep -q 'bytes_sent:'" , addr); +return system (cmd); +} +static void test_first (void ) {struct mptcp_bpf_first *first_skel;
@@ -282,18 +304,17 @@ static void test_first(void)return ; } -add_veth (); -system ("ip mptcp endpoint add 10.0.1.1 subflow" ); -system ("sysctl -qw net.mptcp.scheduler=bpf_first" ); - server_fd =start_mptcp_server (AF_INET ,NULL ,0 ,0 ); +sched_init ("subflow" ,"bpf_first" ); + server_fd =start_mptcp_server (AF_INET ,ADDR_1 ,0 ,0 ); client_fd =connect_to_fd (server_fd,0 );send_data (server_fd, client_fd); -ASSERT_GT (system ("ss -MOenita | grep '10.0.1.1' | grep 'bytes_sent:'" ),0 ,"ss" ); +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); -cleanup (); +sched_cleanup ();bpf_link__destroy (link);mptcp_bpf_first__destroy (first_skel); }
Signature · 1 line
2.34.1
PATCH 2/3 Squash to "selftests/bpf: Add bpf_bkup test"
In reply to Geliang TangPlease update the commit log:
'''
This patch adds the backup BPF MPTCP scheduler test: test_bkup(). Use sysctl to set net.mptcp.scheduler 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 ADDR_2 to PM netlink with backup flag. Send data, check bytes_sent of 'ss' output, and do some cleanups. '''
--- tools/testing/selftests/bpf/prog_tests/mptcp.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
tools/testing/selftests/bpf/prog_tests/mptcp.c +5 -6
@@ -335,18 +335,17 @@ static void test_bkup(void)return ; } -add_veth (); -system ("ip mptcp endpoint add 10.0.1.1 subflow backup" ); -system ("sysctl -qw net.mptcp.scheduler=bpf_bkup" ); - server_fd =start_mptcp_server (AF_INET ,NULL ,0 ,0 ); +sched_init ("subflow backup" ,"bpf_bkup" ); + server_fd =start_mptcp_server (AF_INET ,ADDR_1 ,0 ,0 ); client_fd =connect_to_fd (server_fd,0 );send_data (server_fd, client_fd); -ASSERT_GT (system ("ss -MOenita | grep '10.0.1.1' | grep 'bytes_sent:'" ),0 ,"ss" ); +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); -cleanup (); +sched_cleanup ();bpf_link__destroy (link);mptcp_bpf_bkup__destroy (bkup_skel); }
Signature · 1 line
2.34.1
PATCH 3/3 Squash to "selftests/bpf: Add bpf_rr test"
In reply to Geliang TangPlease update the commit log:
'''
This patch adds the round-robin BPF MPTCP scheduler test: test_rr(). Use sysctl to set net.mptcp.scheduler 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 ADDR_2 to PM netlink. Send data and check bytes_sent of 'ss' output after it to make sure the data has been sent on both net devices.
'''
--- tools/testing/selftests/bpf/prog_tests/mptcp.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
tools/testing/selftests/bpf/prog_tests/mptcp.c +5 -6
@@ -366,18 +366,17 @@ static void test_rr(void)return ; } -add_veth (); -system ("ip mptcp endpoint add 10.0.1.1 subflow" ); -system ("sysctl -qw net.mptcp.scheduler=bpf_rr" ); - server_fd =start_mptcp_server (AF_INET ,NULL ,0 ,0 ); +sched_init ("subflow" ,"bpf_rr" ); + server_fd =start_mptcp_server (AF_INET ,ADDR_1 ,0 ,0 ); client_fd =connect_to_fd (server_fd,0 );send_data (server_fd, client_fd); -ASSERT_OK (system ("ss -MOenita | grep '10.0.1.1' | grep -q 'bytes_sent:'" ),"ss" ); +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); -cleanup (); +sched_cleanup ();bpf_link__destroy (link);mptcp_bpf_rr__destroy (rr_skel); }
Signature · 1 line
2.34.1
Re: Squash to "selftests/bpf: Add bpf_rr test": Tests Results
Hi Geliang,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal:
- Unstable: 2 failed test(s): selftest_mptcp_join selftest_simult_flows 🔴:
- Task: https://cirrus-ci.com/task/5696523970281472
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5696523970281472/summary/summary.txt
- KVM Validation: debug:
- Unstable: 2 failed test(s): selftest_diag selftest_mptcp_join 🔴:
- Task: https://cirrus-ci.com/task/5133574016860160
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5133574016860160/summary/summary.txt
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/eabbbe1c8c5e
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-debugFor 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 (Tessares)
Quoted 6 lines · Geliang Tang
do some cleanups for bpf sched selftests:
- add one more veth net device.
- use '10.0.1.1' to send data instead of use default '127.0.0.1'.
- add a new helperhas_bytes_sent().
- update commit logs.
Quoted 8 lines
Geliang Tang (3):
Squash to "selftests/bpf: Addbpf_firsttest"
Squash to "selftests/bpf: Addbpf_bkuptest"
Squash to "selftests/bpf: Addbpf_rrtest"
.../testing/selftests/bpf/prog_tests/mptcp.c| 63 ++++++++++++-------1 file changed, 41 insertions(+), 22 deletions(-)
Hi Geliang -
Thanks for these selftest enhancements. These 3 commits are ok to squash.
--
Mat Martineau
Intel
Hi Geliang, Mat,
Quoted 10 lines · Geliang Tang
do some cleanups for bpf sched selftests:
- add one more veth net device.
- use '10.0.1.1' to send data instead of use default '127.0.0.1'.
- add a new helperhas_bytes_sent().
- update commit logs.Geliang Tang (3):
Squash to "selftests/bpf: Addbpf_firsttest"
Squash to "selftests/bpf: Addbpf_bkuptest"
Squash to "selftests/bpf: Addbpf_rrtest"
Thank you for these patches and reviews!
- 8106c5f35319: "squashed" patch 1/3 in "selftests/bpf: Add bpf_first test"
- 1404767ad7db: tg:msg: import new commit message
- 8c2344d28fb6: "squashed" patch 2/3 in "selftests/bpf: Add bpf_bkup test"
- 65805439dcb2: tg:msg: import new commit message
- 9d020c5e7420: "squashed" patch 3/3 in "selftests/bpf: Add bpf_rr test"
- f1ca39aef385: tg:msg: import new commit message
- Results: 293143ba65b0..c3839c0496a1 (export)
Builds and tests are now in progress:
https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export/20220607T125051
https://github.com/multipath-tcp/mptcp_net-next/actions/workflows/build-validation.yml?query=branch:export
Cheers,
Matt
Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions www.tessares.net