Skip to content

Commit

Permalink
selftests/bpf: Add bpf_red scheduler & test
Browse files Browse the repository at this point in the history
This patch implements the redundant BPF MPTCP scheduler, named bpf_red,
which sends all packets redundantly on all available subflows.

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.

Signed-off-by: Geliang Tang <[email protected]>
Reviewed-by: Mat Martineau <[email protected]>
Reviewed-by: Matthieu Baerts (NGI0) <[email protected]>
  • Loading branch information
Geliang Tang authored and matttbe committed Feb 24, 2025
1 parent 335e596 commit e6f4878
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tools/testing/selftests/bpf/prog_tests/mptcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "mptcp_bpf_first.skel.h"
#include "mptcp_bpf_bkup.skel.h"
#include "mptcp_bpf_rr.skel.h"
#include "mptcp_bpf_red.skel.h"

#define NS_TEST "mptcp_ns"
#define ADDR_1 "10.0.1.1"
Expand Down Expand Up @@ -709,6 +710,18 @@ static void test_rr(void)
mptcp_bpf_rr__destroy(skel);
}

static void test_red(void)
{
struct mptcp_bpf_red *skel;

skel = mptcp_bpf_red__open_and_load();
if (!ASSERT_OK_PTR(skel, "open_and_load: red"))
return;

test_bpf_sched(skel->obj, "red", WITH_DATA, WITH_DATA);
mptcp_bpf_red__destroy(skel);
}

void test_mptcp(void)
{
if (test__start_subtest("base"))
Expand All @@ -727,4 +740,6 @@ void test_mptcp(void)
test_bkup();
if (test__start_subtest("rr"))
test_rr();
if (test__start_subtest("red"))
test_red();
}
39 changes: 39 additions & 0 deletions tools/testing/selftests/bpf/progs/mptcp_bpf_red.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2022, SUSE. */

#include "mptcp_bpf.h"
#include <bpf/bpf_tracing.h>

char _license[] SEC("license") = "GPL";

SEC("struct_ops")
void BPF_PROG(mptcp_sched_red_init, struct mptcp_sock *msk)
{
}

SEC("struct_ops")
void BPF_PROG(mptcp_sched_red_release, struct mptcp_sock *msk)
{
}

SEC("struct_ops")
int BPF_PROG(bpf_red_get_send, struct mptcp_sock *msk,
struct mptcp_sched_data *data)
{
for (int i = 0; i < data->subflows && i < MPTCP_SUBFLOWS_MAX; i++) {
if (!bpf_mptcp_subflow_ctx_by_pos(data, i))
break;

mptcp_subflow_set_scheduled(bpf_mptcp_subflow_ctx_by_pos(data, i), true);
}

return 0;
}

SEC(".struct_ops")
struct mptcp_sched_ops red = {
.init = (void *)mptcp_sched_red_init,
.release = (void *)mptcp_sched_red_release,
.get_send = (void *)bpf_red_get_send,
.name = "bpf_red",
};

0 comments on commit e6f4878

Please sign in to comment.