Skip to content

Commit 6c05ca2

Browse files
idoschdavem330
authored andcommitted
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 <[email protected]> Acked-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0508ff8 commit 6c05ca2

File tree

1 file changed

+76
-0
lines changed
  • tools/testing/selftests/drivers/net/mlxsw

1 file changed

+76
-0
lines changed

tools/testing/selftests/drivers/net/mlxsw/fib.sh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ ALL_TESTS="
1414
ipv4_plen
1515
ipv4_replay
1616
ipv4_flush
17+
ipv4_local_replace
1718
ipv6_add
1819
ipv6_metric
1920
ipv6_append_single
@@ -26,6 +27,7 @@ ALL_TESTS="
2627
ipv6_delete_multipath
2728
ipv6_replay_single
2829
ipv6_replay_multipath
30+
ipv6_local_replace
2931
"
3032
NUM_NETIFS=0
3133
source $lib_dir/lib.sh
@@ -89,6 +91,43 @@ ipv4_flush()
8991
fib_ipv4_flush_test "testns1"
9092
}
9193

94+
ipv4_local_replace()
95+
{
96+
local ns="testns1"
97+
98+
RET=0
99+
100+
ip -n $ns link add name dummy1 type dummy
101+
ip -n $ns link set dev dummy1 up
102+
103+
ip -n $ns route add table local 192.0.2.1/32 dev dummy1
104+
fib4_trap_check $ns "table local 192.0.2.1/32 dev dummy1" false
105+
check_err $? "Local table route not in hardware when should"
106+
107+
ip -n $ns route add table main 192.0.2.1/32 dev dummy1
108+
fib4_trap_check $ns "table main 192.0.2.1/32 dev dummy1" true
109+
check_err $? "Main table route in hardware when should not"
110+
111+
fib4_trap_check $ns "table local 192.0.2.1/32 dev dummy1" false
112+
check_err $? "Local table route was replaced when should not"
113+
114+
# Test that local routes can replace routes in main table.
115+
ip -n $ns route add table main 192.0.2.2/32 dev dummy1
116+
fib4_trap_check $ns "table main 192.0.2.2/32 dev dummy1" false
117+
check_err $? "Main table route not in hardware when should"
118+
119+
ip -n $ns route add table local 192.0.2.2/32 dev dummy1
120+
fib4_trap_check $ns "table local 192.0.2.2/32 dev dummy1" false
121+
check_err $? "Local table route did not replace route in main table when should"
122+
123+
fib4_trap_check $ns "table main 192.0.2.2/32 dev dummy1" true
124+
check_err $? "Main table route was not replaced when should"
125+
126+
log_test "IPv4 local table route replacement"
127+
128+
ip -n $ns link del dev dummy1
129+
}
130+
92131
ipv6_add()
93132
{
94133
fib_ipv6_add_test "testns1"
@@ -149,6 +188,43 @@ ipv6_replay_multipath()
149188
fib_ipv6_replay_multipath_test "testns1" "$DEVLINK_DEV"
150189
}
151190

191+
ipv6_local_replace()
192+
{
193+
local ns="testns1"
194+
195+
RET=0
196+
197+
ip -n $ns link add name dummy1 type dummy
198+
ip -n $ns link set dev dummy1 up
199+
200+
ip -n $ns route add table local 2001:db8:1::1/128 dev dummy1
201+
fib6_trap_check $ns "table local 2001:db8:1::1/128 dev dummy1" false
202+
check_err $? "Local table route not in hardware when should"
203+
204+
ip -n $ns route add table main 2001:db8:1::1/128 dev dummy1
205+
fib6_trap_check $ns "table main 2001:db8:1::1/128 dev dummy1" true
206+
check_err $? "Main table route in hardware when should not"
207+
208+
fib6_trap_check $ns "table local 2001:db8:1::1/128 dev dummy1" false
209+
check_err $? "Local table route was replaced when should not"
210+
211+
# Test that local routes can replace routes in main table.
212+
ip -n $ns route add table main 2001:db8:1::2/128 dev dummy1
213+
fib6_trap_check $ns "table main 2001:db8:1::2/128 dev dummy1" false
214+
check_err $? "Main table route not in hardware when should"
215+
216+
ip -n $ns route add table local 2001:db8:1::2/128 dev dummy1
217+
fib6_trap_check $ns "table local 2001:db8:1::2/128 dev dummy1" false
218+
check_err $? "Local route route did not replace route in main table when should"
219+
220+
fib6_trap_check $ns "table main 2001:db8:1::2/128 dev dummy1" true
221+
check_err $? "Main table route was not replaced when should"
222+
223+
log_test "IPv6 local table route replacement"
224+
225+
ip -n $ns link del dev dummy1
226+
}
227+
152228
setup_prepare()
153229
{
154230
ip netns add testns1

0 commit comments

Comments
 (0)