Skip to content

Commit 90fbb76

Browse files
Geliang Tangintel-lab-lkp
authored andcommitted
Squash to "bpf: Register mptcp common kfunc set"
Drop bpf_mptcp_sk() and bpf_mptcp_subflow_tcp_sock() definitions. Use bpf_skc_to_mptcp_sock() and mptcp_subflow_tcp_sock() in mptcp_subflow bpf_iter selftests instead. Address Martin's comments in v1: - add null-check for bpf_mptcp_subflow_ctx. - add KF_RET_NULL flags for bpf_mptcp_subflow_ctx. - register this kfunc set to BPF_PROG_TYPE_CGROUP_SOCKOPT only, not BPF_PROG_TYPE_UNSPEC. Signed-off-by: Geliang Tang <[email protected]>
1 parent 4e6f56c commit 90fbb76

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

net/mptcp/bpf.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -222,21 +222,14 @@ struct bpf_iter_mptcp_subflow_kern {
222222

223223
__bpf_kfunc_start_defs();
224224

225-
__bpf_kfunc static struct mptcp_sock *bpf_mptcp_sk(struct sock *sk)
226-
{
227-
return mptcp_sk(sk);
228-
}
229-
230225
__bpf_kfunc static struct mptcp_subflow_context *
231226
bpf_mptcp_subflow_ctx(const struct sock *sk)
232227
{
233-
return mptcp_subflow_ctx(sk);
234-
}
228+
if (sk && sk_fullsock(sk) &&
229+
sk->sk_protocol == IPPROTO_TCP && sk_is_mptcp(sk))
230+
return mptcp_subflow_ctx(sk);
235231

236-
__bpf_kfunc static struct sock *
237-
bpf_mptcp_subflow_tcp_sock(const struct mptcp_subflow_context *subflow)
238-
{
239-
return mptcp_subflow_tcp_sock(subflow);
232+
return NULL;
240233
}
241234

242235
__bpf_kfunc static int
@@ -305,9 +298,7 @@ __bpf_kfunc static bool bpf_mptcp_subflow_queues_empty(struct sock *sk)
305298
__bpf_kfunc_end_defs();
306299

307300
BTF_KFUNCS_START(bpf_mptcp_common_kfunc_ids)
308-
BTF_ID_FLAGS(func, bpf_mptcp_sk)
309-
BTF_ID_FLAGS(func, bpf_mptcp_subflow_ctx)
310-
BTF_ID_FLAGS(func, bpf_mptcp_subflow_tcp_sock)
301+
BTF_ID_FLAGS(func, bpf_mptcp_subflow_ctx, KF_RET_NULL)
311302
BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_new, KF_ITER_NEW | KF_TRUSTED_ARGS)
312303
BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_next, KF_ITER_NEXT | KF_RET_NULL)
313304
BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_destroy, KF_ITER_DESTROY)
@@ -341,7 +332,7 @@ static int __init bpf_mptcp_kfunc_init(void)
341332
int ret;
342333

343334
ret = register_btf_fmodret_id_set(&bpf_mptcp_fmodret_set);
344-
ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_UNSPEC,
335+
ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_CGROUP_SOCKOPT,
345336
&bpf_mptcp_common_kfunc_set);
346337
ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,
347338
&bpf_mptcp_sched_kfunc_set);

0 commit comments

Comments
 (0)