Skip to content

Commit d2274bd

Browse files
Geliang Tangintel-lab-lkp
authored andcommitted
Squash to "selftests/bpf: Add mptcp_subflow bpf_iter subtest"
IPPROTO_MPTCP is checked in bpf_mptcp_sk(), no need to check it in BPF program. bpf_mptcp_sk() and bpf_mptcp_subflow_ctx() may return NULL, need to check the return values. Signed-off-by: Geliang Tang <[email protected]>
1 parent 1faebcc commit d2274bd

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ int iters_subflow(struct bpf_sockopt *ctx)
2121
struct mptcp_sock *msk;
2222
int local_ids = 0;
2323

24-
if (!sk || sk->protocol != IPPROTO_MPTCP ||
25-
ctx->level != SOL_TCP || ctx->optname != TCP_IS_MPTCP)
24+
if (ctx->level != SOL_TCP || ctx->optname != TCP_IS_MPTCP)
2625
return 1;
2726

2827
msk = bpf_mptcp_sk((struct sock *)sk);
29-
if (msk->pm.server_side || !msk->pm.subflows)
28+
if (!msk || msk->pm.server_side || !msk->pm.subflows)
3029
return 1;
3130

3231
msk = bpf_mptcp_sock_acquire(msk);
@@ -53,7 +52,7 @@ int iters_subflow(struct bpf_sockopt *ctx)
5352

5453
/* only to check the following kfunc works */
5554
subflow = bpf_mptcp_subflow_ctx(ssk);
56-
if (subflow->token != msk->token)
55+
if (!subflow || subflow->token != msk->token)
5756
goto out;
5857

5958
ids = local_ids;

0 commit comments

Comments
 (0)