[PATCH net] ip_tunnel: fragment IPv6 payload when the tunnel MTU is below IPV6_MIN_MTU
From: James Sawyer via B4 Relay
Date: Thu Dec 03 2026 - 06:59:23 EST
From: James Sawyer <james@xxxxxxxxxxxxxxxxx>
When the path MTU to the tunnel peer leaves less than IPV6_MIN_MTU for
an IPv6 payload, tnl_update_pmtu() cannot send a Packet Too Big (IPv6
has no smaller MTU to report) and returns 0 with the outer DF still
set. The encapsulated packet is then dropped by ip_fragment() and the
sender gets no signal at all: IPv6 over GRE silently blackholes every
packet larger than the remaining MTU.
The path MTU can be lowered this way by one forged ICMP
fragmentation-needed message to the tunnel endpoint quoting the
tunnel's outer packet. With plain GRE (24 bytes of overhead) any
unlocked value from 552 to 1303 triggers it. Values below 552 are
stored locked, so iptunnel_xmit() already clears DF in that case.
sit already handles this case by clearing DF ("if (mtu < IPV6_MIN_MTU)
{ mtu = IPV6_MIN_MTU; df = 0; }"). Do the same for ip_tunnel users, so
the outer packet is fragmented instead of dropped. tnl_update_pmtu()
now takes df by reference. For collect_md tunnels this also overrides
IP_TUNNEL_DONT_FRAGMENT_BIT in this one case, as sit does.
Reproduced on 7.0.0-43-generic with network namespaces: after one
forged ICMP with MTU 1000 to the GRE endpoint, 1232-byte UDP payloads
over IPv6 were sent without error and 0 of 3 arrived; a capture on the
sender showed no ICMPv6 Packet Too Big (4 runs).
Tested on v7.4-rc1 in QEMU: unpatched, IPv6 1232-byte payloads over
GRE after a forged MTU of 1000 were 0 of 3 delivered and ping6 lost
3 of 3; with this patch 3 of 3 were delivered and ping6 passed. IPv4
over the same tunnel is unchanged (frag-needed with mtu = 976 is still
returned). Built with W=1 (net/ipv4/ip_tunnel.o) without warnings.
This issue was found and the fix written with AI assistance.
Fixes: c54419321455 ("GRE: Refactor GRE tunneling code.")
Signed-off-by: James Sawyer <james@xxxxxxxxxxxxxxxxx>
---
Notes for reviewers (not for the commit):
- Found and fixed with AI assistance. Measured by me in a lab on
7.0.0-43-generic in network namespaces; reproducer available privately
on request.
- Behaviour change to check: for collect_md tunnels with
IP_TUNNEL_DONT_FRAGMENT_BIT set, this clears DF in the sub-1280 case,
matching what sit does. If that flag should win, the check can be
limited to !md.
- Related, sent separately: "ipv4: do not trust ICMP-locked PMTU while
forwarding".
---
net/ipv4/ip_tunnel.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 0875474a578a..6ea2bf14047b 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -514,7 +514,7 @@ int ip_tunnel_encap_setup(struct ip_tunnel *t,
EXPORT_SYMBOL_GPL(ip_tunnel_encap_setup);
static int tnl_update_pmtu(struct net_device *dev, struct sk_buff *skb,
- struct rtable *rt, __be16 df,
+ struct rtable *rt, __be16 *df,
const struct iphdr *inner_iph,
int tunnel_hlen, __be32 dst, bool md)
{
@@ -526,7 +526,7 @@ static int tnl_update_pmtu(struct net_device *dev, struct sk_buff *skb,
pkt_size = skb->len - tunnel_hlen;
pkt_size -= dev->type == ARPHRD_ETHER ? dev->hard_header_len : 0;
- if (df) {
+ if (*df) {
mtu = dst_mtu(&rt->dst) - (sizeof(struct iphdr) + tunnel_hlen);
mtu -= dev->type == ARPHRD_ETHER ? dev->hard_header_len : 0;
} else {
@@ -553,6 +553,13 @@ static int tnl_update_pmtu(struct net_device *dev, struct sk_buff *skb,
NULL;
daddr = md ? dst : tunnel->parms.iph.daddr;
+ /* IPv6 cannot signal a path MTU below IPV6_MIN_MTU, so no
+ * Packet Too Big can be sent below. Fragment the outer packet
+ * instead of dropping it, as sit does.
+ */
+ if (mtu < IPV6_MIN_MTU)
+ *df = 0;
+
if (rt6 && mtu < dst_mtu(skb_dst(skb)) &&
mtu >= IPV6_MIN_MTU) {
if ((daddr && !ipv4_is_multicast(daddr)) ||
@@ -632,7 +639,7 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
if (test_bit(IP_TUNNEL_DONT_FRAGMENT_BIT, key->tun_flags))
df = htons(IP_DF);
- if (tnl_update_pmtu(dev, skb, rt, df, inner_iph, tunnel_hlen,
+ if (tnl_update_pmtu(dev, skb, rt, &df, inner_iph, tunnel_hlen,
key->u.ipv4.dst, true)) {
ip_rt_put(rt);
goto tx_error;
@@ -807,7 +814,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
if (payload_protocol == htons(ETH_P_IP) && !tunnel->ignore_df)
df |= (inner_iph->frag_off & htons(IP_DF));
- if (tnl_update_pmtu(dev, skb, rt, df, inner_iph, 0, 0, false)) {
+ if (tnl_update_pmtu(dev, skb, rt, &df, inner_iph, 0, 0, false)) {
ip_rt_put(rt);
goto tx_error;
}
---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20261203-ip-tunnel-ipv6-min-mtu-df-75896af91973
Best regards,
--
James Sawyer <james@xxxxxxxxxxxxxxxxx>