-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
selftests: fib_tests: Add test cases for IPv4/IPv6 FIB
Add test cases to check that IPv4 and IPv6 react to a netdev being unregistered as expected. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Acked-by: David Ahern <dsahern@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
- Loading branch information
Ido Schimmel
authored and
David S. Miller
committed
Jan 8, 2018
1 parent
1de178e
commit 607bd2e
Showing
2 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
#!/bin/bash | ||
# SPDX-License-Identifier: GPL-2.0 | ||
|
||
# This test is for checking IPv4 and IPv6 FIB behavior in response to | ||
# different events. | ||
|
||
ret=0 | ||
|
||
check_err() | ||
{ | ||
if [ $ret -eq 0 ]; then | ||
ret=$1 | ||
fi | ||
} | ||
|
||
check_fail() | ||
{ | ||
if [ $1 -eq 0 ]; then | ||
ret=1 | ||
fi | ||
} | ||
|
||
netns_create() | ||
{ | ||
local testns=$1 | ||
|
||
ip netns add $testns | ||
ip netns exec $testns ip link set dev lo up | ||
} | ||
|
||
fib_unreg_unicast_test() | ||
{ | ||
ret=0 | ||
|
||
netns_create "testns" | ||
|
||
ip netns exec testns ip link add dummy0 type dummy | ||
ip netns exec testns ip link set dev dummy0 up | ||
|
||
ip netns exec testns ip address add 198.51.100.1/24 dev dummy0 | ||
ip netns exec testns ip -6 address add 2001:db8:1::1/64 dev dummy0 | ||
|
||
ip netns exec testns ip route get fibmatch 198.51.100.2 &> /dev/null | ||
check_err $? | ||
ip netns exec testns ip -6 route get fibmatch 2001:db8:1::2 &> /dev/null | ||
check_err $? | ||
|
||
ip netns exec testns ip link del dev dummy0 | ||
check_err $? | ||
|
||
ip netns exec testns ip route get fibmatch 198.51.100.2 &> /dev/null | ||
check_fail $? | ||
ip netns exec testns ip -6 route get fibmatch 2001:db8:1::2 &> /dev/null | ||
check_fail $? | ||
|
||
ip netns del testns | ||
|
||
if [ $ret -ne 0 ]; then | ||
echo "FAIL: unicast route test" | ||
return 1 | ||
fi | ||
echo "PASS: unicast route test" | ||
} | ||
|
||
fib_unreg_multipath_test() | ||
{ | ||
ret=0 | ||
|
||
netns_create "testns" | ||
|
||
ip netns exec testns ip link add dummy0 type dummy | ||
ip netns exec testns ip link set dev dummy0 up | ||
|
||
ip netns exec testns ip link add dummy1 type dummy | ||
ip netns exec testns ip link set dev dummy1 up | ||
|
||
ip netns exec testns ip address add 198.51.100.1/24 dev dummy0 | ||
ip netns exec testns ip -6 address add 2001:db8:1::1/64 dev dummy0 | ||
|
||
ip netns exec testns ip address add 192.0.2.1/24 dev dummy1 | ||
ip netns exec testns ip -6 address add 2001:db8:2::1/64 dev dummy1 | ||
|
||
ip netns exec testns ip route add 203.0.113.0/24 \ | ||
nexthop via 198.51.100.2 dev dummy0 \ | ||
nexthop via 192.0.2.2 dev dummy1 | ||
ip netns exec testns ip -6 route add 2001:db8:3::/64 \ | ||
nexthop via 2001:db8:1::2 dev dummy0 \ | ||
nexthop via 2001:db8:2::2 dev dummy1 | ||
|
||
ip netns exec testns ip route get fibmatch 203.0.113.1 &> /dev/null | ||
check_err $? | ||
ip netns exec testns ip -6 route get fibmatch 2001:db8:3::1 &> /dev/null | ||
check_err $? | ||
|
||
ip netns exec testns ip link del dev dummy0 | ||
check_err $? | ||
|
||
ip netns exec testns ip route get fibmatch 203.0.113.1 &> /dev/null | ||
check_fail $? | ||
ip netns exec testns ip -6 route get fibmatch 2001:db8:3::1 &> /dev/null | ||
# In IPv6 we do not flush the entire multipath route. | ||
check_err $? | ||
|
||
ip netns exec testns ip link del dev dummy1 | ||
|
||
ip netns del testns | ||
|
||
if [ $ret -ne 0 ]; then | ||
echo "FAIL: multipath route test" | ||
return 1 | ||
fi | ||
echo "PASS: multipath route test" | ||
} | ||
|
||
fib_unreg_test() | ||
{ | ||
echo "Running netdev unregister tests" | ||
|
||
fib_unreg_unicast_test | ||
fib_unreg_multipath_test | ||
} | ||
|
||
fib_test() | ||
{ | ||
fib_unreg_test | ||
} | ||
|
||
if [ "$(id -u)" -ne 0 ];then | ||
echo "SKIP: Need root privileges" | ||
exit 0 | ||
fi | ||
|
||
if [ ! -x "$(command -v ip)" ]; then | ||
echo "SKIP: Could not run test without ip tool" | ||
exit 0 | ||
fi | ||
|
||
ip route help 2>&1 | grep -q fibmatch | ||
if [ $? -ne 0 ]; then | ||
echo "SKIP: iproute2 too old, missing fibmatch" | ||
exit 0 | ||
fi | ||
|
||
fib_test | ||
|
||
exit $ret |