Article View: linux.kernel.netdev
Article #25248[PATCH 07/22] xfrm: check inner family via skb_dst for small_ipv6 DF clearing
From: Steffen Klassert
Date: Tue, 01 Dec 2026 12:41
Date: Tue, 01 Dec 2026 12:41
69 lines
12399 bytes
12399 bytes
From: Sewook Seo <sewookseo@google.com>
Commit 6821ad877034 ("xfrm: do not set IPv4 DF flag when encapsulating
IPv6 frames <= 1280 bytes.") intended to clear the outer IPv4 DF bit in
xfrm4_tunnel_encap_add() when encapsulating inner IPv6 frames of at most
IPV6_MIN_MTU (1280) bytes, by checking skb->protocol == htons(ETH_P_IPV6).
However, its caller xfrm4_prepare_output() overwrites skb->protocol with
htons(ETH_P_IP) before invoking xfrm4_tunnel_encap_add(), since
commit 0c620e97b349 ("xfrm: remove output indirection from xfrm_mode").
As a result, small_ipv6 always evaluates to false, leaving IP_DF set on
outer IPv4 tunnel packets even when encapsulating <= 1280-byte IPv6
frames.
This issue was observed on devices in production use over IPv6-in-IPv4
ESP-in-UDP tunnels where an intermediate IPv4 link has an MTU smaller
than the encapsulated packet size (e.g. < 1362 bytes) and ICMPv4
Fragmentation Needed errors are either filtered or not actionable below
IPV6_MIN_MTU, causing encapsulated <= 1280-byte IPv6 packets to be
dropped instead of fragmented by the outer IPv4 router.
At the time xfrm4_tunnel_encap_add() runs, skb_dst(skb) has not been
popped yet and still represents the inner packet destination entry, as
already used a few lines below to set top_iph->protocol via
xfrm_af2proto(skb_dst(skb)->ops->family), while skb->len still holds the
unencapsulated inner packet length. Check dst->ops->family == AF_INET6
instead of skb->protocol so small_ipv6 works as intended.
Tested on User-Mode Linux (ARCH=um) with a four-namespace IPv6-over-IPv4
XFRM ESP tunnel reproducer across a 1300-byte MTU router link with ICMPv4
Fragmentation Needed filtered (verifying 1280-byte inner IPv6 frames fail
before the fix and pass via outer IPv4 fragmentation with the fix, while
larger frames still preserve outer IP_DF), and verified all tests pass in
tools/testing/selftests/net/xfrm_state.sh.
Fixes: 6821ad877034 ("xfrm: do not set IPv4 DF flag when encapsulating IPv6 frames <= 1280 bytes.")
Cc: stable@vger.kernel.org
Cc: Maciej Żenczykowski <maze@google.com>
Cc: Lorenzo Colitti <lorenzo@google.com>
Assisted-by: LLM
Signed-off-by: Sewook Seo <sewookseo@google.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
net/xfrm/xfrm_output.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c
index f1f612cd7b43..60ffe9549c09 100644
--- a/net/xfrm/xfrm_output.c
+++ b/net/xfrm/xfrm_output.c
@@ -275,11 +275,14 @@ static int xfrm4_beet_encap_add(struct xfrm_state *x, struct sk_buff *skb)
*/
static int xfrm4_tunnel_encap_add(struct xfrm_state *x, struct sk_buff *skb)
{
- bool small_ipv6 = (skb->protocol == htons(ETH_P_IPV6)) && (skb->len <= IPV6_MIN_MTU);
struct dst_entry *dst = skb_dst(skb);
struct iphdr *top_iph;
+ bool small_ipv6;
int flags;
+ small_ipv6 = (dst->ops->family == AF_INET6) &&
+ (skb->len <= IPV6_MIN_MTU);
+
if (!skb->inner_protocol) {
skb_set_inner_network_header(skb, skb_network_offset(skb));
skb_set_inner_transport_header(skb, skb_transport_offset(skb));
--
2.53.0
Technical Details
Message-ID:
<20261201124252.1163254-8-steffen.klassert@secunet.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375032-linux-kernel-netdev=dewy.ruReferences:
<20261201124252.1163254-1-steffen.klassert@secunet.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375032-linux-kernel-netdev=dewy.ru From: steffen.klassert@secunet.com (Steffen Klassert) Newsgroups: linux.kernel.netdev Subject: [PATCH 07/22] xfrm: check inner family via skb_dst for small_ipv6 DF clearing Date: Tue, 1 Dec 2026 13:41:33 +0100 Organization: Usenet Network Message-ID: <20261201124252.1163254-8-steffen.klassert@secunet.com> References: <20261201124252.1163254-1-steffen.klassert@secunet.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1711677"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:3hWSaLlea1cwSAPfdFuhlNF94Zw= sha256:FJAbhpntt438X97v+yk8ThIqNcO4DTR8K1emfGK/068= sha1:2i5GtTJlM3WtQn73S16sJ48VvPk= sha256:Uu+9EDBM5WoNz0TS5pOded7hwJDJ03LfzFgrki6WIrg= 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 BE92F11738A; Tue, 1 Dec 2026 15:44:29 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.05 X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=secunet.com 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 6aZaVe2_dFNV; Tue, 1 Dec 2026 15:44:27 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-375032-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=secunet.com X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id C82EB117389; Tue, 1 Dec 2026 15:44:18 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 1DFAE28A6B; Tue, 1 Dec 2026 12:44:13 +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=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796129047; b=2yuqCW4ypxXyR+oQf0aOevSAK+6MdrPHatvPygrowSj6nApbK226kgDF7ENQLZ0dYEh/ 2GSeRfDz1/ST2oBe0M8v6mAe3Akf/IBRW/ml4zmepC5YIpC96yKNqxW7Q4N+6RUAIZGX/ tz7CZIAH+VQ39S24XtHXk7CEbL30fi0AGJRt0vWxmpXxcwjAg/v42PyVoTbsqPK8ZOM8a FxYj8sjfmCzP0ejUq/sLCOUDSY7R61t16hrj3IcKhIWbjLfz1oeB3D5NLqfCMREjUaizp junIV1mwxd+JIubgPd4ONDvApz0zT4sc72+6ybMFp9J87pEOE0PC3vCL6ljkcwKYaBQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796129047; h=X-Original-To:Received:DMARC-Filter:Received:X-Virus-Scanned: Received:Received:DKIM-Filter:DKIM-Signature:Received:Received:From: To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type: Content-Transfer-Encoding:X-ClientProxiedBy; bh=zDnRYp2WImpSUpiDiv5BUO+k624i/UwRxL/8/PfJElw=; b=g/gPEpELZrsO08xmOKVJf1uqgx0kC4+8PdVxKqWvkOV29AHRWnrYxiB7LFV6JdhE5zbC FymGpyc2ACfDKBe/MFDgooKD0tBuQQCpADexZMsKjMoEeWdCl9/cGzklRZnL2WbFFb/+x WGDZlzK5d3VUwqYeHHL0+fGEBHSsh+Pwjrx2ji/Wrz9NSLqf2ej/tCYPI3H5Bjq3PC1og Bx1X5GB9YxgJa5WvSWziQKZ5bUs1GtqcJ4SMkYsMKZnPVgmCggCzd5uXPICh+LFcA7GMs 0usxhMMhJJZZ0u03aFMX6YgZLDgxwA4SE7kg9zSf07yaj3XjyHIkpDtbjJXk5WSDNqA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=secunet.com header.i=@secunet.com header.a=rsa-sha256 header.s=202301 header.b=d0NRcf3p; dmarc=pass header.from=secunet.com; spf=pass smtp.mailfrom=secunet.com; 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 D3B1F606A33E; Tue, 1 Dec 2026 12:44:07 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=secunet.com header.i=@secunet.com header.a=rsa-sha256 header.s=202301 header.b=d0NRcf3p X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=62.96.220.36 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796129042; b=ZKqlRajas13XK8kOBwmgSoLmt6sDCldjbYkxSj/zKBO7MJPETAZEwzzLtS0slBIWO7If 3vZudFItoYvO0HIAIYjNQVxcBnEHzOCP1DjZdsXeSo9Wv7mD0UGyCh6V/vp1kuTskcABg hc0t36YwWOKkZePDyM+6yci07KiVSo/WPmYLfEoXzMYrBkr0PNHr38ELtdnpTIKS5mhgh LQeclq8xauVzp6MDvmYF+vIFaOQJ0+YO35X7rbwRL344P/Jp9oMlAAGzdAYFykjoxie0z jazlA+r9aEoVsXx5cI/mbHYbbDOzg3k69ko9tCnxKe+R4WYNWFHR2y2E3VuEi4UoRcg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796129042; h=DMARC-Filter:Received:X-Virus-Scanned:Received:Received:DKIM-Filter: DKIM-Signature:Received:Received:From:To:CC:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding:X-ClientProxiedBy; bh=zDnRYp2WImpSUpiDiv5BUO+k624i/UwRxL/8/PfJElw=; b=SnT1G12zq7nhj8ICvyvYyHIwAT9t1KUOf3I2IQp7bdM3bjH1l4LWD5RPz0VRYu+EJEHx 4+H+J91wdmYZYRADpUvtZh0nQiZoOME2qwdqtWIkJgEME/A6afwmItXFpBSLhqvCYWmCy J9zFv6nqHD3k47XOO1+Yh2Zhyj7LWUAfuW+9Edu/94UZjGZOzZOPEj++R8i8A9jMccEYL mtyW5B7VI5qHEAAsur3v672ose+TWbaF7WeZWk9N5X+jS+V4KDu6BK33bUm+D4OxVp7bn y8p1CkshkUuM9ZZMOuBYT0kKli9Jdp87hStpHJLVTL7DMoEXIr24gT6l6U/NiVp2cng== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=secunet.com; spf=pass smtp.mailfrom=secunet.com; dkim=pass header.d=secunet.com header.i=@secunet.com header.a=rsa-sha256 header.s=202301 header.b=d0NRcf3p; arc=none smtp.remote-ip=62.96.220.36 X-Received: from mx1.secunet.com (mx1.secunet.com [62.96.220.36]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B0C17606A320 for <netdev@vger.kernel.org>; Tue, 1 Dec 2026 12:44:00 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B0C17606A320 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=secunet.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=secunet.com X-Received: from localhost (localhost [127.0.0.1]) by mx1.secunet.com (Postfix) with ESMTP id 6799F2069C; Tue, 1 Dec 2026 13:43:59 +0100 (CET) X-Virus-Scanned: by secunet X-Received: from mx1.secunet.com ([127.0.0.1]) by localhost (mx1.secunet.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KtrzmzDc0pXm; Tue, 1 Dec 2026 13:43:58 +0100 (CET) X-Received: from EXCH-01.secunet.de (rl1.secunet.de [10.32.0.231]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.secunet.com (Postfix) with ESMTPS id BB3A9204D9; Tue, 1 Dec 2026 13:43:58 +0100 (CET) X-DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.secunet.com BB3A9204D9 X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secunet.com; s=202301; t=1796129038; bh=zDnRYp2WImpSUpiDiv5BUO+k624i/UwRxL/8/PfJElw=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=d0NRcf3pZSZOxRZBour8zpBZzfdnrLC87haD8WUkIHnS+Hdv8K377B6DMFk0hjqYm SuTcDIqZAmfFesSLninz/Ao0JBU5AKlZ5FjAhPoDw4S2Mrh4K65eTfXvMmauxZk848 B+IwbwSuHRnuxbhOr6To3vR/Ia6b7n2KQo9rxE9k54i9McVUgXHKdJdgP3awKm+Tlw T8JKDaZmir7mOq99MTaCY79pORF86Re86nwF0KKPaKKxC5toT3w4tejMzsWlX9SZ2T eOAf2HPSRWVHjpN1oeFxJ2wIIqR7GUZRCKmo0mI6PcAePuuR1zlIZOTTFaZ8n54tE2 NaZXS3Sb9QN2g== X-Received: from gauss4 (10.182.7.102) by EXCH-01.secunet.de (10.32.0.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Tue, 1 Dec 2026 13:43:58 +0100 X-Received: (nullmailer pid 1165780 invoked by uid 1000); Tue, 01 Dec 2026 12:43:55 -0000 X-CC: Herbert Xu <herbert@gondor.apana.org.au>, Steffen Klassert <steffen.klassert@secunet.com>, <netdev@vger.kernel.org> X-Mailer: git-send-email 2.53.0 X-In-Reply-To: <20261201124252.1163254-1-steffen.klassert@secunet.com> 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-ClientProxiedBy: EXCH-01.secunet.de (10.32.0.171) To EXCH-01.secunet.de (10.32.0.171)