Skip to content

Commit c0baff0

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 785ca0c commit c0baff0

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

net/mptcp/bpf.c

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -218,21 +218,13 @@ struct bpf_iter_mptcp_subflow_kern {
218218

219219
__bpf_kfunc_start_defs();
220220

221-
__bpf_kfunc static struct mptcp_sock *bpf_mptcp_sk(struct sock *sk)
222-
{
223-
return mptcp_sk(sk);
224-
}
225-
226221
__bpf_kfunc static struct mptcp_subflow_context *
227222
bpf_mptcp_subflow_ctx(const struct sock *sk)
228223
{
229-
return mptcp_subflow_ctx(sk);
230-
}
224+
if (!sk)
225+
return NULL;
231226

232-
__bpf_kfunc static struct sock *
233-
bpf_mptcp_subflow_tcp_sock(const struct mptcp_subflow_context *subflow)
234-
{
235-
return mptcp_subflow_tcp_sock(subflow);
227+
return mptcp_subflow_ctx(sk);
236228
}
237229

238230
__bpf_kfunc static int
@@ -301,9 +293,7 @@ __bpf_kfunc static bool bpf_mptcp_subflow_queues_empty(struct sock *sk)
301293
__bpf_kfunc_end_defs();
302294

303295
BTF_KFUNCS_START(bpf_mptcp_common_kfunc_ids)
304-
BTF_ID_FLAGS(func, bpf_mptcp_sk)
305-
BTF_ID_FLAGS(func, bpf_mptcp_subflow_ctx)
306-
BTF_ID_FLAGS(func, bpf_mptcp_subflow_tcp_sock)
296+
BTF_ID_FLAGS(func, bpf_mptcp_subflow_ctx, KF_RET_NULL)
307297
BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_new, KF_ITER_NEW | KF_TRUSTED_ARGS)
308298
BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_next, KF_ITER_NEXT | KF_RET_NULL)
309299
BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_destroy, KF_ITER_DESTROY)
@@ -337,7 +327,7 @@ static int __init bpf_mptcp_kfunc_init(void)
337327
int ret;
338328

339329
ret = register_btf_fmodret_id_set(&bpf_mptcp_fmodret_set);
340-
ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_UNSPEC,
330+
ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_CGROUP_SOCKOPT,
341331
&bpf_mptcp_common_kfunc_set);
342332
ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,
343333
&bpf_mptcp_sched_kfunc_set);

0 commit comments

Comments
 (0)