selftests/net/fib_tests: update addr_metric_test for peer route testing

This patch update {ipv4, ipv6}_addr_metric_test with
1. Set metric of address with peer route and see if the route added
correctly.
2. Modify metric and peer address for peer route and see if the route
changed correctly.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Reviewed-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Hangbin Liu 2020-03-03 14:37:36 +08:00 committed by David S. Miller
parent d0098e4c6b
commit 0d29169a70
1 changed files with 31 additions and 3 deletions

View File

@ -1041,6 +1041,27 @@ ipv6_addr_metric_test()
fi
log_test $rc 0 "Prefix route with metric on link up"
# verify peer metric added correctly
set -e
run_cmd "$IP -6 addr flush dev dummy2"
run_cmd "$IP -6 addr add dev dummy2 2001:db8:104::1 peer 2001:db8:104::2 metric 260"
set +e
check_route6 "2001:db8:104::1 dev dummy2 proto kernel metric 260"
log_test $? 0 "Set metric with peer route on local side"
log_test $? 0 "User specified metric on local address"
check_route6 "2001:db8:104::2 dev dummy2 proto kernel metric 260"
log_test $? 0 "Set metric with peer route on peer side"
set -e
run_cmd "$IP -6 addr change dev dummy2 2001:db8:104::1 peer 2001:db8:104::3 metric 261"
set +e
check_route6 "2001:db8:104::1 dev dummy2 proto kernel metric 261"
log_test $? 0 "Modify metric and peer address on local side"
check_route6 "2001:db8:104::3 dev dummy2 proto kernel metric 261"
log_test $? 0 "Modify metric and peer address on peer side"
$IP li del dummy1
$IP li del dummy2
cleanup
@ -1457,13 +1478,20 @@ ipv4_addr_metric_test()
run_cmd "$IP addr flush dev dummy2"
run_cmd "$IP addr add dev dummy2 172.16.104.1/32 peer 172.16.104.2 metric 260"
run_cmd "$IP addr change dev dummy2 172.16.104.1/32 peer 172.16.104.2 metric 261"
rc=$?
if [ $rc -eq 0 ]; then
check_route "172.16.104.2 dev dummy2 proto kernel scope link src 172.16.104.1 metric 261"
check_route "172.16.104.2 dev dummy2 proto kernel scope link src 172.16.104.1 metric 260"
rc=$?
fi
log_test $rc 0 "Modify metric of address with peer route"
log_test $rc 0 "Set metric of address with peer route"
run_cmd "$IP addr change dev dummy2 172.16.104.1/32 peer 172.16.104.3 metric 261"
rc=$?
if [ $rc -eq 0 ]; then
check_route "172.16.104.3 dev dummy2 proto kernel scope link src 172.16.104.1 metric 261"
rc=$?
fi
log_test $rc 0 "Modify metric and peer address for peer route"
$IP li del dummy1
$IP li del dummy2