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 suppress ipv6_rt ipv4_rt ipv6_addr_metric ipv4_addr_metric ipv6_route_metrics ipv4_route_metrics ipv4_route_v6_gw rp_filter ipv4_del_addr ipv4_mangle ipv6_mangle ipv4_bcast_neigh"
18 NS_EXEC="ip netns exec ns1"
20 which ping6 > /dev/null 2>&1 && ping6=$(which ping6) || ping6=$(which ping)
28 if [ ${rc} -eq ${expected} ]; then
29 printf " TEST: %-60s [ OK ]\n" "${msg}"
30 nsuccess=$((nsuccess+1))
34 printf " TEST: %-60s [FAIL]\n" "${msg}"
35 if [ "${PAUSE_ON_FAIL}" = "yes" ]; then
37 echo "hit enter to continue, 'q' to quit"
39 [ "$a" = "q" ] && exit 1
43 if [ "${PAUSE}" = "yes" ]; then
45 echo "hit enter to continue, 'q' to quit"
47 [ "$a" = "q" ] && exit 1
56 $IP link set dev lo up
57 ip netns exec ns1 sysctl -qw net.ipv4.ip_forward=1
58 ip netns exec ns1 sysctl -qw net.ipv6.conf.all.forwarding=1
60 $IP link add dummy0 type dummy
61 $IP link set dev dummy0 up
62 $IP address add 198.51.100.1/24 dev dummy0
63 $IP -6 address add 2001:db8:1::1/64 dev dummy0
70 $IP link del dev dummy0 &> /dev/null
72 ip netns del ns2 &> /dev/null
80 addr=$($IP -6 -br addr show dev ${dev} | \
82 for (i = 3; i <= NF; ++i) {
90 [ -z "$addr" ] && return 1
97 fib_unreg_unicast_test()
100 echo "Single path route test"
105 $IP route get fibmatch 198.51.100.2 &> /dev/null
106 log_test $? 0 "IPv4 fibmatch"
107 $IP -6 route get fibmatch 2001:db8:1::2 &> /dev/null
108 log_test $? 0 "IPv6 fibmatch"
111 $IP link del dev dummy0
114 echo " Nexthop device deleted"
115 $IP route get fibmatch 198.51.100.2 &> /dev/null
116 log_test $? 2 "IPv4 fibmatch - no route"
117 $IP -6 route get fibmatch 2001:db8:1::2 &> /dev/null
118 log_test $? 2 "IPv6 fibmatch - no route"
123 fib_unreg_multipath_test()
127 echo "Multipath route test"
132 $IP link add dummy1 type dummy
133 $IP link set dev dummy1 up
134 $IP address add 192.0.2.1/24 dev dummy1
135 $IP -6 address add 2001:db8:2::1/64 dev dummy1
137 $IP route add 203.0.113.0/24 \
138 nexthop via 198.51.100.2 dev dummy0 \
139 nexthop via 192.0.2.2 dev dummy1
140 $IP -6 route add 2001:db8:3::/64 \
141 nexthop via 2001:db8:1::2 dev dummy0 \
142 nexthop via 2001:db8:2::2 dev dummy1
146 $IP route get fibmatch 203.0.113.1 &> /dev/null
147 log_test $? 0 "IPv4 fibmatch"
148 $IP -6 route get fibmatch 2001:db8:3::1 &> /dev/null
149 log_test $? 0 "IPv6 fibmatch"
152 $IP link del dev dummy0
155 echo " One nexthop device deleted"
156 $IP route get fibmatch 203.0.113.1 &> /dev/null
157 log_test $? 2 "IPv4 - multipath route removed on delete"
159 $IP -6 route get fibmatch 2001:db8:3::1 &> /dev/null
160 # In IPv6 we do not flush the entire multipath route.
161 log_test $? 0 "IPv6 - multipath down to single path"
164 $IP link del dev dummy1
167 echo " Second nexthop device deleted"
168 $IP -6 route get fibmatch 2001:db8:3::1 &> /dev/null
169 log_test $? 2 "IPv6 - no route"
176 fib_unreg_unicast_test
177 fib_unreg_multipath_test
180 fib_down_unicast_test()
183 echo "Single path, admin down"
188 $IP route get fibmatch 198.51.100.2 &> /dev/null
189 log_test $? 0 "IPv4 fibmatch"
190 $IP -6 route get fibmatch 2001:db8:1::2 &> /dev/null
191 log_test $? 0 "IPv6 fibmatch"
194 $IP link set dev dummy0 down
197 echo " Route deleted on down"
198 $IP route get fibmatch 198.51.100.2 &> /dev/null
199 log_test $? 2 "IPv4 fibmatch"
200 $IP -6 route get fibmatch 2001:db8:1::2 &> /dev/null
201 log_test $? 2 "IPv6 fibmatch"
206 fib_down_multipath_test_do()
211 $IP route get fibmatch 203.0.113.1 \
212 oif $down_dev &> /dev/null
213 log_test $? 2 "IPv4 fibmatch on down device"
214 $IP -6 route get fibmatch 2001:db8:3::1 \
215 oif $down_dev &> /dev/null
216 log_test $? 2 "IPv6 fibmatch on down device"
218 $IP route get fibmatch 203.0.113.1 \
219 oif $up_dev &> /dev/null
220 log_test $? 0 "IPv4 fibmatch on up device"
221 $IP -6 route get fibmatch 2001:db8:3::1 \
222 oif $up_dev &> /dev/null
223 log_test $? 0 "IPv6 fibmatch on up device"
225 $IP route get fibmatch 203.0.113.1 | \
226 grep $down_dev | grep -q "dead linkdown"
227 log_test $? 0 "IPv4 flags on down device"
228 $IP -6 route get fibmatch 2001:db8:3::1 | \
229 grep $down_dev | grep -q "dead linkdown"
230 log_test $? 0 "IPv6 flags on down device"
232 $IP route get fibmatch 203.0.113.1 | \
233 grep $up_dev | grep -q "dead linkdown"
234 log_test $? 1 "IPv4 flags on up device"
235 $IP -6 route get fibmatch 2001:db8:3::1 | \
236 grep $up_dev | grep -q "dead linkdown"
237 log_test $? 1 "IPv6 flags on up device"
240 fib_down_multipath_test()
243 echo "Admin down multipath"
248 $IP link add dummy1 type dummy
249 $IP link set dev dummy1 up
251 $IP address add 192.0.2.1/24 dev dummy1
252 $IP -6 address add 2001:db8:2::1/64 dev dummy1
254 $IP route add 203.0.113.0/24 \
255 nexthop via 198.51.100.2 dev dummy0 \
256 nexthop via 192.0.2.2 dev dummy1
257 $IP -6 route add 2001:db8:3::/64 \
258 nexthop via 2001:db8:1::2 dev dummy0 \
259 nexthop via 2001:db8:2::2 dev dummy1
262 echo " Verify start point"
263 $IP route get fibmatch 203.0.113.1 &> /dev/null
264 log_test $? 0 "IPv4 fibmatch"
266 $IP -6 route get fibmatch 2001:db8:3::1 &> /dev/null
267 log_test $? 0 "IPv6 fibmatch"
270 $IP link set dev dummy0 down
273 echo " One device down, one up"
274 fib_down_multipath_test_do "dummy0" "dummy1"
277 $IP link set dev dummy0 up
278 $IP link set dev dummy1 down
281 echo " Other device down and up"
282 fib_down_multipath_test_do "dummy1" "dummy0"
285 $IP link set dev dummy0 down
288 echo " Both devices down"
289 $IP route get fibmatch 203.0.113.1 &> /dev/null
290 log_test $? 2 "IPv4 fibmatch"
291 $IP -6 route get fibmatch 2001:db8:3::1 &> /dev/null
292 log_test $? 2 "IPv6 fibmatch"
294 $IP link del dev dummy1
300 fib_down_unicast_test
301 fib_down_multipath_test
304 # Local routes should not be affected when carrier changes.
305 fib_carrier_local_test()
308 echo "Local carrier tests - single path"
313 $IP link set dev dummy0 carrier on
317 $IP route get fibmatch 198.51.100.1 &> /dev/null
318 log_test $? 0 "IPv4 fibmatch"
319 $IP -6 route get fibmatch 2001:db8:1::1 &> /dev/null
320 log_test $? 0 "IPv6 fibmatch"
322 $IP route get fibmatch 198.51.100.1 | \
324 log_test $? 1 "IPv4 - no linkdown flag"
325 $IP -6 route get fibmatch 2001:db8:1::1 | \
327 log_test $? 1 "IPv6 - no linkdown flag"
330 $IP link set dev dummy0 carrier off
334 echo " Carrier off on nexthop"
335 $IP route get fibmatch 198.51.100.1 &> /dev/null
336 log_test $? 0 "IPv4 fibmatch"
337 $IP -6 route get fibmatch 2001:db8:1::1 &> /dev/null
338 log_test $? 0 "IPv6 fibmatch"
340 $IP route get fibmatch 198.51.100.1 | \
342 log_test $? 1 "IPv4 - linkdown flag set"
343 $IP -6 route get fibmatch 2001:db8:1::1 | \
345 log_test $? 1 "IPv6 - linkdown flag set"
348 $IP address add 192.0.2.1/24 dev dummy0
349 $IP -6 address add 2001:db8:2::1/64 dev dummy0
352 echo " Route to local address with carrier down"
353 $IP route get fibmatch 192.0.2.1 &> /dev/null
354 log_test $? 0 "IPv4 fibmatch"
355 $IP -6 route get fibmatch 2001:db8:2::1 &> /dev/null
356 log_test $? 0 "IPv6 fibmatch"
358 $IP route get fibmatch 192.0.2.1 | \
360 log_test $? 1 "IPv4 linkdown flag set"
361 $IP -6 route get fibmatch 2001:db8:2::1 | \
363 log_test $? 1 "IPv6 linkdown flag set"
368 fib_carrier_unicast_test()
373 echo "Single path route carrier test"
378 $IP link set dev dummy0 carrier on
382 $IP route get fibmatch 198.51.100.2 &> /dev/null
383 log_test $? 0 "IPv4 fibmatch"
384 $IP -6 route get fibmatch 2001:db8:1::2 &> /dev/null
385 log_test $? 0 "IPv6 fibmatch"
387 $IP route get fibmatch 198.51.100.2 | \
389 log_test $? 1 "IPv4 no linkdown flag"
390 $IP -6 route get fibmatch 2001:db8:1::2 | \
392 log_test $? 1 "IPv6 no linkdown flag"
395 $IP link set dev dummy0 carrier off
400 $IP route get fibmatch 198.51.100.2 &> /dev/null
401 log_test $? 0 "IPv4 fibmatch"
402 $IP -6 route get fibmatch 2001:db8:1::2 &> /dev/null
403 log_test $? 0 "IPv6 fibmatch"
405 $IP route get fibmatch 198.51.100.2 | \
407 log_test $? 0 "IPv4 linkdown flag set"
408 $IP -6 route get fibmatch 2001:db8:1::2 | \
410 log_test $? 0 "IPv6 linkdown flag set"
413 $IP address add 192.0.2.1/24 dev dummy0
414 $IP -6 address add 2001:db8:2::1/64 dev dummy0
417 echo " Second address added with carrier down"
418 $IP route get fibmatch 192.0.2.2 &> /dev/null
419 log_test $? 0 "IPv4 fibmatch"
420 $IP -6 route get fibmatch 2001:db8:2::2 &> /dev/null
421 log_test $? 0 "IPv6 fibmatch"
423 $IP route get fibmatch 192.0.2.2 | \
425 log_test $? 0 "IPv4 linkdown flag set"
426 $IP -6 route get fibmatch 2001:db8:2::2 | \
428 log_test $? 0 "IPv6 linkdown flag set"
435 fib_carrier_local_test
436 fib_carrier_unicast_test
442 echo "IPv4 rp_filter tests"
448 ip netns set ns2 auto
450 ip -netns ns2 link set dev lo up
452 $IP link add name veth1 type veth peer name veth2
453 $IP link set dev veth2 netns ns2
454 $IP address add 192.0.2.1/24 dev veth1
455 ip -netns ns2 address add 192.0.2.1/24 dev veth2
456 $IP link set dev veth1 up
457 ip -netns ns2 link set dev veth2 up
459 $IP link set dev lo address 52:54:00:6a:c7:5e
460 $IP link set dev veth1 address 52:54:00:6a:c7:5e
461 ip -netns ns2 link set dev lo address 52:54:00:6a:c7:5e
462 ip -netns ns2 link set dev veth2 address 52:54:00:6a:c7:5e
464 # 1. (ns2) redirect lo's egress to veth2's egress
465 ip netns exec ns2 tc qdisc add dev lo parent root handle 1: fq_codel
466 ip netns exec ns2 tc filter add dev lo parent 1: protocol arp basic \
467 action mirred egress redirect dev veth2
468 ip netns exec ns2 tc filter add dev lo parent 1: protocol ip basic \
469 action mirred egress redirect dev veth2
471 # 2. (ns1) redirect veth1's ingress to lo's ingress
472 $NS_EXEC tc qdisc add dev veth1 ingress
473 $NS_EXEC tc filter add dev veth1 ingress protocol arp basic \
474 action mirred ingress redirect dev lo
475 $NS_EXEC tc filter add dev veth1 ingress protocol ip basic \
476 action mirred ingress redirect dev lo
478 # 3. (ns1) redirect lo's egress to veth1's egress
479 $NS_EXEC tc qdisc add dev lo parent root handle 1: fq_codel
480 $NS_EXEC tc filter add dev lo parent 1: protocol arp basic \
481 action mirred egress redirect dev veth1
482 $NS_EXEC tc filter add dev lo parent 1: protocol ip basic \
483 action mirred egress redirect dev veth1
485 # 4. (ns2) redirect veth2's ingress to lo's ingress
486 ip netns exec ns2 tc qdisc add dev veth2 ingress
487 ip netns exec ns2 tc filter add dev veth2 ingress protocol arp basic \
488 action mirred ingress redirect dev lo
489 ip netns exec ns2 tc filter add dev veth2 ingress protocol ip basic \
490 action mirred ingress redirect dev lo
492 $NS_EXEC sysctl -qw net.ipv4.conf.all.rp_filter=1
493 $NS_EXEC sysctl -qw net.ipv4.conf.all.accept_local=1
494 $NS_EXEC sysctl -qw net.ipv4.conf.all.route_localnet=1
495 ip netns exec ns2 sysctl -qw net.ipv4.conf.all.rp_filter=1
496 ip netns exec ns2 sysctl -qw net.ipv4.conf.all.accept_local=1
497 ip netns exec ns2 sysctl -qw net.ipv4.conf.all.route_localnet=1
500 run_cmd "ip netns exec ns2 ping -w1 -c1 192.0.2.1"
501 log_test $? 0 "rp_filter passes local packets"
503 run_cmd "ip netns exec ns2 ping -w1 -c1 127.0.0.1"
504 log_test $? 0 "rp_filter passes loopback packets"
509 ################################################################################
510 # Tests on nexthop spec
512 # run 'ip route add' with given spec
523 [ "$vrf" = "-" ] && vrf="default"
524 [ -n "$gw" ] && gw="via $gw"
525 [ -n "$dev" ] && dev="dev $dev"
527 cmd="$IP route add vrf $vrf $pfx $gw $dev"
528 if [ "$VERBOSE" = "1" ]; then
529 printf "\n COMMAND: $cmd\n"
532 out=$(eval $cmd 2>&1)
534 if [ "$VERBOSE" = "1" -a -n "$out" ]; then
537 log_test $rc $erc "$desc"
543 echo "IPv4 nexthop tests"
545 echo "<<< write me >>>"
550 local lldummy=$(get_linklocal dummy0)
551 local llv1=$(get_linklocal dummy0)
553 if [ -z "$lldummy" ]; then
554 echo "Failed to get linklocal address for dummy0"
557 if [ -z "$llv1" ]; then
558 echo "Failed to get linklocal address for veth1"
563 echo "IPv6 nexthop tests"
565 add_rt "Directly connected nexthop, unicast address" 0 \
566 - 2001:db8:101::/64 2001:db8:1::2
567 add_rt "Directly connected nexthop, unicast address with device" 0 \
568 - 2001:db8:102::/64 2001:db8:1::2 "dummy0"
569 add_rt "Gateway is linklocal address" 0 \
570 - 2001:db8:103::1/64 $llv1 "veth0"
572 # fails because LL address requires a device
573 add_rt "Gateway is linklocal address, no device" 2 \
574 - 2001:db8:104::1/64 $llv1
576 # local address can not be a gateway
577 add_rt "Gateway can not be local unicast address" 2 \
578 - 2001:db8:105::/64 2001:db8:1::1
579 add_rt "Gateway can not be local unicast address, with device" 2 \
580 - 2001:db8:106::/64 2001:db8:1::1 "dummy0"
581 add_rt "Gateway can not be a local linklocal address" 2 \
582 - 2001:db8:107::1/64 $lldummy "dummy0"
585 add_rt "Gateway can be local address in a VRF" 0 \
586 - 2001:db8:108::/64 2001:db8:51::2
587 add_rt "Gateway can be local address in a VRF, with device" 0 \
588 - 2001:db8:109::/64 2001:db8:51::2 "veth0"
589 add_rt "Gateway can be local linklocal address in a VRF" 0 \
590 - 2001:db8:110::1/64 $llv1 "veth0"
592 add_rt "Redirect to VRF lookup" 0 \
593 - 2001:db8:111::/64 "" "red"
595 add_rt "VRF route, gateway can be local address in default VRF" 0 \
596 red 2001:db8:112::/64 2001:db8:51::1
598 # local address in same VRF fails
599 add_rt "VRF route, gateway can not be a local address" 2 \
600 red 2001:db8:113::1/64 2001:db8:2::1
601 add_rt "VRF route, gateway can not be a local addr with device" 2 \
602 red 2001:db8:114::1/64 2001:db8:2::1 "dummy1"
606 # dummy0 - 198.51.100.1/24 2001:db8:1::1/64
607 # veth0 - 192.0.2.1/24 2001:db8:51::1/64
610 # dummy1 - 192.168.2.1/24 2001:db8:2::1/64
611 # veth1 - 192.0.2.2/24 2001:db8:51::2/64
613 # [ dummy0 veth0 ]--[ veth1 dummy1 ]
621 $IP -4 rule add pref 32765 table local
622 $IP -4 rule del pref 0
623 $IP -6 rule add pref 32765 table local
624 $IP -6 rule del pref 0
626 $IP link add red type vrf table 1
628 $IP -4 route add vrf red unreachable default metric 4278198272
629 $IP -6 route add vrf red unreachable default metric 4278198272
631 $IP link add veth0 type veth peer name veth1
632 $IP link set dev veth0 up
633 $IP address add 192.0.2.1/24 dev veth0
634 $IP -6 address add 2001:db8:51::1/64 dev veth0
636 $IP link set dev veth1 vrf red up
637 $IP address add 192.0.2.2/24 dev veth1
638 $IP -6 address add 2001:db8:51::2/64 dev veth1
640 $IP link add dummy1 type dummy
641 $IP link set dev dummy1 vrf red up
642 $IP address add 192.168.2.1/24 dev dummy1
643 $IP -6 address add 2001:db8:2::1/64 dev dummy1
651 $IP link del dev dummy1
661 echo "FIB rule with suppress_prefixlength"
664 $IP link add dummy1 type dummy
665 $IP link set dummy1 up
666 $IP -6 route add default dev dummy1
667 $IP -6 rule add table main suppress_prefixlength 0
668 ping -f -c 1000 -W 1 1234::1 >/dev/null 2>&1
669 $IP -6 rule del table main suppress_prefixlength 0
672 # If we got here without crashing, we're good.
673 log_test 0 0 "FIB rule suppress test"
678 ################################################################################
679 # Tests on route add and replace
685 local stderr="2>/dev/null"
687 if [ "$VERBOSE" = "1" ]; then
688 printf " COMMAND: $cmd\n"
692 out=$(eval $cmd $stderr)
694 if [ "$VERBOSE" = "1" -a -n "$out" ]; then
698 [ "$VERBOSE" = "1" ] && echo
709 [ "${out}" = "${expected}" ] && return 0
711 if [ -z "${out}" ]; then
712 if [ "$VERBOSE" = "1" ]; then
713 printf "\nNo route entry found\n"
715 printf " ${expected}\n"
720 # tricky way to convert output to 1-line without ip's
721 # messy '\'; this drops all extra white space
723 if [ "${out}" != "${expected}" ]; then
725 if [ "${VERBOSE}" = "1" ]; then
726 printf " Unexpected route entry. Have:\n"
728 printf " Expected:\n"
729 printf " ${expected}\n\n"
736 # add route for a prefix, flushing any existing routes first
737 # expected to be the first step of a test
744 if [ "$VERBOSE" = "1" ]; then
746 echo " ##################################################"
750 run_cmd "$IP -6 ro flush ${pfx}"
751 [ $? -ne 0 ] && exit 1
753 out=$($IP -6 ro ls match ${pfx})
754 if [ -n "$out" ]; then
755 echo "Failed to flush routes for prefix used for tests."
759 run_cmd "$IP -6 ro add ${pfx} ${nh}"
760 if [ $? -ne 0 ]; then
761 echo "Failed to add initial route for test."
766 # add initial route - used in replace route tests
769 add_route6 "2001:db8:104::/64" "$1"
782 out=$($IP -6 ro ls match ${pfx} | sed -e 's/ pref medium//')
783 check_expected "${out}" "${expected}"
788 $IP li del red 2>/dev/null
789 $IP li del dummy1 2>/dev/null
790 $IP li del veth1 2>/dev/null
791 $IP li del veth3 2>/dev/null
801 [ "${VERBOSE}" = "1" ] && set -x
805 ip netns set ns2 auto
806 ip -netns ns2 link set dev lo up
807 ip netns exec ns2 sysctl -qw net.ipv4.ip_forward=1
808 ip netns exec ns2 sysctl -qw net.ipv6.conf.all.forwarding=1
810 $IP li add veth1 type veth peer name veth2
811 $IP li add veth3 type veth peer name veth4
815 $IP li set veth2 netns ns2 up
816 $IP li set veth4 netns ns2 up
817 ip -netns ns2 li add dummy1 type dummy
818 ip -netns ns2 li set dummy1 up
820 $IP -6 addr add 2001:db8:101::1/64 dev veth1 nodad
821 $IP -6 addr add 2001:db8:103::1/64 dev veth3 nodad
822 $IP addr add 172.16.101.1/24 dev veth1
823 $IP addr add 172.16.103.1/24 dev veth3
825 ip -netns ns2 -6 addr add 2001:db8:101::2/64 dev veth2 nodad
826 ip -netns ns2 -6 addr add 2001:db8:103::2/64 dev veth4 nodad
827 ip -netns ns2 -6 addr add 2001:db8:104::1/64 dev dummy1 nodad
829 ip -netns ns2 addr add 172.16.101.2/24 dev veth2
830 ip -netns ns2 addr add 172.16.103.2/24 dev veth4
831 ip -netns ns2 addr add 172.16.104.1/24 dev dummy1
836 # assumption is that basic add of a single path route works
837 # otherwise just adding an address on an interface is broken
843 echo "IPv6 route add / append tests"
845 # route add same prefix - fails with EEXISTS b/c ip adds NLM_F_EXCL
846 add_route6 "2001:db8:104::/64" "via 2001:db8:101::2"
847 run_cmd "$IP -6 ro add 2001:db8:104::/64 via 2001:db8:103::2"
848 log_test $? 2 "Attempt to add duplicate route - gw"
850 # route add same prefix - fails with EEXISTS b/c ip adds NLM_F_EXCL
851 add_route6 "2001:db8:104::/64" "via 2001:db8:101::2"
852 run_cmd "$IP -6 ro add 2001:db8:104::/64 dev veth3"
853 log_test $? 2 "Attempt to add duplicate route - dev only"
855 # route add same prefix - fails with EEXISTS b/c ip adds NLM_F_EXCL
856 add_route6 "2001:db8:104::/64" "via 2001:db8:101::2"
857 run_cmd "$IP -6 ro add unreachable 2001:db8:104::/64"
858 log_test $? 2 "Attempt to add duplicate route - reject route"
860 # route append with same prefix adds a new route
861 # - iproute2 sets NLM_F_CREATE | NLM_F_APPEND
862 add_route6 "2001:db8:104::/64" "via 2001:db8:101::2"
863 run_cmd "$IP -6 ro append 2001:db8:104::/64 via 2001:db8:103::2"
864 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"
865 log_test $? 0 "Append nexthop to existing route - gw"
867 # insert mpath directly
868 add_route6 "2001:db8:104::/64" "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
869 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"
870 log_test $? 0 "Add multipath route"
872 add_route6 "2001:db8:104::/64" "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
873 run_cmd "$IP -6 ro add 2001:db8:104::/64 nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
874 log_test $? 2 "Attempt to add duplicate multipath route"
876 # insert of a second route without append but different metric
877 add_route6 "2001:db8:104::/64" "via 2001:db8:101::2"
878 run_cmd "$IP -6 ro add 2001:db8:104::/64 via 2001:db8:103::2 metric 512"
880 if [ $rc -eq 0 ]; then
881 run_cmd "$IP -6 ro add 2001:db8:104::/64 via 2001:db8:103::3 metric 256"
884 log_test $rc 0 "Route add with different metrics"
886 run_cmd "$IP -6 ro del 2001:db8:104::/64 metric 512"
888 if [ $rc -eq 0 ]; then
889 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"
892 log_test $rc 0 "Route delete with metric"
895 ipv6_rt_replace_single()
897 # single path with single path
899 add_initial_route6 "via 2001:db8:101::2"
900 run_cmd "$IP -6 ro replace 2001:db8:104::/64 via 2001:db8:103::2"
901 check_route6 "2001:db8:104::/64 via 2001:db8:103::2 dev veth3 metric 1024"
902 log_test $? 0 "Single path with single path"
904 # single path with multipath
906 add_initial_route6 "nexthop via 2001:db8:101::2"
907 run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:101::3 nexthop via 2001:db8:103::2"
908 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"
909 log_test $? 0 "Single path with multipath"
911 # single path with single path using MULTIPATH attribute
913 add_initial_route6 "via 2001:db8:101::2"
914 run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:103::2"
915 check_route6 "2001:db8:104::/64 via 2001:db8:103::2 dev veth3 metric 1024"
916 log_test $? 0 "Single path with single path via multipath attribute"
918 # route replace fails - invalid nexthop
919 add_initial_route6 "via 2001:db8:101::2"
920 run_cmd "$IP -6 ro replace 2001:db8:104::/64 via 2001:db8:104::2"
921 if [ $? -eq 0 ]; then
922 # previous command is expected to fail so if it returns 0
923 # that means the test failed.
924 log_test 0 1 "Invalid nexthop"
926 check_route6 "2001:db8:104::/64 via 2001:db8:101::2 dev veth1 metric 1024"
927 log_test $? 0 "Invalid nexthop"
930 # replace non-existent route
931 # - note use of change versus replace since ip adds NLM_F_CREATE
933 add_initial_route6 "via 2001:db8:101::2"
934 run_cmd "$IP -6 ro change 2001:db8:105::/64 via 2001:db8:101::2"
935 log_test $? 2 "Single path - replace of non-existent route"
938 ipv6_rt_replace_mpath()
940 # multipath with multipath
941 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
942 run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:101::3 nexthop via 2001:db8:103::3"
943 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"
944 log_test $? 0 "Multipath with multipath"
946 # multipath with single
947 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
948 run_cmd "$IP -6 ro replace 2001:db8:104::/64 via 2001:db8:101::3"
949 check_route6 "2001:db8:104::/64 via 2001:db8:101::3 dev veth1 metric 1024"
950 log_test $? 0 "Multipath with single path"
952 # multipath with single
953 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
954 run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:101::3"
955 check_route6 "2001:db8:104::/64 via 2001:db8:101::3 dev veth1 metric 1024"
956 log_test $? 0 "Multipath with single path via multipath attribute"
958 # multipath with dev-only
959 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
960 run_cmd "$IP -6 ro replace 2001:db8:104::/64 dev veth1"
961 check_route6 "2001:db8:104::/64 dev veth1 metric 1024"
962 log_test $? 0 "Multipath with dev-only"
964 # route replace fails - invalid nexthop 1
965 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
966 run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:111::3 nexthop via 2001:db8:103::3"
967 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"
968 log_test $? 0 "Multipath - invalid first nexthop"
970 # route replace fails - invalid nexthop 2
971 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
972 run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:101::3 nexthop via 2001:db8:113::3"
973 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"
974 log_test $? 0 "Multipath - invalid second nexthop"
976 # multipath non-existent route
977 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
978 run_cmd "$IP -6 ro change 2001:db8:105::/64 nexthop via 2001:db8:101::3 nexthop via 2001:db8:103::3"
979 log_test $? 2 "Multipath - replace of non-existent route"
985 echo "IPv6 route replace tests"
987 ipv6_rt_replace_single
988 ipv6_rt_replace_mpath
994 echo "IPv6 route with dsfield tests"
996 run_cmd "$IP -6 route flush 2001:db8:102::/64"
998 # IPv6 doesn't support routing based on dsfield
999 run_cmd "$IP -6 route add 2001:db8:102::/64 dsfield 0x04 via 2001:db8:101::2"
1000 log_test $? 2 "Reject route with dsfield"
1014 ip_addr_metric_check()
1016 ip addr help 2>&1 | grep -q metric
1017 if [ $? -ne 0 ]; then
1018 echo "iproute2 command does not support metric for addresses. Skipping test"
1025 ipv6_addr_metric_test()
1030 echo "IPv6 prefix route tests"
1032 ip_addr_metric_check || return 1
1037 $IP li add dummy1 type dummy
1038 $IP li add dummy2 type dummy
1039 $IP li set dummy1 up
1040 $IP li set dummy2 up
1042 # default entry is metric 256
1043 run_cmd "$IP -6 addr add dev dummy1 2001:db8:104::1/64"
1044 run_cmd "$IP -6 addr add dev dummy2 2001:db8:104::2/64"
1047 check_route6 "2001:db8:104::/64 dev dummy1 proto kernel metric 256 2001:db8:104::/64 dev dummy2 proto kernel metric 256"
1048 log_test $? 0 "Default metric"
1051 run_cmd "$IP -6 addr flush dev dummy1"
1052 run_cmd "$IP -6 addr add dev dummy1 2001:db8:104::1/64 metric 257"
1055 check_route6 "2001:db8:104::/64 dev dummy2 proto kernel metric 256 2001:db8:104::/64 dev dummy1 proto kernel metric 257"
1056 log_test $? 0 "User specified metric on first device"
1059 run_cmd "$IP -6 addr flush dev dummy2"
1060 run_cmd "$IP -6 addr add dev dummy2 2001:db8:104::2/64 metric 258"
1063 check_route6 "2001:db8:104::/64 dev dummy1 proto kernel metric 257 2001:db8:104::/64 dev dummy2 proto kernel metric 258"
1064 log_test $? 0 "User specified metric on second device"
1066 run_cmd "$IP -6 addr del dev dummy1 2001:db8:104::1/64 metric 257"
1068 if [ $rc -eq 0 ]; then
1069 check_route6 "2001:db8:104::/64 dev dummy2 proto kernel metric 258"
1072 log_test $rc 0 "Delete of address on first device"
1074 run_cmd "$IP -6 addr change dev dummy2 2001:db8:104::2/64 metric 259"
1076 if [ $rc -eq 0 ]; then
1077 check_route6 "2001:db8:104::/64 dev dummy2 proto kernel metric 259"
1080 log_test $rc 0 "Modify metric of address"
1082 # verify prefix route removed on down
1083 run_cmd "ip netns exec ns1 sysctl -qw net.ipv6.conf.all.keep_addr_on_down=1"
1084 run_cmd "$IP li set dev dummy2 down"
1086 if [ $rc -eq 0 ]; then
1087 out=$($IP -6 ro ls match 2001:db8:104::/64)
1088 check_expected "${out}" ""
1091 log_test $rc 0 "Prefix route removed on link down"
1093 # verify prefix route re-inserted with assigned metric
1094 run_cmd "$IP li set dev dummy2 up"
1096 if [ $rc -eq 0 ]; then
1097 check_route6 "2001:db8:104::/64 dev dummy2 proto kernel metric 259"
1100 log_test $rc 0 "Prefix route with metric on link up"
1102 # verify peer metric added correctly
1104 run_cmd "$IP -6 addr flush dev dummy2"
1105 run_cmd "$IP -6 addr add dev dummy2 2001:db8:104::1 peer 2001:db8:104::2 metric 260"
1108 check_route6 "2001:db8:104::1 dev dummy2 proto kernel metric 260"
1109 log_test $? 0 "Set metric with peer route on local side"
1110 check_route6 "2001:db8:104::2 dev dummy2 proto kernel metric 260"
1111 log_test $? 0 "Set metric with peer route on peer side"
1114 run_cmd "$IP -6 addr change dev dummy2 2001:db8:104::1 peer 2001:db8:104::3 metric 261"
1117 check_route6 "2001:db8:104::1 dev dummy2 proto kernel metric 261"
1118 log_test $? 0 "Modify metric and peer address on local side"
1119 check_route6 "2001:db8:104::3 dev dummy2 proto kernel metric 261"
1120 log_test $? 0 "Modify metric and peer address on peer side"
1127 ipv6_route_metrics_test()
1132 echo "IPv6 routes with metrics"
1137 # single path with metrics
1139 run_cmd "$IP -6 ro add 2001:db8:111::/64 via 2001:db8:101::2 mtu 1400"
1141 if [ $rc -eq 0 ]; then
1142 check_route6 "2001:db8:111::/64 via 2001:db8:101::2 dev veth1 metric 1024 mtu 1400"
1145 log_test $rc 0 "Single path route with mtu metric"
1149 # multipath via separate routes with metrics
1151 run_cmd "$IP -6 ro add 2001:db8:112::/64 via 2001:db8:101::2 mtu 1400"
1152 run_cmd "$IP -6 ro append 2001:db8:112::/64 via 2001:db8:103::2"
1154 if [ $rc -eq 0 ]; then
1155 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"
1158 log_test $rc 0 "Multipath route via 2 single routes with mtu metric on first"
1160 # second route is coalesced to first to make a multipath route.
1161 # MTU of the second path is hidden from display!
1162 run_cmd "$IP -6 ro add 2001:db8:113::/64 via 2001:db8:101::2"
1163 run_cmd "$IP -6 ro append 2001:db8:113::/64 via 2001:db8:103::2 mtu 1400"
1165 if [ $rc -eq 0 ]; then
1166 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"
1169 log_test $rc 0 "Multipath route via 2 single routes with mtu metric on 2nd"
1171 run_cmd "$IP -6 ro del 2001:db8:113::/64 via 2001:db8:101::2"
1172 if [ $? -eq 0 ]; then
1173 check_route6 "2001:db8:113::/64 via 2001:db8:103::2 dev veth3 metric 1024 mtu 1400"
1174 log_test $? 0 " MTU of second leg"
1178 # multipath with metrics
1180 run_cmd "$IP -6 ro add 2001:db8:115::/64 mtu 1400 nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
1182 if [ $rc -eq 0 ]; then
1183 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"
1186 log_test $rc 0 "Multipath route with mtu metric"
1188 $IP -6 ro add 2001:db8:104::/64 via 2001:db8:101::2 mtu 1300
1189 run_cmd "ip netns exec ns1 ${ping6} -w1 -c1 -s 1500 2001:db8:104::1"
1190 log_test $? 0 "Using route with mtu metric"
1192 run_cmd "$IP -6 ro add 2001:db8:114::/64 via 2001:db8:101::2 congctl lock foo"
1193 log_test $? 2 "Invalid metric (fails metric_convert)"
1198 # add route for a prefix, flushing any existing routes first
1199 # expected to be the first step of a test
1206 if [ "$VERBOSE" = "1" ]; then
1208 echo " ##################################################"
1212 run_cmd "$IP ro flush ${pfx}"
1213 [ $? -ne 0 ] && exit 1
1215 out=$($IP ro ls match ${pfx})
1216 if [ -n "$out" ]; then
1217 echo "Failed to flush routes for prefix used for tests."
1221 run_cmd "$IP ro add ${pfx} ${nh}"
1222 if [ $? -ne 0 ]; then
1223 echo "Failed to add initial route for test."
1228 # add initial route - used in replace route tests
1231 add_route "172.16.104.0/24" "$1"
1242 [ "${pfx}" = "unreachable" ] && pfx=$2
1244 out=$($IP ro ls match ${pfx})
1245 check_expected "${out}" "${expected}"
1248 # assumption is that basic add of a single path route works
1249 # otherwise just adding an address on an interface is broken
1255 echo "IPv4 route add / append tests"
1257 # route add same prefix - fails with EEXISTS b/c ip adds NLM_F_EXCL
1258 add_route "172.16.104.0/24" "via 172.16.101.2"
1259 run_cmd "$IP ro add 172.16.104.0/24 via 172.16.103.2"
1260 log_test $? 2 "Attempt to add duplicate route - gw"
1262 # route add same prefix - fails with EEXISTS b/c ip adds NLM_F_EXCL
1263 add_route "172.16.104.0/24" "via 172.16.101.2"
1264 run_cmd "$IP ro add 172.16.104.0/24 dev veth3"
1265 log_test $? 2 "Attempt to add duplicate route - dev only"
1267 # route add same prefix - fails with EEXISTS b/c ip adds NLM_F_EXCL
1268 add_route "172.16.104.0/24" "via 172.16.101.2"
1269 run_cmd "$IP ro add unreachable 172.16.104.0/24"
1270 log_test $? 2 "Attempt to add duplicate route - reject route"
1272 # iproute2 prepend only sets NLM_F_CREATE
1273 # - adds a new route; does NOT convert existing route to ECMP
1274 add_route "172.16.104.0/24" "via 172.16.101.2"
1275 run_cmd "$IP ro prepend 172.16.104.0/24 via 172.16.103.2"
1276 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"
1277 log_test $? 0 "Add new nexthop for existing prefix"
1279 # route append with same prefix adds a new route
1280 # - iproute2 sets NLM_F_CREATE | NLM_F_APPEND
1281 add_route "172.16.104.0/24" "via 172.16.101.2"
1282 run_cmd "$IP ro append 172.16.104.0/24 via 172.16.103.2"
1283 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"
1284 log_test $? 0 "Append nexthop to existing route - gw"
1286 add_route "172.16.104.0/24" "via 172.16.101.2"
1287 run_cmd "$IP ro append 172.16.104.0/24 dev veth3"
1288 check_route "172.16.104.0/24 via 172.16.101.2 dev veth1 172.16.104.0/24 dev veth3 scope link"
1289 log_test $? 0 "Append nexthop to existing route - dev only"
1291 add_route "172.16.104.0/24" "via 172.16.101.2"
1292 run_cmd "$IP ro append unreachable 172.16.104.0/24"
1293 check_route "172.16.104.0/24 via 172.16.101.2 dev veth1 unreachable 172.16.104.0/24"
1294 log_test $? 0 "Append nexthop to existing route - reject route"
1296 run_cmd "$IP ro flush 172.16.104.0/24"
1297 run_cmd "$IP ro add unreachable 172.16.104.0/24"
1298 run_cmd "$IP ro append 172.16.104.0/24 via 172.16.103.2"
1299 check_route "unreachable 172.16.104.0/24 172.16.104.0/24 via 172.16.103.2 dev veth3"
1300 log_test $? 0 "Append nexthop to existing reject route - gw"
1302 run_cmd "$IP ro flush 172.16.104.0/24"
1303 run_cmd "$IP ro add unreachable 172.16.104.0/24"
1304 run_cmd "$IP ro append 172.16.104.0/24 dev veth3"
1305 check_route "unreachable 172.16.104.0/24 172.16.104.0/24 dev veth3 scope link"
1306 log_test $? 0 "Append nexthop to existing reject route - dev only"
1308 # insert mpath directly
1309 add_route "172.16.104.0/24" "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1310 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"
1311 log_test $? 0 "add multipath route"
1313 add_route "172.16.104.0/24" "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1314 run_cmd "$IP ro add 172.16.104.0/24 nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1315 log_test $? 2 "Attempt to add duplicate multipath route"
1317 # insert of a second route without append but different metric
1318 add_route "172.16.104.0/24" "via 172.16.101.2"
1319 run_cmd "$IP ro add 172.16.104.0/24 via 172.16.103.2 metric 512"
1321 if [ $rc -eq 0 ]; then
1322 run_cmd "$IP ro add 172.16.104.0/24 via 172.16.103.3 metric 256"
1325 log_test $rc 0 "Route add with different metrics"
1327 run_cmd "$IP ro del 172.16.104.0/24 metric 512"
1329 if [ $rc -eq 0 ]; then
1330 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"
1333 log_test $rc 0 "Route delete with metric"
1336 ipv4_rt_replace_single()
1338 # single path with single path
1340 add_initial_route "via 172.16.101.2"
1341 run_cmd "$IP ro replace 172.16.104.0/24 via 172.16.103.2"
1342 check_route "172.16.104.0/24 via 172.16.103.2 dev veth3"
1343 log_test $? 0 "Single path with single path"
1345 # single path with multipath
1347 add_initial_route "nexthop via 172.16.101.2"
1348 run_cmd "$IP ro replace 172.16.104.0/24 nexthop via 172.16.101.3 nexthop via 172.16.103.2"
1349 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"
1350 log_test $? 0 "Single path with multipath"
1352 # single path with reject
1354 add_initial_route "nexthop via 172.16.101.2"
1355 run_cmd "$IP ro replace unreachable 172.16.104.0/24"
1356 check_route "unreachable 172.16.104.0/24"
1357 log_test $? 0 "Single path with reject route"
1359 # single path with single path using MULTIPATH attribute
1361 add_initial_route "via 172.16.101.2"
1362 run_cmd "$IP ro replace 172.16.104.0/24 nexthop via 172.16.103.2"
1363 check_route "172.16.104.0/24 via 172.16.103.2 dev veth3"
1364 log_test $? 0 "Single path with single path via multipath attribute"
1366 # route replace fails - invalid nexthop
1367 add_initial_route "via 172.16.101.2"
1368 run_cmd "$IP ro replace 172.16.104.0/24 via 2001:db8:104::2"
1369 if [ $? -eq 0 ]; then
1370 # previous command is expected to fail so if it returns 0
1371 # that means the test failed.
1372 log_test 0 1 "Invalid nexthop"
1374 check_route "172.16.104.0/24 via 172.16.101.2 dev veth1"
1375 log_test $? 0 "Invalid nexthop"
1378 # replace non-existent route
1379 # - note use of change versus replace since ip adds NLM_F_CREATE
1381 add_initial_route "via 172.16.101.2"
1382 run_cmd "$IP ro change 172.16.105.0/24 via 172.16.101.2"
1383 log_test $? 2 "Single path - replace of non-existent route"
1386 ipv4_rt_replace_mpath()
1388 # multipath with multipath
1389 add_initial_route "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1390 run_cmd "$IP ro replace 172.16.104.0/24 nexthop via 172.16.101.3 nexthop via 172.16.103.3"
1391 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"
1392 log_test $? 0 "Multipath with multipath"
1394 # multipath with single
1395 add_initial_route "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1396 run_cmd "$IP ro replace 172.16.104.0/24 via 172.16.101.3"
1397 check_route "172.16.104.0/24 via 172.16.101.3 dev veth1"
1398 log_test $? 0 "Multipath with single path"
1400 # multipath with single
1401 add_initial_route "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1402 run_cmd "$IP ro replace 172.16.104.0/24 nexthop via 172.16.101.3"
1403 check_route "172.16.104.0/24 via 172.16.101.3 dev veth1"
1404 log_test $? 0 "Multipath with single path via multipath attribute"
1406 # multipath with reject
1407 add_initial_route "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1408 run_cmd "$IP ro replace unreachable 172.16.104.0/24"
1409 check_route "unreachable 172.16.104.0/24"
1410 log_test $? 0 "Multipath with reject route"
1412 # route replace fails - invalid nexthop 1
1413 add_initial_route "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1414 run_cmd "$IP ro replace 172.16.104.0/24 nexthop via 172.16.111.3 nexthop via 172.16.103.3"
1415 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"
1416 log_test $? 0 "Multipath - invalid first nexthop"
1418 # route replace fails - invalid nexthop 2
1419 add_initial_route "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1420 run_cmd "$IP ro replace 172.16.104.0/24 nexthop via 172.16.101.3 nexthop via 172.16.113.3"
1421 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"
1422 log_test $? 0 "Multipath - invalid second nexthop"
1424 # multipath non-existent route
1425 add_initial_route "nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1426 run_cmd "$IP ro change 172.16.105.0/24 nexthop via 172.16.101.3 nexthop via 172.16.103.3"
1427 log_test $? 2 "Multipath - replace of non-existent route"
1433 echo "IPv4 route replace tests"
1435 ipv4_rt_replace_single
1436 ipv4_rt_replace_mpath
1439 # checks that cached input route on VRF port is deleted
1440 # when VRF is deleted
1441 ipv4_local_rt_cache()
1443 run_cmd "ip addr add 10.0.0.1/32 dev lo"
1444 run_cmd "ip netns add test-ns"
1445 run_cmd "ip link add veth-outside type veth peer name veth-inside"
1446 run_cmd "ip link add vrf-100 type vrf table 1100"
1447 run_cmd "ip link set veth-outside master vrf-100"
1448 run_cmd "ip link set veth-inside netns test-ns"
1449 run_cmd "ip link set veth-outside up"
1450 run_cmd "ip link set vrf-100 up"
1451 run_cmd "ip route add 10.1.1.1/32 dev veth-outside table 1100"
1452 run_cmd "ip netns exec test-ns ip link set veth-inside up"
1453 run_cmd "ip netns exec test-ns ip addr add 10.1.1.1/32 dev veth-inside"
1454 run_cmd "ip netns exec test-ns ip route add 10.0.0.1/32 dev veth-inside"
1455 run_cmd "ip netns exec test-ns ip route add default via 10.0.0.1"
1456 run_cmd "ip netns exec test-ns ping 10.0.0.1 -c 1 -i 1"
1457 run_cmd "ip link delete vrf-100"
1459 # if we do not hang test is a success
1460 log_test $? 0 "Cached route removed from VRF port device"
1466 echo "IPv4 route with dsfield tests"
1468 run_cmd "$IP route flush 172.16.102.0/24"
1470 # New routes should reject dsfield options that interfere with ECN
1471 run_cmd "$IP route add 172.16.102.0/24 dsfield 0x01 via 172.16.101.2"
1472 log_test $? 2 "Reject route with dsfield 0x01"
1474 run_cmd "$IP route add 172.16.102.0/24 dsfield 0x02 via 172.16.101.2"
1475 log_test $? 2 "Reject route with dsfield 0x02"
1477 run_cmd "$IP route add 172.16.102.0/24 dsfield 0x03 via 172.16.101.2"
1478 log_test $? 2 "Reject route with dsfield 0x03"
1480 # A generic route that doesn't take DSCP into account
1481 run_cmd "$IP route add 172.16.102.0/24 via 172.16.101.2"
1483 # A more specific route for DSCP 0x10
1484 run_cmd "$IP route add 172.16.102.0/24 dsfield 0x10 via 172.16.103.2"
1486 # DSCP 0x10 should match the specific route, no matter the ECN bits
1487 $IP route get fibmatch 172.16.102.1 dsfield 0x10 | \
1488 grep -q "via 172.16.103.2"
1489 log_test $? 0 "IPv4 route with DSCP and ECN:Not-ECT"
1491 $IP route get fibmatch 172.16.102.1 dsfield 0x11 | \
1492 grep -q "via 172.16.103.2"
1493 log_test $? 0 "IPv4 route with DSCP and ECN:ECT(1)"
1495 $IP route get fibmatch 172.16.102.1 dsfield 0x12 | \
1496 grep -q "via 172.16.103.2"
1497 log_test $? 0 "IPv4 route with DSCP and ECN:ECT(0)"
1499 $IP route get fibmatch 172.16.102.1 dsfield 0x13 | \
1500 grep -q "via 172.16.103.2"
1501 log_test $? 0 "IPv4 route with DSCP and ECN:CE"
1503 # Unknown DSCP should match the generic route, no matter the ECN bits
1504 $IP route get fibmatch 172.16.102.1 dsfield 0x14 | \
1505 grep -q "via 172.16.101.2"
1506 log_test $? 0 "IPv4 route with unknown DSCP and ECN:Not-ECT"
1508 $IP route get fibmatch 172.16.102.1 dsfield 0x15 | \
1509 grep -q "via 172.16.101.2"
1510 log_test $? 0 "IPv4 route with unknown DSCP and ECN:ECT(1)"
1512 $IP route get fibmatch 172.16.102.1 dsfield 0x16 | \
1513 grep -q "via 172.16.101.2"
1514 log_test $? 0 "IPv4 route with unknown DSCP and ECN:ECT(0)"
1516 $IP route get fibmatch 172.16.102.1 dsfield 0x17 | \
1517 grep -q "via 172.16.101.2"
1518 log_test $? 0 "IPv4 route with unknown DSCP and ECN:CE"
1520 # Null DSCP should match the generic route, no matter the ECN bits
1521 $IP route get fibmatch 172.16.102.1 dsfield 0x00 | \
1522 grep -q "via 172.16.101.2"
1523 log_test $? 0 "IPv4 route with no DSCP and ECN:Not-ECT"
1525 $IP route get fibmatch 172.16.102.1 dsfield 0x01 | \
1526 grep -q "via 172.16.101.2"
1527 log_test $? 0 "IPv4 route with no DSCP and ECN:ECT(1)"
1529 $IP route get fibmatch 172.16.102.1 dsfield 0x02 | \
1530 grep -q "via 172.16.101.2"
1531 log_test $? 0 "IPv4 route with no DSCP and ECN:ECT(0)"
1533 $IP route get fibmatch 172.16.102.1 dsfield 0x03 | \
1534 grep -q "via 172.16.101.2"
1535 log_test $? 0 "IPv4 route with no DSCP and ECN:CE"
1550 ipv4_addr_metric_test()
1555 echo "IPv4 prefix route tests"
1557 ip_addr_metric_check || return 1
1562 $IP li add dummy1 type dummy
1563 $IP li add dummy2 type dummy
1564 $IP li set dummy1 up
1565 $IP li set dummy2 up
1567 # default entry is metric 256
1568 run_cmd "$IP addr add dev dummy1 172.16.104.1/24"
1569 run_cmd "$IP addr add dev dummy2 172.16.104.2/24"
1572 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"
1573 log_test $? 0 "Default metric"
1576 run_cmd "$IP addr flush dev dummy1"
1577 run_cmd "$IP addr add dev dummy1 172.16.104.1/24 metric 257"
1580 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"
1581 log_test $? 0 "User specified metric on first device"
1584 run_cmd "$IP addr flush dev dummy2"
1585 run_cmd "$IP addr add dev dummy2 172.16.104.2/24 metric 258"
1588 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"
1589 log_test $? 0 "User specified metric on second device"
1591 run_cmd "$IP addr del dev dummy1 172.16.104.1/24 metric 257"
1593 if [ $rc -eq 0 ]; then
1594 check_route "172.16.104.0/24 dev dummy2 proto kernel scope link src 172.16.104.2 metric 258"
1597 log_test $rc 0 "Delete of address on first device"
1599 run_cmd "$IP addr change dev dummy2 172.16.104.2/24 metric 259"
1601 if [ $rc -eq 0 ]; then
1602 check_route "172.16.104.0/24 dev dummy2 proto kernel scope link src 172.16.104.2 metric 259"
1605 log_test $rc 0 "Modify metric of address"
1607 # verify prefix route removed on down
1608 run_cmd "$IP li set dev dummy2 down"
1610 if [ $rc -eq 0 ]; then
1611 out=$($IP ro ls match 172.16.104.0/24)
1612 check_expected "${out}" ""
1615 log_test $rc 0 "Prefix route removed on link down"
1617 # verify prefix route re-inserted with assigned metric
1618 run_cmd "$IP li set dev dummy2 up"
1620 if [ $rc -eq 0 ]; then
1621 check_route "172.16.104.0/24 dev dummy2 proto kernel scope link src 172.16.104.2 metric 259"
1624 log_test $rc 0 "Prefix route with metric on link up"
1626 # explicitly check for metric changes on edge scenarios
1627 run_cmd "$IP addr flush dev dummy2"
1628 run_cmd "$IP addr add dev dummy2 172.16.104.0/24 metric 259"
1629 run_cmd "$IP addr change dev dummy2 172.16.104.0/24 metric 260"
1631 if [ $rc -eq 0 ]; then
1632 check_route "172.16.104.0/24 dev dummy2 proto kernel scope link src 172.16.104.0 metric 260"
1635 log_test $rc 0 "Modify metric of .0/24 address"
1637 run_cmd "$IP addr flush dev dummy2"
1638 run_cmd "$IP addr add dev dummy2 172.16.104.1/32 peer 172.16.104.2 metric 260"
1640 if [ $rc -eq 0 ]; then
1641 check_route "172.16.104.2 dev dummy2 proto kernel scope link src 172.16.104.1 metric 260"
1644 log_test $rc 0 "Set metric of address with peer route"
1646 run_cmd "$IP addr change dev dummy2 172.16.104.1/32 peer 172.16.104.3 metric 261"
1648 if [ $rc -eq 0 ]; then
1649 check_route "172.16.104.3 dev dummy2 proto kernel scope link src 172.16.104.1 metric 261"
1652 log_test $rc 0 "Modify metric and peer address for peer route"
1659 ipv4_route_metrics_test()
1664 echo "IPv4 route add / append tests"
1668 run_cmd "$IP ro add 172.16.111.0/24 via 172.16.101.2 mtu 1400"
1670 if [ $rc -eq 0 ]; then
1671 check_route "172.16.111.0/24 via 172.16.101.2 dev veth1 mtu 1400"
1674 log_test $rc 0 "Single path route with mtu metric"
1677 run_cmd "$IP ro add 172.16.112.0/24 mtu 1400 nexthop via 172.16.101.2 nexthop via 172.16.103.2"
1679 if [ $rc -eq 0 ]; then
1680 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"
1683 log_test $rc 0 "Multipath route with mtu metric"
1685 $IP ro add 172.16.104.0/24 via 172.16.101.2 mtu 1300
1686 run_cmd "ip netns exec ns1 ping -w1 -c1 -s 1500 172.16.104.1"
1687 log_test $? 0 "Using route with mtu metric"
1689 run_cmd "$IP ro add 172.16.111.0/24 via 172.16.101.2 congctl lock foo"
1690 log_test $? 2 "Invalid metric (fails metric_convert)"
1695 ipv4_del_addr_test()
1698 echo "IPv4 delete address route tests"
1703 $IP li add dummy1 type dummy
1704 $IP li set dummy1 up
1705 $IP li add dummy2 type dummy
1706 $IP li set dummy2 up
1707 $IP li add red type vrf table 1111
1709 $IP ro add vrf red unreachable default
1710 $IP li set dummy2 vrf red
1712 $IP addr add dev dummy1 172.16.104.1/24
1713 $IP addr add dev dummy1 172.16.104.11/24
1714 $IP addr add dev dummy1 172.16.104.12/24
1715 $IP addr add dev dummy2 172.16.104.1/24
1716 $IP addr add dev dummy2 172.16.104.11/24
1717 $IP addr add dev dummy2 172.16.104.12/24
1718 $IP route add 172.16.105.0/24 via 172.16.104.2 src 172.16.104.11
1719 $IP route add 172.16.106.0/24 dev lo src 172.16.104.12
1720 $IP route add vrf red 172.16.105.0/24 via 172.16.104.2 src 172.16.104.11
1721 $IP route add vrf red 172.16.106.0/24 dev lo src 172.16.104.12
1724 # removing address from device in vrf should only remove route from vrf table
1725 echo " Regular FIB info"
1727 $IP addr del dev dummy2 172.16.104.11/24
1728 $IP ro ls vrf red | grep -q 172.16.105.0/24
1729 log_test $? 1 "Route removed from VRF when source address deleted"
1731 $IP ro ls | grep -q 172.16.105.0/24
1732 log_test $? 0 "Route in default VRF not removed"
1734 $IP addr add dev dummy2 172.16.104.11/24
1735 $IP route add vrf red 172.16.105.0/24 via 172.16.104.2 src 172.16.104.11
1737 $IP addr del dev dummy1 172.16.104.11/24
1738 $IP ro ls | grep -q 172.16.105.0/24
1739 log_test $? 1 "Route removed in default VRF when source address deleted"
1741 $IP ro ls vrf red | grep -q 172.16.105.0/24
1742 log_test $? 0 "Route in VRF is not removed by address delete"
1744 # removing address from device in vrf should only remove route from vrf
1745 # table even when the associated fib info only differs in table ID
1746 echo " Identical FIB info with different table ID"
1748 $IP addr del dev dummy2 172.16.104.12/24
1749 $IP ro ls vrf red | grep -q 172.16.106.0/24
1750 log_test $? 1 "Route removed from VRF when source address deleted"
1752 $IP ro ls | grep -q 172.16.106.0/24
1753 log_test $? 0 "Route in default VRF not removed"
1755 $IP addr add dev dummy2 172.16.104.12/24
1756 $IP route add vrf red 172.16.106.0/24 dev lo src 172.16.104.12
1758 $IP addr del dev dummy1 172.16.104.12/24
1759 $IP ro ls | grep -q 172.16.106.0/24
1760 log_test $? 1 "Route removed in default VRF when source address deleted"
1762 $IP ro ls vrf red | grep -q 172.16.106.0/24
1763 log_test $? 0 "Route in VRF is not removed by address delete"
1771 ipv4_route_v6_gw_test()
1776 echo "IPv4 route with IPv6 gateway tests"
1784 run_cmd "$IP ro add 172.16.104.0/24 via inet6 2001:db8:101::2"
1786 log_test $rc 0 "Single path route with IPv6 gateway"
1787 if [ $rc -eq 0 ]; then
1788 check_route "172.16.104.0/24 via inet6 2001:db8:101::2 dev veth1"
1791 run_cmd "ip netns exec ns1 ping -w1 -c1 172.16.104.1"
1792 log_test $rc 0 "Single path route with IPv6 gateway - ping"
1794 run_cmd "$IP ro del 172.16.104.0/24 via inet6 2001:db8:101::2"
1796 log_test $rc 0 "Single path route delete"
1797 if [ $rc -eq 0 ]; then
1798 check_route "172.16.112.0/24"
1802 # multipath - v6 then v4
1804 run_cmd "$IP ro add 172.16.104.0/24 nexthop via inet6 2001:db8:101::2 dev veth1 nexthop via 172.16.103.2 dev veth3"
1806 log_test $rc 0 "Multipath route add - v6 nexthop then v4"
1807 if [ $rc -eq 0 ]; then
1808 check_route "172.16.104.0/24 nexthop via inet6 2001:db8:101::2 dev veth1 weight 1 nexthop via 172.16.103.2 dev veth3 weight 1"
1811 run_cmd "$IP ro del 172.16.104.0/24 nexthop via 172.16.103.2 dev veth3 nexthop via inet6 2001:db8:101::2 dev veth1"
1812 log_test $? 2 " Multipath route delete - nexthops in wrong order"
1814 run_cmd "$IP ro del 172.16.104.0/24 nexthop via inet6 2001:db8:101::2 dev veth1 nexthop via 172.16.103.2 dev veth3"
1815 log_test $? 0 " Multipath route delete exact match"
1818 # multipath - v4 then v6
1820 run_cmd "$IP ro add 172.16.104.0/24 nexthop via 172.16.103.2 dev veth3 nexthop via inet6 2001:db8:101::2 dev veth1"
1822 log_test $rc 0 "Multipath route add - v4 nexthop then v6"
1823 if [ $rc -eq 0 ]; then
1824 check_route "172.16.104.0/24 nexthop via 172.16.103.2 dev veth3 weight 1 nexthop via inet6 2001:db8:101::2 dev veth1 weight 1"
1827 run_cmd "$IP ro del 172.16.104.0/24 nexthop via inet6 2001:db8:101::2 dev veth1 nexthop via 172.16.103.2 dev veth3"
1828 log_test $? 2 " Multipath route delete - nexthops in wrong order"
1830 run_cmd "$IP ro del 172.16.104.0/24 nexthop via 172.16.103.2 dev veth3 nexthop via inet6 2001:db8:101::2 dev veth1"
1831 log_test $? 0 " Multipath route delete exact match"
1838 if [ ! -x "$(command -v socat)" ]; then
1839 echo "socat command not found. Skipping test"
1848 iptables -t mangle -L OUTPUT &> /dev/null
1849 if [ $? -ne 0 ]; then
1850 echo "iptables configuration not supported. Skipping test"
1859 ip6tables -t mangle -L OUTPUT &> /dev/null
1860 if [ $? -ne 0 ]; then
1861 echo "ip6tables configuration not supported. Skipping test"
1873 echo "IPv4 mangling tests"
1875 socat_check || return 1
1876 iptables_check || return 1
1881 local tmp_file=$(mktemp)
1882 ip netns exec ns2 socat UDP4-LISTEN:54321,fork $tmp_file &
1884 # Add a FIB rule and a route that will direct our connection to the
1886 $IP rule add pref 100 ipproto udp sport 12345 dport 54321 table 123
1887 $IP route add table 123 172.16.101.0/24 dev veth1
1889 # Add an unreachable route to the main table that will block our
1890 # connection in case the FIB rule is not hit.
1891 $IP route add unreachable 172.16.101.2/32
1893 run_cmd "echo a | $NS_EXEC socat STDIN UDP4:172.16.101.2:54321,sourceport=12345"
1894 log_test $? 0 " Connection with correct parameters"
1896 run_cmd "echo a | $NS_EXEC socat STDIN UDP4:172.16.101.2:54321,sourceport=11111"
1897 log_test $? 1 " Connection with incorrect parameters"
1899 # Add a mangling rule and make sure connection is still successful.
1900 $NS_EXEC iptables -t mangle -A OUTPUT -j MARK --set-mark 1
1902 run_cmd "echo a | $NS_EXEC socat STDIN UDP4:172.16.101.2:54321,sourceport=12345"
1903 log_test $? 0 " Connection with correct parameters - mangling"
1905 # Delete the mangling rule and make sure connection is still
1907 $NS_EXEC iptables -t mangle -D OUTPUT -j MARK --set-mark 1
1909 run_cmd "echo a | $NS_EXEC socat STDIN UDP4:172.16.101.2:54321,sourceport=12345"
1910 log_test $? 0 " Connection with correct parameters - no mangling"
1912 # Verify connections were indeed successful on server side.
1913 [[ $(cat $tmp_file | wc -l) -eq 3 ]]
1914 log_test $? 0 " Connection check - server side"
1916 $IP route del unreachable 172.16.101.2/32
1917 $IP route del table 123 172.16.101.0/24 dev veth1
1918 $IP rule del pref 100
1920 { kill %% && wait %%; } 2>/dev/null
1931 echo "IPv6 mangling tests"
1933 socat_check || return 1
1934 ip6tables_check || return 1
1939 local tmp_file=$(mktemp)
1940 ip netns exec ns2 socat UDP6-LISTEN:54321,fork $tmp_file &
1942 # Add a FIB rule and a route that will direct our connection to the
1944 $IP -6 rule add pref 100 ipproto udp sport 12345 dport 54321 table 123
1945 $IP -6 route add table 123 2001:db8:101::/64 dev veth1
1947 # Add an unreachable route to the main table that will block our
1948 # connection in case the FIB rule is not hit.
1949 $IP -6 route add unreachable 2001:db8:101::2/128
1951 run_cmd "echo a | $NS_EXEC socat STDIN UDP6:[2001:db8:101::2]:54321,sourceport=12345"
1952 log_test $? 0 " Connection with correct parameters"
1954 run_cmd "echo a | $NS_EXEC socat STDIN UDP6:[2001:db8:101::2]:54321,sourceport=11111"
1955 log_test $? 1 " Connection with incorrect parameters"
1957 # Add a mangling rule and make sure connection is still successful.
1958 $NS_EXEC ip6tables -t mangle -A OUTPUT -j MARK --set-mark 1
1960 run_cmd "echo a | $NS_EXEC socat STDIN UDP6:[2001:db8:101::2]:54321,sourceport=12345"
1961 log_test $? 0 " Connection with correct parameters - mangling"
1963 # Delete the mangling rule and make sure connection is still
1965 $NS_EXEC ip6tables -t mangle -D OUTPUT -j MARK --set-mark 1
1967 run_cmd "echo a | $NS_EXEC socat STDIN UDP6:[2001:db8:101::2]:54321,sourceport=12345"
1968 log_test $? 0 " Connection with correct parameters - no mangling"
1970 # Verify connections were indeed successful on server side.
1971 [[ $(cat $tmp_file | wc -l) -eq 3 ]]
1972 log_test $? 0 " Connection check - server side"
1974 $IP -6 route del unreachable 2001:db8:101::2/128
1975 $IP -6 route del table 123 2001:db8:101::/64 dev veth1
1976 $IP -6 rule del pref 100
1978 { kill %% && wait %%; } 2>/dev/null
1984 ip_neigh_get_check()
1986 ip neigh help 2>&1 | grep -q 'ip neigh get'
1987 if [ $? -ne 0 ]; then
1988 echo "iproute2 command does not support neigh get. Skipping test"
1995 ipv4_bcast_neigh_test()
2000 echo "IPv4 broadcast neighbour tests"
2002 ip_neigh_get_check || return 1
2007 run_cmd "$IP neigh add 192.0.2.111 lladdr 00:11:22:33:44:55 nud perm dev dummy0"
2008 run_cmd "$IP neigh add 192.0.2.255 lladdr 00:11:22:33:44:55 nud perm dev dummy0"
2010 run_cmd "$IP neigh get 192.0.2.111 dev dummy0"
2011 run_cmd "$IP neigh get 192.0.2.255 dev dummy0"
2013 run_cmd "$IP address add 192.0.2.1/24 broadcast 192.0.2.111 dev dummy0"
2015 run_cmd "$IP neigh add 203.0.113.111 nud failed dev dummy0"
2016 run_cmd "$IP neigh add 203.0.113.255 nud failed dev dummy0"
2018 run_cmd "$IP neigh get 203.0.113.111 dev dummy0"
2019 run_cmd "$IP neigh get 203.0.113.255 dev dummy0"
2021 run_cmd "$IP address add 203.0.113.1/24 broadcast 203.0.113.111 dev dummy0"
2024 run_cmd "$IP neigh get 192.0.2.111 dev dummy0"
2025 log_test $? 0 "Resolved neighbour for broadcast address"
2027 run_cmd "$IP neigh get 192.0.2.255 dev dummy0"
2028 log_test $? 0 "Resolved neighbour for network broadcast address"
2030 run_cmd "$IP neigh get 203.0.113.111 dev dummy0"
2031 log_test $? 2 "Unresolved neighbour for broadcast address"
2033 run_cmd "$IP neigh get 203.0.113.255 dev dummy0"
2034 log_test $? 2 "Unresolved neighbour for network broadcast address"
2039 ################################################################################
2045 usage: ${0##*/} OPTS
2047 -t <test> Test(s) to run (default: all)
2050 -P Pause after each test before cleanup
2051 -v verbose mode (show commands and output)
2055 ################################################################################
2058 while getopts :t:pPhv o
2062 p) PAUSE_ON_FAIL=yes;;
2064 v) VERBOSE=$(($VERBOSE + 1));;
2070 PEER_CMD="ip netns exec ${PEER_NS}"
2072 # make sure we don't pause twice
2073 [ "${PAUSE}" = "yes" ] && PAUSE_ON_FAIL=no
2075 if [ "$(id -u)" -ne 0 ];then
2076 echo "SKIP: Need root privileges"
2080 if [ ! -x "$(command -v ip)" ]; then
2081 echo "SKIP: Could not run test without ip tool"
2085 ip route help 2>&1 | grep -q fibmatch
2086 if [ $? -ne 0 ]; then
2087 echo "SKIP: iproute2 too old, missing fibmatch"
2092 cleanup &> /dev/null
2097 fib_unreg_test|unregister) fib_unreg_test;;
2098 fib_down_test|down) fib_down_test;;
2099 fib_carrier_test|carrier) fib_carrier_test;;
2100 fib_rp_filter_test|rp_filter) fib_rp_filter_test;;
2101 fib_nexthop_test|nexthop) fib_nexthop_test;;
2102 fib_suppress_test|suppress) fib_suppress_test;;
2103 ipv6_route_test|ipv6_rt) ipv6_route_test;;
2104 ipv4_route_test|ipv4_rt) ipv4_route_test;;
2105 ipv6_addr_metric) ipv6_addr_metric_test;;
2106 ipv4_addr_metric) ipv4_addr_metric_test;;
2107 ipv4_del_addr) ipv4_del_addr_test;;
2108 ipv6_route_metrics) ipv6_route_metrics_test;;
2109 ipv4_route_metrics) ipv4_route_metrics_test;;
2110 ipv4_route_v6_gw) ipv4_route_v6_gw_test;;
2111 ipv4_mangle) ipv4_mangle_test;;
2112 ipv6_mangle) ipv6_mangle_test;;
2113 ipv4_bcast_neigh) ipv4_bcast_neigh_test;;
2115 help) echo "Test names: $TESTS"; exit 0;;
2119 if [ "$TESTS" != "none" ]; then
2120 printf "\nTests passed: %3d\n" ${nsuccess}
2121 printf "Tests failed: %3d\n" ${nfail}