2 # SPDX-License-Identifier: GPL-2.0
4 # This test is for checking IPv4 and IPv6 FIB behavior in response to
8 # Kselftest framework requirement - SKIP code is 4.
11 # all tests in this script. Can be overridden with -t option
12 TESTS="unregister down carrier nexthop ipv6_rt ipv4_rt ipv6_addr_metric ipv4_addr_metric ipv6_route_metrics ipv4_route_metrics"
24 if [ ${rc} -eq ${expected} ]; then
25 printf " TEST: %-60s [ OK ]\n" "${msg}"
26 nsuccess=$((nsuccess+1))
30 printf " TEST: %-60s [FAIL]\n" "${msg}"
31 if [ "${PAUSE_ON_FAIL}" = "yes" ]; then
33 echo "hit enter to continue, 'q' to quit"
35 [ "$a" = "q" ] && exit 1
39 if [ "${PAUSE}" = "yes" ]; then
41 echo "hit enter to continue, 'q' to quit"
43 [ "$a" = "q" ] && exit 1
51 $IP link set dev lo up
52 ip netns exec ns1 sysctl -qw net.ipv4.ip_forward=1
53 ip netns exec ns1 sysctl -qw net.ipv6.conf.all.forwarding=1
55 $IP link add dummy0 type dummy
56 $IP link set dev dummy0 up
57 $IP address add 198.51.100.1/24 dev dummy0
58 $IP -6 address add 2001:db8:1::1/64 dev dummy0
65 $IP link del dev dummy0 &> /dev/null
67 ip netns del ns2 &> /dev/null
75 addr=$($IP -6 -br addr show dev ${dev} | \
77 for (i = 3; i <= NF; ++i) {
85 [ -z "$addr" ] && return 1
92 fib_unreg_unicast_test()
95 echo "Single path route test"
100 $IP route get fibmatch 198.51.100.2 &> /dev/null
101 log_test $? 0 "IPv4 fibmatch"
102 $IP -6 route get fibmatch 2001:db8:1::2 &> /dev/null
103 log_test $? 0 "IPv6 fibmatch"
106 $IP link del dev dummy0
109 echo " Nexthop device deleted"
110 $IP route get fibmatch 198.51.100.2 &> /dev/null
111 log_test $? 2 "IPv4 fibmatch - no route"
112 $IP -6 route get fibmatch 2001:db8:1::2 &> /dev/null
113 log_test $? 2 "IPv6 fibmatch - no route"
118 fib_unreg_multipath_test()
122 echo "Multipath route test"
127 $IP link add dummy1 type dummy
128 $IP link set dev dummy1 up
129 $IP address add 192.0.2.1/24 dev dummy1
130 $IP -6 address add 2001:db8:2::1/64 dev dummy1
132 $IP route add 203.0.113.0/24 \
133 nexthop via 198.51.100.2 dev dummy0 \
134 nexthop via 192.0.2.2 dev dummy1
135 $IP -6 route add 2001:db8:3::/64 \
136 nexthop via 2001:db8:1::2 dev dummy0 \
137 nexthop via 2001:db8:2::2 dev dummy1
141 $IP route get fibmatch 203.0.113.1 &> /dev/null
142 log_test $? 0 "IPv4 fibmatch"
143 $IP -6 route get fibmatch 2001:db8:3::1 &> /dev/null
144 log_test $? 0 "IPv6 fibmatch"
147 $IP link del dev dummy0
150 echo " One nexthop device deleted"
151 $IP route get fibmatch 203.0.113.1 &> /dev/null
152 log_test $? 2 "IPv4 - multipath route removed on delete"
154 $IP -6 route get fibmatch 2001:db8:3::1 &> /dev/null
155 # In IPv6 we do not flush the entire multipath route.
156 log_test $? 0 "IPv6 - multipath down to single path"
159 $IP link del dev dummy1
162 echo " Second nexthop device deleted"
163 $IP -6 route get fibmatch 2001:db8:3::1 &> /dev/null
164 log_test $? 2 "IPv6 - no route"
171 fib_unreg_unicast_test
172 fib_unreg_multipath_test
175 fib_down_unicast_test()
178 echo "Single path, admin down"
183 $IP route get fibmatch 198.51.100.2 &> /dev/null
184 log_test $? 0 "IPv4 fibmatch"
185 $IP -6 route get fibmatch 2001:db8:1::2 &> /dev/null
186 log_test $? 0 "IPv6 fibmatch"
189 $IP link set dev dummy0 down
192 echo " Route deleted on down"
193 $IP route get fibmatch 198.51.100.2 &> /dev/null
194 log_test $? 2 "IPv4 fibmatch"
195 $IP -6 route get fibmatch 2001:db8:1::2 &> /dev/null
196 log_test $? 2 "IPv6 fibmatch"
201 fib_down_multipath_test_do()
206 $IP route get fibmatch 203.0.113.1 \
207 oif $down_dev &> /dev/null
208 log_test $? 2 "IPv4 fibmatch on down device"
209 $IP -6 route get fibmatch 2001:db8:3::1 \
210 oif $down_dev &> /dev/null
211 log_test $? 2 "IPv6 fibmatch on down device"
213 $IP route get fibmatch 203.0.113.1 \
214 oif $up_dev &> /dev/null
215 log_test $? 0 "IPv4 fibmatch on up device"
216 $IP -6 route get fibmatch 2001:db8:3::1 \
217 oif $up_dev &> /dev/null
218 log_test $? 0 "IPv6 fibmatch on up device"
220 $IP route get fibmatch 203.0.113.1 | \
221 grep $down_dev | grep -q "dead linkdown"
222 log_test $? 0 "IPv4 flags on down device"
223 $IP -6 route get fibmatch 2001:db8:3::1 | \
224 grep $down_dev | grep -q "dead linkdown"
225 log_test $? 0 "IPv6 flags on down device"
227 $IP route get fibmatch 203.0.113.1 | \
228 grep $up_dev | grep -q "dead linkdown"
229 log_test $? 1 "IPv4 flags on up device"
230 $IP -6 route get fibmatch 2001:db8:3::1 | \
231 grep $up_dev | grep -q "dead linkdown"
232 log_test $? 1 "IPv6 flags on up device"
235 fib_down_multipath_test()
238 echo "Admin down multipath"
243 $IP link add dummy1 type dummy
244 $IP link set dev dummy1 up
246 $IP address add 192.0.2.1/24 dev dummy1
247 $IP -6 address add 2001:db8:2::1/64 dev dummy1
249 $IP route add 203.0.113.0/24 \
250 nexthop via 198.51.100.2 dev dummy0 \
251 nexthop via 192.0.2.2 dev dummy1
252 $IP -6 route add 2001:db8:3::/64 \
253 nexthop via 2001:db8:1::2 dev dummy0 \
254 nexthop via 2001:db8:2::2 dev dummy1
257 echo " Verify start point"
258 $IP route get fibmatch 203.0.113.1 &> /dev/null
259 log_test $? 0 "IPv4 fibmatch"
261 $IP -6 route get fibmatch 2001:db8:3::1 &> /dev/null
262 log_test $? 0 "IPv6 fibmatch"
265 $IP link set dev dummy0 down
268 echo " One device down, one up"
269 fib_down_multipath_test_do "dummy0" "dummy1"
272 $IP link set dev dummy0 up
273 $IP link set dev dummy1 down
276 echo " Other device down and up"
277 fib_down_multipath_test_do "dummy1" "dummy0"
280 $IP link set dev dummy0 down
283 echo " Both devices down"
284 $IP route get fibmatch 203.0.113.1 &> /dev/null
285 log_test $? 2 "IPv4 fibmatch"
286 $IP -6 route get fibmatch 2001:db8:3::1 &> /dev/null
287 log_test $? 2 "IPv6 fibmatch"
289 $IP link del dev dummy1
295 fib_down_unicast_test
296 fib_down_multipath_test
299 # Local routes should not be affected when carrier changes.
300 fib_carrier_local_test()
303 echo "Local carrier tests - single path"
308 $IP link set dev dummy0 carrier on
312 $IP route get fibmatch 198.51.100.1 &> /dev/null
313 log_test $? 0 "IPv4 fibmatch"
314 $IP -6 route get fibmatch 2001:db8:1::1 &> /dev/null
315 log_test $? 0 "IPv6 fibmatch"
317 $IP route get fibmatch 198.51.100.1 | \
319 log_test $? 1 "IPv4 - no linkdown flag"
320 $IP -6 route get fibmatch 2001:db8:1::1 | \
322 log_test $? 1 "IPv6 - no linkdown flag"
325 $IP link set dev dummy0 carrier off
329 echo " Carrier off on nexthop"
330 $IP route get fibmatch 198.51.100.1 &> /dev/null
331 log_test $? 0 "IPv4 fibmatch"
332 $IP -6 route get fibmatch 2001:db8:1::1 &> /dev/null
333 log_test $? 0 "IPv6 fibmatch"
335 $IP route get fibmatch 198.51.100.1 | \
337 log_test $? 1 "IPv4 - linkdown flag set"
338 $IP -6 route get fibmatch 2001:db8:1::1 | \
340 log_test $? 1 "IPv6 - linkdown flag set"
343 $IP address add 192.0.2.1/24 dev dummy0
344 $IP -6 address add 2001:db8:2::1/64 dev dummy0
347 echo " Route to local address with carrier down"
348 $IP route get fibmatch 192.0.2.1 &> /dev/null
349 log_test $? 0 "IPv4 fibmatch"
350 $IP -6 route get fibmatch 2001:db8:2::1 &> /dev/null
351 log_test $? 0 "IPv6 fibmatch"
353 $IP route get fibmatch 192.0.2.1 | \
355 log_test $? 1 "IPv4 linkdown flag set"
356 $IP -6 route get fibmatch 2001:db8:2::1 | \
358 log_test $? 1 "IPv6 linkdown flag set"
363 fib_carrier_unicast_test()
368 echo "Single path route carrier test"
373 $IP link set dev dummy0 carrier on
377 $IP route get fibmatch 198.51.100.2 &> /dev/null
378 log_test $? 0 "IPv4 fibmatch"
379 $IP -6 route get fibmatch 2001:db8:1::2 &> /dev/null
380 log_test $? 0 "IPv6 fibmatch"
382 $IP route get fibmatch 198.51.100.2 | \
384 log_test $? 1 "IPv4 no linkdown flag"
385 $IP -6 route get fibmatch 2001:db8:1::2 | \
387 log_test $? 1 "IPv6 no linkdown flag"
390 $IP link set dev dummy0 carrier off
395 $IP route get fibmatch 198.51.100.2 &> /dev/null
396 log_test $? 0 "IPv4 fibmatch"
397 $IP -6 route get fibmatch 2001:db8:1::2 &> /dev/null
398 log_test $? 0 "IPv6 fibmatch"
400 $IP route get fibmatch 198.51.100.2 | \
402 log_test $? 0 "IPv4 linkdown flag set"
403 $IP -6 route get fibmatch 2001:db8:1::2 | \
405 log_test $? 0 "IPv6 linkdown flag set"
408 $IP address add 192.0.2.1/24 dev dummy0
409 $IP -6 address add 2001:db8:2::1/64 dev dummy0
412 echo " Second address added with carrier down"
413 $IP route get fibmatch 192.0.2.2 &> /dev/null
414 log_test $? 0 "IPv4 fibmatch"
415 $IP -6 route get fibmatch 2001:db8:2::2 &> /dev/null
416 log_test $? 0 "IPv6 fibmatch"
418 $IP route get fibmatch 192.0.2.2 | \
420 log_test $? 0 "IPv4 linkdown flag set"
421 $IP -6 route get fibmatch 2001:db8:2::2 | \
423 log_test $? 0 "IPv6 linkdown flag set"
430 fib_carrier_local_test
431 fib_carrier_unicast_test
434 ################################################################################
435 # Tests on nexthop spec
437 # run 'ip route add' with given spec
448 [ "$vrf" = "-" ] && vrf="default"
449 [ -n "$gw" ] && gw="via $gw"
450 [ -n "$dev" ] && dev="dev $dev"
452 cmd="$IP route add vrf $vrf $pfx $gw $dev"
453 if [ "$VERBOSE" = "1" ]; then
454 printf "\n COMMAND: $cmd\n"
457 out=$(eval $cmd 2>&1)
459 if [ "$VERBOSE" = "1" -a -n "$out" ]; then
462 log_test $rc $erc "$desc"
468 echo "IPv4 nexthop tests"
470 echo "<<< write me >>>"
475 local lldummy=$(get_linklocal dummy0)
476 local llv1=$(get_linklocal dummy0)
478 if [ -z "$lldummy" ]; then
479 echo "Failed to get linklocal address for dummy0"
482 if [ -z "$llv1" ]; then
483 echo "Failed to get linklocal address for veth1"
488 echo "IPv6 nexthop tests"
490 add_rt "Directly connected nexthop, unicast address" 0 \
491 - 2001:db8:101::/64 2001:db8:1::2
492 add_rt "Directly connected nexthop, unicast address with device" 0 \
493 - 2001:db8:102::/64 2001:db8:1::2 "dummy0"
494 add_rt "Gateway is linklocal address" 0 \
495 - 2001:db8:103::1/64 $llv1 "veth0"
497 # fails because LL address requires a device
498 add_rt "Gateway is linklocal address, no device" 2 \
499 - 2001:db8:104::1/64 $llv1
501 # local address can not be a gateway
502 add_rt "Gateway can not be local unicast address" 2 \
503 - 2001:db8:105::/64 2001:db8:1::1
504 add_rt "Gateway can not be local unicast address, with device" 2 \
505 - 2001:db8:106::/64 2001:db8:1::1 "dummy0"
506 add_rt "Gateway can not be a local linklocal address" 2 \
507 - 2001:db8:107::1/64 $lldummy "dummy0"
510 add_rt "Gateway can be local address in a VRF" 0 \
511 - 2001:db8:108::/64 2001:db8:51::2
512 add_rt "Gateway can be local address in a VRF, with device" 0 \
513 - 2001:db8:109::/64 2001:db8:51::2 "veth0"
514 add_rt "Gateway can be local linklocal address in a VRF" 0 \
515 - 2001:db8:110::1/64 $llv1 "veth0"
517 add_rt "Redirect to VRF lookup" 0 \
518 - 2001:db8:111::/64 "" "red"
520 add_rt "VRF route, gateway can be local address in default VRF" 0 \
521 red 2001:db8:112::/64 2001:db8:51::1
523 # local address in same VRF fails
524 add_rt "VRF route, gateway can not be a local address" 2 \
525 red 2001:db8:113::1/64 2001:db8:2::1
526 add_rt "VRF route, gateway can not be a local addr with device" 2 \
527 red 2001:db8:114::1/64 2001:db8:2::1 "dummy1"
531 # dummy0 - 198.51.100.1/24 2001:db8:1::1/64
532 # veth0 - 192.0.2.1/24 2001:db8:51::1/64
535 # dummy1 - 192.168.2.1/24 2001:db8:2::1/64
536 # veth1 - 192.0.2.2/24 2001:db8:51::2/64
538 # [ dummy0 veth0 ]--[ veth1 dummy1 ]
546 $IP -4 rule add pref 32765 table local
547 $IP -4 rule del pref 0
548 $IP -6 rule add pref 32765 table local
549 $IP -6 rule del pref 0
551 $IP link add red type vrf table 1
553 $IP -4 route add vrf red unreachable default metric 4278198272
554 $IP -6 route add vrf red unreachable default metric 4278198272
556 $IP link add veth0 type veth peer name veth1
557 $IP link set dev veth0 up
558 $IP address add 192.0.2.1/24 dev veth0
559 $IP -6 address add 2001:db8:51::1/64 dev veth0
561 $IP link set dev veth1 vrf red up
562 $IP address add 192.0.2.2/24 dev veth1
563 $IP -6 address add 2001:db8:51::2/64 dev veth1
565 $IP link add dummy1 type dummy
566 $IP link set dev dummy1 vrf red up
567 $IP address add 192.168.2.1/24 dev dummy1
568 $IP -6 address add 2001:db8:2::1/64 dev dummy1
576 $IP link del dev dummy1
583 ################################################################################
584 # Tests on route add and replace
590 local stderr="2>/dev/null"
592 if [ "$VERBOSE" = "1" ]; then
593 printf " COMMAND: $cmd\n"
597 out=$(eval $cmd $stderr)
599 if [ "$VERBOSE" = "1" -a -n "$out" ]; then
603 [ "$VERBOSE" = "1" ] && echo
614 [ "${out}" = "${expected}" ] && return 0
616 if [ -z "${out}" ]; then
617 if [ "$VERBOSE" = "1" ]; then
618 printf "\nNo route entry found\n"
620 printf " ${expected}\n"
625 # tricky way to convert output to 1-line without ip's
626 # messy '\'; this drops all extra white space
628 if [ "${out}" != "${expected}" ]; then
630 if [ "${VERBOSE}" = "1" ]; then
631 printf " Unexpected route entry. Have:\n"
633 printf " Expected:\n"
634 printf " ${expected}\n\n"
641 # add route for a prefix, flushing any existing routes first
642 # expected to be the first step of a test
649 if [ "$VERBOSE" = "1" ]; then
651 echo " ##################################################"
655 run_cmd "$IP -6 ro flush ${pfx}"
656 [ $? -ne 0 ] && exit 1
658 out=$($IP -6 ro ls match ${pfx})
659 if [ -n "$out" ]; then
660 echo "Failed to flush routes for prefix used for tests."
664 run_cmd "$IP -6 ro add ${pfx} ${nh}"
665 if [ $? -ne 0 ]; then
666 echo "Failed to add initial route for test."
671 # add initial route - used in replace route tests
674 add_route6 "2001:db8:104::/64" "$1"
687 out=$($IP -6 ro ls match ${pfx} | sed -e 's/ pref medium//')
688 check_expected "${out}" "${expected}"
693 $IP li del red 2>/dev/null
694 $IP li del dummy1 2>/dev/null
695 $IP li del veth1 2>/dev/null
696 $IP li del veth3 2>/dev/null
706 [ "${VERBOSE}" = "1" ] && set -x
710 ip -netns ns2 link set dev lo up
711 ip netns exec ns2 sysctl -qw net.ipv4.ip_forward=1
712 ip netns exec ns2 sysctl -qw net.ipv6.conf.all.forwarding=1
714 $IP li add veth1 type veth peer name veth2
715 $IP li add veth3 type veth peer name veth4
719 $IP li set veth2 netns ns2 up
720 $IP li set veth4 netns ns2 up
721 ip -netns ns2 li add dummy1 type dummy
722 ip -netns ns2 li set dummy1 up
724 $IP -6 addr add 2001:db8:101::1/64 dev veth1 nodad
725 $IP -6 addr add 2001:db8:103::1/64 dev veth3 nodad
726 $IP addr add 172.16.101.1/24 dev veth1
727 $IP addr add 172.16.103.1/24 dev veth3
729 ip -netns ns2 -6 addr add 2001:db8:101::2/64 dev veth2 nodad
730 ip -netns ns2 -6 addr add 2001:db8:103::2/64 dev veth4 nodad
731 ip -netns ns2 -6 addr add 2001:db8:104::1/64 dev dummy1 nodad
733 ip -netns ns2 addr add 172.16.101.2/24 dev veth2
734 ip -netns ns2 addr add 172.16.103.2/24 dev veth4
735 ip -netns ns2 addr add 172.16.104.1/24 dev dummy1
740 # assumption is that basic add of a single path route works
741 # otherwise just adding an address on an interface is broken
747 echo "IPv6 route add / append tests"
749 # route add same prefix - fails with EEXISTS b/c ip adds NLM_F_EXCL
750 add_route6 "2001:db8:104::/64" "via 2001:db8:101::2"
751 run_cmd "$IP -6 ro add 2001:db8:104::/64 via 2001:db8:103::2"
752 log_test $? 2 "Attempt to add duplicate route - gw"
754 # route add same prefix - fails with EEXISTS b/c ip adds NLM_F_EXCL
755 add_route6 "2001:db8:104::/64" "via 2001:db8:101::2"
756 run_cmd "$IP -6 ro add 2001:db8:104::/64 dev veth3"
757 log_test $? 2 "Attempt to add duplicate route - dev only"
759 # route add same prefix - fails with EEXISTS b/c ip adds NLM_F_EXCL
760 add_route6 "2001:db8:104::/64" "via 2001:db8:101::2"
761 run_cmd "$IP -6 ro add unreachable 2001:db8:104::/64"
762 log_test $? 2 "Attempt to add duplicate route - reject route"
764 # route append with same prefix adds a new route
765 # - iproute2 sets NLM_F_CREATE | NLM_F_APPEND
766 add_route6 "2001:db8:104::/64" "via 2001:db8:101::2"
767 run_cmd "$IP -6 ro append 2001:db8:104::/64 via 2001:db8:103::2"
768 check_route6 "2001:db8:104::/64 metric 1024 nexthop via 2001:db8:101::2 dev veth1 weight 1 nexthop via 2001:db8:103::2 dev veth3 weight 1"
769 log_test $? 0 "Append nexthop to existing route - gw"
771 # insert mpath directly
772 add_route6 "2001:db8:104::/64" "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
773 check_route6 "2001:db8:104::/64 metric 1024 nexthop via 2001:db8:101::2 dev veth1 weight 1 nexthop via 2001:db8:103::2 dev veth3 weight 1"
774 log_test $? 0 "Add multipath route"
776 add_route6 "2001:db8:104::/64" "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
777 run_cmd "$IP -6 ro add 2001:db8:104::/64 nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
778 log_test $? 2 "Attempt to add duplicate multipath route"
780 # insert of a second route without append but different metric
781 add_route6 "2001:db8:104::/64" "via 2001:db8:101::2"
782 run_cmd "$IP -6 ro add 2001:db8:104::/64 via 2001:db8:103::2 metric 512"
784 if [ $rc -eq 0 ]; then
785 run_cmd "$IP -6 ro add 2001:db8:104::/64 via 2001:db8:103::3 metric 256"
788 log_test $rc 0 "Route add with different metrics"
790 run_cmd "$IP -6 ro del 2001:db8:104::/64 metric 512"
792 if [ $rc -eq 0 ]; then
793 check_route6 "2001:db8:104::/64 via 2001:db8:103::3 dev veth3 metric 256 2001:db8:104::/64 via 2001:db8:101::2 dev veth1 metric 1024"
796 log_test $rc 0 "Route delete with metric"
799 ipv6_rt_replace_single()
801 # single path with single path
803 add_initial_route6 "via 2001:db8:101::2"
804 run_cmd "$IP -6 ro replace 2001:db8:104::/64 via 2001:db8:103::2"
805 check_route6 "2001:db8:104::/64 via 2001:db8:103::2 dev veth3 metric 1024"
806 log_test $? 0 "Single path with single path"
808 # single path with multipath
810 add_initial_route6 "nexthop via 2001:db8:101::2"
811 run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:101::3 nexthop via 2001:db8:103::2"
812 check_route6 "2001:db8:104::/64 metric 1024 nexthop via 2001:db8:101::3 dev veth1 weight 1 nexthop via 2001:db8:103::2 dev veth3 weight 1"
813 log_test $? 0 "Single path with multipath"
815 # single path with single path using MULTIPATH attribute
817 add_initial_route6 "via 2001:db8:101::2"
818 run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:103::2"
819 check_route6 "2001:db8:104::/64 via 2001:db8:103::2 dev veth3 metric 1024"
820 log_test $? 0 "Single path with single path via multipath attribute"
822 # route replace fails - invalid nexthop
823 add_initial_route6 "via 2001:db8:101::2"
824 run_cmd "$IP -6 ro replace 2001:db8:104::/64 via 2001:db8:104::2"
825 if [ $? -eq 0 ]; then
826 # previous command is expected to fail so if it returns 0
827 # that means the test failed.
828 log_test 0 1 "Invalid nexthop"
830 check_route6 "2001:db8:104::/64 via 2001:db8:101::2 dev veth1 metric 1024"
831 log_test $? 0 "Invalid nexthop"
834 # replace non-existent route
835 # - note use of change versus replace since ip adds NLM_F_CREATE
837 add_initial_route6 "via 2001:db8:101::2"
838 run_cmd "$IP -6 ro change 2001:db8:105::/64 via 2001:db8:101::2"
839 log_test $? 2 "Single path - replace of non-existent route"
842 ipv6_rt_replace_mpath()
844 # multipath with multipath
845 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
846 run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:101::3 nexthop via 2001:db8:103::3"
847 check_route6 "2001:db8:104::/64 metric 1024 nexthop via 2001:db8:101::3 dev veth1 weight 1 nexthop via 2001:db8:103::3 dev veth3 weight 1"
848 log_test $? 0 "Multipath with multipath"
850 # multipath with single
851 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
852 run_cmd "$IP -6 ro replace 2001:db8:104::/64 via 2001:db8:101::3"
853 check_route6 "2001:db8:104::/64 via 2001:db8:101::3 dev veth1 metric 1024"
854 log_test $? 0 "Multipath with single path"
856 # multipath with single
857 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
858 run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:101::3"
859 check_route6 "2001:db8:104::/64 via 2001:db8:101::3 dev veth1 metric 1024"
860 log_test $? 0 "Multipath with single path via multipath attribute"
862 # route replace fails - invalid nexthop 1
863 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
864 run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:111::3 nexthop via 2001:db8:103::3"
865 check_route6 "2001:db8:104::/64 metric 1024 nexthop via 2001:db8:101::2 dev veth1 weight 1 nexthop via 2001:db8:103::2 dev veth3 weight 1"
866 log_test $? 0 "Multipath - invalid first nexthop"
868 # route replace fails - invalid nexthop 2
869 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
870 run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:101::3 nexthop via 2001:db8:113::3"
871 check_route6 "2001:db8:104::/64 metric 1024 nexthop via 2001:db8:101::2 dev veth1 weight 1 nexthop via 2001:db8:103::2 dev veth3 weight 1"
872 log_test $? 0 "Multipath - invalid second nexthop"
874 # multipath non-existent route
875 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
876 run_cmd "$IP -6 ro change 2001:db8:105::/64 nexthop via 2001:db8:101::3 nexthop via 2001:db8:103::3"
877 log_test $? 2 "Multipath - replace of non-existent route"
883 echo "IPv6 route replace tests"
885 ipv6_rt_replace_single
886 ipv6_rt_replace_mpath
899 ip_addr_metric_check()
901 ip addr help 2>&1 | grep -q metric
902 if [ $? -ne 0 ]; then
903 echo "iproute2 command does not support metric for addresses. Skipping test"
910 ipv6_addr_metric_test()
915 echo "IPv6 prefix route tests"
917 ip_addr_metric_check || return 1
922 $IP li add dummy1 type dummy
923 $IP li add dummy2 type dummy
927 # default entry is metric 256
928 run_cmd "$IP -6 addr add dev dummy1 2001:db8:104::1/64"
929 run_cmd "$IP -6 addr add dev dummy2 2001:db8:104::2/64"
932 check_route6 "2001:db8:104::/64 dev dummy1 proto kernel metric 256 2001:db8:104::/64 dev dummy2 proto kernel metric 256"
933 log_test $? 0 "Default metric"
936 run_cmd "$IP -6 addr flush dev dummy1"
937 run_cmd "$IP -6 addr add dev dummy1 2001:db8:104::1/64 metric 257"
940 check_route6 "2001:db8:104::/64 dev dummy2 proto kernel metric 256 2001:db8:104::/64 dev dummy1 proto kernel metric 257"
941 log_test $? 0 "User specified metric on first device"
944 run_cmd "$IP -6 addr flush dev dummy2"
945 run_cmd "$IP -6 addr add dev dummy2 2001:db8:104::2/64 metric 258"
948 check_route6 "2001:db8:104::/64 dev dummy1 proto kernel metric 257 2001:db8:104::/64 dev dummy2 proto kernel metric 258"
949 log_test $? 0 "User specified metric on second device"
951 run_cmd "$IP -6 addr del dev dummy1 2001:db8:104::1/64 metric 257"
953 if [ $rc -eq 0 ]; then
954 check_route6 "2001:db8:104::/64 dev dummy2 proto kernel metric 258"
957 log_test $rc 0 "Delete of address on first device"
959 run_cmd "$IP -6 addr change dev dummy2 2001:db8:104::2/64 metric 259"
961 if [ $rc -eq 0 ]; then
962 check_route6 "2001:db8:104::/64 dev dummy2 proto kernel metric 259"
965 log_test $rc 0 "Modify metric of address"
967 # verify prefix route removed on down
968 run_cmd "ip netns exec ns1 sysctl -qw net.ipv6.conf.all.keep_addr_on_down=1"
969 run_cmd "$IP li set dev dummy2 down"
971 if [ $rc -eq 0 ]; then
972 out=$($IP -6 ro ls match 2001:db8:104::/64)
973 check_expected "${out}" ""
976 log_test $rc 0 "Prefix route removed on link down"
978 # verify prefix route re-inserted with assigned metric
979 run_cmd "$IP li set dev dummy2 up"
981 if [ $rc -eq 0 ]; then
982 check_route6 "2001:db8:104::/64 dev dummy2 proto kernel metric 259"
985 log_test $rc 0 "Prefix route with metric on link up"
992 ipv6_route_metrics_test()
997 echo "IPv6 routes with metrics"
1002 # single path with metrics
1004 run_cmd "$IP -6 ro add 2001:db8:111::/64 via 2001:db8:101::2 mtu 1400"
1006 if [ $rc -eq 0 ]; then
1007 check_route6 "2001:db8:111::/64 via 2001:db8:101::2 dev veth1 metric 1024 mtu 1400"
1010 log_test $rc 0 "Single path route with mtu metric"
1014 # multipath via separate routes with metrics
1016 run_cmd "$IP -6 ro add 2001:db8:112::/64 via 2001:db8:101::2 mtu 1400"
1017 run_cmd "$IP -6 ro append 2001:db8:112::/64 via 2001:db8:103::2"
1019 if [ $rc -eq 0 ]; then
1020 check_route6 "2001:db8:112::/64 metric 1024 mtu 1400 nexthop via 2001:db8:101::2 dev veth1 weight 1 nexthop via 2001:db8:103::2 dev veth3 weight 1"
1023 log_test $rc 0 "Multipath route via 2 single routes with mtu metric on first"
1025 # second route is coalesced to first to make a multipath route.
1026 # MTU of the second path is hidden from display!
1027 run_cmd "$IP -6 ro add 2001:db8:113::/64 via 2001:db8:101::2"
1028 run_cmd "$IP -6 ro append 2001:db8:113::/64 via 2001:db8:103::2 mtu 1400"
1030 if [ $rc -eq 0 ]; then
1031 check_route6 "2001:db8:113::/64 metric 1024 nexthop via 2001:db8:101::2 dev veth1 weight 1 nexthop via 2001:db8:103::2 dev veth3 weight 1"
1034 log_test $rc 0 "Multipath route via 2 single routes with mtu metric on 2nd"
1036 run_cmd "$IP -6 ro del 2001:db8:113::/64 via 2001:db8:101::2"
1037 if [ $? -eq 0 ]; then
1038 check_route6 "2001:db8:113::/64 via 2001:db8:103::2 dev veth3 metric 1024 mtu 1400"
1039 log_test $? 0 " MTU of second leg"
1043 # multipath with metrics
1045 run_cmd "$IP -6 ro add 2001:db8:115::/64 mtu 1400 nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
1047 if [ $rc -eq 0 ]; then
1048 check_route6 "2001:db8:115::/64 metric 1024 mtu 1400 nexthop via 2001:db8:101::2 dev veth1 weight 1 nexthop via 2001:db8:103::2 dev veth3 weight 1"
1051 log_test $rc 0 "Multipath route with mtu metric"
1053 $IP -6 ro add 2001:db8:104::/64 via 2001:db8:101::2 mtu 1300
1054 run_cmd "ip netns exec ns1 ping6 -w1 -c1 -s 1500 2001:db8:104::1"
1055 log_test $? 0 "Using route with mtu metric"
1057 run_cmd "$IP -6 ro add 2001:db8:114::/64 via 2001:db8:101::2 congctl lock foo"
1058 log_test $? 2 "Invalid metric (fails metric_convert)"
1063 # add route for a prefix, flushing any existing routes first
1064 # expected to be the first step of a test
1071 if [ "$VERBOSE" = "1" ]; then
1073 echo " ##################################################"
1077 run_cmd "$IP ro flush ${pfx}"
1078 [ $? -ne 0 ] && exit 1
1080 out=$($IP ro ls match ${pfx})
1081 if [ -n "$out" ]; then
1082 echo "Failed to flush routes for prefix used for tests."
1086 run_cmd "$IP ro add ${pfx} ${nh}"
1087 if [ $? -ne 0 ]; then
1088 echo "Failed to add initial route for test."
1093 # add initial route - used in replace route tests
1096 add_route "172.16.104.0/24" "$1"
1107 [ "${pfx}" = "unreachable" ] && pfx=$2
1109 out=$($IP ro ls match ${pfx})
1110 check_expected "${out}" "${expected}"
1113 # assumption is that basic add of a single path route works
1114 # otherwise just adding an address on an interface is broken
1120 echo "IPv4 route add / append tests"
1122 # route add same prefix - fails with EEXISTS b/c ip adds NLM_F_EXCL
1123 add_route "172.16.104.0/24" "via 172.16.101.2"
1124 run_cmd "$IP ro add 172.16.104.0/24 via 172.16.103.2"
1125 log_test $? 2 "Attempt to add duplicate route - gw"
1127 # route add same prefix - fails with EEXISTS b/c ip adds NLM_F_EXCL
1128 add_route "172.16.104.0/24" "via 172.16.101.2"
1129 run_cmd "$IP ro add 172.16.104.0/24 dev veth3"
1130 log_test $? 2 "Attempt to add duplicate route - dev only"
1132 # route add same prefix - fails with EEXISTS b/c ip adds NLM_F_EXCL
1133 add_route "172.16.104.0/24" "via 172.16.101.2"
1134 run_cmd "$IP ro add unreachable 172.16.104.0/24"
1135 log_test $? 2 "Attempt to add duplicate route - reject route"
1137 # iproute2 prepend only sets NLM_F_CREATE
1138 # - adds a new route; does NOT convert existing route to ECMP
1139 add_route "172.16.104.0/24" "via 172.16.101.2"
1140 run_cmd "$IP ro prepend 172.16.104.0/24 via 172.16.103.2"
1141 check_route "172.16.104.0/24 via 172.16.103.2 dev veth3 172.16.104.0/24 via 172.16.101.2 dev veth1"
1142 log_test $? 0 "Add new nexthop for existing prefix"
1144 # route append with same prefix adds a new route
1145 # - iproute2 sets NLM_F_CREATE | NLM_F_APPEND
1146 add_route "172.16.104.0/24" "via 172.16.101.2"
1147 run_cmd "$IP ro append 172.16.104.0/24 via 172.16.103.2"
1148 check_route "172.16.104.0/24 via 172.16.101.2 dev veth1 172.16.104.0/24 via 172.16.103.2 dev veth3"
1149 log_test $? 0 "Append nexthop to existing route - gw"
1151 add_route "172.16.104.0/24" "via 172.16.101.2"
1152 run_cmd "$IP ro append 172.16.104.0/24 dev veth3"
1153 check_route "172.16.104.0/24 via 172.16.101.2 dev veth1 172.16.104.0/24 dev veth3 scope link"
1154 log_test $? 0 "Append nexthop to existing route - dev only"
1156 add_route "172.16.104.0/24" "via 172.16.101.2"
1157 run_cmd "$IP ro append unreachable 172.16.104.0/24"
1158 check_route "172.16.104.0/24 via 172.16.101.2 dev veth1 unreachable 172.16.104.0/24"
1159 log_test $? 0 "Append nexthop to existing route - reject route"
1161 run_cmd "$IP ro flush 172.16.104.0/24"
1162 run_cmd "$IP ro add unreachable 172.16.104.0/24"
1163 run_cmd "$IP ro append 172.16.104.0/24 via 172.16.103.2"
1164 check_route "unreachable 172.16.104.0/24 172.16.104.0/24 via 172.16.103.2 dev veth3"
1165 log_test $? 0 "Append nexthop to existing reject route - gw"
1167 run_cmd "$IP ro flush 172.16.104.0/24"
1168 run_cmd "$IP ro add unreachable 172.16.104.0/24"
1169 run_cmd "$IP ro append 172.16.104.0/24 dev veth3"
1170 check_route "unreachable 172.16.104.0/24 172.16.104.0/24 dev veth3 scope link"
1171 log_test $? 0 "Append nexthop to existing reject route - dev only"
1173 # insert mpath directly
1174 add_route "172.16.104.0/24" "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1175 check_route "172.16.104.0/24 nexthop via 172.16.101.2 dev veth1 weight 1 nexthop via 172.16.103.2 dev veth3 weight 1"
1176 log_test $? 0 "add multipath route"
1178 add_route "172.16.104.0/24" "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1179 run_cmd "$IP ro add 172.16.104.0/24 nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1180 log_test $? 2 "Attempt to add duplicate multipath route"
1182 # insert of a second route without append but different metric
1183 add_route "172.16.104.0/24" "via 172.16.101.2"
1184 run_cmd "$IP ro add 172.16.104.0/24 via 172.16.103.2 metric 512"
1186 if [ $rc -eq 0 ]; then
1187 run_cmd "$IP ro add 172.16.104.0/24 via 172.16.103.3 metric 256"
1190 log_test $rc 0 "Route add with different metrics"
1192 run_cmd "$IP ro del 172.16.104.0/24 metric 512"
1194 if [ $rc -eq 0 ]; then
1195 check_route "172.16.104.0/24 via 172.16.101.2 dev veth1 172.16.104.0/24 via 172.16.103.3 dev veth3 metric 256"
1198 log_test $rc 0 "Route delete with metric"
1201 ipv4_rt_replace_single()
1203 # single path with single path
1205 add_initial_route "via 172.16.101.2"
1206 run_cmd "$IP ro replace 172.16.104.0/24 via 172.16.103.2"
1207 check_route "172.16.104.0/24 via 172.16.103.2 dev veth3"
1208 log_test $? 0 "Single path with single path"
1210 # single path with multipath
1212 add_initial_route "nexthop via 172.16.101.2"
1213 run_cmd "$IP ro replace 172.16.104.0/24 nexthop via 172.16.101.3 nexthop via 172.16.103.2"
1214 check_route "172.16.104.0/24 nexthop via 172.16.101.3 dev veth1 weight 1 nexthop via 172.16.103.2 dev veth3 weight 1"
1215 log_test $? 0 "Single path with multipath"
1217 # single path with reject
1219 add_initial_route "nexthop via 172.16.101.2"
1220 run_cmd "$IP ro replace unreachable 172.16.104.0/24"
1221 check_route "unreachable 172.16.104.0/24"
1222 log_test $? 0 "Single path with reject route"
1224 # single path with single path using MULTIPATH attribute
1226 add_initial_route "via 172.16.101.2"
1227 run_cmd "$IP ro replace 172.16.104.0/24 nexthop via 172.16.103.2"
1228 check_route "172.16.104.0/24 via 172.16.103.2 dev veth3"
1229 log_test $? 0 "Single path with single path via multipath attribute"
1231 # route replace fails - invalid nexthop
1232 add_initial_route "via 172.16.101.2"
1233 run_cmd "$IP ro replace 172.16.104.0/24 via 2001:db8:104::2"
1234 if [ $? -eq 0 ]; then
1235 # previous command is expected to fail so if it returns 0
1236 # that means the test failed.
1237 log_test 0 1 "Invalid nexthop"
1239 check_route "172.16.104.0/24 via 172.16.101.2 dev veth1"
1240 log_test $? 0 "Invalid nexthop"
1243 # replace non-existent route
1244 # - note use of change versus replace since ip adds NLM_F_CREATE
1246 add_initial_route "via 172.16.101.2"
1247 run_cmd "$IP ro change 172.16.105.0/24 via 172.16.101.2"
1248 log_test $? 2 "Single path - replace of non-existent route"
1251 ipv4_rt_replace_mpath()
1253 # multipath with multipath
1254 add_initial_route "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1255 run_cmd "$IP ro replace 172.16.104.0/24 nexthop via 172.16.101.3 nexthop via 172.16.103.3"
1256 check_route "172.16.104.0/24 nexthop via 172.16.101.3 dev veth1 weight 1 nexthop via 172.16.103.3 dev veth3 weight 1"
1257 log_test $? 0 "Multipath with multipath"
1259 # multipath with single
1260 add_initial_route "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1261 run_cmd "$IP ro replace 172.16.104.0/24 via 172.16.101.3"
1262 check_route "172.16.104.0/24 via 172.16.101.3 dev veth1"
1263 log_test $? 0 "Multipath with single path"
1265 # multipath with single
1266 add_initial_route "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1267 run_cmd "$IP ro replace 172.16.104.0/24 nexthop via 172.16.101.3"
1268 check_route "172.16.104.0/24 via 172.16.101.3 dev veth1"
1269 log_test $? 0 "Multipath with single path via multipath attribute"
1271 # multipath with reject
1272 add_initial_route "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1273 run_cmd "$IP ro replace unreachable 172.16.104.0/24"
1274 check_route "unreachable 172.16.104.0/24"
1275 log_test $? 0 "Multipath with reject route"
1277 # route replace fails - invalid nexthop 1
1278 add_initial_route "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1279 run_cmd "$IP ro replace 172.16.104.0/24 nexthop via 172.16.111.3 nexthop via 172.16.103.3"
1280 check_route "172.16.104.0/24 nexthop via 172.16.101.2 dev veth1 weight 1 nexthop via 172.16.103.2 dev veth3 weight 1"
1281 log_test $? 0 "Multipath - invalid first nexthop"
1283 # route replace fails - invalid nexthop 2
1284 add_initial_route "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1285 run_cmd "$IP ro replace 172.16.104.0/24 nexthop via 172.16.101.3 nexthop via 172.16.113.3"
1286 check_route "172.16.104.0/24 nexthop via 172.16.101.2 dev veth1 weight 1 nexthop via 172.16.103.2 dev veth3 weight 1"
1287 log_test $? 0 "Multipath - invalid second nexthop"
1289 # multipath non-existent route
1290 add_initial_route "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1291 run_cmd "$IP ro change 172.16.105.0/24 nexthop via 172.16.101.3 nexthop via 172.16.103.3"
1292 log_test $? 2 "Multipath - replace of non-existent route"
1298 echo "IPv4 route replace tests"
1300 ipv4_rt_replace_single
1301 ipv4_rt_replace_mpath
1314 ipv4_addr_metric_test()
1319 echo "IPv4 prefix route tests"
1321 ip_addr_metric_check || return 1
1326 $IP li add dummy1 type dummy
1327 $IP li add dummy2 type dummy
1328 $IP li set dummy1 up
1329 $IP li set dummy2 up
1331 # default entry is metric 256
1332 run_cmd "$IP addr add dev dummy1 172.16.104.1/24"
1333 run_cmd "$IP addr add dev dummy2 172.16.104.2/24"
1336 check_route "172.16.104.0/24 dev dummy1 proto kernel scope link src 172.16.104.1 172.16.104.0/24 dev dummy2 proto kernel scope link src 172.16.104.2"
1337 log_test $? 0 "Default metric"
1340 run_cmd "$IP addr flush dev dummy1"
1341 run_cmd "$IP addr add dev dummy1 172.16.104.1/24 metric 257"
1344 check_route "172.16.104.0/24 dev dummy2 proto kernel scope link src 172.16.104.2 172.16.104.0/24 dev dummy1 proto kernel scope link src 172.16.104.1 metric 257"
1345 log_test $? 0 "User specified metric on first device"
1348 run_cmd "$IP addr flush dev dummy2"
1349 run_cmd "$IP addr add dev dummy2 172.16.104.2/24 metric 258"
1352 check_route "172.16.104.0/24 dev dummy1 proto kernel scope link src 172.16.104.1 metric 257 172.16.104.0/24 dev dummy2 proto kernel scope link src 172.16.104.2 metric 258"
1353 log_test $? 0 "User specified metric on second device"
1355 run_cmd "$IP addr del dev dummy1 172.16.104.1/24 metric 257"
1357 if [ $rc -eq 0 ]; then
1358 check_route "172.16.104.0/24 dev dummy2 proto kernel scope link src 172.16.104.2 metric 258"
1361 log_test $rc 0 "Delete of address on first device"
1363 run_cmd "$IP addr change dev dummy2 172.16.104.2/24 metric 259"
1365 if [ $rc -eq 0 ]; then
1366 check_route "172.16.104.0/24 dev dummy2 proto kernel scope link src 172.16.104.2 metric 259"
1369 log_test $rc 0 "Modify metric of address"
1371 # verify prefix route removed on down
1372 run_cmd "$IP li set dev dummy2 down"
1374 if [ $rc -eq 0 ]; then
1375 out=$($IP ro ls match 172.16.104.0/24)
1376 check_expected "${out}" ""
1379 log_test $rc 0 "Prefix route removed on link down"
1381 # verify prefix route re-inserted with assigned metric
1382 run_cmd "$IP li set dev dummy2 up"
1384 if [ $rc -eq 0 ]; then
1385 check_route "172.16.104.0/24 dev dummy2 proto kernel scope link src 172.16.104.2 metric 259"
1388 log_test $rc 0 "Prefix route with metric on link up"
1395 ipv4_route_metrics_test()
1400 echo "IPv4 route add / append tests"
1404 run_cmd "$IP ro add 172.16.111.0/24 via 172.16.101.2 mtu 1400"
1406 if [ $rc -eq 0 ]; then
1407 check_route "172.16.111.0/24 via 172.16.101.2 dev veth1 mtu 1400"
1410 log_test $rc 0 "Single path route with mtu metric"
1413 run_cmd "$IP ro add 172.16.112.0/24 mtu 1400 nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1415 if [ $rc -eq 0 ]; then
1416 check_route "172.16.112.0/24 mtu 1400 nexthop via 172.16.101.2 dev veth1 weight 1 nexthop via 172.16.103.2 dev veth3 weight 1"
1419 log_test $rc 0 "Multipath route with mtu metric"
1421 $IP ro add 172.16.104.0/24 via 172.16.101.2 mtu 1300
1422 run_cmd "ip netns exec ns1 ping -w1 -c1 -s 1500 172.16.104.1"
1423 log_test $? 0 "Using route with mtu metric"
1425 run_cmd "$IP ro add 172.16.111.0/24 via 172.16.101.2 congctl lock foo"
1426 log_test $? 2 "Invalid metric (fails metric_convert)"
1432 ################################################################################
1438 usage: ${0##*/} OPTS
1440 -t <test> Test(s) to run (default: all)
1443 -P Pause after each test before cleanup
1444 -v verbose mode (show commands and output)
1448 ################################################################################
1451 while getopts :t:pPhv o
1455 p) PAUSE_ON_FAIL=yes;;
1457 v) VERBOSE=$(($VERBOSE + 1));;
1463 PEER_CMD="ip netns exec ${PEER_NS}"
1465 # make sure we don't pause twice
1466 [ "${PAUSE}" = "yes" ] && PAUSE_ON_FAIL=no
1468 if [ "$(id -u)" -ne 0 ];then
1469 echo "SKIP: Need root privileges"
1473 if [ ! -x "$(command -v ip)" ]; then
1474 echo "SKIP: Could not run test without ip tool"
1478 ip route help 2>&1 | grep -q fibmatch
1479 if [ $? -ne 0 ]; then
1480 echo "SKIP: iproute2 too old, missing fibmatch"
1485 cleanup &> /dev/null
1490 fib_unreg_test|unregister) fib_unreg_test;;
1491 fib_down_test|down) fib_down_test;;
1492 fib_carrier_test|carrier) fib_carrier_test;;
1493 fib_nexthop_test|nexthop) fib_nexthop_test;;
1494 ipv6_route_test|ipv6_rt) ipv6_route_test;;
1495 ipv4_route_test|ipv4_rt) ipv4_route_test;;
1496 ipv6_addr_metric) ipv6_addr_metric_test;;
1497 ipv4_addr_metric) ipv4_addr_metric_test;;
1498 ipv6_route_metrics) ipv6_route_metrics_test;;
1499 ipv4_route_metrics) ipv4_route_metrics_test;;
1501 help) echo "Test names: $TESTS"; exit 0;;
1505 if [ "$TESTS" != "none" ]; then
1506 printf "\nTests passed: %3d\n" ${nsuccess}
1507 printf "Tests failed: %3d\n" ${nfail}