Skip to content

Commit d3ce822

Browse files
Geliang Tangintel-lab-lkp
authored andcommitted
Squash to "bpf: Add mptcp_subflow bpf_iter"
Drop the NULL check for 'msk' as Martin suggested, add more checks for 'sk'. Use the "struct sock *sk" instead of "struct mptcp-sock *msk" as the argument in the bpf_iter_mptcp_subflow_new as Martin suggested. v4: - drop sock_owned_by_user_nocheck and spin_is_locked. According to comments from Mat [2] and Martin [1], in this set mptcp_subflow bpf_iter only used from a cg sockopt bpf prog, no need to add these check at this moment. [1] https://lore.kernel.org/all/[email protected]/ [2] https://patchwork.kernel.org/project/mptcp/patch/f6469225598beecbf0bda12a4c33fafa86c0ff15.1739787744.git.tanggeliang@kylinos.cn/ v3: - continue to use sock_owned_by_user_nocheck and spin_is_locked checks instead of using msk_owned_by_me(). v2: - check the owner before assigning the msk as Mat suggested. Signed-off-by: Geliang Tang <[email protected]>
1 parent 49e74e8 commit d3ce822

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

net/mptcp/bpf.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,24 +235,24 @@ bpf_mptcp_subflow_ctx(const struct sock *sk)
235235

236236
__bpf_kfunc static int
237237
bpf_iter_mptcp_subflow_new(struct bpf_iter_mptcp_subflow *it,
238-
struct mptcp_sock *msk)
238+
struct sock *sk)
239239
{
240240
struct bpf_iter_mptcp_subflow_kern *kit = (void *)it;
241-
struct sock *sk = (struct sock *)msk;
241+
struct mptcp_sock *msk;
242242

243243
BUILD_BUG_ON(sizeof(struct bpf_iter_mptcp_subflow_kern) >
244244
sizeof(struct bpf_iter_mptcp_subflow));
245245
BUILD_BUG_ON(__alignof__(struct bpf_iter_mptcp_subflow_kern) !=
246246
__alignof__(struct bpf_iter_mptcp_subflow));
247247

248-
kit->msk = msk;
249-
if (!msk)
248+
if (unlikely(!sk || !sk_fullsock(sk)))
250249
return -EINVAL;
251250

252-
if (!sock_owned_by_user_nocheck(sk) &&
253-
!spin_is_locked(&sk->sk_lock.slock))
251+
if (sk->sk_protocol != IPPROTO_MPTCP)
254252
return -EINVAL;
255253

254+
msk = mptcp_sk(sk);
255+
kit->msk = msk;
256256
kit->pos = &msk->conn_list;
257257
return 0;
258258
}

0 commit comments

Comments
 (0)