Skip to content

Commit 746ec40

Browse files
Geliang Tangmatttbe
authored andcommitted
selftests/bpf: Add bpf_red scheduler & test
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]>
1 parent a1d32ba commit 746ec40

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

tools/testing/selftests/bpf/prog_tests/mptcp.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "mptcp_bpf_first.skel.h"
1616
#include "mptcp_bpf_bkup.skel.h"
1717
#include "mptcp_bpf_rr.skel.h"
18+
#include "mptcp_bpf_red.skel.h"
1819

1920
#define NS_TEST "mptcp_ns"
2021
#define ADDR_1 "10.0.1.1"
@@ -727,6 +728,18 @@ static void test_rr(void)
727728
mptcp_bpf_rr__destroy(skel);
728729
}
729730

731+
static void test_red(void)
732+
{
733+
struct mptcp_bpf_red *skel;
734+
735+
skel = mptcp_bpf_red__open_and_load();
736+
if (!ASSERT_OK_PTR(skel, "open_and_load: red"))
737+
return;
738+
739+
test_bpf_sched(skel->obj, "red", WITH_DATA, WITH_DATA);
740+
mptcp_bpf_red__destroy(skel);
741+
}
742+
730743
void test_mptcp(void)
731744
{
732745
if (test__start_subtest("base"))
@@ -745,4 +758,6 @@ void test_mptcp(void)
745758
test_bkup();
746759
if (test__start_subtest("rr"))
747760
test_rr();
761+
if (test__start_subtest("red"))
762+
test_red();
748763
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/* Copyright (c) 2022, SUSE. */
3+
4+
#include "mptcp_bpf.h"
5+
#include <bpf/bpf_tracing.h>
6+
7+
char _license[] SEC("license") = "GPL";
8+
9+
SEC("struct_ops")
10+
void BPF_PROG(mptcp_sched_red_init, struct mptcp_sock *msk)
11+
{
12+
}
13+
14+
SEC("struct_ops")
15+
void BPF_PROG(mptcp_sched_red_release, struct mptcp_sock *msk)
16+
{
17+
}
18+
19+
SEC("struct_ops")
20+
int BPF_PROG(bpf_red_get_subflow, struct mptcp_sock *msk,
21+
struct mptcp_sched_data *data)
22+
{
23+
for (int i = 0; i < data->subflows && i < MPTCP_SUBFLOWS_MAX; i++) {
24+
if (!bpf_mptcp_subflow_ctx_by_pos(data, i))
25+
break;
26+
27+
mptcp_subflow_set_scheduled(bpf_mptcp_subflow_ctx_by_pos(data, i), true);
28+
}
29+
30+
return 0;
31+
}
32+
33+
SEC(".struct_ops")
34+
struct mptcp_sched_ops red = {
35+
.init = (void *)mptcp_sched_red_init,
36+
.release = (void *)mptcp_sched_red_release,
37+
.get_subflow = (void *)bpf_red_get_subflow,
38+
.name = "bpf_red",
39+
};

0 commit comments

Comments
 (0)