Skip to content

Commit 4db100e

Browse files
Geliang Tangintel-lab-lkp
authored andcommitted
Squash to "bpf: Register mptcp common kfunc set"
Define .filter as Martin suggested. Signed-off-by: Geliang Tang <[email protected]>
1 parent 08a4452 commit 4db100e

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

net/mptcp/bpf.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,18 +317,32 @@ BTF_ID_FLAGS(func, bpf_mptcp_subflow_queues_empty)
317317
BTF_ID_FLAGS(func, mptcp_pm_subflow_chk_stale, KF_SLEEPABLE)
318318
BTF_KFUNCS_END(bpf_mptcp_common_kfunc_ids)
319319

320+
static int bpf_mptcp_common_kfunc_filter(const struct bpf_prog *prog, u32 kfunc_id)
321+
{
322+
if (!btf_id_set8_contains(&bpf_mptcp_common_kfunc_ids, kfunc_id))
323+
return 0;
324+
325+
if (prog->type != BPF_PROG_TYPE_STRUCT_OPS)
326+
return -EACCES;
327+
328+
#ifdef CONFIG_BPF_JIT
329+
if (prog->aux->st_ops == &bpf_mptcp_sched_ops)
330+
return 0;
331+
#endif
332+
return -EACCES;
333+
}
334+
320335
static const struct btf_kfunc_id_set bpf_mptcp_common_kfunc_set = {
321336
.owner = THIS_MODULE,
322337
.set = &bpf_mptcp_common_kfunc_ids,
338+
.filter = bpf_mptcp_common_kfunc_filter,
323339
};
324340

325341
static int __init bpf_mptcp_kfunc_init(void)
326342
{
327343
int ret;
328344

329345
ret = register_btf_fmodret_id_set(&bpf_mptcp_fmodret_set);
330-
ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_CGROUP_SOCKOPT,
331-
&bpf_mptcp_common_kfunc_set);
332346
ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,
333347
&bpf_mptcp_common_kfunc_set);
334348
#ifdef CONFIG_BPF_JIT

0 commit comments

Comments
 (0)