[PATCH v2 2/3] selftests: fib_nexthops: Check the IPv6 multipath source address
From: Tim Menninger
Date: Thu Dec 03 2026 - 18:48:43 EST
Extend ipv6_mpath_select to check that, for a destination hashed to each
member of a multipath nexthop group, the reported source address belongs
to the device of the selected nexthop. Without "ipv6: Use the selected
nexthop for source address selection", the source address always comes
from the first nexthop's device and the check fails for the other
member.
Signed-off-by: Tim Menninger <tmenninger@xxxxxxxxxxxxxxxx>
---
Changes in v2:
- New patch
tools/testing/selftests/net/fib_nexthops.sh | 35 +++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/tools/testing/selftests/net/fib_nexthops.sh b/tools/testing/selftests/net/fib_nexthops.sh
index adbec51917eb..cdc8d53d87ac 100755
--- a/tools/testing/selftests/net/fib_nexthops.sh
+++ b/tools/testing/selftests/net/fib_nexthops.sh
@@ -387,6 +387,16 @@ get_route_dev()
fi
}
+get_route_prefsrc()
+{
+ local pfx="$1"
+ local out
+
+ if out=$($IP -j route get "$pfx" | jq -re ".[0].prefsrc"); then
+ echo "$out"
+ fi
+}
+
check_route_dev()
{
local pfx="$1"
@@ -867,6 +877,31 @@ ipv6_mpath_select()
done
log_test $rc 0 "Use valid neighbor during multipath selection"
+ # The source address must belong to the selected nexthop's device,
+ # not the device of the group's first nexthop.
+ local -A srcs
+ srcs=([veth1]=2001:db8:91::1 [veth3]=2001:db8:92::1)
+ rc=0
+ for dev in veth1 veth3; do
+ match=0
+ for h in {1..65535}; do
+ addr=$(printf "2001:db8:101::%x" $h)
+ if [ "$(get_route_dev "$addr")" = "$dev" ]; then
+ match=1
+ break
+ fi
+ done
+ if (( match == 0 )); then
+ echo "SKIP: Did not find a route using device $dev"
+ return $ksft_skip
+ fi
+ if ! check_output "$(get_route_prefsrc "$addr")" "${srcs[$dev]}"; then
+ rc=1
+ break
+ fi
+ done
+ log_test $rc 0 "Source address of selected multipath nexthop"
+
run_cmd "$IP neigh add 2001:db8:91::2 dev veth1 nud incomplete"
run_cmd "$IP neigh add 2001:db8:92::2 dev veth3 nud incomplete"
run_cmd "$IP route get 2001:db8:101::1"
--
2.53.0