selftests: fib_tests: add temporary IPv6 address renewal test

Add a test to check that temporary IPv6 address is regenerated properly
after the base prefix is deprecated and restored.

Fib6 temporary address renewal test
    TEST: IPv6 temporary address cleanly deprecated and regenerated     [ OK ]

Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20260523103811.3790-2-fmancera@suse.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Fernando Fernandez Mancera
2026-05-23 12:38:11 +02:00
committed by Jakub Kicinski
parent e20d8922aa
commit 2b9cceb061

View File

@@ -12,7 +12,7 @@ TESTS="unregister down carrier nexthop suppress ipv6_notify ipv4_notify \
ipv4_route_metrics ipv4_route_v6_gw rp_filter ipv4_del_addr \
ipv6_del_addr ipv4_mangle ipv6_mangle ipv4_bcast_neigh fib6_gc_test \
ipv4_mpath_list ipv6_mpath_list ipv4_mpath_balance ipv6_mpath_balance \
ipv4_mpath_balance_preferred fib6_ra_to_static"
ipv4_mpath_balance_preferred fib6_ra_to_static fib6_temp_addr_renewal"
VERBOSE=0
PAUSE_ON_FAIL=no
@@ -1611,6 +1611,62 @@ fib6_ra_to_static()
cleanup &> /dev/null
}
fib6_temp_addr_renewal() {
setup
echo
echo "Fib6 temporary address renewal test"
set -e
# ra6 is required for the test. (ipv6toolkit)
if [ ! -x "$(command -v ra6)" ]; then
echo "SKIP: ra6 not found."
set +e
cleanup &> /dev/null
return
fi
# Create a pair of veth devices to send a RA message from one
# device to another.
$IP link add veth1 type veth peer name veth2
$IP link set dev veth1 up
$IP link set dev veth2 up
# Make veth1 ready to receive RA messages.
$NS_EXEC sysctl -wq net.ipv6.conf.veth1.accept_ra=2
$NS_EXEC sysctl -wq net.ipv6.conf.veth1.use_tempaddr=2
$NS_EXEC sysctl -wq net.ipv6.conf.veth1.temp_prefered_lft=15
$NS_EXEC sysctl -wq net.ipv6.conf.veth1.max_desync_factor=0
# Send a RA message with a prefix from veth2.
$NS_EXEC ra6 -i veth2 -s fe80::1 -d ff02::1 -P 2001:12::/64\#LA\#3600\#3600 -e
sleep 3
# Deprecate it
$NS_EXEC ra6 -i veth2 -s fe80::1 -d ff02::1 -P 2001:12::/64\#LA\#3600\#0 -e
sleep 3
# Restore it
$NS_EXEC ra6 -i veth2 -s fe80::1 -d ff02::1 -P 2001:12::/64\#LA\#3600\#3600 -e
ret=1
for i in $(seq 1 25); do
sleep 1
num_dep="$($IP -6 addr | grep -c "temporary deprecated" || true)"
num_tot="$($IP -6 addr | grep -c "temporary" || true)"
if [ "$num_dep" -eq 1 ] && [ "$num_tot" -ge 2 ]; then
ret=0
break
fi
done
log_test "$ret" 0 "IPv6 temporary address cleanly deprecated and regenerated"
set +e
cleanup &> /dev/null
}
# add route for a prefix, flushing any existing routes first
# expected to be the first step of a test
add_route()
@@ -3002,6 +3058,7 @@ do
ipv6_mpath_balance) ipv6_mpath_balance_test;;
ipv4_mpath_balance_preferred) ipv4_mpath_balance_preferred_test;;
fib6_ra_to_static) fib6_ra_to_static;;
fib6_temp_addr_renewal) fib6_temp_addr_renewal;;
help) echo "Test names: $TESTS"; exit 0;;
esac