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 v2] gve: fix checksum state and gso_segs of HW-GRO packets
Date: Tue, 17 Nov 2026 23:32:39 +0000 [thread overview]
Message-ID: <179495835918.3136.2006086240050992361@kernel.org> (raw)
In-Reply-To: <20261116224308.986555-1-joshwash@google.com>
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?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116224308.986555-1-joshwash%40google.com
prev parent reply other threads:[~2026-11-17 23:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 22:43 Joshua Washington
2026-11-17 23:32 ` 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=179495835918.3136.2006086240050992361@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
all inboxes | Powered by JetHome®