[PATCH net-next v10 1/4] net: xdp: add __xdp_build_skb_from_buff() helper

Lorenzo Bianconi lorenzo.bianconi at oss.qualcomm.com
Tue Nov 17 04:55:33 PST 2026


> Thank you for your contribution! Sashiko AI review found more severe
> issue(s) in other patches of this series. This mail is only an FYI, in case
> you want to address the nit picks below when you respin.
> 
> Low priority / nit picks for your consideration:
> 
> - [Low] The kerneldoc for the newly exported __xdp_build_skb_from_buff()
>   (net/core/xdp.c:622-633) says only "Protocol parsing is left to the…
> 
> --
> 
> net: xdp: add __xdp_build_skb_from_buff() helper
> 
> This patch splits xdp_build_skb_from_buff() in two. The new exported
> __xdp_build_skb_from_buff() builds the skb without calling
> eth_type_trans(). A static inline wrapper in include/net/xdp.h keeps the
> old behaviour and still calls eth_type_trans(). The goal is to let stmmac
> process the L2 header (software VLAN) before protocol parsing.
> 
> > diff --git a/net/core/xdp.c b/net/core/xdp.c
> > index 1d679e8fd6493..470bf90d93ef2 100644
> > --- a/net/core/xdp.c
> > +++ b/net/core/xdp.c
> > @@ -620,17 +620,18 @@ void xdp_warn(const char *msg, const char *func, const int line)
> >  EXPORT_SYMBOL_GPL(xdp_warn);
> >  
> >  /**
> > - * xdp_build_skb_from_buff - create an skb from &xdp_buff
> > + * __xdp_build_skb_from_buff - create an skb from &xdp_buff
> >   * @xdp: &xdp_buff to convert to an skb
> >   *
> >   * Perform common operations to create a new skb to pass up the stack from
> >   * &xdp_buff: allocate an skb head from the NAPI percpu cache, initialize
> >   * skb data pointers and offsets, set the recycle bit if the buff is
> > - * PP-backed, Rx queue index, protocol and update frags info.
> > + * PP-backed, record the Rx queue index and update frags info. Protocol
> > + * parsing is left to the caller.
> 
> [Severity: Low]
> Does "Protocol parsing is left to the caller" fully describe what the
> caller now has to do?
> 
> Moving eth_type_trans() out of __xdp_build_skb_from_buff() also moves out
> the other work it does:
> 
> net/ethernet/eth.c:eth_type_trans() {
> 	skb->dev = dev;
> 	skb_reset_mac_header(skb);
> 
> 	eth = eth_skb_pull_mac(skb);
> 	eth_skb_pkt_type(skb, dev);
>     ...
> }
> 
> So the skb returned by __xdp_build_skb_from_buff() has skb->dev == NULL
> and no mac header, and protocol and pkt_type are not set. This is true
> even though rxq->dev is available inside the helper.
> 
> The peer helper __xdp_build_skb_from_frame() still sets these:
> 
> 	/* Essential SKB info: protocol and skb->dev */
> 	skb->protocol = eth_type_trans(skb, dev);
> 
> As a result, the two __xdp_build_skb_* helpers now return different
> minimal skb state.
> 
> Nothing breaks today. The only in-tree user of the underscore variant
> later in the series is stmmac_rx(), and it calls
> eth_type_trans(skb, priv->dev) before napi_gro_receive(). A future caller
> that does its own L2 handling and reads "protocol parsing" as just
> skb->protocol could pass an skb with no dev to napi_gro_receive() or
> netif_receive_skb().
> 
> Could the kerneldoc say that the caller must also set skb->dev and reset
> the mac header, for example by calling eth_type_trans()?
> 
> A smaller point: the public xdp_build_skb_from_buff() wrapper in
> include/net/xdp.h no longer has any kerneldoc. The kerneldoc for
> xdp_build_skb_from_zc() still refers readers to it:
> 
>  * Similar to xdp_build_skb_from_buff(), but for XSk frames. Allocate an skb
> 
> [ ... ]

I will fix it in v11.

Regards,
Lorenzo

> 
> -- 
> Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112-stmmac-rx-mb-v10-0-d3d04b65c6bc%40oss.qualcomm.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20261117/246c3d98/attachment-0001.sig>


More information about the linux-arm-kernel mailing list