Skip to content

Commit

Permalink
Squash to "selftests/bpf: Add mptcp_subflow bpf_iter subtest"
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Geliang Tang authored and intel-lab-lkp committed Nov 21, 2024
1 parent 1faebcc commit d2274bd
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ int iters_subflow(struct bpf_sockopt *ctx)
struct mptcp_sock *msk;
int local_ids = 0;

if (!sk || sk->protocol != IPPROTO_MPTCP ||
ctx->level != SOL_TCP || ctx->optname != TCP_IS_MPTCP)
if (ctx->level != SOL_TCP || ctx->optname != TCP_IS_MPTCP)
return 1;

msk = bpf_mptcp_sk((struct sock *)sk);
if (msk->pm.server_side || !msk->pm.subflows)
if (!msk || msk->pm.server_side || !msk->pm.subflows)
return 1;

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

/* only to check the following kfunc works */
subflow = bpf_mptcp_subflow_ctx(ssk);
if (subflow->token != msk->token)
if (!subflow || subflow->token != msk->token)
goto out;

ids = local_ids;
Expand Down

0 comments on commit d2274bd

Please sign in to comment.