🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #13200

[PATCH net-next 06/10] net/sched: cls_flower: add enc_key_id mask

#13200
From: Alexandre Cassen
Date: Mon, 09 Nov 2026 13:10
83 lines
12007 bytes
Flower only matches enc_key_id exactly. A block of tunnel keys takes one
filter per key. Add an optional mask. Without one the match stays exact.

  tc filter add dev <dev> ingress protocol ip flower \
      enc_key_id 0x100/0xf00 action ...

cxgb4, mlx5 and nfp program the mask. sfc does when its firmware supports
it. hns3 and ice reject a partial one. The previous patches make bnxt and
mlx5 tunnel mapping reject it too. i40e and iavf never program the value
of enc_key_id, with or without this patch.

Hardware holding a 24 bit VNI truncates the mask too. This is correct when
the key fits the VNI. The previous patches enforce this on cxgb4, nfp and
mlx5.

Signed-off-by: Alexandre Cassen <acassen@corp.free.fr>
---
 Documentation/netlink/specs/tc.yaml | 4 ++++
 include/uapi/linux/pkt_cls.h        | 2 ++
 net/sched/cls_flower.c              | 5 +++--
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/Documentation/netlink/specs/tc.yaml b/Documentation/netlink/specs/tc.yaml
index b6ccc645b0e3..a20fa42e6715 100644
--- a/Documentation/netlink/specs/tc.yaml
+++ b/Documentation/netlink/specs/tc.yaml
@@ -2908,6 +2908,10 @@ attribute-sets:
         byte-order: big-endian
         enum: flower-key-ctrl-flags
         enum-as-flags: true
+      -
+        name: key-enc-key-id-mask
+        type: u32
+        byte-order: big-endian
   -
     name: flower-key-enc-opts-attrs
     name-prefix: tca-flower-key-enc-opts-
diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h
index 28d94b11d1aa..fcaf06c6892d 100644
--- a/include/uapi/linux/pkt_cls.h
+++ b/include/uapi/linux/pkt_cls.h
@@ -560,6 +560,8 @@ enum {
 	TCA_FLOWER_KEY_ENC_FLAGS,	/* be32 */
 	TCA_FLOWER_KEY_ENC_FLAGS_MASK,	/* be32 */
 
+	TCA_FLOWER_KEY_ENC_KEY_ID_MASK,	/* be32 */
+
 	__TCA_FLOWER_MAX,
 };
 
diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index 23eba4a00a94..dd248a335402 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -661,6 +661,7 @@ static const struct nla_policy fl_policy[TCA_FLOWER_MAX + 1] = {
 	[TCA_FLOWER_KEY_VLAN_PRIO]	= { .type = NLA_U8 },
 	[TCA_FLOWER_KEY_VLAN_ETH_TYPE]	= { .type = NLA_U16 },
 	[TCA_FLOWER_KEY_ENC_KEY_ID]	= { .type = NLA_U32 },
+	[TCA_FLOWER_KEY_ENC_KEY_ID_MASK] = { .type = NLA_U32 },
 	[TCA_FLOWER_KEY_ENC_IPV4_SRC]	= { .type = NLA_U32 },
 	[TCA_FLOWER_KEY_ENC_IPV4_SRC_MASK] = { .type = NLA_U32 },
 	[TCA_FLOWER_KEY_ENC_IPV4_DST]	= { .type = NLA_U32 },
@@ -2110,7 +2111,7 @@ static int fl_set_key(struct net *net, struct nlattr *tca_opts,
 	}
 
 	fl_set_key_val(tb, &key->enc_key_id.keyid, TCA_FLOWER_KEY_ENC_KEY_ID,
-		       &mask->enc_key_id.keyid, TCA_FLOWER_UNSPEC,
+		       &mask->enc_key_id.keyid, TCA_FLOWER_KEY_ENC_KEY_ID_MASK,
 		       sizeof(key->enc_key_id.keyid));
 
 	fl_set_key_val(tb, &key->enc_tp.src, TCA_FLOWER_KEY_ENC_UDP_SRC_PORT,
@@ -3680,7 +3681,7 @@ static int fl_dump_key(struct sk_buff *skb, struct net *net,
 		goto nla_put_failure;
 
 	if (fl_dump_key_val(skb, &key->enc_key_id, TCA_FLOWER_KEY_ENC_KEY_ID,
-			    &mask->enc_key_id, TCA_FLOWER_UNSPEC,
+			    &mask->enc_key_id, TCA_FLOWER_KEY_ENC_KEY_ID_MASK,
 			    sizeof(key->enc_key_id)) ||
 	    fl_dump_key_val(skb, &key->enc_tp.src,
 			    TCA_FLOWER_KEY_ENC_UDP_SRC_PORT,
-- 
2.43.0
Technical Details
Message-ID: <20261109131039.959438-7-acassen@corp.free.fr>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359314-linux-kernel-netdev=dewy.ru
References: <20261109131039.959438-1-acassen@corp.free.fr>

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-359314-linux-kernel-netdev=dewy.ru
From: acassen@corp.free.fr (Alexandre Cassen)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next 06/10] net/sched: cls_flower: add enc_key_id mask
Date: Mon,  9 Nov 2026 14:10:32 +0100
Organization: Usenet Network
Message-ID: <20261109131039.959438-7-acassen@corp.free.fr>
References: <20261109131039.959438-1-acassen@corp.free.fr>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="362764"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:nH972LLcSQy9gN9Cq2I4CkFW2HQ= sha256:paVMy+Evz6P+L8utt8Ejhb0Y6PWmQcHFBjAxJwZsLOE=
	sha1:MeQQOKMIC4vPudt2+YvcIA+Uy+g= sha256:Ghyg9tZtD2+ieUoAUk5WebLmWll25qCB/wRpfwSWIR8=
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 392C21137F2; Mon,  9 Nov 2026 16:15:18 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 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] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=corp.free.fr
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 CeJ3j9i89GYo;
	Mon,  9 Nov 2026 16:15:15 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-359314-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=corp.free.fr
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 0D6301137C3; Mon,  9 Nov 2026 16:15:07 +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 5614010603E; Mon,  9 Nov 2026 13:11:15 +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=1794229851;
	b=ixGB/WSZNoetUvMsHoF78DPIsavVyTfPJQAmVP8EDWJcg2YEk/9pjieRjxtcRr1GmRJP
	 3OUBvXmC6SceqS9FNHgfIjuDMD4qzb0GkS1SSaAAh2Co6pJ82isDiHFI9ElS1/9KOyzhl
	 kc7ctvehxJBHk5xu+Io1DXCqW+NuZX1Wj4xKQuvzdorwJj0LMLvUI71eDfC0iOc1AgGkA
	 UqIUVwVG/98vC5zV/cWKtcryh8omaUM21F7kHvdRxQDzhINLnRwX1QxH00R67C1iv8RvZ
	 mNRM/zULOK1qF7WPkS6Vtrur23VkQ5kDmzNI2O3VdnBqA85HxwjzT19kJn1dEZFn92g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794229851;
	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=iqFiRT83QmZISlmWEdJqLfZrAjHt8KFvUpnVMhb9+C0=;
	b=U4gp5pUx1XpOZwdvICzzkiuwgrMSdNY5yKh6IJZsenXJ09760EOZwNd1CJpoaZkOw6pc
	 OZw3r2mppTqZvOaQbPRU9GE76X94KlRSqdAt0HqNG4GlLDrX8T7MLceEcIn3B7qnpnbc2
	 cMT69ZVetjYW/MMio+sscOCEudA6TTVqmbkHDWcvyinb4OnDYTmzw2d1xj3S5z2r+V+/R
	 VfKv0vWfpAk3F5gJrqL0Du6j0QLieStKoMu5uVYk26EUIK9+3jiX38vMg4kDwTCi6HwL2
	 dIVrLuUllW3aQa5ki2hCajX7zayRqhQ2iCz+ZFAcL3jMqX0imte1GQMFRpaUCtZBvhw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=corp.free.fr header.i=@corp.free.fr header.a=rsa-sha256 header.s=rcs header.b=CRHJZNOU;
	dmarc=pass header.from=corp.free.fr;
	spf=pass smtp.mailfrom=corp.free.fr;
	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 93005606EEAE;
	Mon,  9 Nov 2026 13:10:51 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=corp.free.fr header.i=@corp.free.fr header.a=rsa-sha256 header.s=rcs header.b=CRHJZNOU
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=212.27.60.169
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794229850;
	b=vGodC8FzNu3oGB5n3XtQm2LKvEC0vUcifLxhERVV1/kLJgf4ZEc3HQEBvD9kpv1yAq6Y
	 43QX0pnk9lYvlGRLhiozcVfavLwOR4wG+uJWaBC7KJJGucG/Ao/gjtmRZBElnwKjT1y12
	 J0Sk5Ux5VSQ/vhAD/CxwnP1O8TS8SJq9B36wSlHkt+f1R5Rh8QVDczLuRLWVlwhXVXiSe
	 TFvaKTzDTzBVewq/D4IMIZembmlRl9RXmVUw/fhi5ea3EPVRt7zE7IZmA9WpTaexEUScr
	 L2JH8y+Q/T9liVI7s11/tVk03ECIo76wg9ZNniE5ZRo/pTu1ygInlkL4HlrUpruKihQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794229850;
	h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date:
	 Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding;
	bh=iqFiRT83QmZISlmWEdJqLfZrAjHt8KFvUpnVMhb9+C0=;
	b=P9OEH1tlMVQZeIBIos3NafZnXNcknTBuxm7/gB78CrRcTJO9D+aV8jlbCqydxYiPpIVl
	 M7UEaPkJWpKnAv94QNWCRuk5Q0fND/9l5g3RAzybNaO2CGl8qZKXg2X8MpvX7TUczDBmb
	 BcsXswPF1Ec/jutXn1GlPhKRMFa8IdkkKT7ntCNAk8ga/lskP5DKEWM4jzGwOleYh/Ie4
	 FXp5kxEoKqr61q69SfSZ0KwcQ3/C6qR6xevriC7V77dzGoUQO1+7BRvhWFlkY7pR+fRJy
	 LlwGDRpRPhCkb5I1wmEn/EW5LFPN44Zqxx0oIClgRSDkq+wtkEfkjJDrFcydzWu2joA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=corp.free.fr;
	spf=pass smtp.mailfrom=corp.free.fr;
	dkim=pass header.d=corp.free.fr header.i=@corp.free.fr header.a=rsa-sha256 header.s=rcs header.b=CRHJZNOU;
	arc=none smtp.remote-ip=212.27.60.169
X-Received: from rcs.proxad.net (rcs.proxad.net [212.27.60.169])
	(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 E48B5606D834;
	Mon,  9 Nov 2026 13:10:49 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E48B5606D834
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=corp.free.fr
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=corp.free.fr
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=corp.free.fr; s=rcs;
	t=1794229848; bh=Db4ooscFNMd6Sx00ziJUqW+Qe9cjVpd/j8N9fbAoU2M=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
	b=CRHJZNOUx9+/5iq4KxxROQ54SW1CSJYfkyWdhl2vGKHU0tQgP7YqWBosh7IMvT2DR
	 79nv+3fQlUXrrF/odf9+9NZ+Pp5XidBdzyMkXQv+CRMTCif/5YC4Ioe8VrOFWGPHO/
	 C2122KFfE49rpQ1dwDab2PmadWNJ9HqTFO7LSXq8yJMX+0Wjm57DGzTH9MQspTKhlS
	 l64RdAzbUbGKvwfeeQSMBqyQ+YBFgmjT8gVSKDYxH5f5/ZeKBO98LIebFO1OUOOrxO
	 POqYYB/Gk/4LjIn8+GIEJ95wgAxvNwNuK71Sue5OieRYHAXX4etwD1cvfsPzORk8S3
	 T0yr4SqhbgNyg==
X-Received: from lnxos-dev.home (82-66-150-212.subs.proxad.net [82.66.150.212])
	by rcs.proxad.net (Postfix) with ESMTPSA id 3680244C11CC;
	Mon,  9 Nov 2026 14:10:48 +0100 (CET)
X-Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	Michael Chan <michael.chan@broadcom.com>,
	Pavan Chebbi <pavan.chebbi@broadcom.com>,
	Potnuri Bharat Teja <bharat@chelsio.com>,
	Donald Hunter <donald.hunter@gmail.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Shuah Khan <skhan@linuxfoundation.org>,
	Randy Dunlap <rdunlap@infradead.org>,
	David Ahern <dsahern@kernel.org>,
	Ido Schimmel <idosch@nvidia.com>,
	Shuah Khan <shuah@kernel.org>,
	netdev@vger.kernel.org,
	linux-rdma@vger.kernel.org,
	linux-doc@vger.kernel.org,
	linux-kselftest@vger.kernel.org,
	oss-drivers@corigine.com
X-Mailer: git-send-email 2.43.0
X-In-Reply-To: <20261109131039.959438-1-acassen@corp.free.fr>
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