-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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]>
- Loading branch information
Showing
3 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// 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_bkup_init, struct mptcp_sock *msk) | ||
{ | ||
} | ||
|
||
SEC("struct_ops") | ||
void BPF_PROG(mptcp_sched_bkup_release, struct mptcp_sock *msk) | ||
{ | ||
} | ||
|
||
SEC("struct_ops") | ||
int BPF_PROG(bpf_bkup_get_subflow, struct mptcp_sock *msk, | ||
struct mptcp_sched_data *data) | ||
{ | ||
int nr = -1; | ||
|
||
for (int i = 0; i < data->subflows && i < MPTCP_SUBFLOWS_MAX; i++) { | ||
struct mptcp_subflow_context *subflow; | ||
|
||
subflow = bpf_mptcp_subflow_ctx_by_pos(data, i); | ||
if (!subflow) | ||
break; | ||
|
||
if (!BPF_CORE_READ_BITFIELD_PROBED(subflow, backup) || | ||
!BPF_CORE_READ_BITFIELD_PROBED(subflow, request_bkup)) { | ||
nr = i; | ||
break; | ||
} | ||
} | ||
|
||
if (nr != -1) { | ||
mptcp_subflow_set_scheduled(bpf_mptcp_subflow_ctx_by_pos(data, nr), true); | ||
return -1; | ||
} | ||
return 0; | ||
} | ||
|
||
SEC(".struct_ops") | ||
struct mptcp_sched_ops bkup = { | ||
.init = (void *)mptcp_sched_bkup_init, | ||
.release = (void *)mptcp_sched_bkup_release, | ||
.get_subflow = (void *)bpf_bkup_get_subflow, | ||
.name = "bpf_bkup", | ||
}; |