This patch adds the round-robin BPF MPTCP scheduler test. Use sysctl to
set net.mptcp.scheduler to use this sched. Add a veth net device to
simulate the multiple addresses case. Use 'ip mptcp endpoint' command to
add this new endpoint to PM netlink.
Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
.../testing/selftests/bpf/prog_tests/mptcp.c | 38 +++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c
index 93a5739712ce..6303eba67fab 100644
--- a/tools/testing/selftests/bpf/prog_tests/mptcp.c
+++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c
@@ -6,6 +6,7 @@
#include "cgroup_helpers.h"
#include "network_helpers.h"
#include "mptcp_bpf_first.skel.h"
+#include "mptcp_bpf_rr.skel.h"
#ifndef TCP_CA_NAME_MAX
#define TCP_CA_NAME_MAX 16
@@ -369,10 +370,47 @@ static void test_first(void)
mptcp_bpf_first__destroy(first_skel);
}
+static void test_rr(void)
+{
+ struct mptcp_bpf_rr *rr_skel;
+ int server_fd, client_fd;
+ 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;
+ }
+
+ system("ip link add veth1 type veth");
+ system("ip addr add 10.0.1.1/24 dev veth1");
+ system("ip link set veth1 up");
+ 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);
+ client_fd = connect_to_mptcp_fd(server_fd, 0);
+
+ send_data(server_fd, client_fd);
+
+ close(client_fd);
+ close(server_fd);
+ system("sysctl -qw net.mptcp.scheduler=default");
+ system("ip mptcp endpoint flush");
+ system("ip link del veth1");
+ bpf_link__destroy(link);
+ mptcp_bpf_rr__destroy(rr_skel);
+}
+
void test_mptcp(void)
{
if (test__start_subtest("base"))
test_base();
if (test__start_subtest("first"))
test_first();
+ if (test__start_subtest("rr"))
+ test_rr();
}
--
2.34.1
On Wed, 11 May 2022, Geliang Tang wrote:
> This patch adds the round-robin BPF MPTCP scheduler test. Use sysctl to
> set net.mptcp.scheduler to use this sched. Add a veth net device to
> simulate the multiple addresses case. Use 'ip mptcp endpoint' command to
> add this new endpoint to PM netlink.
>
> Signed-off-by: Geliang Tang <geliang.tang@suse.com>
> ---
> .../testing/selftests/bpf/prog_tests/mptcp.c | 38 +++++++++++++++++++
> 1 file changed, 38 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c
> index 93a5739712ce..6303eba67fab 100644
> --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c
> +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c
> @@ -6,6 +6,7 @@
> #include "cgroup_helpers.h"
> #include "network_helpers.h"
> #include "mptcp_bpf_first.skel.h"
> +#include "mptcp_bpf_rr.skel.h"
>
> #ifndef TCP_CA_NAME_MAX
> #define TCP_CA_NAME_MAX 16
> @@ -369,10 +370,47 @@ static void test_first(void)
> mptcp_bpf_first__destroy(first_skel);
> }
>
> +static void test_rr(void)
> +{
> + struct mptcp_bpf_rr *rr_skel;
> + int server_fd, client_fd;
> + 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;
> + }
> +
> + system("ip link add veth1 type veth");
> + system("ip addr add 10.0.1.1/24 dev veth1");
> + system("ip link set veth1 up");
> + 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);
> + client_fd = connect_to_mptcp_fd(server_fd, 0);
> +
> + send_data(server_fd, client_fd);
> +
Is there a way to verify data was sent on both subflows? Maybe look at
bytes_sent or segs_out in 'ss' output?
> + close(client_fd);
> + close(server_fd);
> + system("sysctl -qw net.mptcp.scheduler=default");
> + system("ip mptcp endpoint flush");
> + system("ip link del veth1");
> + bpf_link__destroy(link);
> + mptcp_bpf_rr__destroy(rr_skel);
> +}
> +
> void test_mptcp(void)
> {
> if (test__start_subtest("base"))
> test_base();
> if (test__start_subtest("first"))
> test_first();
> + if (test__start_subtest("rr"))
> + test_rr();
> }
> --
> 2.34.1
>
>
>
--
Mat Martineau
Intel
© 2016 - 2026 Red Hat, Inc.