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
394 $IP route get fibmatch 198.51.100.2 &> /dev/null
395 log_test $? 0 "IPv4 fibmatch"
396 $IP -6 route get fibmatch 2001:db8:1::2 &> /dev/null
397 log_test $? 0 "IPv6 fibmatch"
399 $IP route get fibmatch 198.51.100.2 | \
401 log_test $? 0 "IPv4 linkdown flag set"
402 $IP -6 route get fibmatch 2001:db8:1::2 | \
404 log_test $? 0 "IPv6 linkdown flag set"
407 $IP address add 192.0.2.1/24 dev dummy0
408 $IP -6 address add 2001:db8:2::1/64 dev dummy0
411 echo " Second address added with carrier down"
412 $IP route get fibmatch 192.0.2.2 &> /dev/null
413 log_test $? 0 "IPv4 fibmatch"
414 $IP -6 route get fibmatch 2001:db8:2::2 &> /dev/null
415 log_test $? 0 "IPv6 fibmatch"
417 $IP route get fibmatch 192.0.2.2 | \
419 log_test $? 0 "IPv4 linkdown flag set"
420 $IP -6 route get fibmatch 2001:db8:2::2 | \
422 log_test $? 0 "IPv6 linkdown flag set"
429 fib_carrier_local_test
430 fib_carrier_unicast_test
433 ################################################################################
434 # Tests on nexthop spec
436 # run 'ip route add' with given spec
447 [ "$vrf" = "-" ] && vrf="default"
448 [ -n "$gw" ] && gw="via $gw"
449 [ -n "$dev" ] && dev="dev $dev"
451 cmd="$IP route add vrf $vrf $pfx $gw $dev"
452 if [ "$VERBOSE" = "1" ]; then
453 printf "\n COMMAND: $cmd\n"
456 out=$(eval $cmd 2>&1)
458 if [ "$VERBOSE" = "1" -a -n "$out" ]; then
461 log_test $rc $erc "$desc"
467 echo "IPv4 nexthop tests"
469 echo "<<< write me >>>"
474 local lldummy=$(get_linklocal dummy0)
475 local llv1=$(get_linklocal dummy0)
477 if [ -z "$lldummy" ]; then
478 echo "Failed to get linklocal address for dummy0"
481 if [ -z "$llv1" ]; then
482 echo "Failed to get linklocal address for veth1"
487 echo "IPv6 nexthop tests"
489 add_rt "Directly connected nexthop, unicast address" 0 \
490 - 2001:db8:101::/64 2001:db8:1::2
491 add_rt "Directly connected nexthop, unicast address with device" 0 \
492 - 2001:db8:102::/64 2001:db8:1::2 "dummy0"
493 add_rt "Gateway is linklocal address" 0 \
494 - 2001:db8:103::1/64 $llv1 "veth0"
496 # fails because LL address requires a device
497 add_rt "Gateway is linklocal address, no device" 2 \
498 - 2001:db8:104::1/64 $llv1
500 # local address can not be a gateway
501 add_rt "Gateway can not be local unicast address" 2 \
502 - 2001:db8:105::/64 2001:db8:1::1
503 add_rt "Gateway can not be local unicast address, with device" 2 \
504 - 2001:db8:106::/64 2001:db8:1::1 "dummy0"
505 add_rt "Gateway can not be a local linklocal address" 2 \
506 - 2001:db8:107::1/64 $lldummy "dummy0"
509 add_rt "Gateway can be local address in a VRF" 0 \
510 - 2001:db8:108::/64 2001:db8:51::2
511 add_rt "Gateway can be local address in a VRF, with device" 0 \
512 - 2001:db8:109::/64 2001:db8:51::2 "veth0"
513 add_rt "Gateway can be local linklocal address in a VRF" 0 \
514 - 2001:db8:110::1/64 $llv1 "veth0"
516 add_rt "Redirect to VRF lookup" 0 \
517 - 2001:db8:111::/64 "" "red"
519 add_rt "VRF route, gateway can be local address in default VRF" 0 \
520 red 2001:db8:112::/64 2001:db8:51::1
522 # local address in same VRF fails
523 add_rt "VRF route, gateway can not be a local address" 2 \
524 red 2001:db8:113::1/64 2001:db8:2::1
525 add_rt "VRF route, gateway can not be a local addr with device" 2 \
526 red 2001:db8:114::1/64 2001:db8:2::1 "dummy1"
530 # dummy0 - 198.51.100.1/24 2001:db8:1::1/64
531 # veth0 - 192.0.2.1/24 2001:db8:51::1/64
534 # dummy1 - 192.168.2.1/24 2001:db8:2::1/64
535 # veth1 - 192.0.2.2/24 2001:db8:51::2/64
537 # [ dummy0 veth0 ]--[ veth1 dummy1 ]
545 $IP -4 rule add pref 32765 table local
546 $IP -4 rule del pref 0
547 $IP -6 rule add pref 32765 table local
548 $IP -6 rule del pref 0
550 $IP link add red type vrf table 1
552 $IP -4 route add vrf red unreachable default metric 4278198272
553 $IP -6 route add vrf red unreachable default metric 4278198272
555 $IP link add veth0 type veth peer name veth1
556 $IP link set dev veth0 up
557 $IP address add 192.0.2.1/24 dev veth0
558 $IP -6 address add 2001:db8:51::1/64 dev veth0
560 $IP link set dev veth1 vrf red up
561 $IP address add 192.0.2.2/24 dev veth1
562 $IP -6 address add 2001:db8:51::2/64 dev veth1
564 $IP link add dummy1 type dummy
565 $IP link set dev dummy1 vrf red up
566 $IP address add 192.168.2.1/24 dev dummy1
567 $IP -6 address add 2001:db8:2::1/64 dev dummy1
575 $IP link del dev dummy1
582 ################################################################################
583 # Tests on route add and replace
589 local stderr="2>/dev/null"
591 if [ "$VERBOSE" = "1" ]; then
592 printf " COMMAND: $cmd\n"
596 out=$(eval $cmd $stderr)
598 if [ "$VERBOSE" = "1" -a -n "$out" ]; then
602 [ "$VERBOSE" = "1" ] && echo
607 # add route for a prefix, flushing any existing routes first
608 # expected to be the first step of a test
615 if [ "$VERBOSE" = "1" ]; then
617 echo " ##################################################"
621 run_cmd "$IP -6 ro flush ${pfx}"
622 [ $? -ne 0 ] && exit 1
624 out=$($IP -6 ro ls match ${pfx})
625 if [ -n "$out" ]; then
626 echo "Failed to flush routes for prefix used for tests."
630 run_cmd "$IP -6 ro add ${pfx} ${nh}"
631 if [ $? -ne 0 ]; then
632 echo "Failed to add initial route for test."
637 # add initial route - used in replace route tests
640 add_route6 "2001:db8:104::/64" "$1"
653 out=$($IP -6 ro ls match ${pfx} | sed -e 's/ pref medium//')
654 [ "${out}" = "${expected}" ] && return 0
656 if [ -z "${out}" ]; then
657 if [ "$VERBOSE" = "1" ]; then
658 printf "\nNo route entry found\n"
660 printf " ${expected}\n"
665 # tricky way to convert output to 1-line without ip's
666 # messy '\'; this drops all extra white space
668 if [ "${out}" != "${expected}" ]; then
670 if [ "${VERBOSE}" = "1" ]; then
671 printf " Unexpected route entry. Have:\n"
673 printf " Expected:\n"
674 printf " ${expected}\n\n"
683 $IP li del red 2>/dev/null
684 $IP li del dummy1 2>/dev/null
685 $IP li del veth1 2>/dev/null
686 $IP li del veth3 2>/dev/null
696 [ "${VERBOSE}" = "1" ] && set -x
700 ip -netns ns2 link set dev lo up
701 ip netns exec ns2 sysctl -qw net.ipv4.ip_forward=1
702 ip netns exec ns2 sysctl -qw net.ipv6.conf.all.forwarding=1
704 $IP li add veth1 type veth peer name veth2
705 $IP li add veth3 type veth peer name veth4
709 $IP li set veth2 netns ns2 up
710 $IP li set veth4 netns ns2 up
711 ip -netns ns2 li add dummy1 type dummy
712 ip -netns ns2 li set dummy1 up
714 $IP -6 addr add 2001:db8:101::1/64 dev veth1 nodad
715 $IP -6 addr add 2001:db8:103::1/64 dev veth3 nodad
716 $IP addr add 172.16.101.1/24 dev veth1
717 $IP addr add 172.16.103.1/24 dev veth3
719 ip -netns ns2 -6 addr add 2001:db8:101::2/64 dev veth2 nodad
720 ip -netns ns2 -6 addr add 2001:db8:103::2/64 dev veth4 nodad
721 ip -netns ns2 -6 addr add 2001:db8:104::1/64 dev dummy1 nodad
723 ip -netns ns2 addr add 172.16.101.2/24 dev veth2
724 ip -netns ns2 addr add 172.16.103.2/24 dev veth4
725 ip -netns ns2 addr add 172.16.104.1/24 dev dummy1
730 # assumption is that basic add of a single path route works
731 # otherwise just adding an address on an interface is broken
737 echo "IPv6 route add / append tests"
739 # route add same prefix - fails with EEXISTS b/c ip adds NLM_F_EXCL
740 add_route6 "2001:db8:104::/64" "via 2001:db8:101::2"
741 run_cmd "$IP -6 ro add 2001:db8:104::/64 via 2001:db8:103::2"
742 log_test $? 2 "Attempt to add duplicate route - gw"
744 # route add same prefix - fails with EEXISTS b/c ip adds NLM_F_EXCL
745 add_route6 "2001:db8:104::/64" "via 2001:db8:101::2"
746 run_cmd "$IP -6 ro add 2001:db8:104::/64 dev veth3"
747 log_test $? 2 "Attempt to add duplicate route - dev only"
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 unreachable 2001:db8:104::/64"
752 log_test $? 2 "Attempt to add duplicate route - reject route"
754 # route append with same prefix adds a new route
755 # - iproute2 sets NLM_F_CREATE | NLM_F_APPEND
756 add_route6 "2001:db8:104::/64" "via 2001:db8:101::2"
757 run_cmd "$IP -6 ro append 2001:db8:104::/64 via 2001:db8:103::2"
758 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"
759 log_test $? 0 "Append nexthop to existing route - gw"
761 # insert mpath directly
762 add_route6 "2001:db8:104::/64" "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
763 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"
764 log_test $? 0 "Add multipath route"
766 add_route6 "2001:db8:104::/64" "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
767 run_cmd "$IP -6 ro add 2001:db8:104::/64 nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
768 log_test $? 2 "Attempt to add duplicate multipath route"
770 # insert of a second route without append but different metric
771 add_route6 "2001:db8:104::/64" "via 2001:db8:101::2"
772 run_cmd "$IP -6 ro add 2001:db8:104::/64 via 2001:db8:103::2 metric 512"
774 if [ $rc -eq 0 ]; then
775 run_cmd "$IP -6 ro add 2001:db8:104::/64 via 2001:db8:103::3 metric 256"
778 log_test $rc 0 "Route add with different metrics"
780 run_cmd "$IP -6 ro del 2001:db8:104::/64 metric 512"
782 if [ $rc -eq 0 ]; then
783 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"
786 log_test $rc 0 "Route delete with metric"
789 ipv6_rt_replace_single()
791 # single path with single path
793 add_initial_route6 "via 2001:db8:101::2"
794 run_cmd "$IP -6 ro replace 2001:db8:104::/64 via 2001:db8:103::2"
795 check_route6 "2001:db8:104::/64 via 2001:db8:103::2 dev veth3 metric 1024"
796 log_test $? 0 "Single path with single path"
798 # single path with multipath
800 add_initial_route6 "nexthop via 2001:db8:101::2"
801 run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:101::3 nexthop via 2001:db8:103::2"
802 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"
803 log_test $? 0 "Single path with multipath"
805 # single path with single path using MULTIPATH attribute
807 add_initial_route6 "via 2001:db8:101::2"
808 run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:103::2"
809 check_route6 "2001:db8:104::/64 via 2001:db8:103::2 dev veth3 metric 1024"
810 log_test $? 0 "Single path with single path via multipath attribute"
812 # route replace fails - invalid nexthop
813 add_initial_route6 "via 2001:db8:101::2"
814 run_cmd "$IP -6 ro replace 2001:db8:104::/64 via 2001:db8:104::2"
815 if [ $? -eq 0 ]; then
816 # previous command is expected to fail so if it returns 0
817 # that means the test failed.
818 log_test 0 1 "Invalid nexthop"
820 check_route6 "2001:db8:104::/64 via 2001:db8:101::2 dev veth1 metric 1024"
821 log_test $? 0 "Invalid nexthop"
824 # replace non-existent route
825 # - note use of change versus replace since ip adds NLM_F_CREATE
827 add_initial_route6 "via 2001:db8:101::2"
828 run_cmd "$IP -6 ro change 2001:db8:105::/64 via 2001:db8:101::2"
829 log_test $? 2 "Single path - replace of non-existent route"
832 ipv6_rt_replace_mpath()
834 # multipath with multipath
835 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
836 run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:101::3 nexthop via 2001:db8:103::3"
837 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"
838 log_test $? 0 "Multipath with multipath"
840 # multipath with single
841 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
842 run_cmd "$IP -6 ro replace 2001:db8:104::/64 via 2001:db8:101::3"
843 check_route6 "2001:db8:104::/64 via 2001:db8:101::3 dev veth1 metric 1024"
844 log_test $? 0 "Multipath with single path"
846 # multipath with single
847 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
848 run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:101::3"
849 check_route6 "2001:db8:104::/64 via 2001:db8:101::3 dev veth1 metric 1024"
850 log_test $? 0 "Multipath with single path via multipath attribute"
852 # route replace fails - invalid nexthop 1
853 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
854 run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:111::3 nexthop via 2001:db8:103::3"
855 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"
856 log_test $? 0 "Multipath - invalid first nexthop"
858 # route replace fails - invalid nexthop 2
859 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
860 run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:101::3 nexthop via 2001:db8:113::3"
861 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"
862 log_test $? 0 "Multipath - invalid second nexthop"
864 # multipath non-existent route
865 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
866 run_cmd "$IP -6 ro change 2001:db8:105::/64 nexthop via 2001:db8:101::3 nexthop via 2001:db8:103::3"
867 log_test $? 2 "Multipath - replace of non-existent route"
873 echo "IPv6 route replace tests"
875 ipv6_rt_replace_single
876 ipv6_rt_replace_mpath
889 ip_addr_metric_check()
891 ip addr help 2>&1 | grep -q metric
892 if [ $? -ne 0 ]; then
893 echo "iproute2 command does not support metric for addresses. Skipping test"
900 ipv6_addr_metric_test()
905 echo "IPv6 prefix route tests"
907 ip_addr_metric_check || return 1
912 $IP li add dummy1 type dummy
913 $IP li add dummy2 type dummy
917 # default entry is metric 256
918 run_cmd "$IP -6 addr add dev dummy1 2001:db8:104::1/64"
919 run_cmd "$IP -6 addr add dev dummy2 2001:db8:104::2/64"
922 check_route6 "2001:db8:104::/64 dev dummy1 proto kernel metric 256 2001:db8:104::/64 dev dummy2 proto kernel metric 256"
923 log_test $? 0 "Default metric"
926 run_cmd "$IP -6 addr flush dev dummy1"
927 run_cmd "$IP -6 addr add dev dummy1 2001:db8:104::1/64 metric 257"
930 check_route6 "2001:db8:104::/64 dev dummy2 proto kernel metric 256 2001:db8:104::/64 dev dummy1 proto kernel metric 257"
931 log_test $? 0 "User specified metric on first device"
934 run_cmd "$IP -6 addr flush dev dummy2"
935 run_cmd "$IP -6 addr add dev dummy2 2001:db8:104::2/64 metric 258"
938 check_route6 "2001:db8:104::/64 dev dummy1 proto kernel metric 257 2001:db8:104::/64 dev dummy2 proto kernel metric 258"
939 log_test $? 0 "User specified metric on second device"
941 run_cmd "$IP -6 addr del dev dummy1 2001:db8:104::1/64 metric 257"
943 if [ $rc -eq 0 ]; then
944 check_route6 "2001:db8:104::/64 dev dummy2 proto kernel metric 258"
947 log_test $rc 0 "Delete of address on first device"
949 run_cmd "$IP -6 addr change dev dummy2 2001:db8:104::2/64 metric 259"
951 if [ $rc -eq 0 ]; then
952 check_route6 "2001:db8:104::/64 dev dummy2 proto kernel metric 259"
955 log_test $rc 0 "Modify metric of address"
957 # verify prefix route removed on down
958 run_cmd "ip netns exec ns1 sysctl -qw net.ipv6.conf.all.keep_addr_on_down=1"
959 run_cmd "$IP li set dev dummy2 down"
961 if [ $rc -eq 0 ]; then
965 log_test $rc 0 "Prefix route removed on link down"
967 # verify prefix route re-inserted with assigned metric
968 run_cmd "$IP li set dev dummy2 up"
970 if [ $rc -eq 0 ]; then
971 check_route6 "2001:db8:104::/64 dev dummy2 proto kernel metric 259"
974 log_test $rc 0 "Prefix route with metric on link up"
981 ipv6_route_metrics_test()
986 echo "IPv6 routes with metrics"
991 # single path with metrics
993 run_cmd "$IP -6 ro add 2001:db8:111::/64 via 2001:db8:101::2 mtu 1400"
995 if [ $rc -eq 0 ]; then
996 check_route6 "2001:db8:111::/64 via 2001:db8:101::2 dev veth1 metric 1024 mtu 1400"
999 log_test $rc 0 "Single path route with mtu metric"
1003 # multipath via separate routes with metrics
1005 run_cmd "$IP -6 ro add 2001:db8:112::/64 via 2001:db8:101::2 mtu 1400"
1006 run_cmd "$IP -6 ro append 2001:db8:112::/64 via 2001:db8:103::2"
1008 if [ $rc -eq 0 ]; then
1009 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"
1012 log_test $rc 0 "Multipath route via 2 single routes with mtu metric on first"
1014 # second route is coalesced to first to make a multipath route.
1015 # MTU of the second path is hidden from display!
1016 run_cmd "$IP -6 ro add 2001:db8:113::/64 via 2001:db8:101::2"
1017 run_cmd "$IP -6 ro append 2001:db8:113::/64 via 2001:db8:103::2 mtu 1400"
1019 if [ $rc -eq 0 ]; then
1020 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"
1023 log_test $rc 0 "Multipath route via 2 single routes with mtu metric on 2nd"
1025 run_cmd "$IP -6 ro del 2001:db8:113::/64 via 2001:db8:101::2"
1026 if [ $? -eq 0 ]; then
1027 check_route6 "2001:db8:113::/64 via 2001:db8:103::2 dev veth3 metric 1024 mtu 1400"
1028 log_test $? 0 " MTU of second leg"
1032 # multipath with metrics
1034 run_cmd "$IP -6 ro add 2001:db8:115::/64 mtu 1400 nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
1036 if [ $rc -eq 0 ]; then
1037 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"
1040 log_test $rc 0 "Multipath route with mtu metric"
1042 $IP -6 ro add 2001:db8:104::/64 via 2001:db8:101::2 mtu 1300
1043 run_cmd "ip netns exec ns1 ping6 -w1 -c1 -s 1500 2001:db8:104::1"
1044 log_test $? 0 "Using route with mtu metric"
1046 run_cmd "$IP -6 ro add 2001:db8:114::/64 via 2001:db8:101::2 congctl lock foo"
1047 log_test $? 2 "Invalid metric (fails metric_convert)"
1052 # add route for a prefix, flushing any existing routes first
1053 # expected to be the first step of a test
1060 if [ "$VERBOSE" = "1" ]; then
1062 echo " ##################################################"
1066 run_cmd "$IP ro flush ${pfx}"
1067 [ $? -ne 0 ] && exit 1
1069 out=$($IP ro ls match ${pfx})
1070 if [ -n "$out" ]; then
1071 echo "Failed to flush routes for prefix used for tests."
1075 run_cmd "$IP ro add ${pfx} ${nh}"
1076 if [ $? -ne 0 ]; then
1077 echo "Failed to add initial route for test."
1082 # add initial route - used in replace route tests
1085 add_route "172.16.104.0/24" "$1"
1097 [ "${pfx}" = "unreachable" ] && pfx=$2
1099 out=$($IP ro ls match ${pfx})
1100 [ "${out}" = "${expected}" ] && return 0
1102 if [ -z "${out}" ]; then
1103 if [ "$VERBOSE" = "1" ]; then
1104 printf "\nNo route entry found\n"
1105 printf "Expected:\n"
1106 printf " ${expected}\n"
1111 # tricky way to convert output to 1-line without ip's
1112 # messy '\'; this drops all extra white space
1114 if [ "${out}" != "${expected}" ]; then
1116 if [ "${VERBOSE}" = "1" ]; then
1117 printf " Unexpected route entry. Have:\n"
1119 printf " Expected:\n"
1120 printf " ${expected}\n\n"
1127 # assumption is that basic add of a single path route works
1128 # otherwise just adding an address on an interface is broken
1134 echo "IPv4 route add / append tests"
1136 # route add same prefix - fails with EEXISTS b/c ip adds NLM_F_EXCL
1137 add_route "172.16.104.0/24" "via 172.16.101.2"
1138 run_cmd "$IP ro add 172.16.104.0/24 via 172.16.103.2"
1139 log_test $? 2 "Attempt to add duplicate route - gw"
1141 # route add same prefix - fails with EEXISTS b/c ip adds NLM_F_EXCL
1142 add_route "172.16.104.0/24" "via 172.16.101.2"
1143 run_cmd "$IP ro add 172.16.104.0/24 dev veth3"
1144 log_test $? 2 "Attempt to add duplicate route - dev only"
1146 # route add same prefix - fails with EEXISTS b/c ip adds NLM_F_EXCL
1147 add_route "172.16.104.0/24" "via 172.16.101.2"
1148 run_cmd "$IP ro add unreachable 172.16.104.0/24"
1149 log_test $? 2 "Attempt to add duplicate route - reject route"
1151 # iproute2 prepend only sets NLM_F_CREATE
1152 # - adds a new route; does NOT convert existing route to ECMP
1153 add_route "172.16.104.0/24" "via 172.16.101.2"
1154 run_cmd "$IP ro prepend 172.16.104.0/24 via 172.16.103.2"
1155 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"
1156 log_test $? 0 "Add new nexthop for existing prefix"
1158 # route append with same prefix adds a new route
1159 # - iproute2 sets NLM_F_CREATE | NLM_F_APPEND
1160 add_route "172.16.104.0/24" "via 172.16.101.2"
1161 run_cmd "$IP ro append 172.16.104.0/24 via 172.16.103.2"
1162 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"
1163 log_test $? 0 "Append nexthop to existing route - gw"
1165 add_route "172.16.104.0/24" "via 172.16.101.2"
1166 run_cmd "$IP ro append 172.16.104.0/24 dev veth3"
1167 check_route "172.16.104.0/24 via 172.16.101.2 dev veth1 172.16.104.0/24 dev veth3 scope link"
1168 log_test $? 0 "Append nexthop to existing route - dev only"
1170 add_route "172.16.104.0/24" "via 172.16.101.2"
1171 run_cmd "$IP ro append unreachable 172.16.104.0/24"
1172 check_route "172.16.104.0/24 via 172.16.101.2 dev veth1 unreachable 172.16.104.0/24"
1173 log_test $? 0 "Append nexthop to existing route - reject route"
1175 run_cmd "$IP ro flush 172.16.104.0/24"
1176 run_cmd "$IP ro add unreachable 172.16.104.0/24"
1177 run_cmd "$IP ro append 172.16.104.0/24 via 172.16.103.2"
1178 check_route "unreachable 172.16.104.0/24 172.16.104.0/24 via 172.16.103.2 dev veth3"
1179 log_test $? 0 "Append nexthop to existing reject route - gw"
1181 run_cmd "$IP ro flush 172.16.104.0/24"
1182 run_cmd "$IP ro add unreachable 172.16.104.0/24"
1183 run_cmd "$IP ro append 172.16.104.0/24 dev veth3"
1184 check_route "unreachable 172.16.104.0/24 172.16.104.0/24 dev veth3 scope link"
1185 log_test $? 0 "Append nexthop to existing reject route - dev only"
1187 # insert mpath directly
1188 add_route "172.16.104.0/24" "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1189 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"
1190 log_test $? 0 "add multipath route"
1192 add_route "172.16.104.0/24" "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1193 run_cmd "$IP ro add 172.16.104.0/24 nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1194 log_test $? 2 "Attempt to add duplicate multipath route"
1196 # insert of a second route without append but different metric
1197 add_route "172.16.104.0/24" "via 172.16.101.2"
1198 run_cmd "$IP ro add 172.16.104.0/24 via 172.16.103.2 metric 512"
1200 if [ $rc -eq 0 ]; then
1201 run_cmd "$IP ro add 172.16.104.0/24 via 172.16.103.3 metric 256"
1204 log_test $rc 0 "Route add with different metrics"
1206 run_cmd "$IP ro del 172.16.104.0/24 metric 512"
1208 if [ $rc -eq 0 ]; then
1209 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"
1212 log_test $rc 0 "Route delete with metric"
1215 ipv4_rt_replace_single()
1217 # single path with single path
1219 add_initial_route "via 172.16.101.2"
1220 run_cmd "$IP ro replace 172.16.104.0/24 via 172.16.103.2"
1221 check_route "172.16.104.0/24 via 172.16.103.2 dev veth3"
1222 log_test $? 0 "Single path with single path"
1224 # single path with multipath
1226 add_initial_route "nexthop via 172.16.101.2"
1227 run_cmd "$IP ro replace 172.16.104.0/24 nexthop via 172.16.101.3 nexthop via 172.16.103.2"
1228 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"
1229 log_test $? 0 "Single path with multipath"
1231 # single path with reject
1233 add_initial_route "nexthop via 172.16.101.2"
1234 run_cmd "$IP ro replace unreachable 172.16.104.0/24"
1235 check_route "unreachable 172.16.104.0/24"
1236 log_test $? 0 "Single path with reject route"
1238 # single path with single path using MULTIPATH attribute
1240 add_initial_route "via 172.16.101.2"
1241 run_cmd "$IP ro replace 172.16.104.0/24 nexthop via 172.16.103.2"
1242 check_route "172.16.104.0/24 via 172.16.103.2 dev veth3"
1243 log_test $? 0 "Single path with single path via multipath attribute"
1245 # route replace fails - invalid nexthop
1246 add_initial_route "via 172.16.101.2"
1247 run_cmd "$IP ro replace 172.16.104.0/24 via 2001:db8:104::2"
1248 if [ $? -eq 0 ]; then
1249 # previous command is expected to fail so if it returns 0
1250 # that means the test failed.
1251 log_test 0 1 "Invalid nexthop"
1253 check_route "172.16.104.0/24 via 172.16.101.2 dev veth1"
1254 log_test $? 0 "Invalid nexthop"
1257 # replace non-existent route
1258 # - note use of change versus replace since ip adds NLM_F_CREATE
1260 add_initial_route "via 172.16.101.2"
1261 run_cmd "$IP ro change 172.16.105.0/24 via 172.16.101.2"
1262 log_test $? 2 "Single path - replace of non-existent route"
1265 ipv4_rt_replace_mpath()
1267 # multipath with multipath
1268 add_initial_route "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1269 run_cmd "$IP ro replace 172.16.104.0/24 nexthop via 172.16.101.3 nexthop via 172.16.103.3"
1270 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"
1271 log_test $? 0 "Multipath with multipath"
1273 # multipath with single
1274 add_initial_route "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1275 run_cmd "$IP ro replace 172.16.104.0/24 via 172.16.101.3"
1276 check_route "172.16.104.0/24 via 172.16.101.3 dev veth1"
1277 log_test $? 0 "Multipath with single path"
1279 # multipath with single
1280 add_initial_route "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1281 run_cmd "$IP ro replace 172.16.104.0/24 nexthop via 172.16.101.3"
1282 check_route "172.16.104.0/24 via 172.16.101.3 dev veth1"
1283 log_test $? 0 "Multipath with single path via multipath attribute"
1285 # multipath with reject
1286 add_initial_route "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1287 run_cmd "$IP ro replace unreachable 172.16.104.0/24"
1288 check_route "unreachable 172.16.104.0/24"
1289 log_test $? 0 "Multipath with reject route"
1291 # route replace fails - invalid nexthop 1
1292 add_initial_route "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1293 run_cmd "$IP ro replace 172.16.104.0/24 nexthop via 172.16.111.3 nexthop via 172.16.103.3"
1294 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"
1295 log_test $? 0 "Multipath - invalid first nexthop"
1297 # route replace fails - invalid nexthop 2
1298 add_initial_route "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1299 run_cmd "$IP ro replace 172.16.104.0/24 nexthop via 172.16.101.3 nexthop via 172.16.113.3"
1300 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"
1301 log_test $? 0 "Multipath - invalid second nexthop"
1303 # multipath non-existent route
1304 add_initial_route "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1305 run_cmd "$IP ro change 172.16.105.0/24 nexthop via 172.16.101.3 nexthop via 172.16.103.3"
1306 log_test $? 2 "Multipath - replace of non-existent route"
1312 echo "IPv4 route replace tests"
1314 ipv4_rt_replace_single
1315 ipv4_rt_replace_mpath
1328 ipv4_addr_metric_test()
1333 echo "IPv4 prefix route tests"
1335 ip_addr_metric_check || return 1
1340 $IP li add dummy1 type dummy
1341 $IP li add dummy2 type dummy
1342 $IP li set dummy1 up
1343 $IP li set dummy2 up
1345 # default entry is metric 256
1346 run_cmd "$IP addr add dev dummy1 172.16.104.1/24"
1347 run_cmd "$IP addr add dev dummy2 172.16.104.2/24"
1350 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"
1351 log_test $? 0 "Default metric"
1354 run_cmd "$IP addr flush dev dummy1"
1355 run_cmd "$IP addr add dev dummy1 172.16.104.1/24 metric 257"
1358 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"
1359 log_test $? 0 "User specified metric on first device"
1362 run_cmd "$IP addr flush dev dummy2"
1363 run_cmd "$IP addr add dev dummy2 172.16.104.2/24 metric 258"
1366 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"
1367 log_test $? 0 "User specified metric on second device"
1369 run_cmd "$IP addr del dev dummy1 172.16.104.1/24 metric 257"
1371 if [ $rc -eq 0 ]; then
1372 check_route "172.16.104.0/24 dev dummy2 proto kernel scope link src 172.16.104.2 metric 258"
1375 log_test $rc 0 "Delete of address on first device"
1377 run_cmd "$IP addr change dev dummy2 172.16.104.2/24 metric 259"
1379 if [ $rc -eq 0 ]; then
1380 check_route "172.16.104.0/24 dev dummy2 proto kernel scope link src 172.16.104.2 metric 259"
1383 log_test $rc 0 "Modify metric of address"
1385 # verify prefix route removed on down
1386 run_cmd "$IP li set dev dummy2 down"
1388 if [ $rc -eq 0 ]; then
1392 log_test $rc 0 "Prefix route removed on link down"
1394 # verify prefix route re-inserted with assigned metric
1395 run_cmd "$IP li set dev dummy2 up"
1397 if [ $rc -eq 0 ]; then
1398 check_route "172.16.104.0/24 dev dummy2 proto kernel scope link src 172.16.104.2 metric 259"
1401 log_test $rc 0 "Prefix route with metric on link up"
1408 ipv4_route_metrics_test()
1413 echo "IPv4 route add / append tests"
1417 run_cmd "$IP ro add 172.16.111.0/24 via 172.16.101.2 mtu 1400"
1419 if [ $rc -eq 0 ]; then
1420 check_route "172.16.111.0/24 via 172.16.101.2 dev veth1 mtu 1400"
1423 log_test $rc 0 "Single path route with mtu metric"
1426 run_cmd "$IP ro add 172.16.112.0/24 mtu 1400 nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1428 if [ $rc -eq 0 ]; then
1429 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"
1432 log_test $rc 0 "Multipath route with mtu metric"
1434 $IP ro add 172.16.104.0/24 via 172.16.101.2 mtu 1300
1435 run_cmd "ip netns exec ns1 ping -w1 -c1 -s 1500 172.16.104.1"
1436 log_test $? 0 "Using route with mtu metric"
1438 run_cmd "$IP ro add 172.16.111.0/24 via 172.16.101.2 congctl lock foo"
1439 log_test $? 2 "Invalid metric (fails metric_convert)"
1445 ################################################################################
1451 usage: ${0##*/} OPTS
1453 -t <test> Test(s) to run (default: all)
1456 -P Pause after each test before cleanup
1457 -v verbose mode (show commands and output)
1461 ################################################################################
1464 while getopts :t:pPhv o
1468 p) PAUSE_ON_FAIL=yes;;
1470 v) VERBOSE=$(($VERBOSE + 1));;
1476 PEER_CMD="ip netns exec ${PEER_NS}"
1478 # make sure we don't pause twice
1479 [ "${PAUSE}" = "yes" ] && PAUSE_ON_FAIL=no
1481 if [ "$(id -u)" -ne 0 ];then
1482 echo "SKIP: Need root privileges"
1486 if [ ! -x "$(command -v ip)" ]; then
1487 echo "SKIP: Could not run test without ip tool"
1491 ip route help 2>&1 | grep -q fibmatch
1492 if [ $? -ne 0 ]; then
1493 echo "SKIP: iproute2 too old, missing fibmatch"
1498 cleanup &> /dev/null
1503 fib_unreg_test|unregister) fib_unreg_test;;
1504 fib_down_test|down) fib_down_test;;
1505 fib_carrier_test|carrier) fib_carrier_test;;
1506 fib_nexthop_test|nexthop) fib_nexthop_test;;
1507 ipv6_route_test|ipv6_rt) ipv6_route_test;;
1508 ipv4_route_test|ipv4_rt) ipv4_route_test;;
1509 ipv6_addr_metric) ipv6_addr_metric_test;;
1510 ipv4_addr_metric) ipv4_addr_metric_test;;
1511 ipv6_route_metrics) ipv6_route_metrics_test;;
1512 ipv4_route_metrics) ipv4_route_metrics_test;;
1514 help) echo "Test names: $TESTS"; exit 0;;
1518 if [ "$TESTS" != "none" ]; then
1519 printf "\nTests passed: %3d\n" ${nsuccess}
1520 printf "Tests failed: %3d\n" ${nfail}