Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: joshwash@google.com
Cc: netdev@vger.kernel.org, hramamurthy@google.com,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com, jordanrhee@google.com,
	nktgrg@google.com, thostet@google.com, willemb@google.com,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	pkaligineedi@google.com
Subject: Re: [PATCH net] gve: fix checksum state and gso_segs of HW-GRO packets
Date: Tue, 17 Nov 2026 20:11:56 +0000	[thread overview]
Message-ID: <179494631679.3136.4477194401214815440@kernel.org> (raw)
In-Reply-To: <20261113195553.2220562-1-joshwash@google.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 1 · 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).

- [High] Regression: HW-GRO packets in VLAN-tagged TCP flows are now
  dropped.
- [Medium] For IPv6, gve_rx_complete_rsc() assumes TCP always starts
  right after the fixed 40-byte header: `thoff = nhoff + sizeof(struct…

--

gve: fix checksum state and gso_segs of HW-GRO packets

The patch makes gve_rx_complete_rsc() set the network and transport
headers for HW-GRO packets. For packets the device verified, it also seeds
th->check with the pseudo-header checksum and calls tcp_gro_complete() so
the skb becomes CHECKSUM_PARTIAL. It also tells IPv4 from IPv6 by the
EtherType instead of the device packet type, and computes gso_segs 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..58696d26c6986 100644
> --- a/drivers/net/ethernet/google/gve/gve_rx_dqo.c
> +++ b/drivers/net/ethernet/google/gve/gve_rx_dqo.c

[ ... ]

> @@ -1017,20 +1039,11 @@ static int gve_rx_complete_rsc(struct sk_buff *skb,
>  	if (!rsc_seg_len)
>  		return 0;
>  
> -	switch (ptype.l3_type) {
> -	case GVE_L3_TYPE_IPV4:
> -		shinfo->gso_type = SKB_GSO_TCPV4;
> -		break;
> -	case GVE_L3_TYPE_IPV6:
> -		shinfo->gso_type = SKB_GSO_TCPV6;
> -		break;
> -	default:
> -		return -EINVAL;
> -	}
> -

[ ... ]

> @@ -1049,10 +1061,35 @@ 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;
>  	}
> +
> +	skb_set_network_header(skb, nhoff);
> +	proto = nhoff ? ((struct ethhdr *)skb->data)->h_proto : skb->protocol;
> +	switch (proto) {
> +	case htons(ETH_P_IP):
> +		shinfo->gso_type = SKB_GSO_TCPV4;
> +		thoff = nhoff + ip_hdrlen(skb);
> +		break;
> +	case htons(ETH_P_IPV6):
> +		shinfo->gso_type = SKB_GSO_TCPV6;
> +		thoff = nhoff + sizeof(struct ipv6hdr);
> +		break;
> +	default:
> +		return -EINVAL;
> +	}

[Severity: High]
Could this cause HW-GRO packets from VLAN-tagged TCP flows to be dropped?

gve sets no NETIF_F_HW_VLAN_* features, and struct
gve_rx_compl_desc_dqo has no VLAN tag field. A tagged frame therefore
arrives here with h_proto (or the skb->protocol set by eth_type_trans())
equal to ETH_P_8021Q or ETH_P_8021AD. That value hits the default case and
returns -EINVAL. The error then ends up as a silent drop:

gve_rx_poll_dqo()
  gve_rx_complete_skb()
    gve_rx_complete_rsc()
      return -EINVAL;
  gve_rx_free_skb(napi, rx);
  rx->rx_desc_err_dropped_pkt++;

Before this patch, gso_type came from ptype.l3_type, which does not depend
on the L2 layout. These packets then went on to napi_gro_frags() or
napi_gro_receive() and were delivered.

The fixed nhoff of 0 or ETH_HLEN also assumes there is no tag. Adding the
VLAN EtherTypes to this switch alone would leave the network and transport
headers pointing at the tag instead of the IP and TCP headers.

The commit message says:

  "tell IPv4 from IPv6 by the EtherType, as qede and bnx2x do"

Both of those drivers strip VLAN tags in hardware. For example, qede sets
NETIF_F_HW_VLAN_CTAG_RX. Also, on an unknown protocol qede_gro_receive()
only logs an error and still delivers the skb.

Would it be better to keep using ptype.l3_type here? Or, for an
unrecognized EtherType, deliver the skb without the fixup instead of
returning -EINVAL? The patch is also tagged for stable, and the commit
message does not mention this behavior change.

> +	skb_set_transport_header(skb, thoff);
> +
>  	shinfo->gso_size = rsc_seg_len;
> -	shinfo->gso_segs = rsc_segments;
> +	shinfo->gso_segs = DIV_ROUND_UP(skb->len - thoff - tcp_hdrlen(skb),
> +					rsc_seg_len);
> +
> +	if (!IS_ENABLED(CONFIG_INET) ||
> +	    unlikely(skb->ip_summed != CHECKSUM_UNNECESSARY))
> +		return 0;
>  
> +	gve_rx_fixup_gro_checksum(skb);

[Severity: Medium]
For IPv6, is it safe to assume TCP always starts right after the fixed
40-byte header?

	case htons(ETH_P_IPV6):
		shinfo->gso_type = SKB_GSO_TCPV6;
		thoff = nhoff + sizeof(struct ipv6hdr);

Nothing checks that ipv6_hdr(skb)->nexthdr == IPPROTO_TCP, and
desc->ipv6_ex_add is not checked here.

gve_rx_skb_csum() withholds CHECKSUM_UNNECESSARY only when ipv6_ex_add 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;
	}

According to gve_desc_dqo.h, that bit only covers Destination Options and
Routing headers. Suppose the device coalesces a TCP flow that carries, for
example, a Hop-by-Hop header. The transport header would then land on the
extension header, and tcp_hdrlen() would read a bogus doff, so gso_segs
would be wrong.

gve_rx_fixup_gro_checksum() would then write the pseudo-header seed at
thoff + 16. With an 8-byte Hop-by-Hop header, that offset is the upper
half of the real ack_seq:

	th->check = ~tcp_v6_check(len, &ipv6_hdr(skb)->saddr,
				  &ipv6_hdr(skb)->daddr, 0);

tcp_gro_complete() would also set csum_start and csum_offset from the same
wrong offset.

When ipv6_ex_add is set, the checksum write is skipped. The transport
header and gso_segs are still set from the assumed offset, though. Before
this patch, the RSC path did not read or write the TCP header.

The driver doesn't show whether the device's RSC engine ever coalesces
IPv6 packets with extension headers. qede and bnx2x make the same
fixed-offset assumption. If the device can do this, should the code check
nexthdr, or skip the fixup when nexthdr is not IPPROTO_TCP?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113195553.2220562-1-joshwash%40google.com

      parent reply	other threads:[~2026-11-17 20:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 19:55 [PATCH net] gve: fix checksum state and gso_segs of HW-GRO packets Joshua Washington
2026-11-13 20:37 ` Joshua Washington
2026-11-14 15:14 ` Eric Dumazet
2026-11-16  4:32   ` Ankit Garg
2026-11-17 20:11 ` netdev-bot+sashiko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179494631679.3136.4477194401214815440@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=hramamurthy@google.com \
    --cc=jordanrhee@google.com \
    --cc=joshwash@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nktgrg@google.com \
    --cc=pabeni@redhat.com \
    --cc=pkaligineedi@google.com \
    --cc=stable@vger.kernel.org \
    --cc=thostet@google.com \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox