Skip to content

Commit 887fc23

Browse files
Geliang Tangmatttbe
authored andcommitted
selftests/bpf: Add bpf_bkup scheduler & test
This patch implements the backup flag test scheduler, named bpf_bkup, which picks the first non-backup subflow to send data. Using MPTCP_SCHED_TEST macro to add a new test for this bpf_bkup scheduler, the arguments "1 0" means data has been only sent on the first subflow ADDR1. 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 6e8283b commit 887fc23

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-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
@@ -12,6 +12,7 @@
1212
#include "mptcpify.skel.h"
1313
#include "mptcp_subflow.skel.h"
1414
#include "mptcp_bpf_first.skel.h"
15+
#include "mptcp_bpf_bkup.skel.h"
1516

1617
#define NS_TEST "mptcp_ns"
1718
#define ADDR_1 "10.0.1.1"
@@ -613,6 +614,18 @@ static void test_first(void)
613614
mptcp_bpf_first__destroy(skel);
614615
}
615616

617+
static void test_bkup(void)
618+
{
619+
struct mptcp_bpf_bkup *skel;
620+
621+
skel = mptcp_bpf_bkup__open_and_load();
622+
if (!ASSERT_OK_PTR(skel, "open_and_load: bkup"))
623+
return;
624+
625+
test_bpf_sched(skel->maps.bkup, "bkup", WITH_DATA, WITHOUT_DATA);
626+
mptcp_bpf_bkup__destroy(skel);
627+
}
628+
616629
void test_mptcp(void)
617630
{
618631
if (test__start_subtest("base"))
@@ -625,4 +638,6 @@ void test_mptcp(void)
625638
test_default();
626639
if (test__start_subtest("first"))
627640
test_first();
641+
if (test__start_subtest("bkup"))
642+
test_bkup();
628643
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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_bkup_init, struct mptcp_sock *msk)
11+
{
12+
}
13+
14+
SEC("struct_ops")
15+
void BPF_PROG(mptcp_sched_bkup_release, struct mptcp_sock *msk)
16+
{
17+
}
18+
19+
SEC("struct_ops")
20+
int BPF_PROG(bpf_bkup_get_send, struct mptcp_sock *msk)
21+
{
22+
struct mptcp_subflow_context *subflow;
23+
24+
bpf_for_each(mptcp_subflow, subflow, (struct sock *)msk) {
25+
if (!BPF_CORE_READ_BITFIELD_PROBED(subflow, backup) ||
26+
!BPF_CORE_READ_BITFIELD_PROBED(subflow, request_bkup)) {
27+
mptcp_subflow_set_scheduled(subflow, true);
28+
break;
29+
}
30+
}
31+
32+
return 0;
33+
}
34+
35+
SEC(".struct_ops.link")
36+
struct mptcp_sched_ops bkup = {
37+
.init = (void *)mptcp_sched_bkup_init,
38+
.release = (void *)mptcp_sched_bkup_release,
39+
.get_send = (void *)bpf_bkup_get_send,
40+
.name = "bpf_bkup",
41+
};

0 commit comments

Comments
 (0)