Re: [PATCH net v2] gve: fix checksum state and gso_segs of HW-GRO packets

From: Ankit Garg

Date: Tue Nov 17 2026 - 23:34:02 EST


On Tue, Nov 17, 2026 at 3:32 PM <netdev-bot+sashiko@xxxxxxxxxx> wrote:
>
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 1 · Low: 0
>
> If you believe none of the issues are legitimate, please reply to each
> issue of Medium severity or higher and explain why the AI is wrong.
> If any of them are legitimate and you plan to respin, please let patchwork
> know by including "pw-bot: cr" as a separate line at the end of your reply
> (one such reply per series is enough).
>
> - [Medium] gve_rx_complete_rsc()
> (drivers/net/ethernet/google/gve/gve_rx_dqo.c) works out where the TCP…
>
> --
>
> gve: fix checksum state and gso_segs of HW-GRO packets
>
> This patch makes gve_rx_complete_rsc() set the network and transport
> headers on HW-GRO packets. For device-verified packets it also seeds
> th->check with the TCP pseudo-header checksum and calls tcp_gro_complete(),
> so forwarded HW-GRO skbs can be resegmented correctly. IPv4 and IPv6 are
> now told apart by EtherType, and gso_segs is computed from the TCP payload
> length.
>
> > diff --git a/drivers/net/ethernet/google/gve/gve_rx_dqo.c b/drivers/net/ethernet/google/gve/gve_rx_dqo.c
> > index 82ed5e48b00ab..b4dbfb1ba39b0 100644
> > --- a/drivers/net/ethernet/google/gve/gve_rx_dqo.c
> > +++ b/drivers/net/ethernet/google/gve/gve_rx_dqo.c
>
> [ ... ]
>
> > @@ -1049,10 +1061,50 @@ static int gve_rx_complete_rsc(struct sk_buff *skb,
> > skb_frag_off_add(frag, hdr_len);
> > skb->data_len -= hdr_len;
> > skb->tail += hdr_len;
> > + /* napi_gro_frags() pulls the Ethernet header later. */
> > + nhoff = ETH_HLEN;
> > + }
> > +
> > + /* The header lengths come from the packet, so make sure the headers are
> > + * in the linear part before reading them and writing th->check.
> > + */
> > + if (unlikely(skb_headlen(skb) < nhoff + sizeof(struct iphdr)))
> > + return -EINVAL;
> > +
> > + skb_set_network_header(skb, nhoff);
> > + proto = nhoff ? ((struct ethhdr *)skb->data)->h_proto : skb->protocol;
> > + switch (proto) {
> > + case htons(ETH_P_IP):
> > + gso_type = SKB_GSO_TCPV4;
> > + thoff = nhoff + ip_hdrlen(skb);
> > + break;
> > + case htons(ETH_P_IPV6):
> > + gso_type = SKB_GSO_TCPV6;
> > + thoff = nhoff + sizeof(struct ipv6hdr);
>
> [Severity: Medium]
> Is it safe to assume the TCP header comes right after the fixed IPv6
> header here?
>
> Nothing checks ipv6_hdr(skb)->nexthdr == IPPROTO_TCP or desc->ipv6_ex_add.
> The IPv4 case above also uses ip_hdrlen() without checking
> ip_hdr(skb)->protocol == IPPROTO_TCP. The only sign that L4 is TCP is the
> ptype.l4_type check at the top of gve_rx_complete_rsc().
>
> The descriptor suggests the device does parse IPv6 extension headers:
>
> gve_desc_dqo.h:
> /* Set when IPv6 packet contains a destination options header or routing
> * header.
> */
> u8 ipv6_ex_add: 1;
>
> gve_rx_skb_csum() only holds back CHECKSUM_UNNECESSARY when that bit is
> set:
>
> } else if (ptype.l3_type == GVE_L3_TYPE_IPV6) {
> /* Checksum should be skipped if this flag is set. */
> if (unlikely(desc->ipv6_ex_add))
> return;
> }
>
> So an IPv6/TCP packet with a hop-by-hop header and a device-verified
> checksum would still be CHECKSUM_UNNECESSARY when it gets here.
>
> Suppose the device coalesces such a packet, or a tunnelled packet whose
> ptype reports the inner L4 as TCP. Then thoff would point into the
> extension or tunnel header, and tcp_hdrlen() would read doff from the
> wrong bytes.
>
> gve_rx_fixup_gro_checksum() would then write the pseudo-header seed at
> that offset:
>
> th->check = ~tcp_v6_check(len, &ipv6_hdr(skb)->saddr,
> &ipv6_hdr(skb)->daddr, 0);
>
> tcp_gro_complete() would also set csum_start, csum_offset and
> CHECKSUM_PARTIAL at that offset.
>
> Wouldn't a forwarded packet then leave through TSO/GSO with a bad
> checksum? That is the same blackholing this patch sets out to fix.
>
> The destination-options and routing cases are CHECKSUM_NONE, but they
> still hit the wrong doff. That could drop a valid packet with -EINVAL or
> give it a wrong gso_segs. It could also take the new early return:
>
> payload = skb->len - thoff - tcp_hdrlen(skb);
> if (payload <= rsc_seg_len)
> return 0;
>
> and deliver a multi-segment coalesced packet without gso_size.
>
> Before this patch the RSC path never read or wrote the TCP header, so
> this assumption is new. The changelog gives the VLAN guarantee ("The
> device does not coalesce VLAN tagged frames"), but says nothing about
> IPv6 extension headers or encapsulation.
>
> For comparison, bnx2x_set_gro_params() documents the matching hardware
> guarantee ("TPA aggregation won't have either IP options or TCP options
> other than timestamp or IPv6 extension headers"). The mlx5 SHAMPO path
> checks ipv6->nexthdr == IPPROTO_TCP.
>
> Could the device guarantee be documented in the changelog and in a
> comment? Alternatively, could this check ip_hdr(skb)->protocol and
> ipv6_hdr(skb)->nexthdr against IPPROTO_TCP (and ihl >= 5), and skip the
> GSO and checksum fixup otherwise?
>
GVE device doesn't coalesce IPv6 packets with extension headers. I
will send a v3 documenting that guarantee in changelog.
> --
> Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116224308.986555-1-joshwash%40google.com
pw-bot: cr