🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #23218

Re: [PATCH net-next v2 12/12] selftests: net: add amt_gw_v6.sh for the IPv6 netlink attributes

#23218
From: netdev-bot+sashiko
Date: Thu, 26 Nov 2026 19:17
182 lines
14988 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 2 · 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] In probe_v6_gateway()
  (tools/testing/selftests/net/amt_gw_v6.sh, lines 48-64), the first…
- [Medium] In probe_v6_gateway()
  (tools/testing/selftests/net/amt_gw_v6.sh, lines 66-80), the probe…
- [Low] selftests: net: missing CONFIG_AMT skip handling in
  probe_v6_gateway()

--

selftests: net: add amt_gw_v6.sh for the IPv6 netlink attributes

This adds a netlink-only companion to amt_v6.sh. It checks that the IPv6
local and discovery addresses of AMT gateways and relays read back through
amt_fill_info(), and that each invalid combination is refused with the
expected extack message. A probe at the start skips the test when iproute2
or the kernel lacks IPv6 AMT support.

> diff --git a/tools/testing/selftests/net/amt_gw_v6.sh b/tools/testing/selftests/net/amt_gw_v6.sh
> new file mode 100755
> index 0000000000000..92e48d2f54a5c
> --- /dev/null
> +++ b/tools/testing/selftests/net/amt_gw_v6.sh

[ ... ]

> +probe_v6_gateway()
> +{
> +	local got
> +
> +	if ! add_amt amtprobe mode gateway local "$V6_LOCAL" \
> +	     discovery "$V6_DISC"; then
> +		case "$ADD_ERR" in
> +		*"IPv6 address in an IPv4 attribute"*)
> +			# An older iproute2 on this kernel: the rule that
> +			# refuses the 16-byte IPv4 attribute is what ran.
> +			RET=0
> +			log_test "16-byte IPv4 address attribute is refused"
> +			echo "SKIP: iproute2 lacks IPv6 AMT support"
> +			exit "$ksft_skip"
> +			;;
> +		*"Local attribute is required"*|*"expected rather than"*|\
> +		*"IPv6 support is disabled"*)
> +			echo "SKIP: no IPv6 AMT support: $ADD_ERR"
> +			exit "$ksft_skip"
> +			;;
> +		esac
> +		echo "FAIL: cannot create an IPv6 gateway: $ADD_ERR"
> +		exit "$ksft_fail"
> +	fi

[Severity: Low]
What happens here on a kernel built without CONFIG_AMT, or where the
amt module cannot be loaded?

In that case __rtnl_newlink() in net/core/rtnetlink.c finds no link
ops for "amt" and fails the request with -EOPNOTSUPP and the extack
message "Unknown device type". ADD_ERR then holds "Error: Unknown
device type.", or "RTNETLINK answers: Operation not supported" from
an iproute2 that does not print extack. Neither matches any arm of the
case statement, so probe_v6_gateway() prints "FAIL: cannot create an
IPv6 gateway" and exits with ksft_fail.

An iproute2 with no amt link support at all ends up in the same place.
It cannot parse the mode, local and discovery arguments, so it
typically fails with "Garbage instead of arguments" before anything
is sent to the kernel.

Both are missing prerequisites, not failures of the code under test.
The comment above probe_v6_gateway() says only failures of the code
under test should be reported as FAIL. amt.sh already handles the
iproute2 side by checking ip link help for amt before it starts.

Would it make sense to do the same check here, and to add "Unknown
device type" and "Operation not supported" to the skip arm? The test
would then report SKIP rather than FAIL on such a setup.

[Severity: Medium]
Can the first case arm in probe_v6_gateway() ever match? I could not find
the string "IPv6 address in an IPv4 attribute" anywhere in the kernel
tree. It only shows up here and in probe_v6_relay() in amt_v6.sh.

As far as I can tell, the only thing that refuses a 16-byte
IFLA_AMT_LOCAL_IP or IFLA_AMT_DISCOVERY_IP is the policy in
drivers/net/amt.c:

amt_policy[] {
    ...
	[IFLA_AMT_LOCAL_IP]	= NLA_POLICY_EXACT_LEN(sizeof(__be32)),
    ...
	[IFLA_AMT_DISCOVERY_IP]	= NLA_POLICY_EXACT_LEN(sizeof(__be32)),
    ...
}

validate_nla() checks that policy before amt_validate() or amt_newlink()
runs. When the length is wrong, nla_validate_range_unsigned() in
lib/nlattr.c reports:

		if (binary)
			NL_SET_ERR_MSG_ATTR_POL(extack, nla, pt,
						"binary attribute size out of range");

Take an iproute2 that packs the IPv6 literal into the IPv4 attribute.
Wouldn't ADD_ERR be "Error: binary attribute size out of range." in that
case? That string matches none of the arms, so the script reaches the
"FAIL: cannot create an IPv6 gateway" exit on a correct kernel, not the
intended PASS and SKIP.

The commit message also says:

    this kernel refuses it ("IPv6 address in an IPv4
    attribute").

Does any rule in this series emit that message? The skip list in
probe_v6_relay() in amt_v6.sh has the same pattern, so it would also
report FAIL instead of SKIP with such an iproute2.

> +	got=$(amt_field amtprobe discovery)
> +	ip -n "$GW" link del amtprobe
> +	if [[ "$got" != *:* ]]; then
> +		# A kernel with the IPv6 attributes names the missing
> +		# discovery address this way, and must have refused the
> +		# 16-byte IPv4 attribute that an older iproute2 sent.
> +		add_amt amtprobe mode gateway local "$V4_LOCAL"
> +		ip -n "$GW" link del amtprobe 2>/dev/null
> +		if [[ "$ADD_ERR" == *"of the local family is required"* ]]; then
> +			echo "FAIL: 16-byte IPv4 attribute read back as '$got'"
> +			exit "$ksft_fail"
> +		fi

[Severity: Medium]
Can this FAIL branch be reached through anything other than a userspace
limitation?

If the probe link was created, the exact-length policy on
IFLA_AMT_LOCAL_IP and IFLA_AMT_DISCOVERY_IP means iproute2 sent 4-byte
attributes, not 16-byte ones. A readback without a colon here, or an
empty one from the "// empty" in amt_field(), would come from one of two
sources:

- an iproute2 that truncated 2001:db8:a::1 and 2001:db8:a::2 to
  32.1.13.184. The kernel correctly accepts that as a valid IPv4 unicast
  local and discovery address.
- an iproute2 that prints IFLA_AMT_DISCOVERY_IP6 under a JSON key other
  than discovery.

The follow-up check then creates an IPv4 gateway with no discovery
address. On this kernel, amt_validate() rejects every such gateway with
the same message:

	if (data[IFLA_AMT_LOCAL_IP6] ? !data[IFLA_AMT_DISCOVERY_IP6] :
				       !data[IFLA_AMT_DISCOVERY_IP]) {
		NL_SET_ERR_MSG_MOD(extack,
				   "Discovery attribute of the local family is required");

So doesn't this branch always print "16-byte IPv4 attribute read back"
and exit with ksft_fail, even though the kernel did what it should?

The commit message describes this case as:

    If such
    an iproute2 gets an IPv4 device back from a kernel that has the IPv6
    attributes, recognised by its "Discovery attribute of the local family
    is required" message, the refusal is broken and the probe fails.

The four truncated bytes cannot be told apart from a real IPv4 address.
Is there a kernel refusal that could be broken here, or should this case
be a SKIP?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125191450.2497936-1-omar%40blockcast.net
Technical Details
Message-ID: <179572062595.3135.5756555149194177847@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372297-linux-kernel-netdev=dewy.ru
References: <20261125191450.2497936-13-omar@blockcast.net>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372297-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v2 12/12] selftests: net: add amt_gw_v6.sh for
 the IPv6 netlink attributes
Date: Thu, 26 Nov 2026 19:17:05 +0000
Organization: Usenet Network
Message-ID: <179572062595.3135.5756555149194177847@kernel.org>
References: <20261125191450.2497936-13-omar@blockcast.net>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="542636"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:2zTO12l+f73ZSYfdegDZna5TTso= sha256:srfl/gbNCIOwj1mGo8BYjo10Fv4NIwah9H7CYcXR5Ic=
	sha1:wdQSjqZ0Ug2MlmxTqhpVHnO+Dw4= sha256:JBMImVmJCy6yY6VmJwK/skQM/8mb+z6JBzINSsI68Io=
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 304DF125EF6; Thu, 26 Nov 2026 22:17:45 +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 ZAjlAG9oilqP;
	Thu, 26 Nov 2026 22:17:41 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-372297-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 C9F56125EF7; Thu, 26 Nov 2026 22:17:32 +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 40FCB30422; Thu, 26 Nov 2026 19:17:11 +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=1795720628;
	b=PE1+u9WV0hNKcCarWIgJlUcdM9+aHX9flZfj1Cvbwzk6UuScatzRI8kKJoYkmfy/4vVA
	 l0NAmQjbt8ia5EL/RAJMglHIuDU9fVEf27qIzRBKYANW3VVtFvZBOlZkJluJoi/Re9w+p
	 uAUo982bwckPvlD6DIo4aGoWBzyVbNZ2SjPuGj7aqCS4nuqdRDmusH93DyM5obLtY5Zij
	 MGfPaapAFXakeMHNl0BIOwy+yZYb4DFCCLdSanZF2/NtxmMNCYXtSOdGwyegf0fuTdQWR
	 mJ5+pC8iNGyIPM+5FDFx0A1xWBdAUsLNDUsIeYeE33Bv38h8cNy95z3k4L9h8tSAgJw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795720628;
	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=TeBv919u0tdzRATsjRKyQB2JzyijIcDOw/pARemxP80=;
	b=uP+1oV0LW2zJIKJVj71ZXrbJPdcUWzd07YcCB2U36Q4FKwo9TzpUHeNIBuyJtulgIXyU
	 m2KCEQ+3tuOjKKNWRdJrhHX+9IE/xKsP70JutEYFoj5p6bDFl7mc6w72y97R9R4aWdUT6
	 oNJbRcASbcLSUEIl8VGoS50HzUvm6yFgE54R6OqzDHp3U8t3iyMQEf6i3TzR4kj3T7dil
	 bGc6j/cghrhpwoLYlDpsmiM2mFxq2dAfazvl4SNx5NVK99oQjhSyqVd8NfwJtadkYiC+d
	 FBJ4s4OdE5g7b0L0bxyW5dO5vs6g8iFoz6CmASTbAfQWQSBCDBVWkkJd29zL/KGZHRA==
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=H4oVjYa0;
	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 3FF9A606A6A7;
	Thu, 26 Nov 2026 19:17:08 +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=H4oVjYa0
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=1795720627;
	b=rdURSHX1GuXLyeQSw29T3kHo3eU5nEfYZlGpGtDScbzEazwbMqKoUDGGuHRd25A6/8+2
	 IymuOhTrnjyh1s2syUkTvN9Zr/+Knzor3zImBOinuybQWBmLnVSqyI7CbF/jQF3xGxr+D
	 YqtXYxTg8KQ49McE+s+LlALPPZIhc6HolkXXY9MAWetIMSXAlXsjgwzL3+JLTF9fgIG8Y
	 GgHkIZBTViy35e+uasBFdzyFPZCPKA5r04M64Jx6G2HtSVl75c3E4vBZLJfx4IdasUh/h
	 YGmX2WRnDyfFdEnzqzrlWS7a9eptO44r7FdHPPqFVEkMa/JmKD7fXWkSoFEfFNG+Org==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795720627;
	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=TeBv919u0tdzRATsjRKyQB2JzyijIcDOw/pARemxP80=;
	b=dpALJ/hJIlxeSmmdW43+aw8jnA0MTU6VIk+BtbWqmbteur/4lQ7fbC14ji0w33ZlUpv4
	 ndQt4+ZWwwlWFYNZ6h75mlX8NaN2ReEAdGr13lK0D7ubE80PX8ekaLKP5X4ujdCGa2lig
	 immiZyg51J1w2SWcUS5bIZhF3Xwrb4M1Vr5SReRe6ell7u+/+Plgg1JPajzqDBiJjuUH4
	 f9IHrsyaKd7t3+I4JVo7KUCqYQ4N7YUllG1GqCjAKzu99qMjZ+UhykDdoT9utMFSDOrmS
	 Df+ckUX/tAQ/0GMEtbOpIPxyVXMcLNu6771hRKJ0onxn3xnvEFw6VSwFo4zP9l+myBQ==
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=H4oVjYa0;
	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 6097D606A31E;
	Thu, 26 Nov 2026 19:17:07 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59C641F000D4;
	Thu, 26 Nov 2026 19:17:06 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795720626;
	bh=TeBv919u0tdzRATsjRKyQB2JzyijIcDOw/pARemxP80=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=H4oVjYa0yd00ENrH/AFrETnameCBDXf7RwHVT48HgftH5wKOaY2YRZF8R8C5ThMUI
	 jcqOMw+CN6JXTkUHLDZ+T+B2n1COVN4btv2XxscVZpsr5Dc3lkolMGdrvGPtMimc6K
	 NPcIowyAktvYl/oKk7fIycCb5tksJt1gNnvPkgVXBrWeuzlxDueqQkueHEZTHnzRpb
	 VHzuut/K549ECV4rybQOhaowKgTFgT4AE4vHMpG8Kqk5+lz6aTk0+46rrt8sKiBYpN
	 fRniFDWapuXffZwEkDI7F1QYu2JG38yLs4bwGBAmOThwYX6Po44KzSfPl33tklJYCv
	 VNc7J7gXkAq0Q==
X-Cc: ap420073@gmail.com, andrew+netdev@lunn.ch, davem@davemloft.net,
 edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, shuah@kernel.org,
 horms@kernel.org, netdev@vger.kernel.org, linux-kselftest@vger.kernel.org,
 linux-kernel@vger.kernel.org
X-In-Reply-To: <20261125191450.2497936-13-omar@blockcast.net>
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