diff options
author | Ido Schimmel <idosch@mellanox.com> | 2018-01-07 05:45:18 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-01-07 21:29:41 -0500 |
commit | 82e45b6fd29246f36ff8064e74d412c11feaab23 (patch) | |
tree | c7e921c94f3e0522bd99a79d156f02f39fd07e49 | |
parent | 5adb7683b48e35bc863a37e026dc6038ded30560 (diff) |
selftests: fib_tests: Add test cases for netdev carrier change
Check that IPv4 and IPv6 react the same when the carrier of a netdev is
toggled. Local routes should not be affected by this, whereas unicast
routes should.
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Acked-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rwxr-xr-x | tools/testing/selftests/net/fib_tests.sh | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/tools/testing/selftests/net/fib_tests.sh b/tools/testing/selftests/net/fib_tests.sh index 25ba74f8a37e..a9154eefb2e2 100755 --- a/tools/testing/selftests/net/fib_tests.sh +++ b/tools/testing/selftests/net/fib_tests.sh | |||
@@ -260,10 +260,152 @@ fib_down_test() | |||
260 | fib_down_multipath_test | 260 | fib_down_multipath_test |
261 | } | 261 | } |
262 | 262 | ||
263 | fib_carrier_local_test() | ||
264 | { | ||
265 | ret=0 | ||
266 | |||
267 | # Local routes should not be affected when carrier changes. | ||
268 | netns_create "testns" | ||
269 | |||
270 | ip netns exec testns ip link add dummy0 type dummy | ||
271 | ip netns exec testns ip link set dev dummy0 up | ||
272 | |||
273 | ip netns exec testns ip link set dev dummy0 carrier on | ||
274 | |||
275 | ip netns exec testns ip address add 198.51.100.1/24 dev dummy0 | ||
276 | ip netns exec testns ip -6 address add 2001:db8:1::1/64 dev dummy0 | ||
277 | |||
278 | ip netns exec testns ip route get fibmatch 198.51.100.1 &> /dev/null | ||
279 | check_err $? | ||
280 | ip netns exec testns ip -6 route get fibmatch 2001:db8:1::1 &> /dev/null | ||
281 | check_err $? | ||
282 | |||
283 | ip netns exec testns ip route get fibmatch 198.51.100.1 | \ | ||
284 | grep -q "linkdown" | ||
285 | check_fail $? | ||
286 | ip netns exec testns ip -6 route get fibmatch 2001:db8:1::1 | \ | ||
287 | grep -q "linkdown" | ||
288 | check_fail $? | ||
289 | |||
290 | ip netns exec testns ip link set dev dummy0 carrier off | ||
291 | |||
292 | ip netns exec testns ip route get fibmatch 198.51.100.1 &> /dev/null | ||
293 | check_err $? | ||
294 | ip netns exec testns ip -6 route get fibmatch 2001:db8:1::1 &> /dev/null | ||
295 | check_err $? | ||
296 | |||
297 | ip netns exec testns ip route get fibmatch 198.51.100.1 | \ | ||
298 | grep -q "linkdown" | ||
299 | check_fail $? | ||
300 | ip netns exec testns ip -6 route get fibmatch 2001:db8:1::1 | \ | ||
301 | grep -q "linkdown" | ||
302 | check_fail $? | ||
303 | |||
304 | ip netns exec testns ip address add 192.0.2.1/24 dev dummy0 | ||
305 | ip netns exec testns ip -6 address add 2001:db8:2::1/64 dev dummy0 | ||
306 | |||
307 | ip netns exec testns ip route get fibmatch 192.0.2.1 &> /dev/null | ||
308 | check_err $? | ||
309 | ip netns exec testns ip -6 route get fibmatch 2001:db8:2::1 &> /dev/null | ||
310 | check_err $? | ||
311 | |||
312 | ip netns exec testns ip route get fibmatch 192.0.2.1 | \ | ||
313 | grep -q "linkdown" | ||
314 | check_fail $? | ||
315 | ip netns exec testns ip -6 route get fibmatch 2001:db8:2::1 | \ | ||
316 | grep -q "linkdown" | ||
317 | check_fail $? | ||
318 | |||
319 | ip netns exec testns ip link del dev dummy0 | ||
320 | |||
321 | ip netns del testns | ||
322 | |||
323 | if [ $ret -ne 0 ]; then | ||
324 | echo "FAIL: local route carrier test" | ||
325 | return 1 | ||
326 | fi | ||
327 | echo "PASS: local route carrier test" | ||
328 | } | ||
329 | |||
330 | fib_carrier_unicast_test() | ||
331 | { | ||
332 | ret=0 | ||
333 | |||
334 | netns_create "testns" | ||
335 | |||
336 | ip netns exec testns ip link add dummy0 type dummy | ||
337 | ip netns exec testns ip link set dev dummy0 up | ||
338 | |||
339 | ip netns exec testns ip link set dev dummy0 carrier on | ||
340 | |||
341 | ip netns exec testns ip address add 198.51.100.1/24 dev dummy0 | ||
342 | ip netns exec testns ip -6 address add 2001:db8:1::1/64 dev dummy0 | ||
343 | |||
344 | ip netns exec testns ip route get fibmatch 198.51.100.2 &> /dev/null | ||
345 | check_err $? | ||
346 | ip netns exec testns ip -6 route get fibmatch 2001:db8:1::2 &> /dev/null | ||
347 | check_err $? | ||
348 | |||
349 | ip netns exec testns ip route get fibmatch 198.51.100.2 | \ | ||
350 | grep -q "linkdown" | ||
351 | check_fail $? | ||
352 | ip netns exec testns ip -6 route get fibmatch 2001:db8:1::2 | \ | ||
353 | grep -q "linkdown" | ||
354 | check_fail $? | ||
355 | |||
356 | ip netns exec testns ip link set dev dummy0 carrier off | ||
357 | |||
358 | ip netns exec testns ip route get fibmatch 198.51.100.2 &> /dev/null | ||
359 | check_err $? | ||
360 | ip netns exec testns ip -6 route get fibmatch 2001:db8:1::2 &> /dev/null | ||
361 | check_err $? | ||
362 | |||
363 | ip netns exec testns ip route get fibmatch 198.51.100.2 | \ | ||
364 | grep -q "linkdown" | ||
365 | check_err $? | ||
366 | ip netns exec testns ip -6 route get fibmatch 2001:db8:1::2 | \ | ||
367 | grep -q "linkdown" | ||
368 | check_err $? | ||
369 | |||
370 | ip netns exec testns ip address add 192.0.2.1/24 dev dummy0 | ||
371 | ip netns exec testns ip -6 address add 2001:db8:2::1/64 dev dummy0 | ||
372 | |||
373 | ip netns exec testns ip route get fibmatch 192.0.2.2 &> /dev/null | ||
374 | check_err $? | ||
375 | ip netns exec testns ip -6 route get fibmatch 2001:db8:2::2 &> /dev/null | ||
376 | check_err $? | ||
377 | |||
378 | ip netns exec testns ip route get fibmatch 192.0.2.2 | \ | ||
379 | grep -q "linkdown" | ||
380 | check_err $? | ||
381 | ip netns exec testns ip -6 route get fibmatch 2001:db8:2::2 | \ | ||
382 | grep -q "linkdown" | ||
383 | check_err $? | ||
384 | |||
385 | ip netns exec testns ip link del dev dummy0 | ||
386 | |||
387 | ip netns del testns | ||
388 | |||
389 | if [ $ret -ne 0 ]; then | ||
390 | echo "FAIL: unicast route carrier test" | ||
391 | return 1 | ||
392 | fi | ||
393 | echo "PASS: unicast route carrier test" | ||
394 | } | ||
395 | |||
396 | fib_carrier_test() | ||
397 | { | ||
398 | echo "Running netdev carrier change tests" | ||
399 | |||
400 | fib_carrier_local_test | ||
401 | fib_carrier_unicast_test | ||
402 | } | ||
403 | |||
263 | fib_test() | 404 | fib_test() |
264 | { | 405 | { |
265 | fib_unreg_test | 406 | fib_unreg_test |
266 | fib_down_test | 407 | fib_down_test |
408 | fib_carrier_test | ||
267 | } | 409 | } |
268 | 410 | ||
269 | if [ "$(id -u)" -ne 0 ];then | 411 | if [ "$(id -u)" -ne 0 ];then |