Skip to content

Commit

Permalink
selftests/bpf: Add bpf_burst test
Browse files Browse the repository at this point in the history
This patch adds the burst BPF MPTCP scheduler test: test_burst(). 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.

Signed-off-by: Geliang Tang <[email protected]>
Reviewed-by: Mat Martineau <[email protected]>
  • Loading branch information
geliangtang authored and matttbe committed Nov 22, 2023
1 parent 6c4a1bb commit d8c6407
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tools/testing/selftests/bpf/prog_tests/mptcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "mptcp_bpf_bkup.skel.h"
#include "mptcp_bpf_rr.skel.h"
#include "mptcp_bpf_red.skel.h"
#include "mptcp_bpf_burst.skel.h"

#define NS_TEST "mptcp_ns"

Expand Down Expand Up @@ -615,6 +616,41 @@ static void test_red(void)
mptcp_bpf_red__destroy(red_skel);
}

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

void test_mptcp(void)
{
if (test__start_subtest("base"))
Expand All @@ -631,4 +667,6 @@ void test_mptcp(void)
test_rr();
if (test__start_subtest("red"))
test_red();
if (test__start_subtest("burst"))
test_burst();
}

0 comments on commit d8c6407

Please sign in to comment.