🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26312

[PATCH net] ip_tunnel: fragment IPv6 payload when the tunnel MTU is below IPV6_MIN_MTU

#26312
From: James Sawyer via B4 Relay
Date: Thu, 03 Dec 2026 11:59
114 lines
15282 bytes
From: James Sawyer <james@jamessawyer.co.uk>

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@jamessawyer.co.uk>
---
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@jamessawyer.co.uk>
Technical Details
Message-ID: <20261203-ip-tunnel-ipv6-min-mtu-df-v1-1-ef4b415911a5@jamessawyer.co.uk>
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376534-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376534-linux-kernel-netdev=dewy.ru
From: devnull+james.jamessawyer.co.uk@kernel.org (James Sawyer via B4 Relay)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] ip_tunnel: fragment IPv6 payload when the tunnel MTU
 is below IPV6_MIN_MTU
Date: Thu, 03 Dec 2026 11:59:13 +0000
Organization: Usenet Network
Message-ID: <20261203-ip-tunnel-ipv6-min-mtu-df-v1-1-ef4b415911a5@jamessawyer.co.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="2478252"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:kULe2w0/swnmcbE2Slo7aSUZUPs= sha256:xqiF+081Ta1w4Y4YrDXUzjf6pvqQs/mgJBAxnfYEW0M=
	sha1:SFVM1JWt9936Eng2P/qjED0yxyM= sha256:gRPW3Osi1IYLAdNrSUyKDGiyplvI8RUqmpmwVcLrqzY=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id B2AD41178FF; Thu,  3 Dec 2026 14:59:38 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.64
X-Spam-Status: No, score=-3.64 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id UJv6DDCfhKtJ;
	Thu,  3 Dec 2026 14:59:36 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-376534-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 004F11178F2; Thu,  3 Dec 2026 14:59:27 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id A75D12C45F; Thu,  3 Dec 2026 11:59:25 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796299165;
	b=BSWbijb1xGEJVja9VoLgTVz15KRzldtIm62rQXDgkleN0Mpv8cmrIeduxJkXlBv8q6z6
	 Eo4BAhXZxPrMYY2uKEPle7gOA8LYe5plvHVa7xpA4+4iaJJrsYpck4Tc8uwaYZ4JXQG4A
	 2nQhs6b94gFE8GJ243XFvHIHOY863Jh5gCi2u6oITny5g8i7UJTYIlsrmEo0h/ENNGADS
	 LAsS227jNhZ1/d9iYG1g2tfmry/HaX4Dt0dkheK8WeHIcnV7jwWTMJceR+K8Qb/5xYLWN
	 NcpU2TDcQ+Tm2qYdw205oMe46F19hNNOkENig1y6RID/+RxoGfM7KH9HZ0pipxe1umg==
X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796299165;
	h=X-Original-To:Received:Received:DKIM-Signature:Received:From:Date:
	 Subject:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type:
	 Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer:
	 X-Developer-Signature:X-Developer-Key:X-Endpoint-Received:
	 X-Original-From:Reply-To:Content-Transfer-Encoding;
	bh=bqJscT1GgmwlYPsNBFyi54DdPX3vCZe4sZYhIvFe668=;
	b=FvcjhLoK9kdb0iz6S2wU5AoIYJsiLkmZ6jrg1gkH/MQ+5gLEukMYwFwpjOniT7zV9mw0
	 hLDrVxpZz7ku9qFDMnRN6VFqonNCjMybA39sBwWBO0WN+IUstByBYNgsdSyDV5pZ0w2Ra
	 +D5+3DSQrMvRibh33lX5vJ07iasfkpTYSY9UtbB22FT7mnraCXxbVmkpGn+JmpP9Oa0gY
	 /4sbxT+lJRY6PLPx5PqCyv6sw37ASO+dGVbXYus7CVhG6I7cDH0RFxZjC90O7kG4iMPI8
	 oGBlvustrFvmgksvLZdKAOtnt/QT7Js3b5X7OUPFce2ruxK9PM0p5VA98IcbLn2Ut0A==
X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ReArlZ5p;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 34BA9606A337;
	Thu,  3 Dec 2026 11:59:25 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ReArlZ5p
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796299159;
	b=eWCltBJ7x0ETkrciWoe1nC1hixPpAqtANpE5hifkEWb7sajmd7A/Rh9Gh1MC1rCE+sYJ
	 tlxT9+9kuu/8dYDXMWe79RLikADA6b1CqhTQ3fjrtZtUifFu4390ObUxxkVsAI5ymmWtM
	 QZjC8EXDrX2QeVyzdbYfyt/lMb8i1f9BZDio6hIDeMQq0uuVmAHatREK8V8rs2KT2Qlqy
	 KRdNuhlGSll6H6Yuy6BA2y4uM+dnf6li7UD3mgCSiF4lQqz7tH+KVjmJfDSbvl75YThL1
	 H5WYrIK0idVN/GPhRmZ7aWlziId4SGBoOprPyr1uSdbqWWx3Ml8I/4saqGBrMHVLc/w==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796299159;
	h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version:
	 Content-Type:Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer:
	 X-Developer-Signature:X-Developer-Key:X-Endpoint-Received:
	 X-Original-From:Reply-To:Content-Transfer-Encoding;
	bh=bqJscT1GgmwlYPsNBFyi54DdPX3vCZe4sZYhIvFe668=;
	b=4AWQvT8Mrb2LPPR2U6ohxigGk1feK9XTBg+kkUdX99leMArCzrnA63dhINuC98Nim7MG
	 p8FDchqHu6FCMq2WiX8+3yaf7mWDFVuJ5xd/vi1CMzxV1F0D8ct5Y75fJBe/ziXzIyfoN
	 WALVp7YYuX4pGE3q7y6eAYpfImbbfHlEmIdtsKUP7pHeR9rE2CNJ4mXP7qrNXgiWKrDtE
	 oqur/K57Pu7aYa4mfnA1v+Ak5JyozLLOU5oUrlr8aeb7Aq4bs9AxsBIrEwv3foCjw2aN/
	 R8c18SXY/jAeCtvS57eEyJ0xANzUnvBEuvU2fQcbn6A3LdmR+7DctyO1RAxZb5Y3Ecw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ReArlZ5p;
	arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E0A1606A322;
	Thu,  3 Dec 2026 11:59:19 +0000 (UTC)
X-Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77
X-ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none;
	t=1796299158;
	b=Oj7QMg9rIzvYgRu31OpDjG2OMd15j4frbsNI1tY0AMx7Uh+Bftgbzr4iJkH5YACPfeyw
	 ZRaDR0qG2Q+7O3S3mYteqqcFFozRFrbQ5hrC9mJON9HXcmUu89kvnKaiV+ZHKq/8EQvTR
	 GBoQrkxFylo/GZtw0NC3GHRObIGuCshVhe+RVWtF3CQZ0FnmhBEs4yaqWIj7ujbWQ5/0R
	 FWPV6MesWgmvylDv7xMVdB7tUWuyn7Ex8KBqlCNcc5MP2TQN04sKx6ihiuBfexCuAX3Up
	 x5+sw8PJTSSV0WTXjNGtU0V/G7KyqM1qUNSIdmRzNhTWi2Do6diNULO+mzdvsHsxd1A==
X-ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256;
	c=relaxed/relaxed; t=1796299158;
	h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type:
	 Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer:
	 X-Developer-Signature:X-Developer-Key:X-Endpoint-Received:
	 X-Original-From:Reply-To:Content-Transfer-Encoding;
	bh=bqJscT1GgmwlYPsNBFyi54DdPX3vCZe4sZYhIvFe668=;
	b=X3rELheudTSIVZybqobiGz3AEJWwRkCAknvBJ89HozBPA3kUsfFQlbBV81Vp8UVla3p7
	 Cb+kiUTVGNHbiIpQinNI7UVGYmHZAlroNVCBALt2uH75zbmQqRPitYNJ5m+Yt066xpBht
	 4eZxwCQBYSq+Hg1v2NWdsFLnZbMjf/MGD5fq3JspawvbjG/4bBavl3tzDyMY2OJgTQnNO
	 kCn/RMJUJnVGWz4RW7pLOzzczRZbP+X8B5t/JRtmgvmssg6vW7XLr7ot8QKdVrOdEMuvg
	 vhuIq73fxNoQCURINoSjPnL3DcM7owuWNrbkuybsfjrzEmTGmCCVN2m3UHZOmHAVhTw==
X-ARC-Authentication-Results: i=1; smtp.kernel.org; 
	arc=none smtp.remote-ip=100.80.115.77
X-Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.kernel.org (Postfix) with ESMTPS id 9A6EF1F00893;
	Thu,  3 Dec 2026 11:59:17 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796299158;
	bh=bqJscT1GgmwlYPsNBFyi54DdPX3vCZe4sZYhIvFe668=;
	h=From:Date:Subject:To:Cc:Reply-To;
	b=ReArlZ5pSLKuA9uWZPs7sP11Iqae092fW5FlSTiSzjXVRRA9NJLkOBUz8l4RTxKIi
	 f1jeXp9a2WoykvMmQtYjlydTyLHKmni7ox5kc513Z9yU2cPS33dyO1paKqOOtNlC5a
	 /SWCoNdvqdvQbh9jMqFehjJd99L430FrkccHLLHG/IgnsgRmKNeaEaaGTD0ZY3jIKb
	 PiHbj/CABRyXYivvd6FATMDWFnS3tKb98FLY3Vt2Gm04io937tp6ssxmKqHAHNqVE1
	 SR+WunRPprjQgYtOOPZoI4hbjeI0WjSbwlkNK4rJwGxfb/NLPR37Xdniqw0GmC+PN+
	 FRdIrpvTNw7oQ==
X-Received: from nexus.subspace.kernel.org (localhost [IPv6:::1])
	by lkml.kernel.org (Postfix) with ESMTP id 2A7054F935;
	Thu,  3 Dec 2026 11:59:17 +0000 (UTC)
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-B4-Tracking: v=1; b=H4sIAAAAAAAC/yWMywqDMBBFf0Vm3QETMZr+SnFhdaJT6lTykIL47
 6Z1d8+Fc3YI5JkC3IsdPG0c+CMZ1K2AYe5lIuQxM+hSG6XLCnnFmETonddmcGHBJSYcHTZ1a03
 vrLJNBdlfPTn+/tsPEIrQXWdIzxcN8VeF4zgB/8SR/4IAAAA=
X-Change-ID: 20261203-ip-tunnel-ipv6-min-mtu-df-75896af91973
X-Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, 
 James Sawyer <james@jamessawyer.co.uk>
X-Mailer: b4 0.16.0
X-Developer-Signature: v=1; a=ed25519-sha256; t=1796299156; l=4820;
 i=james@jamessawyer.co.uk; s=20261203; h=from:subject:message-id;
 bh=zdMPKPFA24HxJG4e+ggA4TVzJIkn0/n5S8FWsr+mEbg=;
 b=JPOzDVwtTmZI1w/EbT9G7ajxtz+o0lsG4Uljlkk8YAKR7JwM2zsk0JW1q5nZAcsLUV0mNW0X5
 blNnmBJoqbHDmaPU23yUX6wdnKeb1k0FgffBHtlRTl+9JpftlyNBVGe
X-Developer-Key: i=james@jamessawyer.co.uk; a=ed25519;
 pk=97d0xHacZOmlJXs5Pj8Vv8mVWW2CBNhqBLMVT3VQjis=
X-Endpoint-Received: by B4 Relay for james@jamessawyer.co.uk/20261203 with
 auth_id=1733
X-Original-From: James Sawyer <james@jamessawyer.co.uk>
X-Reply-To: james@jamessawyer.co.uk