[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aQjG1jnPmLlROQh9@boxer>
Date: Mon, 3 Nov 2025 16:14:30 +0100
From: Maciej Fijalkowski <maciej.fijalkowski@...el.com>
To: Your Name <alessandro.d@...il.com>
CC: <netdev@...r.kernel.org>, "David S. Miller" <davem@...emloft.net>, "Alexei
Starovoitov" <ast@...nel.org>, Andrew Lunn <andrew+netdev@...n.ch>, "Daniel
Borkmann" <daniel@...earbox.net>, Eric Dumazet <edumazet@...gle.com>, "Jakub
Kicinski" <kuba@...nel.org>, Jesper Dangaard Brouer <hawk@...nel.org>, "John
Fastabend" <john.fastabend@...il.com>, Paolo Abeni <pabeni@...hat.com>,
Przemek Kitszel <przemyslaw.kitszel@...el.com>, Stanislav Fomichev
<sdf@...ichev.me>, Tirthendu Sarkar <tirthendu.sarkar@...el.com>, Tony Nguyen
<anthony.l.nguyen@...el.com>, <bpf@...r.kernel.org>,
<intel-wired-lan@...ts.osuosl.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH net v2 1/1] i40e: xsk: advance next_to_clean on status
descriptors
On Thu, Oct 23, 2025 at 04:39:29AM +1100, Your Name wrote:
> On Wed, Oct 22, 2025 at 07:17:20PM +0200, Maciej Fijalkowski wrote:
> > On Wed, Oct 22, 2025 at 12:32:00AM +0700, Alessandro Decina wrote:
> >
> > Hi Alessandro,
>
> Hey,
>
> Thanks for the review!
>
>
> >
> > > Whenever a status descriptor is received, i40e processes and skips over
> > > it, correctly updating next_to_process but forgetting to update
> > > next_to_clean. In the next iteration this accidentally causes the
> > > creation of an invalid multi-buffer xdp_buff where the first fragment
> > > is the status descriptor.
> > >
> > > If then a skb is constructed from such an invalid buffer - because the
> > > eBPF program returns XDP_PASS - a panic occurs:
> >
> > can you elaborate on the test case that would reproduce this? I suppose
> > AF_XDP ZC with jumbo frames, doing XDP_PASS, but what was FDIR setup that
> > caused status descriptors?
>
> Doesn't have to be jumbo or multi-frag, anything that does XDP_PASS
> reproduces, as long as status descriptors are posted.
>
> See the scenarios here https://lore.kernel.org/netdev/aPkDtuVgbS4J-Og_@lima-default/
>
> As for what's causing the status descriptors, I haven't been able to
> figure that out. I just know that I periodically get
> I40E_RX_PROG_STATUS_DESC_FD_FILTER_STATUS. Happy to dig deeper if you
> have any ideas!
>
> > > diff --git a/drivers/net/ethernet/intel/i40e/i40e_xsk.c b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
> > > index 9f47388eaba5..dbc19083bbb7 100644
> > > --- a/drivers/net/ethernet/intel/i40e/i40e_xsk.c
> > > +++ b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
> > > @@ -441,13 +441,18 @@ int i40e_clean_rx_irq_zc(struct i40e_ring *rx_ring, int budget)
> > > dma_rmb();
> > >
> > > if (i40e_rx_is_programming_status(qword)) {
> > > + u16 ntp;
> > > +
> > > i40e_clean_programming_status(rx_ring,
> > > rx_desc->raw.qword[0],
> > > qword);
> > > bi = *i40e_rx_bi(rx_ring, next_to_process);
> > > xsk_buff_free(bi);
> > > - if (++next_to_process == count)
> > > + ntp = next_to_process++;
> > > + if (next_to_process == count)
> > > next_to_process = 0;
> > > + if (next_to_clean == ntp)
> > > + next_to_clean = next_to_process;
> >
> > I wonder if this is more readable?
> >
> > diff --git a/drivers/net/ethernet/intel/i40e/i40e_xsk.c b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
> > index 9f47388eaba5..36f412a2d836 100644
> > --- a/drivers/net/ethernet/intel/i40e/i40e_xsk.c
> > +++ b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
> > @@ -446,6 +446,10 @@ int i40e_clean_rx_irq_zc(struct i40e_ring *rx_ring, int budget)
> > qword);
> > bi = *i40e_rx_bi(rx_ring, next_to_process);
> > xsk_buff_free(bi);
> > + if (next_to_clean == next_to_process) {
> > + if (++next_to_clean == count)
> > + next_to_clean = 0;
> > + }
> > if (++next_to_process == count)
> > next_to_process = 0;
> > continue;
> >
> > > continue;
> > > }
>
> Probably because I've looked at it for longer, I find my version clearer
> (I think I copied it from another driver actually). But I don't really
> mind, happy to switch to yours if you prefer!
Hmm. After taking a second look, how about we make it into a common
function shared between i40e_clean_rx_irq() and i40e_clean_rx_irq_zc() ?
>
> Ciao
> Alessandro
>
Powered by blists - more mailing lists