mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: omar@blockcast.net
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
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	[thread overview]
Message-ID: <179572062595.3135.5756555149194177847@kernel.org> (raw)
In-Reply-To: <20261125191450.2497936-13-omar@blockcast.net>

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

      reply	other threads:[~2026-11-26 19:17 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 19:14 [PATCH net-next v2 00/12] amt: add an IPv6 outer transport Omar Ramadan
2026-11-25 19:14 ` [PATCH net-next v2 01/12] amt: create an AF_INET6 encapsulation socket for an IPv6 outer address Omar Ramadan
2026-11-25 19:14 ` [PATCH net-next v2 02/12] amt: send the Relay Advertisement over IPv6 Omar Ramadan
2026-11-26 19:16   ` netdev-bot+sashiko
2026-11-25 19:14 ` [PATCH net-next v2 03/12] amt: key relay tunnels on a union amt_addr endpoint Omar Ramadan
2026-11-26 19:16   ` netdev-bot+sashiko
2026-11-25 19:14 ` [PATCH net-next v2 04/12] amt: send the Membership Query over IPv6 Omar Ramadan
2026-11-26 19:16   ` netdev-bot+sashiko
2026-11-25 19:14 ` [PATCH net-next v2 05/12] amt: forward multicast data " Omar Ramadan
2026-11-26 19:16   ` netdev-bot+sashiko
2026-11-25 19:14 ` [PATCH net-next v2 06/12] amt: size the encapsulation headroom by the outer IP version Omar Ramadan
2026-11-26 19:17   ` netdev-bot+sashiko
2026-11-25 19:14 ` [PATCH net-next v2 07/12] amt: send the AMT gateway control plane over IPv6 Omar Ramadan
2026-11-25 19:14 ` [PATCH net-next v2 08/12] amt: receive " Omar Ramadan
2026-11-26 19:17   ` netdev-bot+sashiko
2026-11-25 19:14 ` [PATCH net-next v2 09/12] amt: add netlink attributes for an IPv6 outer transport Omar Ramadan
2026-11-25 19:14 ` [PATCH net-next v2 10/12] MAINTAINERS: amt: cover the amt headers and selftests Omar Ramadan
2026-11-25 19:14 ` [PATCH net-next v2 11/12] selftests: net: add amt_v6.sh for an IPv6 outer transport Omar Ramadan
2026-11-26 19:17   ` netdev-bot+sashiko
2026-11-25 19:14 ` [PATCH net-next v2 12/12] selftests: net: add amt_gw_v6.sh for the IPv6 netlink attributes Omar Ramadan
2026-11-26 19:17   ` netdev-bot+sashiko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179572062595.3135.5756555149194177847@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=ap420073@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=omar@blockcast.net \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®