On Mon, 23 Nov 2026 at 12:59, Björn Töpel <[email protected]> wrote:
>
> Magnus Karlsson <[email protected]> writes:
>
> > diff --git a/net/xdp/Makefile b/net/xdp/Makefile
> > index 30cdc4315f42..b6109e0e5547 100644
> > --- a/net/xdp/Makefile
> > +++ b/net/xdp/Makefile
> > @@ -986,12 +990,62 @@ static void xsk_drop_skb(struct sk_buff *skb)
> >       xs->skb = NULL;
> >  }
> >
> > +static int xsk_skb_uso(struct sk_buff *skb)
> > +{
> > +     struct xsk_tx_uso_info uso = {
> > +             .metadata.request = {
> > +                     .gso_size = skb_shinfo(skb)->gso_size,
> > +                     .csum_start = skb_transport_offset(skb),
> > +                     .network_offset = skb_network_offset(skb),
> > +             },
> > +             .header_len = skb_transport_offset(skb) + sizeof(struct 
> > udphdr),
> > +             .len = skb->len,
> > +     };
> > +     int depth, err;
> > +
> > +     /* Best effort: a bond or team device can change type while the pool
> > +      * is bound, also after this check.
> > +      */
>
> What would be the effect of that? Would it make sense to be more
> restrictive?

If a bonded device changed the type to non-Ethernet, there would be a
short window in which packets would be dropped and or sent out
garbled. After that, they would be correctly counted as
tx_invalid_descs. So I think it is ok to not be more restrictive since
this should be a rare operation while you are having traffic running
with an xsk socket.

> > @@ -999,18 +1053,43 @@ static int xsk_skb_metadata(struct sk_buff *skb, 
> > void *buffer,
> >
> >       meta = buffer - pool->tx_metadata_len;
> >       if (unlikely(!xsk_buff_valid_tx_metadata(pool, meta, &flags)))
> > -             return -EINVAL;
> > +             goto err;
> > +
> > +     if (flags & XDP_TXMD_FLAGS_USO) {
> > +             u16 nhoff = READ_ONCE(meta->request.network_offset);
> > +             u16 offset = READ_ONCE(meta->request.csum_offset);
> > +             u16 thoff = READ_ONCE(meta->request.csum_start);
> > +             u16 size = READ_ONCE(meta->request.gso_size);
>
> Instead of all these READ_ONCE, maybe snapshot (as in patch 3) here as
> well?

Will do.

> > @@ -1021,6 +1100,9 @@ static int xsk_skb_metadata(struct sk_buff *skb, void 
> > *buffer,
> >       xsk_tx_metadata_to_compl(meta, &skb_shinfo(skb)->xsk_meta);
> >
> >       return 0;
> > +
> > +err:
> > +     return flags & XDP_TXMD_FLAGS_USO ? -EOVERFLOW : err;
>
> Seems error prone? Better to set the proper error further up, or am I
> missing something?

You are not missing anything. I can move it up earlier with some restructuring.

>
> Björn

Reply via email to