Skip to content

Commit 27cf124

Browse files
Geliang Tangintel-lab-lkp
Geliang Tang
authored andcommitted
Squash to "selftests/bpf: Add mptcp_subflow bpf_iter subtest"
Use bpf_core_cast() instead of bpf_skc_to_mptcp_sock(). Change the 2nd parameter type of bpf_for_each() as 'struct sock'. Drop use of bpf_mptcp_sock_acquire/release. Drop declaration of bpf_mptcp_subflow_tcp_sock. It's no longer used. Update the comment for mptcp_subflow_tcp_sock(), which is a BPF helper, not a kfunc. Please update the commit log as: ''' This patch adds a "cgroup/getsockopt" program "iters_subflow" to test the newly added mptcp_subflow bpf_iter. Export mptcp_subflow helpers bpf_iter_mptcp_subflow_new/_next/_destroy and other helpers into bpf_experimental.h. Use bpf_for_each() to walk the subflow list of this msk. MPTCP-specific packet scheduler kfunc can be called in the loop. In this test, just add all subflow ids to local variable local_ids, then invoke the helper mptcp_subflow_tcp_sock() in the loop to pick a subsocket. Out of the loop, use bpf_mptcp_subflow_ctx() to get the subflow context of the picked subsocket and do some verification. Finally, assign local_ids to global variable ids so that the application can obtain this value. Add a subtest named test_iters_subflow to load and verify the newly added mptcp_subflow type bpf_iter example in test_mptcp. Use the helper endpoint_init() to add 3 new subflow endpoints. Send a byte of message to start the mptcp connection, and wait for new subflows to be added. getsockopt() is invoked to trigger the "cgroup/getsockopt" test program "iters_subflow". Check if skel->bss->ids equals 10 to verify whether this mptcp_subflow bpf_iter loops correctly as expected. ''' Signed-off-by: Geliang Tang <[email protected]>
1 parent 850288c commit 27cf124

File tree

3 files changed

+3
-12
lines changed

3 files changed

+3
-12
lines changed

tools/testing/selftests/bpf/bpf_experimental.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ extern void bpf_iter_css_destroy(struct bpf_iter_css *it) __weak __ksym;
577577

578578
struct bpf_iter_mptcp_subflow;
579579
extern int bpf_iter_mptcp_subflow_new(struct bpf_iter_mptcp_subflow *it,
580-
struct mptcp_sock *msk) __weak __ksym;
580+
struct sock *sk) __weak __ksym;
581581
extern struct mptcp_subflow_context *
582582
bpf_iter_mptcp_subflow_next(struct bpf_iter_mptcp_subflow *it) __weak __ksym;
583583
extern void

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

-5
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,8 @@ mptcp_subflow_tcp_sock(const struct mptcp_subflow_context *subflow)
4343
}
4444

4545
/* ksym */
46-
extern struct mptcp_sock *bpf_mptcp_sock_acquire(struct mptcp_sock *msk) __ksym;
47-
extern void bpf_mptcp_sock_release(struct mptcp_sock *msk) __ksym;
48-
4946
extern struct mptcp_subflow_context *
5047
bpf_mptcp_subflow_ctx(const struct sock *sk) __ksym;
51-
extern struct sock *
52-
bpf_mptcp_subflow_tcp_sock(const struct mptcp_subflow_context *subflow) __ksym;
5348

5449
extern void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow,
5550
bool scheduled) __ksym;

tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c

+2-6
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,15 @@ int iters_subflow(struct bpf_sockopt *ctx)
2828
if (!msk || msk->pm.server_side || !msk->pm.subflows)
2929
return 1;
3030

31-
msk = bpf_mptcp_sock_acquire(msk);
32-
if (!msk)
33-
return 1;
34-
bpf_for_each(mptcp_subflow, subflow, msk) {
31+
bpf_for_each(mptcp_subflow, subflow, (struct sock *)sk) {
3532
/* Here MPTCP-specific packet scheduler kfunc can be called:
3633
* this test is not doing anything really useful, only to
3734
* verify the iteration works.
3835
*/
3936

4037
local_ids += subflow->subflow_id;
4138

42-
/* only to check the following kfunc works */
39+
/* only to check the following helper works */
4340
ssk = mptcp_subflow_tcp_sock(subflow);
4441
}
4542

@@ -58,6 +55,5 @@ int iters_subflow(struct bpf_sockopt *ctx)
5855
ids = local_ids;
5956

6057
out:
61-
bpf_mptcp_sock_release(msk);
6258
return 1;
6359
}

0 commit comments

Comments
 (0)