๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
4 messages
4 total messages Started by Bryon Fryer Thu, 12 Nov 2026 03:07
[PATCH net 0/2] udp: preserve outer transport header after tunnel GRO
#14863
Author: Bryon Fryer
Date: Thu, 12 Nov 2026 03:07
42 lines
14381 bytes
UDP tunnel GRO can leave the inner TCP header in skb->transport_header.
The virtio tunnel exporter uses that field as the outer UDP offset,
producing descriptors which the receiving decoder rejects.

Patch 1 restores the parsed outer UDP position after successful tunnel
GRO completion. Patch 2 adds a focused regression to the existing TUN
selftest, including a GRO-off control.

This series is based on net 8d5ce4751fad. Before/after virtme-ng/KVM runs
on that base reproduced and corrected the exported offset for VXLAN,
VXLAN-GPE and Geneve, with clean GRO-off and prebuilt-GSO controls.
The complete extended TUN suite had only the added regression fail
before the fix and no unexpected failures afterward; its 12 expected
failures were unchanged. Selected UDP GSO tests passed on both variants.
Bulk TCP delivery checks also completed, with the receiving TAP rejecting
aggregates before the fix and accepting them afterward. The separate
VXLAN-GPE raw-path segmentation rejection remains outside this series.

Full x86-64 allyesconfig and allmodconfig bzImage/modules builds completed
before and after the fix with Clang/LLVM 19 and W=1. Existing baseline
warnings required KCFLAGS=-Wno-error; the fix introduced no new warnings.
The runtime kernel pair used GCC 14 with matching configurations.

The detailed timing table in patch 1 comes from three paired virtme-ng
runs. Median 32 MiB TCP transfer times fell from 69.8s to 0.15s for
VXLAN and from 70.8s to 0.16s for Geneve. Receiver rejections and
retransmissions fell to zero, all payload bytes were verified, and
GRO-off controls were clean.

Bryon Fryer (2):
  udp: restore outer transport header after tunnel GRO
  selftests: net: check UDP tunnel GRO virtio offsets

 net/ipv4/udp_offload.c            |   2 +
 tools/testing/selftests/net/tun.c | 292 ++++++++++++++++++++++++++++++
 2 files changed, 294 insertions(+)


base-commit: 8d5ce4751fad9499ea408163af7f410f18a85782
-- 
2.47.3
[PATCH net 1/2] udp: restore outer transport header after tunnel GRO
#14864
Author: Bryon Fryer
Date: Thu, 12 Nov 2026 03:07
79 lines
16224 bytes
UDP tunnel GRO can produce invalid virtio tunnel headers, causing
virtio-net to drop whole aggregates. Losing several TCP segments at
once causes retransmissions and can collapse throughput.

Observed as slow VXLAN TCP traffic with kernel logs reporting dropped
packets. Reproduced with ordinary tunnel traffic in disposable VMs. The
unpatched reproductions required no kernel modifications or error
injection.

Inner GRO processing moves skb->transport_header to inner TCP or
UDP. The inner completion callback saves it in inner_transport_header,
but udp_gro_complete() leaves the main transport header there too.
The virtio tunnel exporter added by commit a2fb4bc4e2a6 ("net: implement
virtio helpers to handle UDP GSO tunneling.") treats that field as the
outer UDP location. The exported outer header then appears after
the inner network header, so the receiver rejects the descriptor.

Restore skb->transport_header from nhoff after successful inner
completion. This parsed outer UDP offset retains the inner transport
and checksum offsets without assuming fixed header lengths.

Tested under virtme-ng with socat sending bulk TCP over IPv4 VXLAN
and Geneve between network namespaces. A raw sender TAP supplies
wire-sized packets to a TAP/bridge path with ingress GRO. Exported
virtio headers are relayed unchanged to a receiving TAP using the
shared virtio decoder. Kernels used the same base, config and toolchain
under KVM. For 32 MiB, median transfer times and rejected aggregates
across three paired runs were:

                       Before patch          After patch
  VXLAN, GRO on        69.8s, 1418 rejects    0.15s, 0 rejects
  Geneve, GRO on       70.8s, 1414 rejects    0.16s, 0 rejects
  VXLAN, GRO off       0.22s,    0 rejects    0.23s, 0 rejects
  Geneve, GRO off      0.23s,    0 rejects    0.21s, 0 rejects

Rejections are receiving TAP writes returning -EINVAL. Median TCP
retransmissions fell from 2852 (VXLAN) and 2854 (Geneve) to zero.
Every transfer verified all payload bytes; no TAP queue drops occurred.

Separate eight-packet tests measured these outer UDP offsets, in
bytes from the Ethernet frame start:

                                      TAP-exported outer_th_offset
                       Actual UDP     Before patch    After patch
  VXLAN over IPv4          34              84              34
  VXLAN-GPE over IPv4      34              70              34
  Geneve over IPv4         34              84              34

The inner network and checksum-start offsets were unchanged. The
accompanying TUN regression fails only its outer-offset assertion
before patching and passes afterward. Selected existing TUN and UDP
GSO selftests also passed before and after patching.

VXLAN-GPE raw-TAP/GRO-on software segmentation still returns -EINVAL
before and after this patch. This is a separate issue.

Fixes: a2fb4bc4e2a6 ("net: implement virtio helpers to handle UDP GSO tunneling.")
Cc: stable@vger.kernel.org
Signed-off-by: Bryon Fryer <bryon@fryer.io>
---
 net/ipv4/udp_offload.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index b77ae2f00c..1a1d1a125d 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -948,6 +948,8 @@ int udp_gro_complete(struct sk_buff *skb, int nhoff,
 		skb->encapsulation = 1;
 		err = udp_sk(sk)->gro_complete(sk, skb,
 				nhoff + sizeof(struct udphdr));
+		if (!err)
+			skb_set_transport_header(skb, nhoff);
 	} else {
 		err = udp_gro_complete_segment(skb);
 	}
-- 
2.47.3
Re: [PATCH net 1/2] udp: restore outer transport header after tunnel GRO
#17183
Author: netdev-bot+sashiko
Date: Mon, 16 Nov 2026 13:50
110 lines
12018 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 ยท High: 1 ยท Medium: 0 ยท 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] The patch fixes only one producer: udp_gro_complete().

--

udp: restore outer transport header after tunnel GRO

This patch changes udp_gro_complete() so that skb->transport_header points
back at the outer UDP header (nhoff) after the inner gro_complete()
callback succeeds. Without that, the virtio tunnel exporter reports the
inner transport offset as outer_th_offset, and the receiving TAP rejects
the aggregate.

> diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
> index b77ae2f00c626..1a1d1a125d23e 100644
> --- a/net/ipv4/udp_offload.c
> +++ b/net/ipv4/udp_offload.c
> @@ -948,6 +948,8 @@ int udp_gro_complete(struct sk_buff *skb, int nhoff,
>  		skb->encapsulation = 1;
>  		err = udp_sk(sk)->gro_complete(sk, skb,
>  				nhoff + sizeof(struct udphdr));
> +		if (!err)
> +			skb_set_transport_header(skb, nhoff);

[Severity: High]
The commit message describes the problem in general terms:

  "UDP tunnel GRO can produce invalid virtio tunnel headers, causing
  virtio-net to drop whole aggregates."

The fix only covers aggregates that reach udp_gro_complete(). Can
UDP-tunnel GSO skbs that never pass through gro_complete() still reach
virtio_net_hdr_tnl_from_skb() with the same bad offsets?

The HW-GRO paths in bnxt (bnxt_gro_func_5731x() with bnxt_gro_tunnel())
and bnge (bnge_gro_func() with bnge_gro_tunnel()) build aggregates with
gso_type set to SKB_GSO_TCPV4/6 plus SKB_GSO_UDP_TUNNEL[_CSUM]. These
aggregates also have:

- transport_header on the inner TCP header
- skb->encapsulation never set
- inner_network_header never set

For example, in bnxt_gro_tunnel():

	if (uh) {
		if (uh->check)
			skb_shinfo(skb)->gso_type |= SKB_GSO_UDP_TUNNEL_CSUM;
		else
			skb_shinfo(skb)->gso_type |= SKB_GSO_UDP_TUNNEL;
	}

dev_gro_receive() accepts these TCP-GSO skbs into software GRO. However,
tcp_gro_receive() sets NAPI_GRO_CB(skb)->flush when len !=
count * gso_size, or when the header has PSH/URG/RST/SYN/FIN set. Both
cases are common at the end of a bulk TCP burst.

A flush is also forced when udp_gro_receive() finds no matching tunnel
socket, or when the outer tot_len check in inet_gro_receive() fails. In
each of these cases, dev_gro_receive() takes this path:

	if (NAPI_GRO_CB(skb)->flush)
		goto normal;

and neither gro_complete() nor udp_gro_complete() runs.

If the skb is then bridged to a TAP that negotiated TUN_F_UDP_TUNNEL_GSO,
virtio_net_hdr_tnl_from_skb() does:

	inner_nh = skb->inner_network_header - skb_headroom(skb);
	outer_th = skb->transport_header - skb_headroom(skb);

That gives outer_th_offset equal to the inner TCP offset and
inner_nh_offset equal to (u16)(0 - headroom). On the peer side,
virtio_net_hdr_tnl_to_skb() then fails its inner_th < inner_nh +
inner_l3min check and returns -EINVAL. That is the same dropped-aggregate
symptom described in the commit message.

These aggregates also cannot be re-segmented in software.
udp4_ufo_fragment() returns -EINVAL when encapsulation is 0 and neither
SKB_GSO_UDP nor SKB_GSO_UDP_L4 is set. That suggests the root cause for
this path is in the drivers.

The change itself looks correct. Should it be extended to cover this
path? One option would be to have the bnxt/bnge HW-GRO paths set
encapsulation and the inner mac/network/transport headers, and leave
transport_header on the outer UDP header. Otherwise, could the commit
message be narrowed to the software GRO completion path?

Separately, would it make sense for virtio_net_hdr_tnl_from_skb() to
reject tunnel-GSO skbs with !skb->encapsulation rather than emit these
offsets?

>  	} else {
>  		err = udp_gro_complete_segment(skb);
>  	}

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112030708.1915665-1-bryon%40fryer.io
Re: [PATCH net 1/2] udp: restore outer transport header after tunnel GRO
#19458
Author: Jakub Kicinski
Date: Thu, 19 Nov 2026 23:20
15 lines
8351 bytes
On Wed, 11 Nov 2026 22:07:07 -0500 Bryon Fryer wrote:
> @@ -948,6 +948,8 @@ int udp_gro_complete(struct sk_buff *skb, int nhoff,
>  		skb->encapsulation = 1;
>  		err = udp_sk(sk)->gro_complete(sk, skb,
>  				nhoff + sizeof(struct udphdr));
> +		if (!err)
> +			skb_set_transport_header(skb, nhoff);

IIUC only UDP bothers us because that's what virtio/tun supports but
isn't the header stale for every tunnel (eg GRE?) Should we not reset
this back in inet_gro_complete()/ipv6_gro_complete() ?

Maybe GRO experts prefer it here, dunno. An ACK from someone who
understands this code better than me would be good.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads