forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 1
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 mptcp_subflow bpf_iter test prog
This patch adds a new mptcp bpf selftest program for the newly added mptcp_subflow bpf_iter. Export bpf_iter_mptcp_subflow_new/_next/_destroy into bpf_experimental.h then use bpf_for_each(mptcp_subflow, subflow, msk) to walk the mptcp subflow list. Add a ftrace hook for mptcp_sched_get_send() to do this test and invoke kfuncs mptcp_subflow_active() and mptcp_subflow_set_scheduled() in the loops. Signed-off-by: Geliang Tang <[email protected]>
- Loading branch information
1 parent
4f3b8cb
commit d9384eb
Showing
3 changed files
with
49 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,38 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* Copyright (c) 2024, Kylin Software */ | ||
|
||
/* vmlinux.h, bpf_helpers.h and other 'define' */ | ||
#include "bpf_tracing_net.h" | ||
#include "mptcp_bpf.h" | ||
|
||
char _license[] SEC("license") = "GPL"; | ||
int iter = 0; | ||
int pid; | ||
|
||
SEC("fentry/mptcp_sched_get_send") | ||
int BPF_PROG(trace_mptcp_sched_get_send, struct mptcp_sock *msk) | ||
{ | ||
struct mptcp_subflow_context *subflow; | ||
int i = 0; | ||
|
||
if (bpf_get_current_pid_tgid() >> 32 != pid) | ||
return 0; | ||
|
||
bpf_rcu_read_lock(); | ||
bpf_for_each(mptcp_subflow, subflow, msk) { | ||
if (i++ >= MPTCP_SUBFLOWS_MAX) | ||
break; | ||
|
||
if (subflow->token != msk->token) | ||
break; | ||
|
||
if (!mptcp_subflow_active(subflow)) | ||
continue; | ||
|
||
mptcp_subflow_set_scheduled(subflow, false); | ||
} | ||
bpf_rcu_read_unlock(); | ||
|
||
iter = i; | ||
return 0; | ||
} |