🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #19588

Re: [PATCH net-next v2 07/10] selftests: forwarding: tc_flower: test the enc_key_id mask

#19588
From: netdev-bot+sashiko
Date: Fri, 20 Nov 2026 03:30
144 lines
13406 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] match_enc_key_id_mask_test() in
  tools/testing/selftests/net/forwarding/tc_flower.sh only checks…
- [Low] In tools/testing/selftests/net/forwarding/tc_flower.sh,
  match_enc_key_id_mask_test() depends on a tc (iproute2) change that…

--

selftests: forwarding: tc_flower: test the enc_key_id mask

This adds match_enc_key_id_mask_test() to tc_flower.sh. It creates two
gretap tunnels with keys 300 and 600 and adds a flower filter matching
enc_key_id 256/0xf00 on an external gretap device. It then checks that
key 300 matches and that key 600 falls through to a second filter. The
test returns early without a result when tcflags is skip_sw or when tc
does not know the enc_key_id mask.

> diff --git a/tools/testing/selftests/net/forwarding/tc_flower.sh b/tools/testing/selftests/net/forwarding/tc_flower.sh
> index b58909a931129..693361c4b8f7e 100755
> --- a/tools/testing/selftests/net/forwarding/tc_flower.sh
> +++ b/tools/testing/selftests/net/forwarding/tc_flower.sh

[ ... ]

> @@ -280,6 +281,59 @@ match_vlan_test()
>  	log_test "VLAN match ($tcflags)"
>  }
>  
> +match_enc_key_id_mask_test()
> +{
> +	RET=0
> +
> +	# A tunnel device has no offload to take a skip_sw filter
> +	if [[ $tcflags == "skip_sw" ]]; then
> +		return 0
> +	fi
> +
> +	if ! tc filter add dev $h2 ingress flower help 2>&1 | \
> +		grep -q MASKED-KEY-ID; then
> +		echo "SKIP: iproute2 too old; tc is missing the enc_key_id mask"
> +		return 0
> +	fi

[Severity: Low]
Which iproute2 change adds the MASKED-KEY-ID token to the flower help
output?

The kernel tree does not contain MASKED-KEY-ID. It also does not contain
the "enc_key_id 256/0xf00" dump format checked further down. Released tc
parses enc_key_id as a plain be32 and rejects 256/0xf00. The commit
message does not name or link the tc patch that these strings come from.

With any tc that lacks this exact token, the test echoes the SKIP line
and returns 0 without a TEST: line. The new TCA_FLOWER_KEY_ENC_KEY_ID_MASK
handling in fl_set_key() and fl_dump_key() is then never exercised.

If the final tc patch uses a different help placeholder, the test would
skip forever. If tc prints the key in another format, the dump check
would fail.

Could the commit reference the tc change it depends on? Then the probe
string and the dump format could be checked against it.

> +
> +	tunnel_create gt1 gretap 192.0.2.1 192.0.2.2 dev $h1 key 300
> +	tunnel_create gt2 gretap 192.0.2.1 192.0.2.2 dev $h1 key 600
> +	ip link set dev gt1 master v$h1
> +	ip link set dev gt2 master v$h1
> +	ip link add gt-ex type gretap external # To collect tunnel info
> +	ip link set dev gt-ex up
> +	ip link set dev gt-ex master v$h2
> +	tc qdisc add dev gt-ex clsact
> +
> +	tc filter add dev gt-ex ingress protocol ip pref 1 handle 101 flower \
> +		$tcflags enc_key_id 256/0xf00 action drop
> +	tc filter add dev gt-ex ingress protocol ip pref 2 handle 102 flower \
> +		$tcflags enc_key_id 600 action drop
> +
> +	tc filter show dev gt-ex ingress pref 1 | grep -q "enc_key_id 256/0xf00"
> +	check_err $? "Did not dump the mask"

[Severity: Medium]
What happens here when a tc that knows the mask runs on a kernel without
TCA_FLOWER_KEY_ENC_KEY_ID_MASK?

tc answers the flower help probe above by itself and never asks the
kernel. So the probe only detects userspace support.

TCA_FLOWER_KEY_ENC_KEY_ID_MASK is added just before __TCA_FLOWER_MAX, so
older kernels have a smaller TCA_FLOWER_MAX. fl_change() parses the
options liberally:

net/sched/cls_flower.c:fl_change() {
    ...
	err = nla_parse_nested_deprecated(tb, TCA_FLOWER_MAX,
					  tca_opts, fl_policy, NULL);
    ...
}

In that mode, __nla_validate_parse() skips attributes above maxtype:

lib/nlattr.c:__nla_validate_parse() {
    ...
		if (type == 0 || type > maxtype) {
			if (validate & NL_VALIDATE_MAXTYPE) {
				...
				return -EINVAL;
			}
			continue;
		}
    ...
}

So an older kernel would install the enc_key_id 256/0xf00 filter as an
exact match on key 256. The "Did not dump the mask" and "Did not match a
key inside the mask" checks would both fail, and tc_flower.sh would exit
with ksft_fail.

Documentation/dev-tools/kselftest.rst says mainline kselftests should
skip gracefully on older stable kernels. The test already reads the dump
back. Could a missing mask in the dump be handled the same way as the tc
probe, instead of being reported as a failure?

> +
> +	$MZ gt1 -c 1 -p 64 -a "$(mac_get gt1)" -b $h2mac -t ip -q
> +
> +	tc_check_packets "dev gt-ex ingress" 101 1
> +	check_err $? "Did not match a key inside the mask"

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117092915.255194-1-acassen%40corp.free.fr
Technical Details
Message-ID: <179514544037.3136.16339086532983375306@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367605-linux-kernel-netdev=dewy.ru
References: <20261117092915.255194-8-acassen@corp.free.fr>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367605-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v2 07/10] selftests: forwarding: tc_flower: test
 the enc_key_id mask
Date: Fri, 20 Nov 2026 03:30:40 +0000
Organization: Usenet Network
Message-ID: <179514544037.3136.16339086532983375306@kernel.org>
References: <20261117092915.255194-8-acassen@corp.free.fr>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3050495"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:AV18oriqYti/NwefqXjnxwd1x74= sha256:Lvx/2DspNu1+a2gR9dsNlJm5pKtKJ9pF/0lJkeRK/io=
	sha1:Uyb/zjVLmPxqbUKuQ1YHbZkpCJI= sha256:ymfOgnz1YQslLbLIv9YE2QOcJnHY3tciXPqGenWZvCs=
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 5B905115865; Fri, 20 Nov 2026 06:31:04 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	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=kernel.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 GO9nfvuXpYTi;
	Fri, 20 Nov 2026 06:31:00 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-367605-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 05D6711588B; Fri, 20 Nov 2026 06:30:49 +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 D507984449; Fri, 20 Nov 2026 03:30:43 +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=1795145443;
	b=zU8MEQs44yqDX0sOcHGktOCIZ+/YcY/llmR+EKZ2pmwrmb0z/VtdZRkyLERqXpgjMtGO
	 VwUDK4fVts11Z5jngRQPbZTYlGhYdeGzn0Tre2VsyS6V7e9OaZ2K3NsKBeE1MxzgkrCCo
	 gEcDD9WdPtKNA1TOJzsHktoqvkwzsckY00+seMmK/6qYzeB0lZJ4rghuVEbgaeG+tR0qO
	 NppMFQI8gk2eGRsjk46333HmTkTK4vdedzdhumffZ+Zbk2TOkK38uMaZR/QC+ZRjH6Jyc
	 h6OQl2WHhMUvIPkXx7bLDJXNgGzCVdaf2QXPFKRxwKgkCaxpcSKnc9WktZlqlJ33Mag==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795145443;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=zCwn2O6yZcQVzA3x/FT5d2tM7t7yzAkteMtRQdaOy44=;
	b=07cC0oBXhOUnPHekm4PXzJjZIKEcgUc1DWIssu5MRyrdLNi1NBvuz+cn8BWTicpLduOH
	 D6fQ9eZGjRzPNLZX3a/aflbVwSBYVGOlw83f/ekFTp17N7NQFhxt1sim0/REnjaiHGc2y
	 MhMeKCZAB7944u/acAPWJ938uYqN0Tm0d72MYFq3wjyJKnfhOGKtQifXzSSUCuvxlpfWe
	 QD7iWGCZRkTp4LT8IE8nxcjmHats1pFtS+fVLO44kNneOfzdwHvR9gwRbCL2vkrw/Nve8
	 ZxbmE+8JQ6jYGcP3onheJd+iDEyQONRzQ8J4dpF1GYPHvSBl1yI1js6IfiffCZ4TOtA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Qx61MwNd;
	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 73617606A33E;
	Fri, 20 Nov 2026 03:30:43 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Qx61MwNd
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795145442;
	b=qTAGQlgMrRDkxSy/sGxjrpSaBbyZ4TBrh6RcOwiKaimA9FFB+M51iei940LYnC9nGBXl
	 Vo7sledNt1ADOfHvPGyRprI7mFCpqhqEpeYMpFVuCp74jpKo37z0Vj70X9kPqhvigBEhZ
	 ZfTlcMFmNEvqBVzjCH5FmfST0CZRc5AnT6NR6c18mBsCFuSTri2CU0IKv+OmsABddrnib
	 ChPMjvvhLP7c9auJEFNMGznW3nbdvRCGysrrnGaOjyFn4hiU96NkNfZnZnlUiSJPS+sGh
	 C/LX63DrM9RAyWaGeZL7L3nVJ18q4Dg99zQ0QWPFr0YHHMCfGX1+aCtw11Vzymx00zA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795145442;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=zCwn2O6yZcQVzA3x/FT5d2tM7t7yzAkteMtRQdaOy44=;
	b=PTRH7/KvZbXtUA59y1Pd61XKnD+A0g+KcJexa0y6U+eY/Z/Vu/Vz43jztWQt6HVzfA9X
	 HlenqV0FVCx58DKyKHRDVKpYtq5WArUYy/zkKOPrLk4p/82tYmAQvQTcWaZ5nvYoHl/ji
	 QdIvd9aB731RqZ2uE2pS24Oz9Am6qjG72nQxrmGUSpqB24CQZvxvasRM3FbRQtrA5nhrq
	 +ZW9SXFPayEsMMVFwNuNY9BEoF7uR791t881MOLtBK92+qT2Jt8CbaWoXqXfLmu22xp7h
	 iSC1osliZuIWIOtqpc5DXylJTfQ9Cc+wVMfjmeNExroZvHwWoDKWZCe60MPCPKeapvw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Qx61MwNd;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(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 94B1A606A339;
	Fri, 20 Nov 2026 03:30:42 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1AEE1F000C4;
	Fri, 20 Nov 2026 03:30:40 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795145442;
	bh=zCwn2O6yZcQVzA3x/FT5d2tM7t7yzAkteMtRQdaOy44=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=Qx61MwNdO7CwMx4EQj7j2/ZCRD5LrX+/2DfAZMhmOpl1ow32DZitnpsEgbI0+uhO9
	 clOS2dfsul/i1/pFjCqzp6Xu6iPQQ0vn+Ga5pB6quydKwnK6BjYt4dViNpnJBYztiP
	 GapdBW1wB1Ul+TXUp5Jf7Oy5xH31WKeuO8nMTeUARTgYsrSTqDLQ1dSO82oSn2n807
	 /bf1pOG1dANXtbbA2B3rNsDBtpHt18qQnoldlMRNbfp44HO/CYZlVoguILPw5atRQt
	 Oq9irn4i6rnk+ofnx/tmqz1t4ZvYP2EXaVTxT/j84m6cf/LjYLXn5tWazNf7D1e2Ht
	 RjrbydpT3G4oQ==
X-Cc: saeedm@nvidia.com, leon@kernel.org, tariqt@nvidia.com, mbloch@nvidia.com,
 jhs@mojatatu.com, jiri@resnulli.us, andrew+netdev@lunn.ch,
 davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
 horms@kernel.org, michael.chan@broadcom.com, pavan.chebbi@broadcom.com,
 bharat@chelsio.com, donald.hunter@gmail.com, corbet@lwn.net,
 skhan@linuxfoundation.org, rdunlap@infradead.org, dsahern@kernel.org,
 idosch@nvidia.com, 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-In-Reply-To: <20261117092915.255194-8-acassen@corp.free.fr>
X-sashiko-severity: Medium
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