Netdev List
 help / color / mirror / Atom feed
* [PATCH net v6 0/5] ipmr: forward GSO multicast packets
@ 2026-11-21 21:14 Julius Bairaktaris
  2026-11-21 21:14 ` [PATCH net v6 1/5] net: gro: set the inner transport header of encapsulated fraglist packets Julius Bairaktaris
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Julius Bairaktaris @ 2026-11-21 21:14 UTC (permalink / raw)
  To: netdev
  Cc: davem, edumazet, kuba, pabeni, horms, dsahern, idosch, willemb,
	ncardwell, kuniyu, steffen.klassert, nbd, jiayuan.chen, mfleming,
	almasrymina, bigeasy, richardbgobert, ecree.xilinx,
	bsdhenrymartin

With fraglist GRO or UDP GRO forwarding on, a routed IPv4 multicast
stream arrives as GSO packets. ipmr_prepare_xmit() drops every DF
aggregate larger than the MTU, and ip_encap() sets no tunnel GSO state,
so a GSO packet sent to a VIFF_TUNNEL vif is dropped during
segmentation. Checking the segment length instead of skb->len relies on
skb_gso_transport_seglen(), which reads the inner transport header:
fraglist GRO does not set it for the inner flow of a tunnel, and the
encapsulated UDP case counts the inner UDP header 8 bytes short. A
fraglist packet in a tunnel that computes its outer checksum in software
leaves skb_segment_list() with a wrong outer checksum.

Patch 1 sets the inner transport header of encapsulated fraglist
packets.
Patch 2 segments fraglist packets with a software tunnel checksum by
skb_segment().
Patch 3 counts the inner UDP header of encapsulated UDP GSO packets.
Patch 4 sets up IPXIP4 GSO state, outer IP IDs and length in ip_encap(),
and completes a pending checksum of an encapsulated packet before it.
Patch 5 lets DF GSO packets pass when their segments fit the MTU.

v5 patch 1 was applied as abccf171fa8e ("net: make room for the tunnel
header in skb_segment_list()").

Tested in QEMU (KVM), 3 runs with this series on net (acd205ab5c6d);
comparisons on net ran on d5b89d55a322, 3 commits before it, which do
not touch these paths, unless noted:
- VXLAN with an inner UDP or TCP flow over IPv4 or IPv6, outer UDP
  checksum zero or set, fraglist GRO on the router, forwarded unicast
  and by an MFC entry over a 1400-byte route, 1000 packets per case: net
  delivers 4 to 398 per case (4 runs of 16 cases); with this series all
  1000 arrive with valid outer and inner checksums, also with checksum
  offload on the egress, where skb_segment_list() still segments them,
  and packets with a 1404-byte outer header are refused.
- An IPIP aggregate built by GRO, routed to a tunnel vif: all 1000
  datagrams arrive on net, carried in IPIP packets with 125 to 154
  distinct outer IDs (3 runs); with this series every IPIP packet has its
  own ID.
- A TCP flow from a local VXLAN device (outer UDP checksum) behind veth,
  so the aggregates the router builds are CHECKSUM_PARTIAL, forwarded
  with and without checksum offload on the egress: on net (acd205ab5c6d)
  156 to 1057 segments per 4 MB transfer leave with a wrong outer
  checksum (2 runs of 3 transfers); with this series none, and every
  byte arrives.
- IPIP and VXLAN tunnels that end on the router, rx-gro-list on, inner
  UDP and TCP forwarded: aggregated as on net (fraglist for TCP), every
  payload byte delivered.
- An encapsulated non-GSO packet with a pending checksum, forwarded and
  sent locally to a tunnel vif: net hands the IPIP packet to the device
  as CHECKSUM_PARTIAL (2 runs); with this series the checksum is
  complete. With spliced payload, completing it moves the head; on a
  KASAN kernel no report follows (3 runs).
- An MFC entry to a plain and a tunnel vif, 4000 datagrams per arm,
  UDP_SEGMENT, fraglist GRO and UDP GRO forwarding, DF set and clear,
  software and device segmentation: 4000 of 4000 on the plain vif and
  4000 IPIP packets with unique outer IDs, or the 100 GSO packets whole,
  on the tunnel vif, all 12 arms.
- A GRE GSO packet multicast-routed to a tunnel vif is dropped before
  the vif counts it; with fraglist GRO routed into VXLAN and IPIP, every
  segment reaches the peer.

Changes in v6:
- Patch 1 (new): set the inner transport header in the fraglist
  completion of TCP and UDP, IPv4 and IPv6 (Sashiko on v5 patch 2).
- Patch 2 (new): segment a fraglist packet with skb_segment() when a GRE
  or UDP tunnel computes its outer checksum in software, because the
  egress does not offload it or the packet is still CHECKSUM_PARTIAL,
  which skb_segment_list() leaves wrong; found while testing patch 1
  with an outer checksum.
- Patch 4: drop only encapsulated GSO packets without SKB_GSO_IPXIP4, as
  IPIP and SIT aggregates segment correctly (Sashiko on v5 patch 3);
  complete the pending checksum of an encapsulated non-GSO packet before
  ip_encap() (Sashiko on v5 patch 3); state why GRE and UDP tunnel
  aggregates are dropped and what a device segmenting IPXIP4 gets.
  Simon's Reviewed-by is dropped, as the code changed.
- Rebase onto net.
- v5: https://lore.kernel.org/netdev/cover.1794151759.git.julius@bairaktaris.de/

Changes in v5:
- Patch 3: drop an already encapsulated GSO packet in
  ipmr_prepare_xmit() before the route lookup, so the vif does not count
  it, and call iptunnel_handle_offloads() without error handling, since
  skb_cow() leaves no header to unclone (Eric Dumazet, Sashiko). Simon's
  Reviewed-by stays, as this is the change Eric asked for.
- Outer tot_len 0 (Eric): 50 x 1310-byte datagrams merged by UDP GRO
  forwarding make a 65528-byte packet, so the outer header gets tot_len
  0 from iph_set_totlen(); before, htons() truncated it to 12. In 3 runs
  nft ip forward chains still match it with meta l4proto 4 and
  ip protocol 4 (100 of 100), while a netdev egress chain on the output
  device does not match meta l4proto 4 (0 of 100), as
  nft_set_pktinfo_ipv4_validate() takes the length from iph_totlen().
  All 5000 segments reach the peer, with software and device
  segmentation.
- skb_gso_transport_seglen() also leaves out the inner SCTP header of
  an encapsulated SCTP GSO packet (Sashiko on patch 2). That predates
  this series, and multicast routing does not see such packets:
  sctp_v4_addr_valid() and sctp_v4_available() reject multicast
  addresses.
- Rebase onto net.
- v4: https://lore.kernel.org/netdev/cover.1792838740.git.julius@bairaktaris.de/

Changes in v4:
- Add patch 2 (Sashiko).
- Patch 3: drop GSO packets that are already encapsulated, and set the
  outer length with iph_set_totlen() (Sashiko).
- Drop v3 patch 2 (TCP fixed-ID flag on encapsulation): multicast
  routing does not carry TCP, and the flag also needs the decap and
  GRE/UDP segmentation paths, which go to a separate series (Sashiko).
- Rebase onto net.
- v3: https://lore.kernel.org/netdev/cover.1792293419.git.julius@bairaktaris.de/

Changes in v3:
- Patch 1: name the VXLAN case, where a member has no headroom for the
  tunnel header (Sashiko).
- Add patch 2 (Sashiko).
- Patch 3: reserve one outer IP ID per segment (Sashiko).
- v2: https://lore.kernel.org/netdev/20261011162957.1328474-1-julius@bairaktaris.de/

Changes in v2:
- Add patches 1 and 3; v1 let DF GSO packets reach ip_encap() on tunnel
  vifs, where they were dropped during segmentation (Sashiko).
- Keep the additive MTU comparison and check mtu > encap before
  subtracting, so a route MTU below 20 cannot wrap (Sashiko).
- v1: https://lore.kernel.org/netdev/20261010131842.2157365-1-julius@bairaktaris.de/

I used Claude (Anthropic) to help write these patches.


Julius Bairaktaris (5):
  net: gro: set the inner transport header of encapsulated fraglist
    packets
  net: gso: segment fraglist packets with a software tunnel checksum
  net: gso: count the inner UDP header of encapsulated UDP GSO packets
  ipmr: set up GSO state for tunnel vifs
  ipmr: do not drop GSO packets that fit the MTU after segmentation

 include/net/gso.h        | 24 ++++++++++++++++++++++++
 net/core/gso.c           |  2 ++
 net/ipv4/gre_offload.c   |  2 +-
 net/ipv4/ipmr.c          | 34 +++++++++++++++++++++++++++++++---
 net/ipv4/tcp_offload.c   |  6 +++++-
 net/ipv4/udp_offload.c   |  6 +++++-
 net/ipv6/tcpv6_offload.c |  6 +++++-
 net/ipv6/udp_offload.c   |  3 +++
 8 files changed, 76 insertions(+), 7 deletions(-)


base-commit: acd205ab5c6d762c7ab8f8413a5122e6f6fa2a59
-- 
2.53.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH net v6 1/5] net: gro: set the inner transport header of encapsulated fraglist packets
  2026-11-21 21:14 [PATCH net v6 0/5] ipmr: forward GSO multicast packets Julius Bairaktaris
@ 2026-11-21 21:14 ` Julius Bairaktaris
  2026-11-21 21:14 ` [PATCH net v6 2/5] net: gso: segment fraglist packets with a software tunnel checksum Julius Bairaktaris
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Julius Bairaktaris @ 2026-11-21 21:14 UTC (permalink / raw)
  To: netdev
  Cc: davem, edumazet, kuba, pabeni, horms, dsahern, idosch, willemb,
	ncardwell, kuniyu, steffen.klassert, nbd, jiayuan.chen, mfleming,
	almasrymina, bigeasy, richardbgobert, ecree.xilinx,
	bsdhenrymartin

The fraglist branches of tcp4_gro_complete() and tcp6_gro_complete()
return before tcp_gro_complete(), and those of udp4_gro_complete() and
udp6_gro_complete() before udp_gro_complete_segment(). Only the latter
two set skb->inner_transport_header when skb->encapsulation is set:
commit d51c5907e980 ("net, gro: Set inner transport header offset in
tcp/udp GRO hook") added it to the regular branches only.

The TCP fraglist branch completes the inner flow of every tunnel that
GRO handles (UDP tunnel sockets, FOU/GUE, GRE, IPIP, SIT, ip6ip6,
ip4ip6): tcp4_check_fraglist_gro() and tcp6_check_fraglist_gro() do not
look at the encapsulation. The UDP one completes the inner flow of a
UDP tunnel socket, whose udp_gro_complete() clears encap_mark, and of
FOU/GUE, which clear it on receive; behind GRE, IPIP and SIT encap_mark
stays set and the aggregate completes through
udp_gro_complete_segment().

Such an aggregate keeps an inner transport header from earlier
processing. skb_gso_transport_seglen() computes the segment length from
it, so ip_forward() and ip_finish_output_gso() compare a wrong length
with the MTU; qdisc_pkt_len_segs_init() drops the aggregate with
SKB_DROP_REASON_SKB_BAD_GSO when the offset lies in front of skb->data;
and __skb_udp_tunnel_segment() sets the inner transport header of the
packet it segments from it.

Set the inner transport header in the fraglist branches as well. The
transport header points at the inner TCP or UDP header there, as in
the regular branches.

With rx-gro-list on a virtio-net port of a router with VXLAN sockets,
1000 VXLAN packets per case (outer IPv4, 1400 bytes; inner UDP or TCP
over IPv4 or IPv6) forwarded unicast over a 1400-byte route reached the
receiver 7 to 245 times per case on net, the router's egress counting
the rest as dropped (4 runs of 8 cases), and 1000 times with this change
(2 runs).

Fixes: 9fd1ff5d2ac7 ("udp: Support UDP fraglist GRO/GSO.")
Fixes: 8d95dc474f85 ("net: add code for TCP fraglist GRO")
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
---
 net/ipv4/tcp_offload.c   | 3 +++
 net/ipv4/udp_offload.c   | 3 +++
 net/ipv6/tcpv6_offload.c | 3 +++
 net/ipv6/udp_offload.c   | 3 +++
 4 files changed, 12 insertions(+)

diff --git a/net/ipv4/tcp_offload.c b/net/ipv4/tcp_offload.c
index b84fcd07c723..27bc48a24c2b 100644
--- a/net/ipv4/tcp_offload.c
+++ b/net/ipv4/tcp_offload.c
@@ -465,6 +465,9 @@ INDIRECT_CALLABLE_SCOPE int tcp4_gro_complete(struct sk_buff *skb, int thoff)
 		skb_shinfo(skb)->gso_type |= SKB_GSO_FRAGLIST | SKB_GSO_TCPV4;
 		skb_shinfo(skb)->gso_segs = NAPI_GRO_CB(skb)->count;
 
+		if (skb->encapsulation)
+			skb->inner_transport_header = skb->transport_header;
+
 		__skb_incr_checksum_unnecessary(skb);
 
 		return 0;
diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index b77ae2f00c62..7dc85eb333aa 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -971,6 +971,9 @@ INDIRECT_CALLABLE_SCOPE int udp4_gro_complete(struct sk_buff *skb, int nhoff)
 		skb_shinfo(skb)->gso_type |= (SKB_GSO_FRAGLIST|SKB_GSO_UDP_L4);
 		skb_shinfo(skb)->gso_segs = NAPI_GRO_CB(skb)->count;
 
+		if (skb->encapsulation)
+			skb->inner_transport_header = skb->transport_header;
+
 		__skb_incr_checksum_unnecessary(skb);
 
 		return 0;
diff --git a/net/ipv6/tcpv6_offload.c b/net/ipv6/tcpv6_offload.c
index eec3778855eb..5bed3f341786 100644
--- a/net/ipv6/tcpv6_offload.c
+++ b/net/ipv6/tcpv6_offload.c
@@ -88,6 +88,9 @@ static __always_inline int tcp6_gro_complete(struct sk_buff *skb, int thoff)
 		skb_shinfo(skb)->gso_type |= SKB_GSO_FRAGLIST | SKB_GSO_TCPV6;
 		skb_shinfo(skb)->gso_segs = NAPI_GRO_CB(skb)->count;
 
+		if (skb->encapsulation)
+			skb->inner_transport_header = skb->transport_header;
+
 		__skb_incr_checksum_unnecessary(skb);
 
 		return 0;
diff --git a/net/ipv6/udp_offload.c b/net/ipv6/udp_offload.c
index 7370bcb80332..79346fc17df5 100644
--- a/net/ipv6/udp_offload.c
+++ b/net/ipv6/udp_offload.c
@@ -176,6 +176,9 @@ int udp6_gro_complete(struct sk_buff *skb, int nhoff)
 		skb_shinfo(skb)->gso_type |= (SKB_GSO_FRAGLIST|SKB_GSO_UDP_L4);
 		skb_shinfo(skb)->gso_segs = NAPI_GRO_CB(skb)->count;
 
+		if (skb->encapsulation)
+			skb->inner_transport_header = skb->transport_header;
+
 		__skb_incr_checksum_unnecessary(skb);
 
 		return 0;
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net v6 2/5] net: gso: segment fraglist packets with a software tunnel checksum
  2026-11-21 21:14 [PATCH net v6 0/5] ipmr: forward GSO multicast packets Julius Bairaktaris
  2026-11-21 21:14 ` [PATCH net v6 1/5] net: gro: set the inner transport header of encapsulated fraglist packets Julius Bairaktaris
@ 2026-11-21 21:14 ` Julius Bairaktaris
  2026-11-25 15:15   ` netdev-bot+sashiko
  2026-11-21 21:14 ` [PATCH net v6 3/5] net: gso: count the inner UDP header of encapsulated UDP GSO packets Julius Bairaktaris
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Julius Bairaktaris @ 2026-11-21 21:14 UTC (permalink / raw)
  To: netdev
  Cc: davem, edumazet, kuba, pabeni, horms, dsahern, idosch, willemb,
	ncardwell, kuniyu, steffen.klassert, nbd, jiayuan.chen, mfleming,
	almasrymina, bigeasy, richardbgobert, ecree.xilinx,
	bsdhenrymartin

skb_segment_list() turns the frag_list members of a fraglist packet into
segments and copies the headers of the head in front of each, but sets
no SKB_GSO_CB() checksum state for them. In a UDP tunnel or GRE with
checksum (SKB_GSO_UDP_TUNNEL_CSUM, SKB_GSO_GRE_CSUM),
__skb_udp_tunnel_segment() and gre_gso_segment() compute the outer
checksum of a segment with gso_make_checksum(), which reads exactly that
state, when the egress device does not offload it and for every segment
that is still CHECKSUM_PARTIAL, as they then set skb->encapsulation.
The segments of skb_segment_list() have the ip_summed of the head, so in
both cases their outer checksum is wrong.

Both tunnel segmenters set skb->encap_hdr_csum before they segment the
inner packet. Set it only in those two cases, with one helper for both,
as its description says ("software checksum is needed"), and segment a
fraglist packet with skb_segment() when it is set, as
tcp4_gso_segment(), tcp6_gso_segment() and __udp_gso_segment() already
do for fraglist packets that are DODGY or whose geometry changed. A
fraglist packet that is not CHECKSUM_PARTIAL and leaves through a device
that offloads the outer checksum, and one whose tunnel receive path
cleared the tunnel GSO bits (iptunnel_pull_offloads()), is still
segmented by skb_segment_list().

The UFO segmenters also read encap_hdr_csum. For a UFO packet in such a
tunnel that is not CHECKSUM_PARTIAL, with the outer checksum offloaded,
they now fake the inner checksum offload as they do without an outer
checksum: its segments are CHECKSUM_UNNECESSARY, so the tunnel
segmenters offload the outer checksum and do not call
gso_make_checksum().

In the setup of the previous patch, with the outer UDP checksum set and
checksum offload off on the egress port, 849 to 981 of 1000 segments
per case left with a wrong outer checksum before this change (2 runs of
4 cases) and none after it (3 runs); with checksum offload on, the
packets are still segmented by skb_segment_list() and arrive with valid
checksums (3 runs). With a TCP flow from a local VXLAN device behind
veth, so that the aggregates are CHECKSUM_PARTIAL, 132 to 1098 segments
per transfer left with a wrong outer checksum before this change, with
checksum offload on and off (2 runs), and none after it (3 runs).

Fixes: 9fd1ff5d2ac7 ("udp: Support UDP fraglist GRO/GSO.")
Fixes: bee88cd5bd83 ("net: add support for segmenting TCP fraglist GSO packets")
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
---
 include/net/gso.h        | 24 ++++++++++++++++++++++++
 net/ipv4/gre_offload.c   |  2 +-
 net/ipv4/tcp_offload.c   |  3 ++-
 net/ipv4/udp_offload.c   |  3 ++-
 net/ipv6/tcpv6_offload.c |  3 ++-
 5 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/include/net/gso.h b/include/net/gso.h
index 119fc4c170e1..1cf2bf3a2b4a 100644
--- a/include/net/gso.h
+++ b/include/net/gso.h
@@ -84,6 +84,30 @@ static inline __sum16 gso_make_checksum(struct sk_buff *skb, __wsum res)
 	return csum_fold(csum_partial(csum_start, plen, partial));
 }
 
+/* Whether a GRE or UDP tunnel segmenter computes the outer checksum of a
+ * segment with gso_make_checksum(): when it does not offload it, and for each
+ * segment that is CHECKSUM_PARTIAL, as it then sets skb->encapsulation. Every
+ * segment of skb_segment_list() has the ip_summed of the head.
+ */
+static inline bool skb_gso_tnl_csum_sw(const struct sk_buff *skb,
+				       bool need_csum, bool offload_csum)
+{
+	return need_csum &&
+	       (!offload_csum || skb->ip_summed == CHECKSUM_PARTIAL);
+}
+
+/* skb_segment_list() sets no SKB_GSO_CB() checksum state for the segments it
+ * builds, and gso_make_checksum() reads it: a fraglist packet whose tunnel
+ * computes the outer checksum that way (encap_hdr_csum) has to be segmented
+ * by skb_segment().
+ */
+static inline bool skb_gso_list_csum_ok(const struct sk_buff *skb)
+{
+	return !(skb->encap_hdr_csum &&
+		 (skb_shinfo(skb)->gso_type &
+		  (SKB_GSO_GRE_CSUM | SKB_GSO_UDP_TUNNEL_CSUM)));
+}
+
 struct sk_buff *__skb_gso_segment(struct sk_buff *skb,
 				  netdev_features_t features, bool tx_path,
 				  unsigned int max_segs);
diff --git a/net/ipv4/gre_offload.c b/net/ipv4/gre_offload.c
index c8129782d39d..3ee1ae65f41b 100644
--- a/net/ipv4/gre_offload.c
+++ b/net/ipv4/gre_offload.c
@@ -43,7 +43,6 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb,
 	skb->protocol = skb->inner_protocol;
 
 	need_csum = !!(skb_shinfo(skb)->gso_type & SKB_GSO_GRE_CSUM);
-	skb->encap_hdr_csum = need_csum;
 
 	features &= skb->dev->hw_enc_features;
 	if (need_csum)
@@ -53,6 +52,7 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb,
 	/* Try to offload checksum if possible */
 	offload_csum = !!(need_csum && !need_ipsec &&
 			  (skb->dev->features & NETIF_F_HW_CSUM));
+	skb->encap_hdr_csum = skb_gso_tnl_csum_sw(skb, need_csum, offload_csum);
 
 	/* segment inner packet. */
 	segs = skb_mac_gso_segment(skb, features);
diff --git a/net/ipv4/tcp_offload.c b/net/ipv4/tcp_offload.c
index 27bc48a24c2b..5a9aa3c387f4 100644
--- a/net/ipv4/tcp_offload.c
+++ b/net/ipv4/tcp_offload.c
@@ -108,7 +108,8 @@ static struct sk_buff *tcp4_gso_segment(struct sk_buff *skb,
 		struct tcphdr *th = tcp_hdr(skb);
 
 		if ((skb_pagelen(skb) - th->doff * 4 == skb_shinfo(skb)->gso_size) &&
-		    !(skb_shinfo(skb)->gso_type & SKB_GSO_DODGY))
+		    !(skb_shinfo(skb)->gso_type & SKB_GSO_DODGY) &&
+		    skb_gso_list_csum_ok(skb))
 			return __tcp4_gso_segment_list(skb, features);
 
 		skb->ip_summed = CHECKSUM_NONE;
diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index 7dc85eb333aa..fb2f63774cf6 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -214,7 +214,6 @@ static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb,
 	skb->protocol = new_protocol;
 
 	need_csum = !!(skb_shinfo(skb)->gso_type & SKB_GSO_UDP_TUNNEL_CSUM);
-	skb->encap_hdr_csum = need_csum;
 
 	remcsum = !!(skb_shinfo(skb)->gso_type & SKB_GSO_TUNNEL_REMCSUM);
 	skb->remcsum_offload = remcsum;
@@ -226,6 +225,7 @@ static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb,
 			  (skb->dev->features &
 			   (is_ipv6 ? (NETIF_F_HW_CSUM | NETIF_F_IPV6_CSUM) :
 				      (NETIF_F_HW_CSUM | NETIF_F_IP_CSUM))));
+	skb->encap_hdr_csum = skb_gso_tnl_csum_sw(skb, need_csum, offload_csum);
 
 	features &= skb->dev->hw_enc_features;
 	if (need_csum)
@@ -521,6 +521,7 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
 		 */
 		if ((skb_pagelen(gso_skb) - sizeof(*uh) == skb_shinfo(gso_skb)->gso_size) &&
 		    !(skb_shinfo(gso_skb)->gso_type & SKB_GSO_DODGY) &&
+		    skb_gso_list_csum_ok(gso_skb) &&
 		    ip_hdr(skb_shinfo(gso_skb)->frag_list)->version == (is_ipv6 ? 6 : 4))
 			return __udp_gso_segment_list(gso_skb, features, is_ipv6);
 
diff --git a/net/ipv6/tcpv6_offload.c b/net/ipv6/tcpv6_offload.c
index 5bed3f341786..8d5df64bd1c4 100644
--- a/net/ipv6/tcpv6_offload.c
+++ b/net/ipv6/tcpv6_offload.c
@@ -183,7 +183,8 @@ static struct sk_buff *tcp6_gso_segment(struct sk_buff *skb,
 		struct tcphdr *th = tcp_hdr(skb);
 
 		if ((skb_pagelen(skb) - th->doff * 4 == skb_shinfo(skb)->gso_size) &&
-		    !(skb_shinfo(skb)->gso_type & SKB_GSO_DODGY))
+		    !(skb_shinfo(skb)->gso_type & SKB_GSO_DODGY) &&
+		    skb_gso_list_csum_ok(skb))
 			return __tcp6_gso_segment_list(skb, features);
 
 		skb->ip_summed = CHECKSUM_NONE;
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net v6 3/5] net: gso: count the inner UDP header of encapsulated UDP GSO packets
  2026-11-21 21:14 [PATCH net v6 0/5] ipmr: forward GSO multicast packets Julius Bairaktaris
  2026-11-21 21:14 ` [PATCH net v6 1/5] net: gro: set the inner transport header of encapsulated fraglist packets Julius Bairaktaris
  2026-11-21 21:14 ` [PATCH net v6 2/5] net: gso: segment fraglist packets with a software tunnel checksum Julius Bairaktaris
@ 2026-11-21 21:14 ` Julius Bairaktaris
  2026-11-21 21:14 ` [PATCH net v6 4/5] ipmr: set up GSO state for tunnel vifs Julius Bairaktaris
  2026-11-21 21:14 ` [PATCH net v6 5/5] ipmr: do not drop GSO packets that fit the MTU after segmentation Julius Bairaktaris
  4 siblings, 0 replies; 8+ messages in thread
From: Julius Bairaktaris @ 2026-11-21 21:14 UTC (permalink / raw)
  To: netdev
  Cc: davem, edumazet, kuba, pabeni, horms, dsahern, idosch, willemb,
	ncardwell, kuniyu, steffen.klassert, nbd, jiayuan.chen, mfleming,
	almasrymina, bigeasy, richardbgobert, ecree.xilinx,
	bsdhenrymartin

skb_gso_transport_seglen() adds the inner TCP header length for an
encapsulated GSO packet, but not the inner UDP header for
SKB_GSO_UDP_L4, whose gso_size covers the payload only. Every segment
of a UDP GSO packet in a UDP tunnel, built by UDP GRO behind a tunnel
socket or sent with UDP_SEGMENT over VXLAN, is counted 8 bytes short.
ip_forward() and ip_finish_output_gso() then let DF segments that
exceed the MTU by up to 8 bytes leave unfragmented.

Add the inner UDP header as the unencapsulated branch does.

Fixes: ee80d1ebe5ba ("udp: add udp gso")
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Eric Dumazet <edumazet@kernel.org>
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
---
 net/core/gso.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/core/gso.c b/net/core/gso.c
index b5bd269e56e4..eb95c9d2819b 100644
--- a/net/core/gso.c
+++ b/net/core/gso.c
@@ -156,6 +156,8 @@ static unsigned int skb_gso_transport_seglen(const struct sk_buff *skb)
 
 		if (likely(shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)))
 			thlen += inner_tcp_hdrlen(skb);
+		else if (shinfo->gso_type & SKB_GSO_UDP_L4)
+			thlen += sizeof(struct udphdr);
 	} else if (likely(shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6))) {
 		thlen = tcp_hdrlen(skb);
 	} else if (unlikely(skb_is_gso_sctp(skb))) {
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net v6 4/5] ipmr: set up GSO state for tunnel vifs
  2026-11-21 21:14 [PATCH net v6 0/5] ipmr: forward GSO multicast packets Julius Bairaktaris
                   ` (2 preceding siblings ...)
  2026-11-21 21:14 ` [PATCH net v6 3/5] net: gso: count the inner UDP header of encapsulated UDP GSO packets Julius Bairaktaris
@ 2026-11-21 21:14 ` Julius Bairaktaris
  2026-11-25 15:15   ` netdev-bot+sashiko
  2026-11-21 21:14 ` [PATCH net v6 5/5] ipmr: do not drop GSO packets that fit the MTU after segmentation Julius Bairaktaris
  4 siblings, 1 reply; 8+ messages in thread
From: Julius Bairaktaris @ 2026-11-21 21:14 UTC (permalink / raw)
  To: netdev
  Cc: davem, edumazet, kuba, pabeni, horms, dsahern, idosch, willemb,
	ncardwell, kuniyu, steffen.klassert, nbd, jiayuan.chen, mfleming,
	almasrymina, bigeasy, richardbgobert, ecree.xilinx,
	bsdhenrymartin

ip_encap() pushes the outer IPv4 header but does not set SKB_GSO_IPXIP4,
skb->encapsulation or the inner headers. A GSO packet forwarded to a
VIFF_TUNNEL vif is then rejected by ipip_gso_segment() and dropped in
validate_xmit_skb(), after being counted as sent. A device with UDP
segmentation offload is handed a GSO packet whose transport header
points at the inner IP header.

Call iptunnel_handle_offloads() and skb_set_inner_ipproto() as
ipip_tunnel_xmit() does, reserve one outer IP ID per segment as
iptunnel_xmit() does, and set the outer length with iph_set_totlen(),
since a GSO packet plus the outer header can exceed 64 KB.

An encapsulated GSO packet keeps the inner headers of its own tunnel,
and ip_encap() overwrites skb->inner_protocol for the IPIP header it
adds.
IPIP and SIT aggregates (SKB_GSO_IPXIP4) still segment in software, as
inet_gso_segment() follows the IP headers by their protocol field. GRE
and UDP tunnel aggregates do not: gre_gso_segment() and
skb_udp_tunnel_segment() take the payload type from
skb->inner_protocol. Drop those before the vif counts them; without
this change ipip_gso_segment() dropped them, as they lacked
SKB_GSO_IPXIP4. A device that segments IPXIP4 packets itself, such as
i40e, prepares only the outermost and the innermost IP header of each
segment; it was handed the same three-header IPIP and SIT aggregates
before this change.

Complete the pending checksum of an encapsulated packet that is not GSO
before ip_encap(), as validate_xmit_skb() does for a packet sent through
an ipip device, so that ip_encap() does not leave the inner offsets of
the previous tunnel on the IPIP packet. This is done after the last use
of the IP header pointer, as completing it can reallocate the head.

Fixes: 9fd1ff5d2ac7 ("udp: Support UDP fraglist GRO/GSO.")
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
---
 net/ipv4/ipmr.c | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 836f3f95b20c..eae382a2fadb 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1869,6 +1869,10 @@ static void ip_encap(struct net *net, struct sk_buff *skb,
 	struct iphdr *iph;
 	const struct iphdr *old_iph = ip_hdr(skb);
 
+	/* skb_cow() in ipmr_prepare_xmit() leaves no header to unclone */
+	iptunnel_handle_offloads(skb, SKB_GSO_IPXIP4);
+	skb_set_inner_ipproto(skb, IPPROTO_IPIP);
+
 	skb_push(skb, sizeof(struct iphdr));
 	skb->transport_header = skb->network_header;
 	skb_reset_network_header(skb);
@@ -1882,8 +1886,8 @@ static void ip_encap(struct net *net, struct sk_buff *skb,
 	iph->saddr	=	saddr;
 	iph->protocol	=	IPPROTO_IPIP;
 	iph->ihl	=	5;
-	iph->tot_len	=	htons(skb->len);
-	ip_select_ident(net, skb, NULL);
+	iph_set_totlen(iph, skb->len);
+	ip_select_ident_segs(net, skb, NULL, skb_shinfo(skb)->gso_segs ?: 1);
 	ip_send_check(iph);
 
 	memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
@@ -1951,6 +1955,15 @@ static int ipmr_prepare_xmit(struct net *net, struct mr_table *mrt,
 	}
 
 	if (vif->flags & VIFF_TUNNEL) {
+		/* An encapsulated packet carries the inner headers of its
+		 * own tunnel. Only IPXIP4 GSO packets nest: their IP headers
+		 * are segmented by protocol field, while GRE and UDP tunnel
+		 * segmentation read skb->inner_protocol, which ip_encap()
+		 * sets for its own header.
+		 */
+		if (skb_is_gso(skb) && skb->encapsulation &&
+		    !(skb_shinfo(skb)->gso_type & SKB_GSO_IPXIP4))
+			return -1;
 		rt = ip_route_output_ports(net, &fl4, NULL,
 					   vif->remote, vif->local,
 					   0, 0,
@@ -1985,6 +1998,17 @@ static int ipmr_prepare_xmit(struct net *net, struct mr_table *mrt,
 		return -1;
 	}
 
+	/* Complete the pending checksum of an encapsulated packet, as for
+	 * a packet sent through an ipip device. This may reallocate the
+	 * head: no pointer into it is used after this point.
+	 */
+	if ((vif->flags & VIFF_TUNNEL) && skb->encapsulation &&
+	    !skb_is_gso(skb) && skb->ip_summed == CHECKSUM_PARTIAL &&
+	    skb_checksum_help(skb)) {
+		ip_rt_put(rt);
+		return -1;
+	}
+
 	WRITE_ONCE(vif->pkt_out, vif->pkt_out + 1);
 	WRITE_ONCE(vif->bytes_out, vif->bytes_out + skb->len);
 
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net v6 5/5] ipmr: do not drop GSO packets that fit the MTU after segmentation
  2026-11-21 21:14 [PATCH net v6 0/5] ipmr: forward GSO multicast packets Julius Bairaktaris
                   ` (3 preceding siblings ...)
  2026-11-21 21:14 ` [PATCH net v6 4/5] ipmr: set up GSO state for tunnel vifs Julius Bairaktaris
@ 2026-11-21 21:14 ` Julius Bairaktaris
  4 siblings, 0 replies; 8+ messages in thread
From: Julius Bairaktaris @ 2026-11-21 21:14 UTC (permalink / raw)
  To: netdev
  Cc: davem, edumazet, kuba, pabeni, horms, dsahern, idosch, willemb,
	ncardwell, kuniyu, steffen.klassert, nbd, jiayuan.chen, mfleming,
	almasrymina, bigeasy, richardbgobert, ecree.xilinx,
	bsdhenrymartin

ipmr_prepare_xmit() drops a packet with DF set when skb->len exceeds the
route MTU, without checking whether it is a GSO packet. A UDP multicast
stream received with fraglist GRO or UDP GRO forwarding enabled is
aggregated into GSO packets, and every aggregate is dropped with
FragFails, while ip_forward() lets the same packets pass by checking
skb_gso_validate_network_len(). Do the same for multicast routing,
leaving room for the outer header on tunnel vifs. ip6mr has no such
check and leaves GSO packets to ip6_output().

On an IPQ8074 router with fraglist GRO on, a 10 Mbit/s stream of
1316-byte DF datagrams routed by igmpproxy loses 14.5 to 15.5% (n=3)
and 0% with this change.

Fixes: 9fd1ff5d2ac7 ("udp: Support UDP fraglist GRO/GSO.")
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Eric Dumazet <edumazet@kernel.org>
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
---
 net/ipv4/ipmr.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index eae382a2fadb..3e518877ff5f 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1940,6 +1940,7 @@ static int ipmr_prepare_xmit(struct net *net, struct mr_table *mrt,
 	struct rtable *rt;
 	struct flowi4 fl4;
 	int    encap = 0;
+	unsigned int mtu;
 
 	vif_dev = vif_dev_read(vif);
 	if (!vif_dev)
@@ -1981,7 +1982,10 @@ static int ipmr_prepare_xmit(struct net *net, struct mr_table *mrt,
 			return -1;
 	}
 
-	if (skb->len+encap > dst4_mtu(&rt->dst) && (ntohs(iph->frag_off) & IP_DF)) {
+	mtu = dst4_mtu(&rt->dst);
+	if (skb->len + encap > mtu && (ntohs(iph->frag_off) & IP_DF) &&
+	    !(skb_is_gso(skb) && mtu > encap &&
+	      skb_gso_validate_network_len(skb, mtu - encap))) {
 		/* Do not fragment multicasts. Alas, IPv4 does not
 		 * allow to send ICMP, so that packets will disappear
 		 * to blackhole.
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH net v6 2/5] net: gso: segment fraglist packets with a software tunnel checksum
  2026-11-21 21:14 ` [PATCH net v6 2/5] net: gso: segment fraglist packets with a software tunnel checksum Julius Bairaktaris
@ 2026-11-25 15:15   ` netdev-bot+sashiko
  0 siblings, 0 replies; 8+ messages in thread
From: netdev-bot+sashiko @ 2026-11-25 15:15 UTC (permalink / raw)
  To: julius
  Cc: netdev, davem, edumazet, kuba, pabeni, horms, dsahern, idosch,
	willemb, ncardwell, kuniyu, steffen.klassert, nbd, jiayuan.chen,
	mfleming, almasrymina, bigeasy, richardbgobert, ecree.xilinx,
	bsdhenrymartin

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

Critical: 0 · High: 0 · Medium: 1 · Low: 1

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] skb_gso_tnl_csum_sw() (include/net/gso.h:87-97) is meant to
  predict whether the tunnel segmenter will compute the outer checksum…
- [Low] For UDP, the fix sends affected fraglist aggregates into
  __udp_gso_segment()'s DODGY / changed-geometry fallback, and that…

--

net: gso: segment fraglist packets with a software tunnel checksum

This commit stops skb_segment_list() from segmenting fraglist GSO packets
when a GRE or UDP tunnel segmenter will compute the outer checksum with
gso_make_checksum(). skb_segment_list() sets no SKB_GSO_CB() checksum state,
and gso_make_checksum() reads that state. The patch adds
skb_gso_tnl_csum_sw(), which sets skb->encap_hdr_csum only in those cases,
and skb_gso_list_csum_ok(), which sends such packets to skb_segment() in the
TCP and UDP GSO handlers.

> diff --git a/include/net/gso.h b/include/net/gso.h
> index 119fc4c170e16..1cf2bf3a2b4aa 100644
> --- a/include/net/gso.h
> +++ b/include/net/gso.h
> @@ -84,6 +84,30 @@ static inline __sum16 gso_make_checksum(struct sk_buff *skb, __wsum res)
>  	return csum_fold(csum_partial(csum_start, plen, partial));
>  }
>  
> +/* Whether a GRE or UDP tunnel segmenter computes the outer checksum of a
> + * segment with gso_make_checksum(): when it does not offload it, and for each
> + * segment that is CHECKSUM_PARTIAL, as it then sets skb->encapsulation. Every
> + * segment of skb_segment_list() has the ip_summed of the head.
> + */
> +static inline bool skb_gso_tnl_csum_sw(const struct sk_buff *skb,
> +				       bool need_csum, bool offload_csum)
> +{
> +	return need_csum &&
> +	       (!offload_csum || skb->ip_summed == CHECKSUM_PARTIAL);
> +}

[Severity: Medium]
Does this predicate match what __skb_udp_tunnel_segment() does when
SKB_GSO_TUNNEL_REMCSUM is set?

With remcsum, the segment loop clears CHECKSUM_PARTIAL before it checks
encapsulation:

net/ipv4/udp_offload.c:__skb_udp_tunnel_segment() {
    ...
		if (remcsum)
			skb->ip_summed = CHECKSUM_NONE;

		/* Set up inner headers if we are offloading inner checksum */
		if (skb->ip_summed == CHECKSUM_PARTIAL) {
			skb_reset_inner_headers(skb);
			skb->encapsulation = 1;
		}
    ...
		if (skb->encapsulation || !offload_csum) {
			uh->check = gso_make_checksum(skb, ~uh->check);
    ...
}

So with remcsum and offload_csum true, skb->encapsulation is never set and
gso_make_checksum() is never called. The helper is called without remcsum
and still returns true for a CHECKSUM_PARTIAL head. Its comment also says
"for each segment that is CHECKSUM_PARTIAL, as it then sets
skb->encapsulation", which does not hold here.

vxlan_build_skb() sets SKB_GSO_TUNNEL_REMCSUM only when the skb is
CHECKSUM_PARTIAL, so a CHECKSUM_PARTIAL head is the usual case for remcsum.

Take this setup:

  - VXLAN with REMCSUM_TX and UDP checksums on
  - an egress device that offloads the outer checksum
  - CHECKSUM_PARTIAL fraglist GRO aggregates

Here encap_hdr_csum now gets set and skb_gso_list_csum_ok() returns false.
Before this patch, skb_segment_list() segmented these packets correctly. Now
tcp4_gso_segment() and tcp6_gso_segment() fall back to skb_segment(), and
__udp_gso_segment() linearizes the whole aggregate.

Is this a performance regression for a configuration that already worked?
Could remcsum be passed to skb_gso_tnl_csum_sw(), so that remcsum with
offload_csum counts as offloaded, and the comment updated to match?

[ ... ]

> diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
> index 7dc85eb333aa3..fb2f63774cf6c 100644
> --- a/net/ipv4/udp_offload.c
> +++ b/net/ipv4/udp_offload.c

[ ... ]

> @@ -521,6 +521,7 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
>  		 */
>  		if ((skb_pagelen(gso_skb) - sizeof(*uh) == skb_shinfo(gso_skb)->gso_size) &&
>  		    !(skb_shinfo(gso_skb)->gso_type & SKB_GSO_DODGY) &&
> +		    skb_gso_list_csum_ok(gso_skb) &&
>  		    ip_hdr(skb_shinfo(gso_skb)->frag_list)->version == (is_ipv6 ? 6 : 4))
>  			return __udp_gso_segment_list(gso_skb, features, is_ipv6);
>  

[Severity: Low]
For UDP, this sends the affected aggregates into the DODGY / changed
geometry fallback just below, which linearizes the whole aggregate:

		ret = __skb_linearize(gso_skb);
		if (ret)
			return ERR_PTR(ret);

__skb_linearize() goes through __pskb_pull_tail() -> pskb_expand_head()
with GFP_ATOMIC. A GRO aggregate can have up to 64 frag_list members. That
means one high-order atomic allocation of around 64KB per aggregate on the
xmit path. If the allocation fails, the aggregate is dropped with -ENOMEM.

With skb_gso_tnl_csum_sw(), this fallback becomes the normal path for UDP
fraglist traffic in a checksummed VXLAN, GENEVE or GRE tunnel in two cases:

  - the egress device does not offload the outer checksum
  - the aggregate is CHECKSUM_PARTIAL, even when the device does offload it

These packets used to leave with wrong outer checksums, so nothing that
worked before gets slower here. The commit message only says the patch
will "segment a fraglist packet with skb_segment() when it is set". It does
not mention the linearization in the UDP case.

Could the commit message mention the UDP linearization and its cost?

Alternatively, would it be cheaper to keep the skb_segment_list() fast path
and set up SKB_GSO_CB() checksum state on each segment it builds? That would
mean gso_reset_checksum() for CHECKSUM_PARTIAL segments and a payload
skb_checksum() for the rest.

TCP does not seem to be affected, since tcp_gso_segment() -> skb_segment()
walks frag_list without linearizing.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1795295554.git.julius%40bairaktaris.de

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net v6 4/5] ipmr: set up GSO state for tunnel vifs
  2026-11-21 21:14 ` [PATCH net v6 4/5] ipmr: set up GSO state for tunnel vifs Julius Bairaktaris
@ 2026-11-25 15:15   ` netdev-bot+sashiko
  0 siblings, 0 replies; 8+ messages in thread
From: netdev-bot+sashiko @ 2026-11-25 15:15 UTC (permalink / raw)
  To: julius
  Cc: netdev, davem, edumazet, kuba, pabeni, horms, dsahern, idosch,
	willemb, ncardwell, kuniyu, steffen.klassert, nbd, jiayuan.chen,
	mfleming, almasrymina, bigeasy, richardbgobert, ecree.xilinx,
	bsdhenrymartin

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

Critical: 0 · High: 1 · Medium: 2 · Low: 1

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 new filter in ipmr_prepare_xmit()
  (net/ipv4/ipmr.c:1964-1966) drops an encapsulated GSO packet only when…
- [Medium] ip_encap() (net/ipv4/ipmr.c:1873-1890) adds a new outermost
  IPv4 header with frag_off = 0 (DF clear) to a GSO skb, but leaves…
- [Medium] ipmr: skb_checksum_help() in ipmr_prepare_xmit() corrupts SCTP
  CRC32c
- [Low] The commit message says the encapsulated GRE and UDP-tunnel GSO
  packets the patch now drops were already lost before: 'without this…

--

ipmr: set up GSO state for tunnel vifs

This commit makes ip_encap() in net/ipv4/ipmr.c set up GSO state for
VIFF_TUNNEL vifs. It calls iptunnel_handle_offloads() and
skb_set_inner_ipproto(), reserves one outer IP ID per segment, and sets
the outer length with iph_set_totlen(). It also drops encapsulated GSO
packets without SKB_GSO_IPXIP4 in ipmr_prepare_xmit(), and completes the
pending checksum of encapsulated non-GSO packets before encapsulation.

> GRE
> and UDP tunnel aggregates do not: gre_gso_segment() and
> skb_udp_tunnel_segment() take the payload type from
> skb->inner_protocol. Drop those before the vif counts them; without
> this change ipip_gso_segment() dropped them, as they lacked
> SKB_GSO_IPXIP4.

[Severity: Low]
Is this accurate for devices that segment these packets in hardware?

It holds when the packet is segmented in software. Some NICs list
NETIF_F_GSO_GRE or NETIF_F_GSO_UDP_TUNNEL in hw_enc_features and accept
an outer IPPROTO_IPIP header in ndo_features_check. On those, the old
aggregate never reached ipip_gso_segment().

mlx5 is one example. Its hw_enc_features gets GSO_UDP_TUNNEL and
GSO_GRE, and only the _CSUM variants are in gso_partial_features.
mlx5e_tunnel_features_check() also keeps the features for an outer IPIP
header:

drivers/net/ethernet/mellanox/mlx5/core/en_main.c:mlx5e_tunnel_features_check() {
    ...
	case IPPROTO_IPIP:
	case IPPROTO_IPV6:
		if (mlx5e_tunnel_proto_supported_tx(priv->mdev, IPPROTO_IPIP))
			return features;
    ...
}

So netif_gso_ok() passed and the skb was handed to the hardware, which
most likely produced malformed segments.

On such hardware, the new early return in ipmr_prepare_xmit() changes
the result from transmitting to dropping. The drop also happens before
any vif, device or MIB counter is updated, so nothing records it.

Could the commit message describe this as a behaviour change on these
devices rather than a no-op for all of them?

> diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
> index 836f3f95b20c4..eae382a2fadb3 100644
> --- a/net/ipv4/ipmr.c
> +++ b/net/ipv4/ipmr.c
> @@ -1869,6 +1869,10 @@ static void ip_encap(struct net *net, struct sk_buff *skb,
>  	struct iphdr *iph;
>  	const struct iphdr *old_iph = ip_hdr(skb);
>  
> +	/* skb_cow() in ipmr_prepare_xmit() leaves no header to unclone */
> +	iptunnel_handle_offloads(skb, SKB_GSO_IPXIP4);
> +	skb_set_inner_ipproto(skb, IPPROTO_IPIP);
> +
>  	skb_push(skb, sizeof(struct iphdr));
>  	skb->transport_header = skb->network_header;
>  	skb_reset_network_header(skb);
> @@ -1882,8 +1886,8 @@ static void ip_encap(struct net *net, struct sk_buff *skb,
>  	iph->saddr	=	saddr;
>  	iph->protocol	=	IPPROTO_IPIP;
>  	iph->ihl	=	5;
> -	iph->tot_len	=	htons(skb->len);
> -	ip_select_ident(net, skb, NULL);
> +	iph_set_totlen(iph, skb->len);
> +	ip_select_ident_segs(net, skb, NULL, skb_shinfo(skb)->gso_segs ?: 1);

[Severity: Medium]
What happens to SKB_GSO_TCP_FIXEDID and SKB_GSO_TCP_FIXEDID_INNER here?

These bits are positional. Documentation/networking/segmentation-offloads.rst
says "For encapsulated packets, SKB_GSO_TCP_FIXEDID refers only to the
outer header". tcp4_gro_complete() maps them as:

	BUILD_BUG_ON(SKB_GSO_TCP_FIXEDID << 1 != SKB_GSO_TCP_FIXEDID_INNER);
	skb_shinfo(skb)->gso_type |= SKB_GSO_TCPV4 |
			(NAPI_GRO_CB(skb)->ip_fixedid * SKB_GSO_TCP_FIXEDID);

inet_gso_segment() then computes:

	fixedid = !!(skb_shinfo(skb)->gso_type & (SKB_GSO_TCP_FIXEDID << encap));

When fixedid is set, it does not increment the ID per segment.

ip_encap() adds a new outermost header with frag_off = 0, but it leaves
these bits as they are. Fixed IDs are common for TCP GRO aggregates:
DF packets get ID 0, and inet_gro_flush() sets ip_fixedid when the first
two IDs are equal.

For such an aggregate, doesn't the FIXEDID bit that described the
original header now apply to the new DF-clear ipmr header?

If so, every segment would carry the same outer IP ID with DF clear, and
the gso_segs IDs reserved by ip_select_ident_segs() would go unused. The
original header, now at encap level 1, would be segmented according to
FIXEDID_INNER, which described a different header. Nested IPXIP4
aggregates would shift the same way.

This seems to contradict "reserve one outer IP ID per segment as
iptunnel_xmit() does" in the commit message. Before this patch,
ipip_gso_segment() dropped these packets because they lacked
SKB_GSO_IPXIP4, so this is new behaviour.

>  	ip_send_check(iph);
>  
>  	memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
> @@ -1951,6 +1955,15 @@ static int ipmr_prepare_xmit(struct net *net, struct mr_table *mrt,
>  	}
>  
>  	if (vif->flags & VIFF_TUNNEL) {
> +		/* An encapsulated packet carries the inner headers of its
> +		 * own tunnel. Only IPXIP4 GSO packets nest: their IP headers
> +		 * are segmented by protocol field, while GRE and UDP tunnel
> +		 * segmentation read skb->inner_protocol, which ip_encap()
> +		 * sets for its own header.
> +		 */
> +		if (skb_is_gso(skb) && skb->encapsulation &&
> +		    !(skb_shinfo(skb)->gso_type & SKB_GSO_IPXIP4))
> +			return -1;

[Severity: High]
Can FOU and GUE aggregates get past this check and then be segmented
with the wrong inner protocol?

The check only rejects encapsulated GSO packets when SKB_GSO_IPXIP4 is
clear. fou_gro_receive() and gue_gro_receive() clear
NAPI_GRO_CB(skb)->encap_mark, so ipip or sit GRO can nest inside a UDP
tunnel aggregate:

  udp_gro_complete()
    gso_type |= SKB_GSO_UDP_TUNNEL(_CSUM), encapsulation = 1
  sit_gro_complete() / ipip_gro_complete()
    gso_type |= SKB_GSO_IPXIP4
  ipv6_gro_complete() / inet_gro_complete()
    skb_set_inner_protocol(skb, ETH_P_IPV6 or ETH_P_IP)

Such a packet has both UDP_TUNNEL and IPXIP4 set, so it passes this
check. ip_encap() then overwrites the recorded payload type:

	skb_set_inner_ipproto(skb, IPPROTO_IPIP);

skb_udp_tunnel_segment() in net/ipv4/udp_offload.c dispatches on that
field:

	case ENCAP_TYPE_IPPROTO:
		offloads = is_ipv6 ? inet6_offloads : inet_offloads;
		ops = rcu_dereference(offloads[skb->inner_ipproto]);

For FOU or GUE carrying 6in4 (ipproto 41), wouldn't this run
ipip_gso_segment() and inet_gso_segment() on the IPv6 header?

That would usually fail with -EINVAL and drop the packet after it has
been counted as sent. When the traffic class and source address bytes
happen to form a plausible ihl and protocol, malformed segments would be
built instead.

Before this patch, these aggregates segmented correctly in software. The
outer ipip_gso_segment() accepted them because sit had already set
IPXIP4, and skb_udp_tunnel_segment() dispatched on ETH_P_IPV6.

The comment above says UDP tunnel segmentation reads
skb->inner_protocol, which ip_encap() overwrites. Should the check reject
GSO packets that have any of SKB_GSO_GRE, SKB_GSO_GRE_CSUM,
SKB_GSO_UDP_TUNNEL or SKB_GSO_UDP_TUNNEL_CSUM set, instead of testing for
the absence of SKB_GSO_IPXIP4?

FOU carrying IPIP still works, but only because IPPROTO_IPIP happens to
be the right handler.

>  		rt = ip_route_output_ports(net, &fl4, NULL,
>  					   vif->remote, vif->local,
>  					   0, 0,

[ ... ]

> @@ -1985,6 +1998,17 @@ static int ipmr_prepare_xmit(struct net *net, struct mr_table *mrt,
>  		return -1;
>  	}
>  
> +	/* Complete the pending checksum of an encapsulated packet, as for
> +	 * a packet sent through an ipip device. This may reallocate the
> +	 * head: no pointer into it is used after this point.
> +	 */
> +	if ((vif->flags & VIFF_TUNNEL) && skb->encapsulation &&
> +	    !skb_is_gso(skb) && skb->ip_summed == CHECKSUM_PARTIAL &&
> +	    skb_checksum_help(skb)) {
> +		ip_rt_put(rt);
> +		return -1;
> +	}
> +
>  	WRITE_ONCE(vif->pkt_out, vif->pkt_out + 1);
>  	WRITE_ONCE(vif->bytes_out, vif->bytes_out + skb->len);
>  

[Severity: Medium]
Does this do the right thing for an encapsulated SCTP packet whose
CRC32c is still pending?

The comment and the commit message say this matches what happens to a
packet sent through an ipip device. validate_xmit_skb() does not call
skb_checksum_help() directly, though. It calls
skb_csum_hwoffload_help(), which checks for SCTP first:

	if (unlikely(skb_csum_is_sctp(skb)))
		return !!(features & NETIF_F_SCTP_CRC) ? 0 :
			skb_crc32c_csum_help(skb);

skb_checksum_help() has no such check. For a non-GSO skb with
encapsulation set, ip_summed == CHECKSUM_PARTIAL and csum_not_inet set,
it computes a 16-bit ones-complement sum and writes it at
csum_start + csum_offset. That overwrites half of the 32-bit SCTP
checksum field with the wrong algorithm. It sets ip_summed to
CHECKSUM_NONE but leaves csum_not_inet set. skb_crc32c_csum_help()
would have written the CRC32c and called skb_reset_csum_not_inet().

Such a packet can come from BPF encapsulation (bpf_skb_adjust_room(),
bpf_lwt_push_ip_encap()) or IPVS tunnel mode on a device that
advertises NETIF_F_SCTP_CRC. The receiver would then drop every one of
these packets on a bad CRC, after the vif and device counters have
recorded them as sent.

The trigger needs CAP_NET_ADMIN and an unusual setup, but this is new
behaviour added by the patch, and it does not match the parity the
comment claims.

Would calling skb_csum_hwoffload_help(skb, 0) here be the better fit?
That is what validate_xmit_skb() ends up doing for an encapsulated skb
on an ipip device. It falls through to skb_checksum_help() for the
non-SCTP case and dispatches SCTP to skb_crc32c_csum_help().

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1795295554.git.julius%40bairaktaris.de

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-11-25 15:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-21 21:14 [PATCH net v6 0/5] ipmr: forward GSO multicast packets Julius Bairaktaris
2026-11-21 21:14 ` [PATCH net v6 1/5] net: gro: set the inner transport header of encapsulated fraglist packets Julius Bairaktaris
2026-11-21 21:14 ` [PATCH net v6 2/5] net: gso: segment fraglist packets with a software tunnel checksum Julius Bairaktaris
2026-11-25 15:15   ` netdev-bot+sashiko
2026-11-21 21:14 ` [PATCH net v6 3/5] net: gso: count the inner UDP header of encapsulated UDP GSO packets Julius Bairaktaris
2026-11-21 21:14 ` [PATCH net v6 4/5] ipmr: set up GSO state for tunnel vifs Julius Bairaktaris
2026-11-25 15:15   ` netdev-bot+sashiko
2026-11-21 21:14 ` [PATCH net v6 5/5] ipmr: do not drop GSO packets that fit the MTU after segmentation Julius Bairaktaris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox