🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #4449

[PATCH net-next 13/15] netfilter: flowtable: populate tunnel tuple regardless of inner protocol

#4449
From: Pablo Neira Ayuso
Date: Sun, 18 Oct 2026 00:56
60 lines
7857 bytes
From: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>

Store the outer tunnel addresses and inner protocol in the flow tuple
unconditionally in nf_flow_tuple_encap(), instead of only when the
tunnel is IP-in-IP or IPv6-in-IPv6. Bail out early when the inner
protocol is neither IPPROTO_IPIP nor IPPROTO_IPV6.
This makes the tuple usable for cross-family tunnels such as
IPv4-over-IPv6 and SIT, where the inner protocol differs from the
outer address family.
This is a preliminary patch to support IPv4 over IPv6 and SIT tunnel
flowtable offload.
Please note IPv4 over IPv6 and SIT tunnel flowtable offloading is not
enabled yet.

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/nf_flow_table_ip.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/net/netfilter/nf_flow_table_ip.c b/net/netfilter/nf_flow_table_ip.c
index 29d1a9f4a362..8379b45b2dad 100644
--- a/net/netfilter/nf_flow_table_ip.c
+++ b/net/netfilter/nf_flow_table_ip.c
@@ -189,22 +189,22 @@ static void nf_flow_tuple_encap(struct nf_flowtable_ctx *ctx,
 		break;
 	}
 
+	if (ctx->tun.inner_proto != IPPROTO_IPIP &&
+	    ctx->tun.inner_proto != IPPROTO_IPV6)
+		return;
+
 	switch (ctx->ether_type) {
 	case htons(ETH_P_IP):
 		iph = (struct iphdr *)(skb_network_header(skb) + offset);
-		if (ctx->tun.inner_proto == IPPROTO_IPIP) {
-			tuple->tun.dst_v4.s_addr = iph->daddr;
-			tuple->tun.src_v4.s_addr = iph->saddr;
-			tuple->tun.inner_proto = IPPROTO_IPIP;
-		}
+		tuple->tun.dst_v4.s_addr = iph->daddr;
+		tuple->tun.src_v4.s_addr = iph->saddr;
+		tuple->tun.inner_proto = ctx->tun.inner_proto;
 		break;
 	case htons(ETH_P_IPV6):
 		ip6h = (struct ipv6hdr *)(skb_network_header(skb) + offset);
-		if (ctx->tun.inner_proto == IPPROTO_IPV6) {
-			tuple->tun.dst_v6 = ip6h->daddr;
-			tuple->tun.src_v6 = ip6h->saddr;
-			tuple->tun.inner_proto = IPPROTO_IPV6;
-		}
+		tuple->tun.dst_v6 = ip6h->daddr;
+		tuple->tun.src_v6 = ip6h->saddr;
+		tuple->tun.inner_proto = ctx->tun.inner_proto;
 		break;
 	default:
 		break;
-- 
2.47.3
Technical Details
Message-ID: <20261018005638.1776148-14-pablo@netfilter.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-347894-linux-kernel-netdev=dewy.ru
References: <20261018005638.1776148-1-pablo@netfilter.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-347894-linux-kernel-netdev=dewy.ru
From: pablo@netfilter.org (Pablo Neira Ayuso)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next 13/15] netfilter: flowtable: populate tunnel tuple regardless of inner protocol
Date: Sun, 18 Oct 2026 02:56:36 +0200
Organization: Usenet Network
Message-ID: <20261018005638.1776148-14-pablo@netfilter.org>
References: <20261018005638.1776148-1-pablo@netfilter.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3187768"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:6J9khhDAA0vvFbz4uPUh7bfDm/s= sha256:TZtIFraSQ7VoRhNyvWI5iZ9yi2WwTjgHuYhPB3rMsf8=
	sha1:ADEz9t4Z5gdk2t6peedY3uwMzWk= sha256:5xddaX/WKnpC5DWv3VB3sVYPpkhKhpeqKL4nu7CEfFw=
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 0D44511078A; Sun, 18 Oct 2026 04:01:32 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 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.25,
	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=netfilter.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 MVkRHrfskU0D;
	Sun, 18 Oct 2026 04:01:29 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-347894-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=netfilter.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 86A77110787; Sun, 18 Oct 2026 04:01:21 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by sea.lore.kernel.org (Postfix) with ESMTP id 28AD74221D; Sun, 18 Oct 2026 00:57:09 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id CEBD430E853;
	Sun, 18 Oct 2026 00:57:08 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=netfilter.org header.i=@netfilter.org header.b="VtA+b4m7"
X-Received: from mail.netfilter.org (mail.netfilter.org [217.70.190.124])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3582D31717D;
	Sun, 18 Oct 2026 00:57:06 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.190.124
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1792285028; cv=none; b=tRctSHkSxUj/vc6JhrNDZRFz2XLjWwQx0AFnNHIECmC5g97eENv5Ta2zgQutwHikO2/0W8dJr8h5kLDqmlQ9ec9bdq+Leta0TWXA2npByMJcSbUgP4oj/FswTDRkyYvef08UrnT2nHRsHB+/aLtvqN1leMMiM+bO6m5K6nLvZeY=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1792285028; c=relaxed/simple;
	bh=c0X8scIxgBiBoFLKEotCXBzvHlZu7hchb1pOsCERDi0=;
	h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:
	 MIME-Version; b=SWdsNRH28TbBSODGHO4PhLAbgMuzRC+ABX1CMqdTUv66EEaR4IcMuPe0e5LFcn7knI2uNiGmHXUTJtyt/4qVsrx7anBy/5FIruHXszYQL1kNJaiLc2fzb7EXX4VfS6XTLwNHvaQ7xOcsOH/ieavS0AixoLpNOw5L+rACGQkheuE=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org; spf=pass smtp.mailfrom=netfilter.org; dkim=pass (2048-bit key) header.d=netfilter.org header.i=@netfilter.org header.b=VtA+b4m7; arc=none smtp.client-ip=217.70.190.124
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=netfilter.org
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netfilter.org;
	s=2025; t=1792285024;
	bh=VRlGnmSw0Qyg1o8Sdz1Eo8q6cxmKA/BI113bnJmhlYE=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
	b=VtA+b4m7dy5JG7amnK3zi2tiKLTWMfEU2eiUYII+bZlK5R866EG0+m360Q5Q+2J5q
	 beTiaFwYV3zOmM16/D0xxgmXNN1z2ILhtHLWB9+txyl/ObjhYbuk93beVye4g2yiTM
	 qUTx06863bXtOA+vOAfhbnY4pzSCDCdGtxP+ika9Zuqx9Xnby2TAUWxa8j9HQmtrE0
	 V8lri8Nk87kEyXtv0orIt7JRsyfBRN2SyV94xxKe7paTF1kt61UAKk9px+LFGS/YnA
	 8N1I+76hPHInhRPTTHL5Rnqntlj2h+Haxwy0jjLeNCFjwjgPCwzculKKqq1brY+vbS
	 DrQBpEtpOtt2g==
X-Received: from localhost.localdomain (mail-agni [217.70.190.124])
	by mail.netfilter.org (Postfix) with ESMTPSA id 0983160085;
	Sun, 18 Oct 2026 02:57:03 +0200 (CEST)
X-Cc: davem@davemloft.net,
	netdev@vger.kernel.org,
	kuba@kernel.org,
	pabeni@redhat.com,
	edumazet@kernel.org,
	horms@kernel.org,
	fw@strlen.de,
	ja@ssi.bg
X-Mailer: git-send-email 2.47.3
X-In-Reply-To: <20261018005638.1776148-1-pablo@netfilter.org>
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>