Commit 7e36c337 authored by Ido Schimmel's avatar Ido Schimmel Committed by Jakub Kicinski

selftests: fib_rule_tests: Add VRF tests

After commit 40867d74 ("net: Add l3mdev index to flow struct and
avoid oif reset for port devices") it is possible to configure FIB rules
that match on iif / oif being a l3mdev port. It was not possible before
as these parameters were reset to the ifindex of the l3mdev device
itself prior to the FIB rules lookup.

Add tests that cover this functionality as it does not seem to be
covered by existing ones and I am aware of at least one user that needs
this functionality in addition to the one mentioned in [1].

Reuse the existing FIB rules tests by simply configuring a VRF prior to
the test and removing it afterwards. Differentiate the output of the
non-VRF tests from the VRF tests by appending "(VRF)" to the test name
if a l3mdev FIB rule is present.

Verified that these tests do fail on kernel 5.15.y which does not
include the previously mentioned commit:

 # ./fib_rule_tests.sh -t fib_rule6_vrf
 [...]
     TEST: rule6 check: oif redirect to table (VRF)                      [FAIL]
 [...]
     TEST: rule6 check: iif redirect to table (VRF)                      [FAIL]

 # ./fib_rule_tests.sh -t fib_rule4_vrf
 [...]
     TEST: rule4 check: oif redirect to table (VRF)                      [FAIL]
 [...]
     TEST: rule4 check: iif redirect to table (VRF)                      [FAIL]

[1] https://lore.kernel.org/netdev/20200922131122.GB1601@ICIPI.localdomain/Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
Link: https://lore.kernel.org/r/20240409110816.2508498-1-idosch@nvidia.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 8750539b
......@@ -9,6 +9,7 @@ PAUSE_ON_FAIL=${PAUSE_ON_FAIL:=no}
RTABLE=100
RTABLE_PEER=101
RTABLE_VRF=102
GW_IP4=192.51.100.2
SRC_IP=192.51.100.3
GW_IP6=2001:db8:1::2
......@@ -17,7 +18,14 @@ SRC_IP6=2001:db8:1::3
DEV_ADDR=192.51.100.1
DEV_ADDR6=2001:db8:1::1
DEV=dummy0
TESTS="fib_rule6 fib_rule4 fib_rule6_connect fib_rule4_connect"
TESTS="
fib_rule6
fib_rule4
fib_rule6_connect
fib_rule4_connect
fib_rule6_vrf
fib_rule4_vrf
"
SELFTEST_PATH=""
......@@ -27,13 +35,18 @@ log_test()
local expected=$2
local msg="$3"
$IP rule show | grep -q l3mdev
if [ $? -eq 0 ]; then
msg="$msg (VRF)"
fi
if [ ${rc} -eq ${expected} ]; then
nsuccess=$((nsuccess+1))
printf "\n TEST: %-50s [ OK ]\n" "${msg}"
printf "\n TEST: %-60s [ OK ]\n" "${msg}"
else
ret=1
nfail=$((nfail+1))
printf "\n TEST: %-50s [FAIL]\n" "${msg}"
printf "\n TEST: %-60s [FAIL]\n" "${msg}"
if [ "${PAUSE_ON_FAIL}" = "yes" ]; then
echo
echo "hit enter to continue, 'q' to quit"
......@@ -130,6 +143,17 @@ cleanup_peer()
ip netns del $peerns
}
setup_vrf()
{
$IP link add name vrf0 up type vrf table $RTABLE_VRF
$IP link set dev $DEV master vrf0
}
cleanup_vrf()
{
$IP link del dev vrf0
}
fib_check_iproute_support()
{
ip rule help 2>&1 | grep -q $1
......@@ -248,6 +272,13 @@ fib_rule6_test()
fi
}
fib_rule6_vrf_test()
{
setup_vrf
fib_rule6_test
cleanup_vrf
}
# Verify that the IPV6_TCLASS option of UDPv6 and TCPv6 sockets is properly
# taken into account when connecting the socket and when sending packets.
fib_rule6_connect_test()
......@@ -385,6 +416,13 @@ fib_rule4_test()
fi
}
fib_rule4_vrf_test()
{
setup_vrf
fib_rule4_test
cleanup_vrf
}
# Verify that the IP_TOS option of UDPv4 and TCPv4 sockets is properly taken
# into account when connecting the socket and when sending packets.
fib_rule4_connect_test()
......@@ -467,6 +505,8 @@ do
fib_rule4_test|fib_rule4) fib_rule4_test;;
fib_rule6_connect_test|fib_rule6_connect) fib_rule6_connect_test;;
fib_rule4_connect_test|fib_rule4_connect) fib_rule4_connect_test;;
fib_rule6_vrf_test|fib_rule6_vrf) fib_rule6_vrf_test;;
fib_rule4_vrf_test|fib_rule4_vrf) fib_rule4_vrf_test;;
help) echo "Test names: $TESTS"; exit 0;;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment