🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #5050

[PATCH net 05/10] netfilter: flowtable: use the vlan id, not the full tci, in the tuple key

#5050
From: Pablo Neira Ayuso
Date: Mon, 19 Oct 2026 15:02
57 lines
10389 bytes
From: Shuangfeng He <huangya90@gmail.com>

nf_flow_tuple_encap() stores the skb vlan tag in the encap tuple id
using skb_vlan_tag_get(), which returns the unmasked TCI including
the 3 PCP priority bits. The flowtable entry, however, is programmed
by nf_dev_path_info() with vlan_dev_vlan_id(), a plain 12-bit VID.

When a NIC delivers RX vlan offload skbs with a non-zero priority
(an RTL9617C EPON ONU was observed handing over vid 818 skbs with
tci 0x6332, PCP 3), the runtime lookup key never matches the
programmed entry, so every packet misses the flow table and
software flow offload is silently defeated.

Mask both parse sites to the 12-bit VID so the lookup key matches
for any priority. The in-header variant has the same problem for
frames received with PCP != 0 on a non-offload path.

The egress side is unaffected: nf_flow_encap_push() restores tags
from the programmed tuple id, which never carried priority bits.

Measured on an RTL9617C ONU (PPPoE over VLAN 818 WAN, NATed 6-flow
download over a 1G EPON line), before -> after:

  download throughput      377 Mbps -> 936 Mbps
  CPU0 %soft at that rate    91.5%  ->  70.9%

Fixes: 4cd91f7c290f ("netfilter: flowtable: add vlan support")
Signed-off-by: Shuangfeng He <huangya90@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/nf_flow_table_ip.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/netfilter/nf_flow_table_ip.c b/net/netfilter/nf_flow_table_ip.c
index c8c29a9a1684..2dec15d402ca 100644
--- a/net/netfilter/nf_flow_table_ip.c
+++ b/net/netfilter/nf_flow_table_ip.c
@@ -170,14 +170,14 @@ static void nf_flow_tuple_encap(struct nf_flowtable_ctx *ctx,
 	int i = 0;
 
 	if (skb_vlan_tag_present(skb)) {
-		tuple->encap[i].id = skb_vlan_tag_get(skb);
+		tuple->encap[i].id = skb_vlan_tag_get_id(skb);
 		tuple->encap[i].proto = skb->vlan_proto;
 		i++;
 	}
 	switch (skb->protocol) {
 	case htons(ETH_P_8021Q):
 		veth = (struct vlan_ethhdr *)skb_mac_header(skb);
-		tuple->encap[i].id = ntohs(veth->h_vlan_TCI);
+		tuple->encap[i].id = ntohs(veth->h_vlan_TCI) & VLAN_VID_MASK;
 		tuple->encap[i].proto = skb->protocol;
 		offset += VLAN_HLEN;
 		break;
-- 
2.47.3
Technical Details
Message-ID: <20261019150249.1879516-6-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-348655-linux-kernel-netdev=dewy.ru
References: <20261019150249.1879516-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-348655-linux-kernel-netdev=dewy.ru
From: pablo@netfilter.org (Pablo Neira Ayuso)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net 05/10] netfilter: flowtable: use the vlan id, not the full tci, in the tuple key
Date: Mon, 19 Oct 2026 17:02:44 +0200
Organization: Usenet Network
Message-ID: <20261019150249.1879516-6-pablo@netfilter.org>
References: <20261019150249.1879516-1-pablo@netfilter.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3674863"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:7wACx4+aI1d/LClvzO02xSxDGQw= sha256:oej5xQLQE3h0d1+Ig8w6CxYR2s7gwsNmwe/PeN3qHks=
	sha1:XoQiJlh/PUE8dDBeEAkc4aFLT3c= sha256:9v2FgiN/Vs8h4O3bWoIu7BiTj/46KhCOVOCpNbNuN7s=
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 9908E110AA5; Mon, 19 Oct 2026 20:58:21 +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.25,
	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=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 hYYKA-ffhX7t;
	Mon, 19 Oct 2026 20:58:18 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-348655-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id D795B110A9B; Mon, 19 Oct 2026 20:58:05 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (aws-us-west-2-korg-listserv-alma10-1.taild15c8.ts.net [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id 4B7A8145D9E; Mon, 19 Oct 2026 15:28:39 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail;
	t=1792423697;
	b=xIMnnU237r+if2bxjxbgPSKB2mfH759UT7+Kesc0jb82vT7NCfS2EOue/Q1hhZCAbRhY
	 a+3Ri1qA4ffADYyAkhFlnnJefkGn4gATuuIdiGcdqIChO4Hm6YzeELSBvuyv1SNVBWl6E
	 nlVgBx4VPVY2O1GDRu6onaxQygF8yt4Zko95jZdEyt177Jq0SGQ3nRHUIl1edAPDS3Vkx
	 SOIg37VvWnMVSXEQaG+jWvltJZSg4bwVbZqhp6v5LUFe9au7SYVOmnvwCvuPipRWPDf+i
	 Z5p6gMYRJTTLbu+w6yi/6IQ3Tj9+NJkxHjrki1Uv2E+R4RcKAF85CaCiPvaCfFk4nXw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792423697;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature: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-Transfer-Encoding;
	bh=CYNpmVXRLHMAAVus7/gfQUc1TWW6VTf4/aSf8Tlez+s=;
	b=s1n36isvXDtZlc1MkJZREH0IeIDyMorLM1iZaE9sl3yCn1H6eF9oIYJKkA+bNzkROoNp
	 0J4nq/TG42ArO/ZCMLEosNAZZkFyZZQ0uHa5xp2E2exVXCK7lagTh8x2dtcxHT9240FaM
	 TFxfSJwcPlLJLanCVRSU1PpGnHu/r5Y0dYY9ErW/Ab9vXpEOzXIcvatOwn9pOpvyNF3Lb
	 iK0QK6FXdEZMUZxp2iO2BLQMeldMPhb17I9FAgJp6ziBpkJTkxb1NqBmCNsreB6RE1WgN
	 khrSPHJn+sAqXaKIKJumThNtDVvlxQHuJtI1NqjaPQSyUibU182mdOfHPfO/zwEmLvQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=Y803IFXS;
	dmarc=none header.from=netfilter.org;
	spf=pass smtp.mailfrom=netfilter.org;
	arc=fail 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 0FFAA606C152;
	Mon, 19 Oct 2026 15:28:17 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=Y803IFXS
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.70.190.124
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1792422189;
	b=3uwyKDqA2eY7IZ+RD8ylzrAMnOPFKzDal+zmlotMVtVa7PapvJ5L6TV8HXlWUg9DVoiO
	 J8JeBLHgccxpnI7d381A1rA8gUEeOueYMyN6NL253qPJ5m6QNOpepRzeL/ECK3sR2zjQ1
	 xE9uzvOupR3HwLqYMkIGewRyC5mA5lJ3Ko3Xn80DSgfxGKAffeY3TRagjum4VsveVSBVv
	 j+gxLzpFYhcB9OdqHJzGhJVFHkA/oRv1Ol88rAqvSTSIN7Mv5PcBW87CP4OlMKnqJQMAf
	 AopjrXYaPEGoTW1UxDQLFScU95IjB4pp4C9IaMLOa/FWM5eaKHvYqywQDnUwRcsuQaQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792422189;
	h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date:
	 Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding:X-Spam-Status:X-Spam-Checker-Version;
	bh=CYNpmVXRLHMAAVus7/gfQUc1TWW6VTf4/aSf8Tlez+s=;
	b=lbARv1J98BU+iKoNBXmtIh5KCiPO6D2gi6YTFW4km6pop2vdmGZP95kABbuy2gMdeDV6
	 5aNUmQa4MkVFRKjTYDl9iszbRxpmA/g/28gyCmqyDHuaTxdn6N3g+iIiaSeJ+TOX+gYC1
	 dvt66LLXJ/pSFZ7xZui2IrkbnH74irt2Z0Yyp/rQk1uhdly5WujntYYqh1nzzPC0dAeqR
	 kEvboHUolvs4uZiay7WAGhzSF466yhI/Er74YNN3Lq1i9SHGI3TxM82j1tyhpjTxzhNUM
	 Dgj6AAYklbUB4sbSE0Kx0Pvcljz2Nv/mAUSSJgvumFeNfDwnyB0002qCpJpV6An+rUA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=none header.from=netfilter.org;
	spf=pass smtp.mailfrom=netfilter.org;
	dkim=pass header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=Y803IFXS;
	arc=none smtp.remote-ip=217.70.190.124
X-Received: from mail.netfilter.org (mail.netfilter.org [217.70.190.124])
	(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 5568B607D354;
	Mon, 19 Oct 2026 15:03:08 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5568B607D354
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=1792422185;
	bh=CYNpmVXRLHMAAVus7/gfQUc1TWW6VTf4/aSf8Tlez+s=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
	b=Y803IFXSYCm8RB3z09rcHdIHVTMeVP3SMwuGKtPSBGfBzloQfV45ZvyKESBo9zYwO
	 kmZSjJBww3RCyhObeCJn3TgvCZC2JyBPIduosSZvPPa2kAiCHm+nJlVj6+N/XOg5xi
	 xqKgmqkdFoZGMzjN++3w6PfOLxXe7fYHEwvG2sfwzKDSB/zGZ7Z25HnVuni6vn9kZ8
	 TzdyraFDfQF/KtjZCbwGPFzAFZdTf9dNoLqFEkIauoI55bDn1DAXCTiJJB2LaupJWO
	 IBh0rkqAUKGG4e8UwVYzUp28rPGCKH3Od5ZjxBvig1Xu/MtZ0fUBwTx2dtdD6V6FPT
	 HVZ8HI/neLeMQ==
X-Received: from localhost.localdomain (mail-agni [217.70.190.124])
	by mail.netfilter.org (Postfix) with ESMTPSA id 80FF760074;
	Mon, 19 Oct 2026 17:03:04 +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: <20261019150249.1879516-1-pablo@netfilter.org>
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