Re: [PATCH net v5 2/2] selftests: net: add a test for vxlan snooping moving a MAC

From
netdev-bot+sashiko@kernel.org
Date
2026-11-16 04:55:57
Also in
linux-kselftest
Reply to
Zhefu Peng, 2026-11-15
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] ping_from_cpu0() in
  tools/testing/selftests/net/test_vxlan_snoop_move.sh always pins to…
- [Low] test_move_to_link_local() pins its pings to CPU 0.
- [Low] test_move_behind_router (line 48), test_move_to_link_local (line
  105) and test_same_remote_keeps_via (line 159) ignore the return value…

--

selftests: net: add a test for vxlan snooping moving a MAC

This adds test_vxlan_snoop_move.sh, with three cases for a learning VXLAN
device that snoops a known MAC. The first moves the MAC from an IPv4 remote
to one behind a router. The second moves it from a global IPv6 remote to a
link-local one. The third checks that a dynamic entry keeps its "via"
device. The first two cases pin their pings to CPU 0 because the route
cache is per CPU.
quoted hunk ↗ jump to hunk
diff --git a/tools/testing/selftests/net/test_vxlan_snoop_move.sh b/tools/testing/selftests/net/test_vxlan_snoop_move.sh
new file mode 100755
index 0000000000000..5b78310439d3a
--- /dev/null
+++ b/tools/testing/selftests/net/test_vxlan_snoop_move.sh
@@ -0,0 +1,199 @@
[ ... ]
quoted hunk ↗ jump to hunk
+ping_from_cpu0()
+{
+	local ns=$1; shift
+
+	taskset -c 0 ip netns exec "$ns" ping -c 3 -W 1 -i 0.2 "$@" &> /dev/null
+}
[Severity: Low]
What happens here when CPU 0 is not in the allowed CPU set? That can
happen under a cpuset cgroup that excludes CPU 0, or when CPU 0 is
offline.

In that case sched_setaffinity() fails with EINVAL, taskset exits non-zero
and ping never runs. That status goes straight to check_err in
test_move_behind_router() and test_move_to_link_local(). Both cases then
report "ping before the move failed" on a working kernel instead of
skipping.

The require_command taskset near the end of the script only checks that
the binary is installed. It doesn't check that CPU 0 is usable.

The pinning only needs one CPU to fill the per-CPU dst_cache and then hit
it. Could this pick any CPU from the current affinity mask, or skip when
CPU 0 can't be used? srv6_iptunnel_cache.sh hard-codes taskset -c 0 the
same way.

[ ... ]
quoted hunk ↗ jump to hunk
+test_move_behind_router()
+{
+	RET=0
+
+	setup_ns sw ex a r b
+	defer cleanup_ns "$sw" "$ex" "$a" "$r" "$b"
[Severity: Low]
Should the return value of setup_ns be checked here?

In lib.sh, setup_ns() returns $ksft_skip when ip netns add fails. This
test keeps going anyway, so every later ip -n and bridge -n command fails.
The case then reports "ping before the move failed" instead of SKIP.

The setup_ns calls in test_move_to_link_local() and
test_same_remote_keeps_via() have the same problem. The second one reports
"ping from the remote failed".

Most net selftests don't check setup_ns either, though bareudp.sh,
fou_gre_gro.sh and nsh_gso.sh do. So this matches common practice, but the
result is still reported wrongly.

[ ... ]
+test_move_to_link_local()
+{
[ ... ]
quoted hunk ↗ jump to hunk
+	ip -n "$ex" addr add 2001:db8:1::1/64 dev e0 nodad
+	ip -n "$ex" addr add fe80::1/64 dev e0 nodad
+	ip -n "$a" addr add 2001:db8:1::2/64 dev a0 nodad
+	ip -n "$b" addr add fe80::b/64 dev b0 nodad
+
+	ip -n "$ex" link add vx0 type vxlan id 42 dstport 4789 \
+		local 2001:db8:1::1 learning
+	bridge -n "$ex" fdb append 00:00:00:00:00:00 dev vx0 dst 2001:db8:1::2
+	bridge -n "$ex" fdb append 00:00:00:00:00:00 dev vx0 dst fe80::b via e0
[ ... ]
quoted hunk ↗ jump to hunk
+	ping_from_cpu0 "$ex" 192.168.0.10
+	check_err $? "ping before the move failed"
+
+	ip -n "$a" link set vx0 down
+	ip -n "$b" link set vx0 up
+	ip netns exec "$b" ping -c 1 -W 1 192.168.0.1 &> /dev/null
+
+	bridge -n "$ex" fdb show dev vx0 | grep -q "$MAC dst fe80::b via e0 "
+	check_err $? "fdb entry did not move to the new remote and interface"
+
+	ping_from_cpu0 "$ex" 192.168.0.10
+	check_err $? "ping after the move failed"
[Severity: Low]
Can this post-move ping tell a stale IPv6 dst_cache from a reset one?

The commit message says:

    The first two cases ping from CPU 0. The route cache is per CPU, and
    only the CPU that filled it hits the stale entry.

In this topology the old remote (2001:db8:1::2) and the new remote
(fe80::b) are both on-link through e0 in $ex. The pre-move ping fills
CPU 0's rdst->dst_cache with a non-gateway on-link route on e0. Nothing
changes the routes in $ex between the two pings.

udp_tunnel6_dst_lookup() returns the cached dst without checking oif or
daddr:

net/ipv6/ip6_udp_tunnel.c:udp_tunnel6_dst_lookup() {
    ...
		dst = dst_cache_get_ip6(dst_cache, saddr);
		if (dst)
			return dst;
    ...
}

On an on-link route the next hop is the packet's own daddr. So the stale
dst would deliver to fe80::b just as a fresh lookup would.

Suppose the dst_cache_reset(&rdst->dst_cache) call in vxlan_snoop() were
removed but the remote_ifindex update were kept. Wouldn't this case still
pass? It looks like only the "via e0" grep tests anything here, and the
CPU 0 pinning has no effect.

The IPv4 case still covers dst_cache_reset() itself. Would giving the old
and new IPv6 remotes different egress paths cover the IPv6 cache path? One
option is to put one of them behind a router, as in the first case.
Otherwise, could the commit message be reworded so it doesn't suggest the
second case covers stale routes?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261115040609.61134-1-ilskdw%40gmail.com
Thread (6 messages) 6 messages, 2 authors, last reply 8h ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help