[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <877c0rngsg.fsf@cloudflare.com>
Date: Wed, 02 Jul 2025 10:22:23 +0200
From: Jakub Sitnicki <jakub@...udflare.com>
To: Andrii Nakryiko <andrii.nakryiko@...il.com>
Cc: bpf@...r.kernel.org, Alexei Starovoitov <ast@...nel.org>, Arthur Fabre
<arthur@...hurfabre.com>, Eric Dumazet <edumazet@...gle.com>, Jakub
Kicinski <kuba@...nel.org>, Jesper Dangaard Brouer <hawk@...nel.org>,
Jesse Brandeburg <jbrandeburg@...udflare.com>, Joanne Koong
<joannelkoong@...il.com>, Lorenzo Bianconi <lorenzo@...nel.org>, Toke
Høiland-Jørgensen <thoiland@...hat.com>, Yan Zhai
<yan@...udflare.com>,
netdev@...r.kernel.org, kernel-team@...udflare.com, Stanislav Fomichev
<sdf@...ichev.me>
Subject: Re: [PATCH bpf-next 03/13] bpf: Add new variant of skb dynptr for
the metadata area
On Tue, Jul 01, 2025 at 01:59 PM -07, Andrii Nakryiko wrote:
> On Mon, Jun 30, 2025 at 7:56 AM Jakub Sitnicki <jakub@...udflare.com> 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@...udflare.com>
>> ---
>> 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?
>
> [...]
Agree. Let's keep things simple.
This piggybacking on the skb dynptr was a bad idea.
Powered by blists - more mailing lists