Subject: Re: [PATCH v2 net-next 1/9] xdp: introduce mb in xdp_buff/xdp_frame

From: Jesper Dangaard Brouer <[email-masked]>
Date: Mon, 7 Sep 2020 20:02:45 +0200

On Fri, 4 Sep 2020 10:30:48 -0600
David Ahern <[email-masked]> wrote:

> On 9/4/20 9:59 AM, Jesper Dangaard Brouer wrote:
> >> dev_rx for example seems like it could just be the netdev
> >> index rather than a pointer or perhaps can be removed completely. I
> >> believe it is only used for 1 use case (redirects to CPUMAP); maybe that
> >> code can be refactored to handle the dev outside of xdp_frame.  
> > 
> > The dev_rx is needed when creating an SKB from a xdp_frame (basically
> > skb->dev = rx_dev). Yes, that is done in cpumap, but I want to
> > generalize this.  The veth also creates SKBs from xdp_frame, but use
> > itself as skb->dev.
> > 
> > And yes, we could save some space storing the index instead, and trade
> > space for cycles in a lookup.  
> 
> I think this can be managed without adding a reference to the xdp_frame.
> I'll start a separate thread on that.
> 
> >>
> >> As for frame_sz, why does it need to be larger than a u16?  
> > 
> > Because PAGE_SIZE can be 64KiB on some archs.
> >   

I also believe syzbot managed to create packets for generic-XDP with
frame_sz 128KiB, which was a bit weird (it's on my todo list to
investigate and fix).

> ok, is there any alignment requirement? can frame_sz be number of 32-bit
> words? I believe bit shifts are cheap.

No that is not possible, because some drivers and generic-XDP have a
fully dynamic frame_sz.

-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer