Re: [PATCH net-next v4 11/12] selftests: net: add amt_v6.sh for an IPv6 outer transport

From: netdev-bot+sashiko

Date: Sun Nov 29 2026 - 22:48:44 EST


Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

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

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 tools/testing/selftests/net/amt_v6.sh, disc_answer() can
report "no reply" for a capture that never started.
- [Low] In setup_links() in tools/testing/selftests/net/amt_v6.sh, the
comment says "(amtr is NOARP and skips DAD on its own.)".
- [Low] Concern: setup_topology() calls `slowwait 5 test -S
"$SMCDIR/sock"` while `set -E` and `trap 'setup_fail $LINENO' ERR` are…

--

selftests: net: add amt_v6.sh for an IPv6 outer transport

This adds amt_v6.sh, a variant of amt.sh in which the AMT gateways and the
relay talk to each other over an IPv6 outer link. It checks:

- discovery through a secondary relay address
- IPv4 and IPv6 multicast forwarding
- the per-/64 tunnel cap
- tunnel MTU handling
- that a Discovery sent to ff02::1 gets no answer
- gateway down/up

> diff --git a/tools/testing/selftests/net/amt_v6.sh b/tools/testing/selftests/net/amt_v6.sh
> new file mode 100755
> index 0000000000000..923c2b374ce53
> --- /dev/null
> +++ b/tools/testing/selftests/net/amt_v6.sh
> @@ -0,0 +1,469 @@

[ ... ]

> +setup_links()
> +{
> + local ns
> +
> + # No DAD: the global addresses of the gateway and relay links must
> + # not be tentative, or the gateways could neither bind to them nor
> + # send from them. (amtr is NOARP and skips DAD on its own.)

[Severity: Low]
Is the "amtr is NOARP" part of this comment accurate? amt_link_setup() in
drivers/net/amt.c does set IFF_NOARP, but it calls ether_setup() last:

drivers/net/amt.c:amt_link_setup() {
...
dev->type = ARPHRD_NONE;
dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
...
ether_setup(dev);
}

ether_setup() always sets dev->type = ARPHRD_ETHER and
dev->flags = IFF_BROADCAST|IFF_MULTICAST. That means amtr ends up without
IFF_NOARP and goes through normal DAD.

The test still works because $RELAY is in the accept_dad=0 loop below, and
amtr is created after default.accept_dad=0 is set. Could the note in
parentheses be fixed or removed? Otherwise someone may drop $RELAY from the
loop because of it.

> + for ns in "$LISTENER" "$GATEWAY" "$GATEWAY2" "$RELAY" "$SOURCE"; do
> + ip netns exec "$ns" sysctl -wq \
> + net.ipv6.conf.all.accept_dad=0 \
> + net.ipv6.conf.default.accept_dad=0
> + done

[ ... ]

> + SMCDIR=$(mktemp -d)
> + ip netns exec "$RELAY" smcrouted -P "$SMCDIR/pid" -u "$SMCDIR/sock"
> + slowwait 5 test -S "$SMCDIR/sock"

[Severity: Low]
Can the inherited ERR trap fire inside this slowwait? setup_topology() runs
with errtrace on and the setup_fail ERR trap installed:

set -E
trap 'setup_fail $LINENO' ERR
...
setup_topology

loopy_wait() in lib.sh runs the polled command inside a command
substitution:

if out=$("$@"); then

With set -E, command substitutions inherit the ERR trap. smcrouted
daemonizes before it creates its socket, so the first test -S calls can
fail.

If the trap fires there, setup_fail prints "FAIL: setup failed at line N"
to stderr. Its exit only leaves the substitution subshell, so setup goes on
and the run can still pass.

Bash may suppress this, because the substitution is the condition of an if
and the ignore-return state may carry into the subshell. If so, nothing is
printed. Has this been checked against the bash versions used in CI, so
the output does not show stray FAIL lines?

> + ip netns exec "$RELAY" smcroutectl -u "$SMCDIR/sock" \
> + a relay_src 172.17.0.2 239.0.0.1 amtr

[ ... ]

> +disc_answer()
> +{
> + local dst=$1 filter=$2 pid i rc cap
> + local to="UDP6-SENDTO:[$dst]:2268,sourceport=40000"
> +
> + cap=$(mktemp)
> + ip netns exec "$GATEWAY" timeout 6 \
> + tcpdump -nni gw_relay -c 1 "$filter" > /dev/null 2> "$cap" &
> + pid=$!
> + # The capture is ready once tcpdump says it is listening; it is gone
> + # before that only if it failed to start.
> + for i in $(seq 50); do
> + grep -q "listening on" "$cap" && break
> + if ! kill -0 "$pid" 2> /dev/null; then
> + wait "$pid"
> + rm -f "$cap"
> + return 2
> + fi
> + sleep 0.1
> + done
> + rm -f "$cap"

[Severity: Medium]
What happens if tcpdump is still running but has not printed "listening
on" after all 50 tries? The loop just ends without returning 2. The sends
then go ahead as if the capture were armed.

The 6 second timeout started when tcpdump was launched. After about 5
seconds of polling, only about 1 second is left. The three sends below take
at least 1.5 seconds, so timeout can kill tcpdump before or during them.
The status handling then gives:

wait "$pid"
case $? in
0) return "${rc:-0}" ;;
124) return "${rc:-1}" ;;

wait returns 124, rc is unset, and disc_answer() returns 1. That is the
same status as a real "no reply". test_mcast_discovery() treats 1 as a pass
for the ff02::1 check:

disc_answer ff02::1 "udp and src port 2268 and dst port 40000"
[ $? -eq 1 ]

The ff02::1 check can therefore pass even though no capture covered the
sends. The earlier unicast control ran its own tcpdump, so it does not
show that this one worked.

This also seems to contradict the function comment ("2 if the harness
failed: tcpdump did not start") and the commit message:

The ff02::1 check accepts only "no reply", so a broken capture cannot
pass it.

Should disc_answer() kill tcpdump and return 2 when the loop ends without
seeing "listening on"? Starting the capture deadline only once tcpdump is
listening may also help.

> + # Type 1 (Relay Discovery), version 0, then a nonce.
> + for i in 1 2 3; do
> + printf '\x01\x00\x00\x00\x12\x34\x56\x78' |
> + ip netns exec "$GATEWAY" socat -u - \
> + "$to,so-bindtodevice=gw_relay" || rc=2
> + sleep 0.5
> + done

[ ... ]

--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261129034652.1853485-1-omar%40blockcast.net