Re: [PATCH net v3 1/2] net: gro: fix udp bad offset in socket lookup by adding {inner_}network_offset to napi_gro_cb

From: Willem de Bruijn
Date: Thu Apr 25 2024 - 09:57:05 EST


> >> --- a/net/ipv6/tcpv6_offload.c
> >> +++ b/net/ipv6/tcpv6_offload.c
> >> @@ -29,7 +29,8 @@ struct sk_buff *tcp6_gro_receive(struct list_head *head, struct sk_buff *skb)
> >>
> >> INDIRECT_CALLABLE_SCOPE int tcp6_gro_complete(struct sk_buff *skb, int thoff)
> >> {
> >> - const struct ipv6hdr *iph = ipv6_hdr(skb);
> >> + const u16 offset = NAPI_GRO_CB(skb)->network_offsets[skb->encapsulation];
> >> + const struct ipv6hdr *iph = (struct ipv6hdr *)(skb->data + offset);
> >> struct tcphdr *th = tcp_hdr(skb);
> >>
> >
> > Only udp code is affected, as only that can be used as tunnel.
> >
> > For bug fixes, let's try to avoid touching other code. Also that vlan.
> >
> > As a minimal patch all that is needed is the following, right?
> >
> > - add the fields
> > - store in inet_gro_receive + ipv6_gro_receive
> > - read in udp[46]_gro_complete and udp[46]_lib_lookup_skb
> >
>
> This approach is smaller, thanks for writing it down.
>
> What do you think about doing this and still writing to
> inner_network_offset exclusively in {inet,ipv6}_gro_receive? I still
> prefer it for reasons discussed in the previous series. The code line
> in vlan_gro_receive will still be there, but that will be the only
> addition to your snippet.

That sounds fine, thanks.