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
608 # add route for a prefix, flushing any existing routes first
609 # expected to be the first step of a test
616 if [ "$VERBOSE" = "1" ]; then
618 echo " ##################################################"
622 run_cmd "$IP -6 ro flush ${pfx}"
623 [ $? -ne 0 ] && exit 1
625 out=$($IP -6 ro ls match ${pfx})
626 if [ -n "$out" ]; then
627 echo "Failed to flush routes for prefix used for tests."
631 run_cmd "$IP -6 ro add ${pfx} ${nh}"
632 if [ $? -ne 0 ]; then
633 echo "Failed to add initial route for test."
638 # add initial route - used in replace route tests
641 add_route6 "2001:db8:104::/64" "$1"
654 out=$($IP -6 ro ls match ${pfx} | sed -e 's/ pref medium//')
655 [ "${out}" = "${expected}" ] && return 0
657 if [ -z "${out}" ]; then
658 if [ "$VERBOSE" = "1" ]; then
659 printf "\nNo route entry found\n"
661 printf " ${expected}\n"
666 # tricky way to convert output to 1-line without ip's
667 # messy '\'; this drops all extra white space
669 if [ "${out}" != "${expected}" ]; then
671 if [ "${VERBOSE}" = "1" ]; then
672 printf " Unexpected route entry. Have:\n"
674 printf " Expected:\n"
675 printf " ${expected}\n\n"
684 $IP li del red 2>/dev/null
685 $IP li del dummy1 2>/dev/null
686 $IP li del veth1 2>/dev/null
687 $IP li del veth3 2>/dev/null
697 [ "${VERBOSE}" = "1" ] && set -x
701 ip -netns ns2 link set dev lo up
702 ip netns exec ns2 sysctl -qw net.ipv4.ip_forward=1
703 ip netns exec ns2 sysctl -qw net.ipv6.conf.all.forwarding=1
705 $IP li add veth1 type veth peer name veth2
706 $IP li add veth3 type veth peer name veth4
710 $IP li set veth2 netns ns2 up
711 $IP li set veth4 netns ns2 up
712 ip -netns ns2 li add dummy1 type dummy
713 ip -netns ns2 li set dummy1 up
715 $IP -6 addr add 2001:db8:101::1/64 dev veth1 nodad
716 $IP -6 addr add 2001:db8:103::1/64 dev veth3 nodad
717 $IP addr add 172.16.101.1/24 dev veth1
718 $IP addr add 172.16.103.1/24 dev veth3
720 ip -netns ns2 -6 addr add 2001:db8:101::2/64 dev veth2 nodad
721 ip -netns ns2 -6 addr add 2001:db8:103::2/64 dev veth4 nodad
722 ip -netns ns2 -6 addr add 2001:db8:104::1/64 dev dummy1 nodad
724 ip -netns ns2 addr add 172.16.101.2/24 dev veth2
725 ip -netns ns2 addr add 172.16.103.2/24 dev veth4
726 ip -netns ns2 addr add 172.16.104.1/24 dev dummy1
731 # assumption is that basic add of a single path route works
732 # otherwise just adding an address on an interface is broken
738 echo "IPv6 route add / append tests"
740 # route add same prefix - fails with EEXISTS b/c ip adds NLM_F_EXCL
741 add_route6 "2001:db8:104::/64" "via 2001:db8:101::2"
742 run_cmd "$IP -6 ro add 2001:db8:104::/64 via 2001:db8:103::2"
743 log_test $? 2 "Attempt to add duplicate route - gw"
745 # route add same prefix - fails with EEXISTS b/c ip adds NLM_F_EXCL
746 add_route6 "2001:db8:104::/64" "via 2001:db8:101::2"
747 run_cmd "$IP -6 ro add 2001:db8:104::/64 dev veth3"
748 log_test $? 2 "Attempt to add duplicate route - dev only"
750 # route add same prefix - fails with EEXISTS b/c ip adds NLM_F_EXCL
751 add_route6 "2001:db8:104::/64" "via 2001:db8:101::2"
752 run_cmd "$IP -6 ro add unreachable 2001:db8:104::/64"
753 log_test $? 2 "Attempt to add duplicate route - reject route"
755 # route append with same prefix adds a new route
756 # - iproute2 sets NLM_F_CREATE | NLM_F_APPEND
757 add_route6 "2001:db8:104::/64" "via 2001:db8:101::2"
758 run_cmd "$IP -6 ro append 2001:db8:104::/64 via 2001:db8:103::2"
759 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"
760 log_test $? 0 "Append nexthop to existing route - gw"
762 # insert mpath directly
763 add_route6 "2001:db8:104::/64" "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
764 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"
765 log_test $? 0 "Add multipath route"
767 add_route6 "2001:db8:104::/64" "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
768 run_cmd "$IP -6 ro add 2001:db8:104::/64 nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
769 log_test $? 2 "Attempt to add duplicate multipath route"
771 # insert of a second route without append but different metric
772 add_route6 "2001:db8:104::/64" "via 2001:db8:101::2"
773 run_cmd "$IP -6 ro add 2001:db8:104::/64 via 2001:db8:103::2 metric 512"
775 if [ $rc -eq 0 ]; then
776 run_cmd "$IP -6 ro add 2001:db8:104::/64 via 2001:db8:103::3 metric 256"
779 log_test $rc 0 "Route add with different metrics"
781 run_cmd "$IP -6 ro del 2001:db8:104::/64 metric 512"
783 if [ $rc -eq 0 ]; then
784 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"
787 log_test $rc 0 "Route delete with metric"
790 ipv6_rt_replace_single()
792 # single path with single path
794 add_initial_route6 "via 2001:db8:101::2"
795 run_cmd "$IP -6 ro replace 2001:db8:104::/64 via 2001:db8:103::2"
796 check_route6 "2001:db8:104::/64 via 2001:db8:103::2 dev veth3 metric 1024"
797 log_test $? 0 "Single path with single path"
799 # single path with multipath
801 add_initial_route6 "nexthop via 2001:db8:101::2"
802 run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:101::3 nexthop via 2001:db8:103::2"
803 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"
804 log_test $? 0 "Single path with multipath"
806 # single path with single path using MULTIPATH attribute
808 add_initial_route6 "via 2001:db8:101::2"
809 run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:103::2"
810 check_route6 "2001:db8:104::/64 via 2001:db8:103::2 dev veth3 metric 1024"
811 log_test $? 0 "Single path with single path via multipath attribute"
813 # route replace fails - invalid nexthop
814 add_initial_route6 "via 2001:db8:101::2"
815 run_cmd "$IP -6 ro replace 2001:db8:104::/64 via 2001:db8:104::2"
816 if [ $? -eq 0 ]; then
817 # previous command is expected to fail so if it returns 0
818 # that means the test failed.
819 log_test 0 1 "Invalid nexthop"
821 check_route6 "2001:db8:104::/64 via 2001:db8:101::2 dev veth1 metric 1024"
822 log_test $? 0 "Invalid nexthop"
825 # replace non-existent route
826 # - note use of change versus replace since ip adds NLM_F_CREATE
828 add_initial_route6 "via 2001:db8:101::2"
829 run_cmd "$IP -6 ro change 2001:db8:105::/64 via 2001:db8:101::2"
830 log_test $? 2 "Single path - replace of non-existent route"
833 ipv6_rt_replace_mpath()
835 # multipath with multipath
836 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
837 run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:101::3 nexthop via 2001:db8:103::3"
838 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"
839 log_test $? 0 "Multipath with multipath"
841 # multipath with single
842 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
843 run_cmd "$IP -6 ro replace 2001:db8:104::/64 via 2001:db8:101::3"
844 check_route6 "2001:db8:104::/64 via 2001:db8:101::3 dev veth1 metric 1024"
845 log_test $? 0 "Multipath with single path"
847 # multipath with single
848 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
849 run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:101::3"
850 check_route6 "2001:db8:104::/64 via 2001:db8:101::3 dev veth1 metric 1024"
851 log_test $? 0 "Multipath with single path via multipath attribute"
853 # route replace fails - invalid nexthop 1
854 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
855 run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:111::3 nexthop via 2001:db8:103::3"
856 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"
857 log_test $? 0 "Multipath - invalid first nexthop"
859 # route replace fails - invalid nexthop 2
860 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
861 run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:101::3 nexthop via 2001:db8:113::3"
862 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"
863 log_test $? 0 "Multipath - invalid second nexthop"
865 # multipath non-existent route
866 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
867 run_cmd "$IP -6 ro change 2001:db8:105::/64 nexthop via 2001:db8:101::3 nexthop via 2001:db8:103::3"
868 log_test $? 2 "Multipath - replace of non-existent route"
874 echo "IPv6 route replace tests"
876 ipv6_rt_replace_single
877 ipv6_rt_replace_mpath
890 ip_addr_metric_check()
892 ip addr help 2>&1 | grep -q metric
893 if [ $? -ne 0 ]; then
894 echo "iproute2 command does not support metric for addresses. Skipping test"
901 ipv6_addr_metric_test()
906 echo "IPv6 prefix route tests"
908 ip_addr_metric_check || return 1
913 $IP li add dummy1 type dummy
914 $IP li add dummy2 type dummy
918 # default entry is metric 256
919 run_cmd "$IP -6 addr add dev dummy1 2001:db8:104::1/64"
920 run_cmd "$IP -6 addr add dev dummy2 2001:db8:104::2/64"
923 check_route6 "2001:db8:104::/64 dev dummy1 proto kernel metric 256 2001:db8:104::/64 dev dummy2 proto kernel metric 256"
924 log_test $? 0 "Default metric"
927 run_cmd "$IP -6 addr flush dev dummy1"
928 run_cmd "$IP -6 addr add dev dummy1 2001:db8:104::1/64 metric 257"
931 check_route6 "2001:db8:104::/64 dev dummy2 proto kernel metric 256 2001:db8:104::/64 dev dummy1 proto kernel metric 257"
932 log_test $? 0 "User specified metric on first device"
935 run_cmd "$IP -6 addr flush dev dummy2"
936 run_cmd "$IP -6 addr add dev dummy2 2001:db8:104::2/64 metric 258"
939 check_route6 "2001:db8:104::/64 dev dummy1 proto kernel metric 257 2001:db8:104::/64 dev dummy2 proto kernel metric 258"
940 log_test $? 0 "User specified metric on second device"
942 run_cmd "$IP -6 addr del dev dummy1 2001:db8:104::1/64 metric 257"
944 if [ $rc -eq 0 ]; then
945 check_route6 "2001:db8:104::/64 dev dummy2 proto kernel metric 258"
948 log_test $rc 0 "Delete of address on first device"
950 run_cmd "$IP -6 addr change dev dummy2 2001:db8:104::2/64 metric 259"
952 if [ $rc -eq 0 ]; then
953 check_route6 "2001:db8:104::/64 dev dummy2 proto kernel metric 259"
956 log_test $rc 0 "Modify metric of address"
958 # verify prefix route removed on down
959 run_cmd "ip netns exec ns1 sysctl -qw net.ipv6.conf.all.keep_addr_on_down=1"
960 run_cmd "$IP li set dev dummy2 down"
962 if [ $rc -eq 0 ]; then
966 log_test $rc 0 "Prefix route removed on link down"
968 # verify prefix route re-inserted with assigned metric
969 run_cmd "$IP li set dev dummy2 up"
971 if [ $rc -eq 0 ]; then
972 check_route6 "2001:db8:104::/64 dev dummy2 proto kernel metric 259"
975 log_test $rc 0 "Prefix route with metric on link up"
982 ipv6_route_metrics_test()
987 echo "IPv6 routes with metrics"
992 # single path with metrics
994 run_cmd "$IP -6 ro add 2001:db8:111::/64 via 2001:db8:101::2 mtu 1400"
996 if [ $rc -eq 0 ]; then
997 check_route6 "2001:db8:111::/64 via 2001:db8:101::2 dev veth1 metric 1024 mtu 1400"
1000 log_test $rc 0 "Single path route with mtu metric"
1004 # multipath via separate routes with metrics
1006 run_cmd "$IP -6 ro add 2001:db8:112::/64 via 2001:db8:101::2 mtu 1400"
1007 run_cmd "$IP -6 ro append 2001:db8:112::/64 via 2001:db8:103::2"
1009 if [ $rc -eq 0 ]; then
1010 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"
1013 log_test $rc 0 "Multipath route via 2 single routes with mtu metric on first"
1015 # second route is coalesced to first to make a multipath route.
1016 # MTU of the second path is hidden from display!
1017 run_cmd "$IP -6 ro add 2001:db8:113::/64 via 2001:db8:101::2"
1018 run_cmd "$IP -6 ro append 2001:db8:113::/64 via 2001:db8:103::2 mtu 1400"
1020 if [ $rc -eq 0 ]; then
1021 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"
1024 log_test $rc 0 "Multipath route via 2 single routes with mtu metric on 2nd"
1026 run_cmd "$IP -6 ro del 2001:db8:113::/64 via 2001:db8:101::2"
1027 if [ $? -eq 0 ]; then
1028 check_route6 "2001:db8:113::/64 via 2001:db8:103::2 dev veth3 metric 1024 mtu 1400"
1029 log_test $? 0 " MTU of second leg"
1033 # multipath with metrics
1035 run_cmd "$IP -6 ro add 2001:db8:115::/64 mtu 1400 nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
1037 if [ $rc -eq 0 ]; then
1038 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"
1041 log_test $rc 0 "Multipath route with mtu metric"
1043 $IP -6 ro add 2001:db8:104::/64 via 2001:db8:101::2 mtu 1300
1044 run_cmd "ip netns exec ns1 ping6 -w1 -c1 -s 1500 2001:db8:104::1"
1045 log_test $? 0 "Using route with mtu metric"
1047 run_cmd "$IP -6 ro add 2001:db8:114::/64 via 2001:db8:101::2 congctl lock foo"
1048 log_test $? 2 "Invalid metric (fails metric_convert)"
1053 # add route for a prefix, flushing any existing routes first
1054 # expected to be the first step of a test
1061 if [ "$VERBOSE" = "1" ]; then
1063 echo " ##################################################"
1067 run_cmd "$IP ro flush ${pfx}"
1068 [ $? -ne 0 ] && exit 1
1070 out=$($IP ro ls match ${pfx})
1071 if [ -n "$out" ]; then
1072 echo "Failed to flush routes for prefix used for tests."
1076 run_cmd "$IP ro add ${pfx} ${nh}"
1077 if [ $? -ne 0 ]; then
1078 echo "Failed to add initial route for test."
1083 # add initial route - used in replace route tests
1086 add_route "172.16.104.0/24" "$1"
1098 [ "${pfx}" = "unreachable" ] && pfx=$2
1100 out=$($IP ro ls match ${pfx})
1101 [ "${out}" = "${expected}" ] && return 0
1103 if [ -z "${out}" ]; then
1104 if [ "$VERBOSE" = "1" ]; then
1105 printf "\nNo route entry found\n"
1106 printf "Expected:\n"
1107 printf " ${expected}\n"
1112 # tricky way to convert output to 1-line without ip's
1113 # messy '\'; this drops all extra white space
1115 if [ "${out}" != "${expected}" ]; then
1117 if [ "${VERBOSE}" = "1" ]; then
1118 printf " Unexpected route entry. Have:\n"
1120 printf " Expected:\n"
1121 printf " ${expected}\n\n"
1128 # assumption is that basic add of a single path route works
1129 # otherwise just adding an address on an interface is broken
1135 echo "IPv4 route add / append tests"
1137 # route add same prefix - fails with EEXISTS b/c ip adds NLM_F_EXCL
1138 add_route "172.16.104.0/24" "via 172.16.101.2"
1139 run_cmd "$IP ro add 172.16.104.0/24 via 172.16.103.2"
1140 log_test $? 2 "Attempt to add duplicate route - gw"
1142 # route add same prefix - fails with EEXISTS b/c ip adds NLM_F_EXCL
1143 add_route "172.16.104.0/24" "via 172.16.101.2"
1144 run_cmd "$IP ro add 172.16.104.0/24 dev veth3"
1145 log_test $? 2 "Attempt to add duplicate route - dev only"
1147 # route add same prefix - fails with EEXISTS b/c ip adds NLM_F_EXCL
1148 add_route "172.16.104.0/24" "via 172.16.101.2"
1149 run_cmd "$IP ro add unreachable 172.16.104.0/24"
1150 log_test $? 2 "Attempt to add duplicate route - reject route"
1152 # iproute2 prepend only sets NLM_F_CREATE
1153 # - adds a new route; does NOT convert existing route to ECMP
1154 add_route "172.16.104.0/24" "via 172.16.101.2"
1155 run_cmd "$IP ro prepend 172.16.104.0/24 via 172.16.103.2"
1156 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"
1157 log_test $? 0 "Add new nexthop for existing prefix"
1159 # route append with same prefix adds a new route
1160 # - iproute2 sets NLM_F_CREATE | NLM_F_APPEND
1161 add_route "172.16.104.0/24" "via 172.16.101.2"
1162 run_cmd "$IP ro append 172.16.104.0/24 via 172.16.103.2"
1163 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"
1164 log_test $? 0 "Append nexthop to existing route - gw"
1166 add_route "172.16.104.0/24" "via 172.16.101.2"
1167 run_cmd "$IP ro append 172.16.104.0/24 dev veth3"
1168 check_route "172.16.104.0/24 via 172.16.101.2 dev veth1 172.16.104.0/24 dev veth3 scope link"
1169 log_test $? 0 "Append nexthop to existing route - dev only"
1171 add_route "172.16.104.0/24" "via 172.16.101.2"
1172 run_cmd "$IP ro append unreachable 172.16.104.0/24"
1173 check_route "172.16.104.0/24 via 172.16.101.2 dev veth1 unreachable 172.16.104.0/24"
1174 log_test $? 0 "Append nexthop to existing route - reject route"
1176 run_cmd "$IP ro flush 172.16.104.0/24"
1177 run_cmd "$IP ro add unreachable 172.16.104.0/24"
1178 run_cmd "$IP ro append 172.16.104.0/24 via 172.16.103.2"
1179 check_route "unreachable 172.16.104.0/24 172.16.104.0/24 via 172.16.103.2 dev veth3"
1180 log_test $? 0 "Append nexthop to existing reject route - gw"
1182 run_cmd "$IP ro flush 172.16.104.0/24"
1183 run_cmd "$IP ro add unreachable 172.16.104.0/24"
1184 run_cmd "$IP ro append 172.16.104.0/24 dev veth3"
1185 check_route "unreachable 172.16.104.0/24 172.16.104.0/24 dev veth3 scope link"
1186 log_test $? 0 "Append nexthop to existing reject route - dev only"
1188 # insert mpath directly
1189 add_route "172.16.104.0/24" "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1190 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"
1191 log_test $? 0 "add multipath route"
1193 add_route "172.16.104.0/24" "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1194 run_cmd "$IP ro add 172.16.104.0/24 nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1195 log_test $? 2 "Attempt to add duplicate multipath route"
1197 # insert of a second route without append but different metric
1198 add_route "172.16.104.0/24" "via 172.16.101.2"
1199 run_cmd "$IP ro add 172.16.104.0/24 via 172.16.103.2 metric 512"
1201 if [ $rc -eq 0 ]; then
1202 run_cmd "$IP ro add 172.16.104.0/24 via 172.16.103.3 metric 256"
1205 log_test $rc 0 "Route add with different metrics"
1207 run_cmd "$IP ro del 172.16.104.0/24 metric 512"
1209 if [ $rc -eq 0 ]; then
1210 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"
1213 log_test $rc 0 "Route delete with metric"
1216 ipv4_rt_replace_single()
1218 # single path with single path
1220 add_initial_route "via 172.16.101.2"
1221 run_cmd "$IP ro replace 172.16.104.0/24 via 172.16.103.2"
1222 check_route "172.16.104.0/24 via 172.16.103.2 dev veth3"
1223 log_test $? 0 "Single path with single path"
1225 # single path with multipath
1227 add_initial_route "nexthop via 172.16.101.2"
1228 run_cmd "$IP ro replace 172.16.104.0/24 nexthop via 172.16.101.3 nexthop via 172.16.103.2"
1229 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"
1230 log_test $? 0 "Single path with multipath"
1232 # single path with reject
1234 add_initial_route "nexthop via 172.16.101.2"
1235 run_cmd "$IP ro replace unreachable 172.16.104.0/24"
1236 check_route "unreachable 172.16.104.0/24"
1237 log_test $? 0 "Single path with reject route"
1239 # single path with single path using MULTIPATH attribute
1241 add_initial_route "via 172.16.101.2"
1242 run_cmd "$IP ro replace 172.16.104.0/24 nexthop via 172.16.103.2"
1243 check_route "172.16.104.0/24 via 172.16.103.2 dev veth3"
1244 log_test $? 0 "Single path with single path via multipath attribute"
1246 # route replace fails - invalid nexthop
1247 add_initial_route "via 172.16.101.2"
1248 run_cmd "$IP ro replace 172.16.104.0/24 via 2001:db8:104::2"
1249 if [ $? -eq 0 ]; then
1250 # previous command is expected to fail so if it returns 0
1251 # that means the test failed.
1252 log_test 0 1 "Invalid nexthop"
1254 check_route "172.16.104.0/24 via 172.16.101.2 dev veth1"
1255 log_test $? 0 "Invalid nexthop"
1258 # replace non-existent route
1259 # - note use of change versus replace since ip adds NLM_F_CREATE
1261 add_initial_route "via 172.16.101.2"
1262 run_cmd "$IP ro change 172.16.105.0/24 via 172.16.101.2"
1263 log_test $? 2 "Single path - replace of non-existent route"
1266 ipv4_rt_replace_mpath()
1268 # multipath with multipath
1269 add_initial_route "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1270 run_cmd "$IP ro replace 172.16.104.0/24 nexthop via 172.16.101.3 nexthop via 172.16.103.3"
1271 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"
1272 log_test $? 0 "Multipath with multipath"
1274 # multipath with single
1275 add_initial_route "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1276 run_cmd "$IP ro replace 172.16.104.0/24 via 172.16.101.3"
1277 check_route "172.16.104.0/24 via 172.16.101.3 dev veth1"
1278 log_test $? 0 "Multipath with single path"
1280 # multipath with single
1281 add_initial_route "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1282 run_cmd "$IP ro replace 172.16.104.0/24 nexthop via 172.16.101.3"
1283 check_route "172.16.104.0/24 via 172.16.101.3 dev veth1"
1284 log_test $? 0 "Multipath with single path via multipath attribute"
1286 # multipath with reject
1287 add_initial_route "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1288 run_cmd "$IP ro replace unreachable 172.16.104.0/24"
1289 check_route "unreachable 172.16.104.0/24"
1290 log_test $? 0 "Multipath with reject route"
1292 # route replace fails - invalid nexthop 1
1293 add_initial_route "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1294 run_cmd "$IP ro replace 172.16.104.0/24 nexthop via 172.16.111.3 nexthop via 172.16.103.3"
1295 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"
1296 log_test $? 0 "Multipath - invalid first nexthop"
1298 # route replace fails - invalid nexthop 2
1299 add_initial_route "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1300 run_cmd "$IP ro replace 172.16.104.0/24 nexthop via 172.16.101.3 nexthop via 172.16.113.3"
1301 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"
1302 log_test $? 0 "Multipath - invalid second nexthop"
1304 # multipath non-existent route
1305 add_initial_route "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1306 run_cmd "$IP ro change 172.16.105.0/24 nexthop via 172.16.101.3 nexthop via 172.16.103.3"
1307 log_test $? 2 "Multipath - replace of non-existent route"
1313 echo "IPv4 route replace tests"
1315 ipv4_rt_replace_single
1316 ipv4_rt_replace_mpath
1329 ipv4_addr_metric_test()
1334 echo "IPv4 prefix route tests"
1336 ip_addr_metric_check || return 1
1341 $IP li add dummy1 type dummy
1342 $IP li add dummy2 type dummy
1343 $IP li set dummy1 up
1344 $IP li set dummy2 up
1346 # default entry is metric 256
1347 run_cmd "$IP addr add dev dummy1 172.16.104.1/24"
1348 run_cmd "$IP addr add dev dummy2 172.16.104.2/24"
1351 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"
1352 log_test $? 0 "Default metric"
1355 run_cmd "$IP addr flush dev dummy1"
1356 run_cmd "$IP addr add dev dummy1 172.16.104.1/24 metric 257"
1359 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"
1360 log_test $? 0 "User specified metric on first device"
1363 run_cmd "$IP addr flush dev dummy2"
1364 run_cmd "$IP addr add dev dummy2 172.16.104.2/24 metric 258"
1367 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"
1368 log_test $? 0 "User specified metric on second device"
1370 run_cmd "$IP addr del dev dummy1 172.16.104.1/24 metric 257"
1372 if [ $rc -eq 0 ]; then
1373 check_route "172.16.104.0/24 dev dummy2 proto kernel scope link src 172.16.104.2 metric 258"
1376 log_test $rc 0 "Delete of address on first device"
1378 run_cmd "$IP addr change dev dummy2 172.16.104.2/24 metric 259"
1380 if [ $rc -eq 0 ]; then
1381 check_route "172.16.104.0/24 dev dummy2 proto kernel scope link src 172.16.104.2 metric 259"
1384 log_test $rc 0 "Modify metric of address"
1386 # verify prefix route removed on down
1387 run_cmd "$IP li set dev dummy2 down"
1389 if [ $rc -eq 0 ]; then
1393 log_test $rc 0 "Prefix route removed on link down"
1395 # verify prefix route re-inserted with assigned metric
1396 run_cmd "$IP li set dev dummy2 up"
1398 if [ $rc -eq 0 ]; then
1399 check_route "172.16.104.0/24 dev dummy2 proto kernel scope link src 172.16.104.2 metric 259"
1402 log_test $rc 0 "Prefix route with metric on link up"
1409 ipv4_route_metrics_test()
1414 echo "IPv4 route add / append tests"
1418 run_cmd "$IP ro add 172.16.111.0/24 via 172.16.101.2 mtu 1400"
1420 if [ $rc -eq 0 ]; then
1421 check_route "172.16.111.0/24 via 172.16.101.2 dev veth1 mtu 1400"
1424 log_test $rc 0 "Single path route with mtu metric"
1427 run_cmd "$IP ro add 172.16.112.0/24 mtu 1400 nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1429 if [ $rc -eq 0 ]; then
1430 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"
1433 log_test $rc 0 "Multipath route with mtu metric"
1435 $IP ro add 172.16.104.0/24 via 172.16.101.2 mtu 1300
1436 run_cmd "ip netns exec ns1 ping -w1 -c1 -s 1500 172.16.104.1"
1437 log_test $? 0 "Using route with mtu metric"
1439 run_cmd "$IP ro add 172.16.111.0/24 via 172.16.101.2 congctl lock foo"
1440 log_test $? 2 "Invalid metric (fails metric_convert)"
1446 ################################################################################
1452 usage: ${0##*/} OPTS
1454 -t <test> Test(s) to run (default: all)
1457 -P Pause after each test before cleanup
1458 -v verbose mode (show commands and output)
1462 ################################################################################
1465 while getopts :t:pPhv o
1469 p) PAUSE_ON_FAIL=yes;;
1471 v) VERBOSE=$(($VERBOSE + 1));;
1477 PEER_CMD="ip netns exec ${PEER_NS}"
1479 # make sure we don't pause twice
1480 [ "${PAUSE}" = "yes" ] && PAUSE_ON_FAIL=no
1482 if [ "$(id -u)" -ne 0 ];then
1483 echo "SKIP: Need root privileges"
1487 if [ ! -x "$(command -v ip)" ]; then
1488 echo "SKIP: Could not run test without ip tool"
1492 ip route help 2>&1 | grep -q fibmatch
1493 if [ $? -ne 0 ]; then
1494 echo "SKIP: iproute2 too old, missing fibmatch"
1499 cleanup &> /dev/null
1504 fib_unreg_test|unregister) fib_unreg_test;;
1505 fib_down_test|down) fib_down_test;;
1506 fib_carrier_test|carrier) fib_carrier_test;;
1507 fib_nexthop_test|nexthop) fib_nexthop_test;;
1508 ipv6_route_test|ipv6_rt) ipv6_route_test;;
1509 ipv4_route_test|ipv4_rt) ipv4_route_test;;
1510 ipv6_addr_metric) ipv6_addr_metric_test;;
1511 ipv4_addr_metric) ipv4_addr_metric_test;;
1512 ipv6_route_metrics) ipv6_route_metrics_test;;
1513 ipv4_route_metrics) ipv4_route_metrics_test;;
1515 help) echo "Test names: $TESTS"; exit 0;;
1519 if [ "$TESTS" != "none" ]; then
1520 printf "\nTests passed: %3d\n" ${nsuccess}
1521 printf "Tests failed: %3d\n" ${nfail}