From: Jon Kohler <jon@nutanix.com>
To: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>,
Jason Wang <jasowang@redhat.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Alexei Starovoitov <ast@kernel.org>,
Jesper Dangaard Brouer <hawk@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
Simon Horman <horms@kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"bpf@vger.kernel.org" <bpf@vger.kernel.org>
Subject: Re: [PATCH net-next] xdp: add xdp_skb_reserve_put helper
Date: Wed, 30 Apr 2025 19:09:08 +0000 [thread overview]
Message-ID: <BF410EC2-6DFE-46B2-8AF1-4C48309C5F7B@nutanix.com> (raw)
In-Reply-To: <681274309ee3_30bc5e29490@willemb.c.googlers.com.notmuch>
> On Apr 30, 2025, at 3:04 PM, Willem de Bruijn <willemdebruijn.kernel@gmail.com> wrote:
>
> !-------------------------------------------------------------------|
> CAUTION: External Email
>
> |-------------------------------------------------------------------!
>
> Jon Kohler wrote:
>>
>>
>>> On Apr 30, 2025, at 2:40 PM, Daniel Borkmann <daniel@iogearbox.net> wrote:
>>>
>>> !-------------------------------------------------------------------|
>>> CAUTION: External Email
>>>
>>> |-------------------------------------------------------------------!
>>>
>>> On 4/30/25 8:25 PM, Willem de Bruijn wrote:
>>>> Jon Kohler wrote:
>>>>> Add helper for calling skb_{put|reserve} to reduce repetitive pattern
>>>>> across various drivers.
>>>>>
>>>>> Plumb into tap and tun to start.
>>>>>
>>>>> No functional change intended.
>>>>>
>>>>> Signed-off-by: Jon Kohler <jon@nutanix.com>
>>>>> ---
>>>>> drivers/net/tap.c | 3 +--
>>>>> drivers/net/tun.c | 3 +--
>>>>> include/net/xdp.h | 8 ++++++++
>>>>> net/core/xdp.c | 3 +--
>>>>> 4 files changed, 11 insertions(+), 6 deletions(-)
>>>> Subjective, but I prefer the existing code. I understand what
>>>> skb_reserve and skb_put do. While xdp_skb_reserve_put adds a layer of
>>>> indirection that I'd have to follow.
>>>> Sometimes deduplication makes sense, sometimes the indirection adds
>>>> more mental load than it's worth. In this case the code savings are
>>>> small. As said, subjective. Happy to hear other opinions.
>>>
>>> +1, agree with Willem
>>
>> That’s a fair point. I was also toying with the idea of something like
>> this instead:
>>
>> e.g.
>> xdp_headroom(xdp) == xdp->data - xdp->data_hard_start
>> … similar to skb_headroom
>>
>> xdp_length_base(xdp) == xdp->data_end - xdp->data
>> … similar to xdp_get_buff_len, but doesn’t look at frags
>>
>> then we could do:
>> skb_reserve(skb, xdp_headroom(xdp));
>> skb_put(skb, xdp_length_base(xdp));
>>
>> Names TBD of course, but thoughts?
>>
>> That way we keep skb_reserve/put just the same, but have
>> a nice helper like we do for skb_headroom() already
>
> I like the idea of xdp_headroom and xdk_headlen, similar to
> skb_headroom and skb_headlen.
>
Sold! I’ll cook it up
prev parent reply other threads:[~2025-04-30 19:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-30 18:29 [PATCH net-next] xdp: add xdp_skb_reserve_put helper Jon Kohler
2025-04-30 18:25 ` Willem de Bruijn
2025-04-30 18:40 ` Daniel Borkmann
2025-04-30 18:45 ` Jon Kohler
2025-04-30 19:04 ` Willem de Bruijn
2025-04-30 19:09 ` Jon Kohler [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=BF410EC2-6DFE-46B2-8AF1-4C48309C5F7B@nutanix.com \
--to=jon@nutanix.com \
--cc=andrew+netdev@lunn.ch \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=jasowang@redhat.com \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemdebruijn.kernel@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox