Re: [PATCH net] gro_cells: Avoid packet re-ordering for cloned skbs

From: Thomas Bogendoerfer
Date: Mon Jan 20 2025 - 09:32:14 EST


On Mon, 13 Jan 2025 13:55:18 +0100
Eric Dumazet <edumazet@xxxxxxxxxx> wrote:

> On Mon, Jan 13, 2025 at 12:28 PM Thomas Bogendoerfer
> <tbogendoerfer@xxxxxxx> wrote:
> >
> > On Thu, 9 Jan 2025 15:56:24 +0100
> > Eric Dumazet <edumazet@xxxxxxxxxx> wrote:
> >
> > > On Thu, Jan 9, 2025 at 3:27 PM Thomas Bogendoerfer
> > > <tbogendoerfer@xxxxxxx> wrote:
> > > >
> > > > gro_cells_receive() passes a cloned skb directly up the stack and
> > > > could cause re-ordering against segments still in GRO. To avoid
> > > > this copy the skb and let GRO do it's work.
> > > >
> > > > Fixes: c9e6bc644e55 ("net: add gro_cells infrastructure")
> > > > Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@xxxxxxx>
> > > > ---
> > > > net/core/gro_cells.c | 11 ++++++++++-
> > > > 1 file changed, 10 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/net/core/gro_cells.c b/net/core/gro_cells.c
> > > > index ff8e5b64bf6b..2f8d688f9d82 100644
> > > > --- a/net/core/gro_cells.c
> > > > +++ b/net/core/gro_cells.c
> > > > @@ -20,11 +20,20 @@ int gro_cells_receive(struct gro_cells *gcells, struct sk_buff *skb)
> > > > if (unlikely(!(dev->flags & IFF_UP)))
> > > > goto drop;
> > > >
> > > > - if (!gcells->cells || skb_cloned(skb) || netif_elide_gro(dev)) {
> > > > + if (!gcells->cells || netif_elide_gro(dev)) {
> > > > +netif_rx:
> > > > res = netif_rx(skb);
> > > > goto unlock;
> > > > }
> > > > + if (skb_cloned(skb)) {
> > > > + struct sk_buff *n;
> > > >
> > > > + n = skb_copy(skb, GFP_KERNEL);
> > >
> > > I do not think we want this skb_copy(). This is going to fail too often.
> >
> > ok
> >
> > > Can you remind us why we have this skb_cloned() check here ?
> >
> > some fields of the ip/tcp header are going to be changed in the first gro
> > segment
>
> Presumably we should test skb_header_cloned()
>
> This means something like skb_cow_head(skb, 0) could be much more
> reasonable than skb_copy().

I don't think this will work, because at that point it's skb->data points
at the IPv6 header in my test case (traffic between two namespaces connected
via ip6 tunnel over ipvlan). Correct header offsets are set after later,
when gro_cells napi routine runs.

Do you see another option ?

Thomas.

--
SUSE Software Solutions Germany GmbH
HRB 36809 (AG Nürnberg)
Geschäftsführer: Ivo Totev, Andrew McDonald, Werner Knoblich