* [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; 6+ 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] 6+ 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-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, 0 replies; 6+ 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] 6+ 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; 6+ 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] 6+ 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-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; 6+ 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] 6+ 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; 6+ 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] 6+ messages in thread