Re: [PATCH bpf-next 03/13] bpf: Add new variant of skb dynptr for the metadata area

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jun 30, 2025 at 7:56 AM Jakub Sitnicki <jakub@xxxxxxxxxxxxxx> wrote:
>
> Add a new flag for the bpf_dynptr_from_skb helper to let users to create
> dynptrs to skb metadata area. Access paths are stubbed out. Implemented by
> the following changes.
>
> Signed-off-by: Jakub Sitnicki <jakub@xxxxxxxxxxxxxx>
> ---
>  include/uapi/linux/bpf.h |  9 ++++++++
>  net/core/filter.c        | 60 +++++++++++++++++++++++++++++++++++++++++-------
>  2 files changed, 61 insertions(+), 8 deletions(-)
>
> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
> index 719ba230032f..ab5730d2fb29 100644
> --- a/include/uapi/linux/bpf.h
> +++ b/include/uapi/linux/bpf.h
> @@ -7591,4 +7591,13 @@ enum bpf_kfunc_flags {
>         BPF_F_PAD_ZEROS = (1ULL << 0),
>  };
>
> +/**
> + * enum bpf_dynptr_from_skb_flags - Flags for bpf_dynptr_from_skb()
> + *
> + * @BPF_DYNPTR_F_SKB_METADATA: Create dynptr to the SKB metadata area
> + */
> +enum bpf_dynptr_from_skb_flags {
> +       BPF_DYNPTR_F_SKB_METADATA = (1ULL << 0),
> +};
> +
>  #endif /* _UAPI__LINUX_BPF_H__ */
> diff --git a/net/core/filter.c b/net/core/filter.c
> index 1fee51b72220..3c2948517838 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -11967,12 +11967,27 @@ bpf_sk_base_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
>         return func;
>  }
>
> +enum skb_dynptr_offset {
> +       SKB_DYNPTR_METADATA     = -1,
> +       SKB_DYNPTR_PAYLOAD      = 0,
> +};

I'm missing why you need to do it in this hacky way instead of just
having both bpf_dynptr_from_skb() and bpf_dynptr_from_skb_metadata()
(or whatever we bikeshed it into), which will create
BPF_DYNPTR_TYPE_SKB or new BPF_DYNPTR_TYPE_SKB_META dynptr kind,
respectively. Why so complicated?

[...]





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux