Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: mlxsw: Add test cases for local table route replacement

Test that routes in the main table do not replace identical routes in
the local table and that routes in the local table do replace identical
routes in the main table.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Ido Schimmel and committed by
David S. Miller
6c05ca26 0508ff89

+76
+76
tools/testing/selftests/drivers/net/mlxsw/fib.sh
··· 14 14 ipv4_plen 15 15 ipv4_replay 16 16 ipv4_flush 17 + ipv4_local_replace 17 18 ipv6_add 18 19 ipv6_metric 19 20 ipv6_append_single ··· 27 26 ipv6_delete_multipath 28 27 ipv6_replay_single 29 28 ipv6_replay_multipath 29 + ipv6_local_replace 30 30 " 31 31 NUM_NETIFS=0 32 32 source $lib_dir/lib.sh ··· 91 89 fib_ipv4_flush_test "testns1" 92 90 } 93 91 92 + ipv4_local_replace() 93 + { 94 + local ns="testns1" 95 + 96 + RET=0 97 + 98 + ip -n $ns link add name dummy1 type dummy 99 + ip -n $ns link set dev dummy1 up 100 + 101 + ip -n $ns route add table local 192.0.2.1/32 dev dummy1 102 + fib4_trap_check $ns "table local 192.0.2.1/32 dev dummy1" false 103 + check_err $? "Local table route not in hardware when should" 104 + 105 + ip -n $ns route add table main 192.0.2.1/32 dev dummy1 106 + fib4_trap_check $ns "table main 192.0.2.1/32 dev dummy1" true 107 + check_err $? "Main table route in hardware when should not" 108 + 109 + fib4_trap_check $ns "table local 192.0.2.1/32 dev dummy1" false 110 + check_err $? "Local table route was replaced when should not" 111 + 112 + # Test that local routes can replace routes in main table. 113 + ip -n $ns route add table main 192.0.2.2/32 dev dummy1 114 + fib4_trap_check $ns "table main 192.0.2.2/32 dev dummy1" false 115 + check_err $? "Main table route not in hardware when should" 116 + 117 + ip -n $ns route add table local 192.0.2.2/32 dev dummy1 118 + fib4_trap_check $ns "table local 192.0.2.2/32 dev dummy1" false 119 + check_err $? "Local table route did not replace route in main table when should" 120 + 121 + fib4_trap_check $ns "table main 192.0.2.2/32 dev dummy1" true 122 + check_err $? "Main table route was not replaced when should" 123 + 124 + log_test "IPv4 local table route replacement" 125 + 126 + ip -n $ns link del dev dummy1 127 + } 128 + 94 129 ipv6_add() 95 130 { 96 131 fib_ipv6_add_test "testns1" ··· 186 147 ipv6_replay_multipath() 187 148 { 188 149 fib_ipv6_replay_multipath_test "testns1" "$DEVLINK_DEV" 150 + } 151 + 152 + ipv6_local_replace() 153 + { 154 + local ns="testns1" 155 + 156 + RET=0 157 + 158 + ip -n $ns link add name dummy1 type dummy 159 + ip -n $ns link set dev dummy1 up 160 + 161 + ip -n $ns route add table local 2001:db8:1::1/128 dev dummy1 162 + fib6_trap_check $ns "table local 2001:db8:1::1/128 dev dummy1" false 163 + check_err $? "Local table route not in hardware when should" 164 + 165 + ip -n $ns route add table main 2001:db8:1::1/128 dev dummy1 166 + fib6_trap_check $ns "table main 2001:db8:1::1/128 dev dummy1" true 167 + check_err $? "Main table route in hardware when should not" 168 + 169 + fib6_trap_check $ns "table local 2001:db8:1::1/128 dev dummy1" false 170 + check_err $? "Local table route was replaced when should not" 171 + 172 + # Test that local routes can replace routes in main table. 173 + ip -n $ns route add table main 2001:db8:1::2/128 dev dummy1 174 + fib6_trap_check $ns "table main 2001:db8:1::2/128 dev dummy1" false 175 + check_err $? "Main table route not in hardware when should" 176 + 177 + ip -n $ns route add table local 2001:db8:1::2/128 dev dummy1 178 + fib6_trap_check $ns "table local 2001:db8:1::2/128 dev dummy1" false 179 + check_err $? "Local route route did not replace route in main table when should" 180 + 181 + fib6_trap_check $ns "table main 2001:db8:1::2/128 dev dummy1" true 182 + check_err $? "Main table route was not replaced when should" 183 + 184 + log_test "IPv6 local table route replacement" 185 + 186 + ip -n $ns link del dev dummy1 189 187 } 190 188 191 189 setup_prepare()