mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
bpf: Allow all struct_ops to use bpf_dynptr_from_skb()
bpf_dynptr_from_skb() was only made available to bpf_qdisc, so far the only struct_ops type that needs to read an skb. The upcoming bpf_tcp_ops header-option hooks (parse_hdr/write_hdr_opt) also want to access the TCP options of an skb through a dynptr. All struct_ops programs share BPF_PROG_TYPE_STRUCT_OPS, so register bpf_kfunc_set_skb (which holds bpf_dynptr_from_skb) for that program type once, instead of per struct_ops. This makes bpf_dynptr_from_skb() available to bpf_tcp_ops and any future struct_ops. With the kfunc now provided to all of struct_ops, the bpf_qdisc-specific registration becomes redundant and is dropped: bpf_qdisc_kfunc_filter() only constrains kfuncs listed in qdisc_kfunc_ids, so removing bpf_dynptr_from_skb from that set (and from qdisc_common_kfunc_set) lets it fall through the filter unchanged, and bpf_qdisc keeps access via the generic struct_ops registration. Widening the registration is safe: a struct_ops that does not receive an skb in its context has nothing to pass to the helper. Signed-off-by: Amery Hung <ameryhung@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com> Link: https://patch.msgid.link/20260917200542.3689605-11-ameryhung@gmail.com
This commit is contained in:
parent
369d9dcd8f
commit
6d4ce90766
|
|
@ -12887,6 +12887,7 @@ static int __init bpf_kfunc_init(void)
|
|||
ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_LWT_SEG6LOCAL, &bpf_kfunc_set_skb);
|
||||
ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_NETFILTER, &bpf_kfunc_set_skb);
|
||||
ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, &bpf_kfunc_set_skb);
|
||||
ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, &bpf_kfunc_set_skb);
|
||||
ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_SCHED_CLS, &bpf_kfunc_set_skb_meta);
|
||||
ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_SCHED_ACT, &bpf_kfunc_set_skb_meta);
|
||||
ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_XDP, &bpf_kfunc_set_xdp);
|
||||
|
|
|
|||
|
|
@ -280,7 +280,6 @@ BTF_KFUNCS_START(qdisc_kfunc_ids)
|
|||
BTF_ID_FLAGS(func, bpf_skb_get_hash)
|
||||
BTF_ID_FLAGS(func, bpf_kfree_skb, KF_RELEASE)
|
||||
BTF_ID_FLAGS(func, bpf_qdisc_skb_drop, KF_RELEASE)
|
||||
BTF_ID_FLAGS(func, bpf_dynptr_from_skb)
|
||||
BTF_ID_FLAGS(func, bpf_qdisc_watchdog_schedule)
|
||||
BTF_ID_FLAGS(func, bpf_qdisc_init_prologue)
|
||||
BTF_ID_FLAGS(func, bpf_qdisc_reset_destroy_epilogue)
|
||||
|
|
@ -290,7 +289,6 @@ BTF_KFUNCS_END(qdisc_kfunc_ids)
|
|||
BTF_SET_START(qdisc_common_kfunc_set)
|
||||
BTF_ID(func, bpf_skb_get_hash)
|
||||
BTF_ID(func, bpf_kfree_skb)
|
||||
BTF_ID(func, bpf_dynptr_from_skb)
|
||||
BTF_SET_END(qdisc_common_kfunc_set)
|
||||
|
||||
BTF_SET_START(qdisc_enqueue_kfunc_set)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user