From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=62.96.220.36 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== 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== 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 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 ; Tue, 1 Dec 2026 12:44:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B0C17606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=secunet.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=secunet.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=secunet.com header.i=@secunet.com header.a=rsa-sha256 header.s=202301 header.b=d0NRcf3p 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 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) 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) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.secunet.com BB3A9204D9 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== 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 Received: (nullmailer pid 1165780 invoked by uid 1000); Tue, 01 Dec 2026 12:43:55 -0000 From: Steffen Klassert To: David Miller , Jakub Kicinski CC: Herbert Xu , Steffen Klassert , 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 Message-ID: <20261201124252.1163254-8-steffen.klassert@secunet.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261201124252.1163254-1-steffen.klassert@secunet.com> References: <20261201124252.1163254-1-steffen.klassert@secunet.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: EXCH-01.secunet.de (10.32.0.171) To EXCH-01.secunet.de (10.32.0.171) From: Sewook Seo 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 Cc: Lorenzo Colitti Assisted-by: LLM Signed-off-by: Sewook Seo Signed-off-by: Steffen Klassert --- 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