* [PATCH net v7 0/2] ipmr: forward GSO multicast packets
@ 2026-11-28 16:47 Julius Bairaktaris
2026-11-28 16:47 ` [PATCH net v7 1/2] ipmr: set up GSO state for tunnel vifs Julius Bairaktaris
2026-11-28 16:47 ` [PATCH net v7 2/2] ipmr: do not drop GSO packets that fit the MTU after segmentation Julius Bairaktaris
0 siblings, 2 replies; 3+ messages in thread
From: Julius Bairaktaris @ 2026-11-28 16:47 UTC (permalink / raw)
To: netdev
Cc: davem, edumazet, kuba, pabeni, horms, dsahern, idosch, willemb,
willemdebruijn.kernel, kuniyu, steffen.klassert
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.
Patch 1 sets up IPXIP4 GSO state, outer IP IDs and length in
ip_encap(), segments an already encapsulated GSO packet in software
before it, as an ipip device does, and completes the pending checksum
of an encapsulated packet that is not GSO.
Patch 2 lets DF GSO packets pass when their segments fit the MTU.
Per issue:
- Trigger: a multicast stream from the network, routed by a multicast
routing daemon (igmpproxy, smcroute, pimd; configured with
CAP_NET_ADMIN) while the ingress has rx-gro-list or
rx-udp-gro-forwarding on. Patch 1 needs a VIFF_TUNNEL vif, patch 2
DF set on the stream.
- Impact: the aggregated packets are dropped, patch 1 after counting
them as sent; no memory safety issue. CVSS 3.1: 3.7
(AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L).
- Until the fix lands: ethtool -K <ingress> rx-gro-list off
rx-udp-gro-forwarding off.
- Found: patch 1 by a Sashiko review of v1, patch 2 as packet loss on an
IPQ8074 router.
For UDP GSO packets that patch 1 encapsulates, and for encapsulated
ones that patch 2 lets pass, the MTU check of ip_finish_output_gso()
counts the inner UDP header with "net: gso: count the inner UDP header
of encapsulated UDP GSO packets" from the series "net: gso: segment
length of encapsulated GSO packets", posted beside this one; each
applies to net on its own.
Tested in QEMU (KVM) with network namespaces, on net (28a371228d4e),
with this series alone and together with the series above:
- FOU carrying SIT or IPIP, IPIP, GRE and VXLAN aggregates routed to a
plain and a tunnel vif, underlay segmenting in software or offering
segmentation, 1000 datagrams per case: net delivers every datagram to
both vifs in 2 of 10 cases (2 runs), v6 in 2 of 10 and hands the
underlay 39 to 73 GSO packets with three IP headers per offload case
(2 runs); with this series all 10, with valid checksums and distinct
outer IP IDs, no GSO packet with three IP headers on the underlay
(5 runs, one with KASAN).
- SCTP INIT chunks encapsulated in IPIP by tc BPF, routed to a tunnel
vif: 50 of 50 arrive with a wrong CRC32c with v6 (2 runs), all valid
on net (1 run) and with this series (5 runs).
- IPIP aggregates built by GRO (fraglist, UDP GRO forwarding, none)
routed to a plain and a tunnel vif: 1000 of 1000 on both, distinct
outer IDs (4 runs, one with KASAN, in which 37 datagrams of one case
were lost before the router and missed on both vifs alike).
- 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: all 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 (5 runs, one with KASAN).
- tools/testing/selftests/net/forwarding/ipmr: the same 14 of 22 cases
pass as on net (3 runs and 1 run; the IPv6 cases need
CONFIG_IPV6_MROUTE, which is not set here).
Changes in v7:
- Split: v6 patches 1 and 3 and a new SCTP case go to "net: gso:
segment length of encapsulated GSO packets" (Willem de Bruijn).
- Drop v6 patch 2: Willem's ab5b219a7340 ("net: gso: fall back to
skb_segment when fraglist cannot satisfy checksum") in net covers it;
the two Sashiko findings on it (SKB_GSO_TUNNEL_REMCSUM predicate, UDP
linearization) go with it.
- Patch 1: segment an encapsulated GSO packet with skb_gso_segment()
before ip_encap() on a tunnel vif, in ipmr_queue_fwd_xmit() and
ipmr_queue_output_xmit(), instead of dropping those without
SKB_GSO_IPXIP4 (Willem de Bruijn). This removes FOU/GUE aggregates
carrying IPIP or SIT being segmented with ip_encap()'s inner protocol
(Willem, Sashiko) and IPXIP4 aggregates with three IP headers reaching
a device that segments them (Willem), and GRE and UDP tunnel
aggregates are forwarded instead of dropped, so the commit message no
longer claims they were lost before (Sashiko).
- Patch 1: complete the pending checksum with skb_csum_hwoffload_help()
instead of skb_checksum_help(), which overwrote an SCTP CRC32c
(Willem de Bruijn, Sashiko).
- Patch 1: read the vif flags once per packet.
- Patch 1: name the fixed-ID case every iptunnel_handle_offloads()
caller shares and the net-next series that fixes it (Sashiko).
- Rebase onto net.
- v6: https://lore.kernel.org/netdev/cover.1795295554.git.julius@bairaktaris.de/
I used Claude (Anthropic) to help write these patches.
Julius Bairaktaris (2):
ipmr: set up GSO state for tunnel vifs
ipmr: do not drop GSO packets that fit the MTU after segmentation
net/ipv4/ipmr.c | 84 +++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 75 insertions(+), 9 deletions(-)
base-commit: 28a371228d4eb4857cc31eeb1a0d7d01e9c3ea2f
--
2.53.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH net v7 1/2] ipmr: set up GSO state for tunnel vifs
2026-11-28 16:47 [PATCH net v7 0/2] ipmr: forward GSO multicast packets Julius Bairaktaris
@ 2026-11-28 16:47 ` Julius Bairaktaris
2026-11-28 16:47 ` [PATCH net v7 2/2] ipmr: do not drop GSO packets that fit the MTU after segmentation Julius Bairaktaris
1 sibling, 0 replies; 3+ messages in thread
From: Julius Bairaktaris @ 2026-11-28 16:47 UTC (permalink / raw)
To: netdev
Cc: davem, edumazet, kuba, pabeni, horms, dsahern, idosch, willemb,
willemdebruijn.kernel, kuniyu, steffen.klassert
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.
A packet that is already encapsulated keeps the inner header offsets
and skb->inner_protocol of its own tunnel, and ip_encap() cannot
describe the header it adds without overwriting them: GRE and UDP
tunnel segmentation would read the payload type that ip_encap() sets,
and a device that segments IPXIP4 packets itself, such as i40e, would
prepare only the outermost and the innermost of three IP headers. An
ipip device offers no tunnel offloads, so validate_xmit_skb() segments
such a GSO packet in software before ipip_tunnel_xmit() adds its header.
Do the same in ipmr_queue_fwd_xmit() and ipmr_queue_output_xmit() and
send each segment on its own. The vif flags are read once per packet,
so that a GSO packet that was not segmented does not reach ip_encap()
when the vif becomes a tunnel vif meanwhile.
Complete the pending checksum of an encapsulated packet that is not GSO
with skb_csum_hwoffload_help(), as validate_xmit_skb() does for an ipip
device, which also computes an SCTP CRC32c. This is done after the last
use of the IP header pointer, as completing it can reallocate the head.
Tested in QEMU with network namespaces and veth: 1000 datagrams per
case in FOU carrying SIT or IPIP, in IPIP, GRE and VXLAN, aggregated by
GRO on the router and routed by an MFC entry to a plain and a tunnel
vif, whose underlay segments in software or offers segmentation (10
cases). On net 2 of the 10 cases deliver every datagram to both vifs
with distinct outer IP IDs (2 runs); with this change all 10, with
valid checksums, and the underlay is handed no GSO packet with three
IP headers (5 runs, one with KASAN). 50 SCTP INIT chunks encapsulated
in IPIP by a tc BPF program and routed to a tunnel vif arrive with a
valid CRC32c (5 runs).
iptunnel_handle_offloads() keeps SKB_GSO_TCP_FIXEDID of a TCP GSO
packet that is not encapsulated, so the bit then applies to the added
outer header, whose DF bit is clear. That holds for every caller of
iptunnel_handle_offloads(); "net: keep the TCP fixed-ID flags on the
header they describe", posted for net-next, clears the bit there.
Fixes: 9fd1ff5d2ac7 ("udp: Support UDP fraglist GRO/GSO.")
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
---
Changes in v7:
- Segment an encapsulated GSO packet with skb_gso_segment() before
ip_encap() on a tunnel vif instead of dropping those without
SKB_GSO_IPXIP4 (Willem de Bruijn, Sashiko).
- Complete the checksum with skb_csum_hwoffload_help() (Willem de
Bruijn, Sashiko).
- Read the vif flags once per packet.
- Name the fixed-ID case shared by every iptunnel_handle_offloads()
caller (Sashiko).
- v6: https://lore.kernel.org/netdev/ffd8ca7abd44882707fbca297889f6e43ced4a65.1795295554.git.julius@bairaktaris.de/
net/ipv4/ipmr.c | 78 ++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 70 insertions(+), 8 deletions(-)
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 836f3f95b20c..fc2ba155a9dc 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));
@@ -1928,7 +1932,8 @@ static bool ipmr_forward_offloaded(struct sk_buff *skb, struct mr_table *mrt,
/* Processing handlers for ipmr_forward, under rcu_read_lock() */
static int ipmr_prepare_xmit(struct net *net, struct mr_table *mrt,
- struct sk_buff *skb, int vifi)
+ struct sk_buff *skb, int vifi,
+ unsigned short flags)
{
const struct iphdr *iph = ip_hdr(skb);
struct vif_device *vif = &mrt->vif_table[vifi];
@@ -1941,7 +1946,7 @@ static int ipmr_prepare_xmit(struct net *net, struct mr_table *mrt,
if (!vif_dev)
return -1;
- if (vif->flags & VIFF_REGISTER) {
+ if (flags & VIFF_REGISTER) {
WRITE_ONCE(vif->pkt_out, vif->pkt_out + 1);
WRITE_ONCE(vif->bytes_out, vif->bytes_out + skb->len);
DEV_STATS_ADD(vif_dev, tx_bytes, skb->len);
@@ -1950,7 +1955,7 @@ static int ipmr_prepare_xmit(struct net *net, struct mr_table *mrt,
return -1;
}
- if (vif->flags & VIFF_TUNNEL) {
+ if (flags & VIFF_TUNNEL) {
rt = ip_route_output_ports(net, &fl4, NULL,
vif->remote, vif->local,
0, 0,
@@ -1985,6 +1990,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 ((flags & VIFF_TUNNEL) && skb->encapsulation &&
+ skb->ip_summed == CHECKSUM_PARTIAL &&
+ skb_csum_hwoffload_help(skb, 0)) {
+ 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);
@@ -1995,7 +2011,7 @@ static int ipmr_prepare_xmit(struct net *net, struct mr_table *mrt,
/* FIXME: forward and output firewalls used to be called here.
* What do we do with netfilter? -- RR
*/
- if (vif->flags & VIFF_TUNNEL) {
+ if (flags & VIFF_TUNNEL) {
ip_encap(net, skb, vif->local, vif->remote);
/* FIXME: extra output firewall step used to be here. --RR */
DEV_STATS_INC(vif_dev, tx_packets);
@@ -2005,15 +2021,49 @@ static int ipmr_prepare_xmit(struct net *net, struct mr_table *mrt,
return 0;
}
+/* ip_encap() describes its IPIP header with the inner header offsets of
+ * the skb, which an encapsulated packet already uses for its own tunnel.
+ * An ipip device offers no tunnel offloads, so validate_xmit_skb()
+ * segments such a GSO packet before ipip_tunnel_xmit() adds the header.
+ * Do the same for a tunnel vif.
+ */
+static bool ipmr_needs_segment(const struct sk_buff *skb, unsigned short flags)
+{
+ return (flags & VIFF_TUNNEL) && skb->encapsulation && skb_is_gso(skb);
+}
+
+static struct sk_buff *ipmr_segment(struct sk_buff *skb)
+{
+ struct sk_buff *segs = skb_gso_segment(skb, 0);
+
+ if (IS_ERR_OR_NULL(segs)) {
+ kfree_skb(skb);
+ return NULL;
+ }
+ consume_skb(skb);
+ return segs;
+}
+
static void ipmr_queue_fwd_xmit(struct net *net, struct mr_table *mrt,
int in_vifi, struct sk_buff *skb, int vifi)
{
+ unsigned short flags = READ_ONCE(mrt->vif_table[vifi].flags);
+ struct sk_buff *segs, *next;
struct rtable *rt;
if (ipmr_forward_offloaded(skb, mrt, in_vifi, vifi))
goto out_free;
- if (ipmr_prepare_xmit(net, mrt, skb, vifi))
+ if (ipmr_needs_segment(skb, flags)) {
+ segs = ipmr_segment(skb);
+ skb_list_walk_safe(segs, skb, next) {
+ skb_mark_not_on_list(skb);
+ ipmr_queue_fwd_xmit(net, mrt, in_vifi, skb, vifi);
+ }
+ return;
+ }
+
+ if (ipmr_prepare_xmit(net, mrt, skb, vifi, flags))
goto out_free;
rt = skb_rtable(skb);
@@ -2042,7 +2092,19 @@ static void ipmr_queue_fwd_xmit(struct net *net, struct mr_table *mrt,
static void ipmr_queue_output_xmit(struct net *net, struct mr_table *mrt,
struct sk_buff *skb, int vifi)
{
- if (ipmr_prepare_xmit(net, mrt, skb, vifi))
+ unsigned short flags = READ_ONCE(mrt->vif_table[vifi].flags);
+ struct sk_buff *segs, *next;
+
+ if (ipmr_needs_segment(skb, flags)) {
+ segs = ipmr_segment(skb);
+ skb_list_walk_safe(segs, skb, next) {
+ skb_mark_not_on_list(skb);
+ ipmr_queue_output_xmit(net, mrt, skb, vifi);
+ }
+ return;
+ }
+
+ if (ipmr_prepare_xmit(net, mrt, skb, vifi, flags))
goto out_free;
ip_mc_output(net, NULL, skb);
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH net v7 2/2] ipmr: do not drop GSO packets that fit the MTU after segmentation
2026-11-28 16:47 [PATCH net v7 0/2] ipmr: forward GSO multicast packets Julius Bairaktaris
2026-11-28 16:47 ` [PATCH net v7 1/2] ipmr: set up GSO state for tunnel vifs Julius Bairaktaris
@ 2026-11-28 16:47 ` Julius Bairaktaris
1 sibling, 0 replies; 3+ messages in thread
From: Julius Bairaktaris @ 2026-11-28 16:47 UTC (permalink / raw)
To: netdev
Cc: davem, edumazet, kuba, pabeni, horms, dsahern, idosch, willemb,
willemdebruijn.kernel, kuniyu, steffen.klassert
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>
---
Changes in v7:
- Rebase onto net; no change.
- v6: https://lore.kernel.org/netdev/feedaf85d17bfb8b0e4587729d8cfa5898f94183.1795295554.git.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 fc2ba155a9dc..078079016fc8 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1941,6 +1941,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)
@@ -1973,7 +1974,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] 3+ messages in thread
end of thread, other threads:[~2026-11-28 16:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-28 16:47 [PATCH net v7 0/2] ipmr: forward GSO multicast packets Julius Bairaktaris
2026-11-28 16:47 ` [PATCH net v7 1/2] ipmr: set up GSO state for tunnel vifs Julius Bairaktaris
2026-11-28 16:47 ` [PATCH net v7 2/2] 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