Skip to content

Commit

Permalink
selftests: A few improvements to fib_nexthops.sh
Browse files Browse the repository at this point in the history
Add nodad when adding IPv6 addresses and remove the sleep.

A recent change to iproute2 moved the 'pref medium' to the prefix
(where it belongs). Change the expected route check to strip
'pref medium' to be compatible with old and new iproute2.

Add IPv4 runtime test with an IPv6 address as the gateway in
the default route.

Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David Ahern authored and David S. Miller committed Apr 23, 2020
1 parent 250562a commit 493f3cc
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions tools/testing/selftests/net/fib_nexthops.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,31 +150,31 @@ setup()
$IP li add veth1 type veth peer name veth2
$IP li set veth1 up
$IP addr add 172.16.1.1/24 dev veth1
$IP -6 addr add 2001:db8:91::1/64 dev veth1
$IP -6 addr add 2001:db8:91::1/64 dev veth1 nodad

$IP li add veth3 type veth peer name veth4
$IP li set veth3 up
$IP addr add 172.16.2.1/24 dev veth3
$IP -6 addr add 2001:db8:92::1/64 dev veth3
$IP -6 addr add 2001:db8:92::1/64 dev veth3 nodad

$IP li set veth2 netns peer up
ip -netns peer addr add 172.16.1.2/24 dev veth2
ip -netns peer -6 addr add 2001:db8:91::2/64 dev veth2
ip -netns peer -6 addr add 2001:db8:91::2/64 dev veth2 nodad

$IP li set veth4 netns peer up
ip -netns peer addr add 172.16.2.2/24 dev veth4
ip -netns peer -6 addr add 2001:db8:92::2/64 dev veth4
ip -netns peer -6 addr add 2001:db8:92::2/64 dev veth4 nodad

ip -netns remote li add veth5 type veth peer name veth6
ip -netns remote li set veth5 up
ip -netns remote addr add dev veth5 172.16.101.1/24
ip -netns remote addr add dev veth5 2001:db8:101::1/64
ip -netns remote -6 addr add dev veth5 2001:db8:101::1/64 nodad
ip -netns remote ro add 172.16.0.0/22 via 172.16.101.2
ip -netns remote -6 ro add 2001:db8:90::/40 via 2001:db8:101::2

ip -netns remote li set veth6 netns peer up
ip -netns peer addr add dev veth6 172.16.101.2/24
ip -netns peer addr add dev veth6 2001:db8:101::2/64
ip -netns peer -6 addr add dev veth6 2001:db8:101::2/64 nodad
set +e
}

Expand Down Expand Up @@ -248,7 +248,7 @@ check_route6()
local expected="$2"
local out

out=$($IP -6 route ls match ${pfx} 2>/dev/null)
out=$($IP -6 route ls match ${pfx} 2>/dev/null | sed -e 's/pref medium//')

check_output "${out}" "${expected}"
}
Expand Down Expand Up @@ -423,8 +423,6 @@ ipv6_fcnal_runtime()
echo "IPv6 functional runtime"
echo "-----------------------"

sleep 5

#
# IPv6 - the basics
#
Expand Down Expand Up @@ -481,12 +479,12 @@ ipv6_fcnal_runtime()
run_cmd "$IP -6 nexthop add id 85 dev veth1"
run_cmd "$IP ro replace 2001:db8:101::1/128 nhid 85"
log_test $? 0 "IPv6 route with device only nexthop"
check_route6 "2001:db8:101::1" "2001:db8:101::1 nhid 85 dev veth1 metric 1024 pref medium"
check_route6 "2001:db8:101::1" "2001:db8:101::1 nhid 85 dev veth1 metric 1024"

run_cmd "$IP nexthop add id 123 group 81/85"
run_cmd "$IP ro replace 2001:db8:101::1/128 nhid 123"
log_test $? 0 "IPv6 multipath route with nexthop mix - dev only + gw"
check_route6 "2001:db8:101::1" "2001:db8:101::1 nhid 123 metric 1024 nexthop via 2001:db8:91::2 dev veth1 weight 1 nexthop dev veth1 weight 1 pref medium"
check_route6 "2001:db8:101::1" "2001:db8:101::1 nhid 123 metric 1024 nexthop via 2001:db8:91::2 dev veth1 weight 1 nexthop dev veth1 weight 1"

#
# IPv6 route with v4 nexthop - not allowed
Expand Down Expand Up @@ -843,6 +841,11 @@ ipv4_fcnal_runtime()
$IP neigh sh | grep 'dev veth1'
fi

run_cmd "$IP ro del 172.16.101.1/32 via inet6 ${lladdr} dev veth1"
run_cmd "$IP -4 ro add default via inet6 ${lladdr} dev veth1"
run_cmd "ip netns exec me ping -c1 -w1 172.16.101.1"
log_test $? 0 "IPv4 default route with IPv6 gateway"

#
# MPLS as an example of LWT encap
#
Expand Down

0 comments on commit 493f3cc

Please sign in to comment.