🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #20541

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

#20541
From: Alexandre Cassen
Date: Sun, 22 Nov 2026 21:31
84 lines
12184 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. On cxgb4 a mask without a VNI bit would also drop the tunnel match,
and the cxgb4 patch refuses it.

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: <20261122213200.3207385-7-acassen@corp.free.fr>
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-368838-linux-kernel-netdev=dewy.ru
References: <20261122213200.3207385-1-acassen@corp.free.fr>

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-368838-linux-kernel-netdev=dewy.ru
From: acassen@corp.free.fr (Alexandre Cassen)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v3 06/11] net/sched: cls_flower: add enc_key_id mask
Date: Sun, 22 Nov 2026 22:31:54 +0100
Organization: Usenet Network
Message-ID: <20261122213200.3207385-7-acassen@corp.free.fr>
References: <20261122213200.3207385-1-acassen@corp.free.fr>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3728474"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:i6SOSTU8g3SZqAKcGv/vOkLbc/s= sha256:b1/drAD6B9D+Abo3EHycGQmoQ2LwQ7qAhZuGvTU/L6g=
	sha1:8hCEHfr+rr9NicuqZ8M70Jwl104= sha256:FjuOim46/1eAObKSaI8niSnJL/N1Z17zrXv9eN1EEAc=
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 1F86B125D87; Mon, 23 Nov 2026 00:32:46 +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=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 M5wa_1Cz-7bC;
	Mon, 23 Nov 2026 00:32:43 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-368838-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 1DE83125D88; Mon, 23 Nov 2026 00:32:34 +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 6252C2E2DD; Sun, 22 Nov 2026 21:32:20 +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=1795383134;
	b=mwuKN7uQt9L2/A7VTijEhAbbJN2jScAQ85tnq48I/d5pKbF5Z8JqxuIQhWmF8eeaLpn9
	 qnII5JNoewTOKURgvdMjyU8W95hlKS3uWsY9NDW6+vg/4NBPxdlVS1YhF0Un8+imirw1V
	 Pdb5892gVgWqp68oYkCZx9q2FWCNHF57ajyCaqdlvzlwsC1DabnePsW64FF1i0BXFMisM
	 fyi40v2HzU42Yd7Vi/9Wwo4vA/7GINVUUOOB8gKj8kKD0dNMPkIPvHc8F0Zx+D7/gyMXB
	 iLMDJ13RGeMEX354m6Gsyiw7jGjavFEWjcLaiKYcGPcOLxIgD9RE6YrHCDNNeSCccVg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795383134;
	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=lVrc4oHsxDCDJa3Hp3qUem7EegpD7+yTpsfWRSyZgHs=;
	b=F6kCwrD7qHvvnZY3UzRfXScvpv8kIGMR+ggswWnBANSy/uVR9hqjsldY/Zi+ydKvLWBk
	 OE2PB87pUhPAxiExBySSFx07bUdWnbY3qdGOiBNFqcoRyLpMYQu7AZ5o5il+gD09XyPsa
	 vpZ7gCD4h1hEWPBPcP/Yhe2rsTfts5JqGVCG7ML0+9sbdLEMsjpPTzTv6g27XJm5gRwpP
	 SArMGf/q+FVfoEsnqt009UvY2CxNRMhF0f2u4U7SirEjl1s+R7NZYIA3OfnZkCcORPZjl
	 UFCh6XMvwSWCVf65/zMdTeJ17sPWWO/bnmC+e4LDvP8hgK2kCkBQN4e5AFNBSQi+GUQ==
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=QCSOslgu;
	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 E6F7360A2616;
	Sun, 22 Nov 2026 21:32:13 +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=QCSOslgu
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=1795383133;
	b=FsCteJj5CD1u+Blqz5pN14vuqVQ7JxRCyyfc1W6d8hq3NYxCs6UqSGbpQ/ODQzRr9E2+
	 QRuJ1WmvQ/R++SR4AE4bKYVao4sseISX+5iXinrmrzUQ+nQOjA6LxB/YgQZhOPpEjGSbZ
	 7R3L5V3CxDeig7lbRVQcWuzz9O9BJYph8A+D0q2tl9dzEjCzn8LedHPH929Z7x9oGxeY2
	 gNQJzHqoNncq3SPdYa4n+ZGAvWz9daofGIa/QF/7CWELZTts8QLMihZv/fc2qt0Fiuuhz
	 JSI0jjxWJoEBNV/l/bEMQ3KyJynXRoQaEFSQjgSDE/XM+FXoz/jghT36rgDrK7VELdQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795383133;
	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=lVrc4oHsxDCDJa3Hp3qUem7EegpD7+yTpsfWRSyZgHs=;
	b=iCZu4743r/9WXrZvFkAhfx4Z87e9e3gsG38bHN6+lISQ0jp9dYlmis8SSN0QJdNnjIG6
	 N/gkmIrzi8VbA91G6Rz6zQTsiyq3dibzgygfntc1kU92KH6x0WcPXItAG8bAhNFILHfWF
	 Aqkd62WNS0J2cfSzSwStnuautl7V7v88Mwg7XgJq8SDTKvMq/uS44VYy2y2cLUja15eU5
	 9te8E6aR86UwVQe+D4LCXQjhcYDt7D55pCo6dx6pZLYgc6YKuSXoiGoJ/DBOTAb134smm
	 CZabr0lkLpmPHgG5Qepu/wEKZKkT4iyY96mHVBagkUdcM+AlVp833pIwW59kxIP/kxA==
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=QCSOslgu;
	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 41C7B606A6B2;
	Sun, 22 Nov 2026 21:32:11 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 41C7B606A6B2
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=1795383130; bh=K4Llhg1hmaw8g5dzoUBJThs+VMah2kSFZeuFKLz69pI=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
	b=QCSOslguzicAu4cFP1kFFIskrj4pttEBgU5q+DVVgDRgMEt1CQ7KUW6/Orp0QOmb7
	 ntgEGuLK2E9fdrawUPggb2beoR7JPR3DDIvHeUkSKvUdiXSBjJegVRfx8XOEfQPRYE
	 DOvs7o+Tjt8mARSRJu0OOJUogM6tPrOQIagEjOV82J13Y6tvnNj3mt+2GuYFK8qGJR
	 poyOukZUY0hkn7Jc60eVbupebG7bhl1XHcUc3H4a0Dxn2y6CpZMNi1/3L04H+qdSsX
	 yg9heu7qYq+KlIdmtIE0HM9GxxbFx6ykWGpDvJFXnk7wtpD/+ib9H6o/gGwXKxyW+w
	 nR5gRCKs7ONwg==
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 E758844C0B4E;
	Sun, 22 Nov 2026 22:32:09 +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,
	Asbjørn Sloth Tønnesen <ast@fiberby.net>
X-Mailer: git-send-email 2.43.0
X-In-Reply-To: <20261122213200.3207385-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