Skip to content

Commit dcbe5c3

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 7d7ee76 commit dcbe5c3

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"
@@ -709,6 +710,18 @@ static void test_rr(void)
709710
mptcp_bpf_rr__destroy(skel);
710711
}
711712

713+
static void test_red(void)
714+
{
715+
struct mptcp_bpf_red *skel;
716+
717+
skel = mptcp_bpf_red__open_and_load();
718+
if (!ASSERT_OK_PTR(skel, "open_and_load: red"))
719+
return;
720+
721+
test_bpf_sched(skel->obj, "red", WITH_DATA, WITH_DATA);
722+
mptcp_bpf_red__destroy(skel);
723+
}
724+
712725
void test_mptcp(void)
713726
{
714727
if (test__start_subtest("base"))
@@ -727,4 +740,6 @@ void test_mptcp(void)
727740
test_bkup();
728741
if (test__start_subtest("rr"))
729742
test_rr();
743+
if (test__start_subtest("red"))
744+
test_red();
730745
}
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_send, 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_send = (void *)bpf_red_get_send,
38+
.name = "bpf_red",
39+
};

0 commit comments

Comments
 (0)