Skip to content

Commit

Permalink
selftests/bpf: Add bpf_rr test
Browse files Browse the repository at this point in the history
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. Send data and check bytes_sent of
'ss' output after it to make sure the data has been sent on the new veth
net device.

Reviewed-by: Mat Martineau <[email protected]>
Signed-off-by: Geliang Tang <[email protected]>
  • Loading branch information
geliangtang authored and matttbe committed Jun 4, 2022
1 parent 7338435 commit aa09224
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tools/testing/selftests/bpf/prog_tests/mptcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "mptcp_sock.skel.h"
#include "mptcp_bpf_first.skel.h"
#include "mptcp_bpf_bkup.skel.h"
#include "mptcp_bpf_rr.skel.h"

#ifndef TCP_CA_NAME_MAX
#define TCP_CA_NAME_MAX 16
Expand Down Expand Up @@ -329,6 +330,38 @@ static void test_bkup(void)
mptcp_bpf_bkup__destroy(bkup_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;
}

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);
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");

close(client_fd);
close(server_fd);
cleanup();
bpf_link__destroy(link);
mptcp_bpf_rr__destroy(rr_skel);
}

void test_mptcp(void)
{
if (test__start_subtest("base"))
Expand All @@ -337,4 +370,6 @@ void test_mptcp(void)
test_first();
if (test__start_subtest("bkup"))
test_bkup();
if (test__start_subtest("rr"))
test_rr();
}

0 comments on commit aa09224

Please sign in to comment.