Skip to content

Commit d819ac3

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 57a8750 commit d819ac3

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-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
@@ -13,6 +13,7 @@
1313
#include "mptcp_subflow.skel.h"
1414
#include "mptcp_bpf_iters.skel.h"
1515
#include "mptcp_bpf_first.skel.h"
16+
#include "mptcp_bpf_bkup.skel.h"
1617

1718
#define NS_TEST "mptcp_ns"
1819
#define ADDR_1 "10.0.1.1"
@@ -683,6 +684,18 @@ static void test_first(void)
683684
mptcp_bpf_first__destroy(skel);
684685
}
685686

687+
static void test_bkup(void)
688+
{
689+
struct mptcp_bpf_bkup *skel;
690+
691+
skel = mptcp_bpf_bkup__open_and_load();
692+
if (!ASSERT_OK_PTR(skel, "open_and_load: bkup"))
693+
return;
694+
695+
test_bpf_sched(skel->obj, "bkup", WITH_DATA, WITHOUT_DATA);
696+
mptcp_bpf_bkup__destroy(skel);
697+
}
698+
686699
void test_mptcp(void)
687700
{
688701
if (test__start_subtest("base"))
@@ -697,4 +710,6 @@ void test_mptcp(void)
697710
test_default();
698711
if (test__start_subtest("first"))
699712
test_first();
713+
if (test__start_subtest("bkup"))
714+
test_bkup();
700715
}

tools/testing/selftests/bpf/progs/mptcp_bpf.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
#include "bpf_experimental.h"
66

7+
/* mptcp helpers from include/net/mptcp.h */
8+
#define MPTCP_SUBFLOWS_MAX 8
9+
710
/* list helpers from include/linux/list.h */
811
static inline int list_is_head(const struct list_head *list,
912
const struct list_head *head)
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")
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)