Lines Matching +full:6 +full:- +full:64
2 # SPDX-License-Identifier: GPL-2.0
9 # all tests in this script. Can be overridden with -t option
28 if [ ${rc} -eq ${expected} ]; then
29 printf " TEST: %-60s [ OK ]\n" "${msg}"
34 printf " TEST: %-60s [FAIL]\n" "${msg}"
53 set -e
55 IP="$(which ip) -netns $ns1"
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
63 $IP -6 address add 2001:db8:1::1/64 dev dummy0
79 addr=$($IP -6 -br addr show dev ${dev} | \
89 [ -z "$addr" ] && return 1
106 $IP -6 route get fibmatch 2001:db8:1::2 &> /dev/null
109 set -e
115 log_test $? 2 "IPv4 fibmatch - no route"
116 $IP -6 route get fibmatch 2001:db8:1::2 &> /dev/null
117 log_test $? 2 "IPv6 fibmatch - no route"
130 set -e
134 $IP -6 address add 2001:db8:2::1/64 dev dummy1
139 $IP -6 route add 2001:db8:3::/64 \
147 $IP -6 route get fibmatch 2001:db8:3::1 &> /dev/null
150 set -e
156 log_test $? 2 "IPv4 - multipath route removed on delete"
158 $IP -6 route get fibmatch 2001:db8:3::1 &> /dev/null
160 log_test $? 0 "IPv6 - multipath down to single path"
162 set -e
167 $IP -6 route get fibmatch 2001:db8:3::1 &> /dev/null
168 log_test $? 2 "IPv6 - no route"
189 $IP -6 route get fibmatch 2001:db8:1::2 &> /dev/null
192 set -e
199 $IP -6 route get fibmatch 2001:db8:1::2 &> /dev/null
213 $IP -6 route get fibmatch 2001:db8:3::1 \
220 $IP -6 route get fibmatch 2001:db8:3::1 \
225 grep $down_dev | grep -q "dead linkdown"
227 $IP -6 route get fibmatch 2001:db8:3::1 | \
228 grep $down_dev | grep -q "dead linkdown"
232 grep $up_dev | grep -q "dead linkdown"
234 $IP -6 route get fibmatch 2001:db8:3::1 | \
235 grep $up_dev | grep -q "dead linkdown"
246 set -e
251 $IP -6 address add 2001:db8:2::1/64 dev dummy1
256 $IP -6 route add 2001:db8:3::/64 \
265 $IP -6 route get fibmatch 2001:db8:3::1 &> /dev/null
268 set -e
275 set -e
283 set -e
290 $IP -6 route get fibmatch 2001:db8:3::1 &> /dev/null
307 echo "Local carrier tests - single path"
311 set -e
318 $IP -6 route get fibmatch 2001:db8:1::1 &> /dev/null
322 grep -q "linkdown"
323 log_test $? 1 "IPv4 - no linkdown flag"
324 $IP -6 route get fibmatch 2001:db8:1::1 | \
325 grep -q "linkdown"
326 log_test $? 1 "IPv6 - no linkdown flag"
328 set -e
336 $IP -6 route get fibmatch 2001:db8:1::1 &> /dev/null
340 grep -q "linkdown"
341 log_test $? 1 "IPv4 - linkdown flag set"
342 $IP -6 route get fibmatch 2001:db8:1::1 | \
343 grep -q "linkdown"
344 log_test $? 1 "IPv6 - linkdown flag set"
346 set -e
348 $IP -6 address add 2001:db8:2::1/64 dev dummy0
354 $IP -6 route get fibmatch 2001:db8:2::1 &> /dev/null
358 grep -q "linkdown"
360 $IP -6 route get fibmatch 2001:db8:2::1 | \
361 grep -q "linkdown"
376 set -e
383 $IP -6 route get fibmatch 2001:db8:1::2 &> /dev/null
387 grep -q "linkdown"
389 $IP -6 route get fibmatch 2001:db8:1::2 | \
390 grep -q "linkdown"
393 set -e
401 $IP -6 route get fibmatch 2001:db8:1::2 &> /dev/null
405 grep -q "linkdown"
407 $IP -6 route get fibmatch 2001:db8:1::2 | \
408 grep -q "linkdown"
411 set -e
413 $IP -6 address add 2001:db8:2::1/64 dev dummy0
419 $IP -6 route get fibmatch 2001:db8:2::2 &> /dev/null
423 grep -q "linkdown"
425 $IP -6 route get fibmatch 2001:db8:2::2 | \
426 grep -q "linkdown"
445 set -e
451 ip -netns $ns2 address add 192.0.2.1/24 dev veth2
453 ip -netns $ns2 link set dev veth2 up
455 $IP link set dev lo address 52:54:00:6a:c7:5e
456 $IP link set dev veth1 address 52:54:00:6a:c7:5e
457 ip -netns $ns2 link set dev lo address 52:54:00:6a:c7:5e
458 ip -netns $ns2 link set dev veth2 address 52:54:00:6a:c7:5e
488 $NS_EXEC sysctl -qw net.ipv4.conf.all.rp_filter=1
489 $NS_EXEC sysctl -qw net.ipv4.conf.all.accept_local=1
490 $NS_EXEC sysctl -qw net.ipv4.conf.all.route_localnet=1
491 ip netns exec $ns2 sysctl -qw net.ipv4.conf.all.rp_filter=1
492 ip netns exec $ns2 sysctl -qw net.ipv4.conf.all.accept_local=1
493 ip netns exec $ns2 sysctl -qw net.ipv4.conf.all.route_localnet=1
496 run_cmd "ip netns exec $ns2 ping -w1 -c1 192.0.2.1"
499 run_cmd "ip netns exec $ns2 ping -w1 -c1 127.0.0.1"
516 local dev=$6
519 [ "$vrf" = "-" ] && vrf="default"
520 [ -n "$gw" ] && gw="via $gw"
521 [ -n "$dev" ] && dev="dev $dev"
530 if [ "$VERBOSE" = "1" -a -n "$out" ]; then
549 if [ -z "$lldummy" ]; then
553 if [ -z "$llv1" ]; then
562 - 2001:db8:101::/64 2001:db8:1::2
564 - 2001:db8:102::/64 2001:db8:1::2 "dummy0"
566 - 2001:db8:103::1/64 $llv1 "veth0"
570 - 2001:db8:104::1/64 $llv1
574 - 2001:db8:105::/64 2001:db8:1::1
576 - 2001:db8:106::/64 2001:db8:1::1 "dummy0"
578 - 2001:db8:107::1/64 $lldummy "dummy0"
582 - 2001:db8:108::/64 2001:db8:51::2
584 - 2001:db8:109::/64 2001:db8:51::2 "veth0"
586 - 2001:db8:110::1/64 $llv1 "veth0"
589 - 2001:db8:111::/64 "" "red"
592 red 2001:db8:112::/64 2001:db8:51::1
596 red 2001:db8:113::1/64 2001:db8:2::1
598 red 2001:db8:114::1/64 2001:db8:2::1 "dummy1"
602 # dummy0 - 198.51.100.1/24 2001:db8:1::1/64
603 # veth0 - 192.0.2.1/24 2001:db8:51::1/64
606 # dummy1 - 192.168.2.1/24 2001:db8:2::1/64
607 # veth1 - 192.0.2.2/24 2001:db8:51::2/64
609 # [ dummy0 veth0 ]--[ veth1 dummy1 ]
615 set -e
617 $IP -4 rule add pref 32765 table local
618 $IP -4 rule del pref 0
619 $IP -6 rule add pref 32765 table local
620 $IP -6 rule del pref 0
624 $IP -4 route add vrf red unreachable default metric 4278198272
625 $IP -6 route add vrf red unreachable default metric 4278198272
630 $IP -6 address add 2001:db8:51::1/64 dev veth0
634 $IP -6 address add 2001:db8:51::2/64 dev veth1
639 $IP -6 address add 2001:db8:2::1/64 dev dummy1
660 set -e
666 $IP -6 address add 2001:$i::1/64 dev dummy_$i
672 $IP -6 route add 2001::/64 \
684 if [ -z "$err" ];then
707 set -e
731 if [ -z "$err" ];then
753 $IP -6 address add 2001:10::1/64 dev dummy_10
761 if [ $num -ne $expected ]; then
774 if [ $num -ne $expected ]; then
789 set -e
795 $NS_EXEC sysctl -wq net.ipv6.route.gc_interval=$EXPIRE
799 $IP -6 address add 2001:10::1/64 dev dummy_10
801 $NS_EXEC sysctl -wq net.ipv6.route.flush=1
806 $IP -6 route add 2001:20::$i \
810 $NS_EXEC sysctl -wq net.ipv6.route.flush=1
811 check_rt_num 0 $($IP -6 route list |grep expires|wc -l)
818 $IP -6 route add 2001:30::$i \
824 $IP -6 route add 2001:20::$i \
829 check_rt_num 0 $($IP -6 route list |grep expires|wc -l)
836 $IP -6 route add 2001:20::$i \
842 $IP -6 route replace 2001:20::$i \
847 check_rt_num 0 $($IP -6 route list |grep expires|wc -l)
855 $IP -6 route add 2001:20::$i \
860 $IP -6 route replace 2001:20::$i \
863 check_rt_num_clean 0 $($IP -6 route list |grep expires|wc -l) || return
867 check_rt_num 5 $($IP -6 route list |grep -v expires|grep 2001:20::|wc -l)
871 if [ ! -x "$(command -v ra6)" ]; then
886 $IP -6 address add 2001:10::1/64 dev veth1 nodad
887 $IP -6 address add 2001:10::2/64 dev veth2 nodad
890 $NS_EXEC sysctl -wq net.ipv6.conf.veth1.accept_ra=2
893 $NS_EXEC ra6 -i veth2 -d 2001:10::1 -t $EXPIRE
899 # systemd-networkd.service and systemd-networkd.socket are stopped.
900 check_rt_num_clean 1 $($IP -6 route list|grep expires|wc -l) || return
904 check_rt_num 0 $($IP -6 route list |grep expires|wc -l)
920 $IP -6 route add default dev dummy1
921 $IP -6 rule add table main suppress_prefixlength 0
922 ping -f -c 1000 -W 1 1234::1 >/dev/null 2>&1
923 $IP -6 rule del table main suppress_prefixlength 0
948 if [ "$VERBOSE" = "1" -a -n "$out" ]; then
965 if [ -z "${out}" ]; then
974 # tricky way to convert output to 1-line without ip's
1004 run_cmd "$IP -6 ro flush ${pfx}"
1005 [ $? -ne 0 ] && exit 1
1007 out=$($IP -6 ro ls match ${pfx})
1008 if [ -n "$out" ]; then
1013 run_cmd "$IP -6 ro add ${pfx} ${nh}"
1014 if [ $? -ne 0 ]; then
1020 # add initial route - used in replace route tests
1023 add_route6 "2001:db8:104::/64" "$1"
1033 set -- $expected
1036 out=$($IP -6 ro ls match ${pfx} | sed -e 's/ pref medium//')
1055 [ "${VERBOSE}" = "1" ] && set -x
1056 set -e
1059 ip netns exec $ns2 sysctl -qw net.ipv4.ip_forward=1
1060 ip netns exec $ns2 sysctl -qw net.ipv6.conf.all.forwarding=1
1069 ip -netns $ns2 li add dummy1 type dummy
1070 ip -netns $ns2 li set dummy1 up
1072 $IP -6 addr add 2001:db8:101::1/64 dev veth1 nodad
1073 $IP -6 addr add 2001:db8:103::1/64 dev veth3 nodad
1077 ip -netns $ns2 -6 addr add 2001:db8:101::2/64 dev veth2 nodad
1078 ip -netns $ns2 -6 addr add 2001:db8:103::2/64 dev veth4 nodad
1079 ip -netns $ns2 -6 addr add 2001:db8:104::1/64 dev dummy1 nodad
1081 ip -netns $ns2 addr add 172.16.101.2/24 dev veth2
1082 ip -netns $ns2 addr add 172.16.103.2/24 dev veth4
1083 ip -netns $ns2 addr add 172.16.104.1/24 dev dummy1
1097 # route add same prefix - fails with EEXISTS b/c ip adds NLM_F_EXCL
1098 add_route6 "2001:db8:104::/64" "via 2001:db8:101::2"
1099 run_cmd "$IP -6 ro add 2001:db8:104::/64 via 2001:db8:103::2"
1100 log_test $? 2 "Attempt to add duplicate route - gw"
1102 # route add same prefix - fails with EEXISTS b/c ip adds NLM_F_EXCL
1103 add_route6 "2001:db8:104::/64" "via 2001:db8:101::2"
1104 run_cmd "$IP -6 ro add 2001:db8:104::/64 dev veth3"
1105 log_test $? 2 "Attempt to add duplicate route - dev only"
1107 # route add same prefix - fails with EEXISTS b/c ip adds NLM_F_EXCL
1108 add_route6 "2001:db8:104::/64" "via 2001:db8:101::2"
1109 run_cmd "$IP -6 ro add unreachable 2001:db8:104::/64"
1110 log_test $? 2 "Attempt to add duplicate route - reject route"
1113 # - iproute2 sets NLM_F_CREATE | NLM_F_APPEND
1114 add_route6 "2001:db8:104::/64" "via 2001:db8:101::2"
1115 run_cmd "$IP -6 ro append 2001:db8:104::/64 via 2001:db8:103::2"
1116 …check_route6 "2001:db8:104::/64 metric 1024 nexthop via 2001:db8:101::2 dev veth1 weight 1 nexthop…
1117 log_test $? 0 "Append nexthop to existing route - gw"
1120 add_route6 "2001:db8:104::/64" "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
1121 …check_route6 "2001:db8:104::/64 metric 1024 nexthop via 2001:db8:101::2 dev veth1 weight 1 nextho…
1124 add_route6 "2001:db8:104::/64" "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
1125 run_cmd "$IP -6 ro add 2001:db8:104::/64 nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
1129 add_route6 "2001:db8:104::/64" "via 2001:db8:101::2"
1130 run_cmd "$IP -6 ro add 2001:db8:104::/64 via 2001:db8:103::2 metric 512"
1132 if [ $rc -eq 0 ]; then
1133 run_cmd "$IP -6 ro add 2001:db8:104::/64 via 2001:db8:103::3 metric 256"
1138 run_cmd "$IP -6 ro del 2001:db8:104::/64 metric 512"
1140 if [ $rc -eq 0 ]; then
1141 …check_route6 "2001:db8:104::/64 via 2001:db8:103::3 dev veth3 metric 256 2001:db8:104::/64 via 200…
1152 run_cmd "$IP -6 ro replace 2001:db8:104::/64 via 2001:db8:103::2"
1153 check_route6 "2001:db8:104::/64 via 2001:db8:103::2 dev veth3 metric 1024"
1159 …run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:101::3 nexthop via 2001:db8:103:…
1160 …check_route6 "2001:db8:104::/64 metric 1024 nexthop via 2001:db8:101::3 dev veth1 weight 1 nexthop…
1166 run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:103::2"
1167 check_route6 "2001:db8:104::/64 via 2001:db8:103::2 dev veth3 metric 1024"
1170 # route replace fails - invalid nexthop
1172 run_cmd "$IP -6 ro replace 2001:db8:104::/64 via 2001:db8:104::2"
1173 if [ $? -eq 0 ]; then
1178 check_route6 "2001:db8:104::/64 via 2001:db8:101::2 dev veth1 metric 1024"
1182 # replace non-existent route
1183 # - note use of change versus replace since ip adds NLM_F_CREATE
1186 run_cmd "$IP -6 ro change 2001:db8:105::/64 via 2001:db8:101::2"
1187 log_test $? 2 "Single path - replace of non-existent route"
1194 …run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:101::3 nexthop via 2001:db8:103:…
1195 …check_route6 "2001:db8:104::/64 metric 1024 nexthop via 2001:db8:101::3 dev veth1 weight 1 nextho…
1200 run_cmd "$IP -6 ro replace 2001:db8:104::/64 via 2001:db8:101::3"
1201 check_route6 "2001:db8:104::/64 via 2001:db8:101::3 dev veth1 metric 1024"
1206 run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:101::3"
1207 check_route6 "2001:db8:104::/64 via 2001:db8:101::3 dev veth1 metric 1024"
1210 # multipath with dev-only
1212 run_cmd "$IP -6 ro replace 2001:db8:104::/64 dev veth1"
1213 check_route6 "2001:db8:104::/64 dev veth1 metric 1024"
1214 log_test $? 0 "Multipath with dev-only"
1216 # route replace fails - invalid nexthop 1
1218 …run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:111::3 nexthop via 2001:db8:103:…
1219 …check_route6 "2001:db8:104::/64 metric 1024 nexthop via 2001:db8:101::2 dev veth1 weight 1 nextho…
1220 log_test $? 0 "Multipath - invalid first nexthop"
1222 # route replace fails - invalid nexthop 2
1224 …run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:101::3 nexthop via 2001:db8:113:…
1225 …check_route6 "2001:db8:104::/64 metric 1024 nexthop via 2001:db8:101::2 dev veth1 weight 1 nextho…
1226 log_test $? 0 "Multipath - invalid second nexthop"
1228 # multipath non-existent route
1230 …run_cmd "$IP -6 ro change 2001:db8:105::/64 nexthop via 2001:db8:101::3 nexthop via 2001:db8:103::…
1231 log_test $? 2 "Multipath - replace of non-existent route"
1248 run_cmd "$IP -6 route flush 2001:db8:102::/64"
1251 run_cmd "$IP -6 route add 2001:db8:102::/64 dsfield 0x04 via 2001:db8:101::2"
1268 ip addr help 2>&1 | grep -q metric
1269 if [ $? -ne 0 ]; then
1288 set -e
1295 run_cmd "$IP -6 addr add dev dummy1 2001:db8:104::1/64"
1296 run_cmd "$IP -6 addr add dev dummy2 2001:db8:104::2/64"
1299 …check_route6 "2001:db8:104::/64 dev dummy1 proto kernel metric 256 2001:db8:104::/64 dev dummy2 pr…
1302 set -e
1303 run_cmd "$IP -6 addr flush dev dummy1"
1304 run_cmd "$IP -6 addr add dev dummy1 2001:db8:104::1/64 metric 257"
1307 …check_route6 "2001:db8:104::/64 dev dummy2 proto kernel metric 256 2001:db8:104::/64 dev dummy1 pr…
1310 set -e
1311 run_cmd "$IP -6 addr flush dev dummy2"
1312 run_cmd "$IP -6 addr add dev dummy2 2001:db8:104::2/64 metric 258"
1315 …check_route6 "2001:db8:104::/64 dev dummy1 proto kernel metric 257 2001:db8:104::/64 dev dummy2 pr…
1318 run_cmd "$IP -6 addr del dev dummy1 2001:db8:104::1/64 metric 257"
1320 if [ $rc -eq 0 ]; then
1321 check_route6 "2001:db8:104::/64 dev dummy2 proto kernel metric 258"
1326 run_cmd "$IP -6 addr change dev dummy2 2001:db8:104::2/64 metric 259"
1328 if [ $rc -eq 0 ]; then
1329 check_route6 "2001:db8:104::/64 dev dummy2 proto kernel metric 259"
1335 run_cmd "ip netns exec $ns1 sysctl -qw net.ipv6.conf.all.keep_addr_on_down=1"
1338 if [ $rc -eq 0 ]; then
1339 out=$($IP -6 ro ls match 2001:db8:104::/64)
1345 # verify prefix route re-inserted with assigned metric
1348 if [ $rc -eq 0 ]; then
1349 check_route6 "2001:db8:104::/64 dev dummy2 proto kernel metric 259"
1355 set -e
1356 run_cmd "$IP -6 addr flush dev dummy2"
1357 run_cmd "$IP -6 addr add dev dummy2 2001:db8:104::1 peer 2001:db8:104::2 metric 260"
1365 set -e
1366 run_cmd "$IP -6 addr change dev dummy2 2001:db8:104::1 peer 2001:db8:104::3 metric 261"
1391 run_cmd "$IP -6 ro add 2001:db8:111::/64 via 2001:db8:101::2 mtu 1400"
1393 if [ $rc -eq 0 ]; then
1394 check_route6 "2001:db8:111::/64 via 2001:db8:101::2 dev veth1 metric 1024 mtu 1400"
1403 run_cmd "$IP -6 ro add 2001:db8:112::/64 via 2001:db8:101::2 mtu 1400"
1404 run_cmd "$IP -6 ro append 2001:db8:112::/64 via 2001:db8:103::2"
1406 if [ $rc -eq 0 ]; then
1407 …check_route6 "2001:db8:112::/64 metric 1024 mtu 1400 nexthop via 2001:db8:101::2 dev veth1 weight …
1414 run_cmd "$IP -6 ro add 2001:db8:113::/64 via 2001:db8:101::2"
1415 run_cmd "$IP -6 ro append 2001:db8:113::/64 via 2001:db8:103::2 mtu 1400"
1417 if [ $rc -eq 0 ]; then
1418 …check_route6 "2001:db8:113::/64 metric 1024 nexthop via 2001:db8:101::2 dev veth1 weight 1 nexthop…
1423 run_cmd "$IP -6 ro del 2001:db8:113::/64 via 2001:db8:101::2"
1424 if [ $? -eq 0 ]; then
1425 check_route6 "2001:db8:113::/64 via 2001:db8:103::2 dev veth3 metric 1024 mtu 1400"
1432 …run_cmd "$IP -6 ro add 2001:db8:115::/64 mtu 1400 nexthop via 2001:db8:101::2 nexthop via 2001:db8…
1434 if [ $rc -eq 0 ]; then
1435 …check_route6 "2001:db8:115::/64 metric 1024 mtu 1400 nexthop via 2001:db8:101::2 dev veth1 weight…
1440 $IP -6 ro add 2001:db8:104::/64 via 2001:db8:101::2 mtu 1300
1441 run_cmd "ip netns exec $ns1 ${ping6} -w1 -c1 -s 1500 2001:db8:104::1"
1444 run_cmd "$IP -6 ro add 2001:db8:114::/64 via 2001:db8:101::2 congctl lock foo"
1465 [ $? -ne 0 ] && exit 1
1468 if [ -n "$out" ]; then
1474 if [ $? -ne 0 ]; then
1480 # add initial route - used in replace route tests
1492 set -- $expected
1509 # route add same prefix - fails with EEXISTS b/c ip adds NLM_F_EXCL
1512 log_test $? 2 "Attempt to add duplicate route - gw"
1514 # route add same prefix - fails with EEXISTS b/c ip adds NLM_F_EXCL
1517 log_test $? 2 "Attempt to add duplicate route - dev only"
1519 # route add same prefix - fails with EEXISTS b/c ip adds NLM_F_EXCL
1522 log_test $? 2 "Attempt to add duplicate route - reject route"
1525 # - adds a new route; does NOT convert existing route to ECMP
1532 # - iproute2 sets NLM_F_CREATE | NLM_F_APPEND
1536 log_test $? 0 "Append nexthop to existing route - gw"
1541 log_test $? 0 "Append nexthop to existing route - dev only"
1546 log_test $? 0 "Append nexthop to existing route - reject route"
1552 log_test $? 0 "Append nexthop to existing reject route - gw"
1558 log_test $? 0 "Append nexthop to existing reject route - dev only"
1573 if [ $rc -eq 0 ]; then
1581 if [ $rc -eq 0 ]; then
1618 # route replace fails - invalid nexthop
1621 if [ $? -eq 0 ]; then
1630 # replace non-existent route
1631 # - note use of change versus replace since ip adds NLM_F_CREATE
1635 log_test $? 2 "Single path - replace of non-existent route"
1664 # route replace fails - invalid nexthop 1
1668 log_test $? 0 "Multipath - invalid first nexthop"
1670 # route replace fails - invalid nexthop 2
1674 log_test $? 0 "Multipath - invalid second nexthop"
1676 # multipath non-existent route
1679 log_test $? 2 "Multipath - replace of non-existent route"
1696 run_cmd "setup_ns test-ns"
1697 run_cmd "ip link add veth-outside type veth peer name veth-inside"
1698 run_cmd "ip link add vrf-100 type vrf table 1100"
1699 run_cmd "ip link set veth-outside master vrf-100"
1700 run_cmd "ip link set veth-inside netns $test-ns"
1701 run_cmd "ip link set veth-outside up"
1702 run_cmd "ip link set vrf-100 up"
1703 run_cmd "ip route add 10.1.1.1/32 dev veth-outside table 1100"
1704 run_cmd "ip netns exec $test-ns ip link set veth-inside up"
1705 run_cmd "ip netns exec $test-ns ip addr add 10.1.1.1/32 dev veth-inside"
1706 run_cmd "ip netns exec $test-ns ip route add 10.0.0.1/32 dev veth-inside"
1707 run_cmd "ip netns exec $test-ns ip route add default via 10.0.0.1"
1708 run_cmd "ip netns exec $test-ns ping 10.0.0.1 -c 1 -i 1"
1709 run_cmd "ip link delete vrf-100"
1740 grep -q "172.16.102.0/24 tos 0x10 via 172.16.103.2"
1741 log_test $? 0 "IPv4 route with DSCP and ECN:Not-ECT"
1744 grep -q "172.16.102.0/24 tos 0x10 via 172.16.103.2"
1748 grep -q "172.16.102.0/24 tos 0x10 via 172.16.103.2"
1752 grep -q "172.16.102.0/24 tos 0x10 via 172.16.103.2"
1757 grep -q "172.16.102.0/24 via 172.16.101.2"
1758 log_test $? 0 "IPv4 route with unknown DSCP and ECN:Not-ECT"
1761 grep -q "172.16.102.0/24 via 172.16.101.2"
1765 grep -q "172.16.102.0/24 via 172.16.101.2"
1769 grep -q "172.16.102.0/24 via 172.16.101.2"
1774 grep -q "172.16.102.0/24 via 172.16.101.2"
1775 log_test $? 0 "IPv4 route with no DSCP and ECN:Not-ECT"
1778 grep -q "172.16.102.0/24 via 172.16.101.2"
1782 grep -q "172.16.102.0/24 via 172.16.101.2"
1786 grep -q "172.16.102.0/24 via 172.16.101.2"
1813 set -e
1827 set -e
1835 set -e
1845 if [ $rc -eq 0 ]; then
1853 if [ $rc -eq 0 ]; then
1862 if [ $rc -eq 0 ]; then
1869 # verify prefix route re-inserted with assigned metric
1872 if [ $rc -eq 0 ]; then
1883 if [ $rc -eq 0 ]; then
1892 if [ $rc -eq 0 ]; then
1900 if [ $rc -eq 0 ]; then
1922 if [ $rc -eq 0 ]; then
1931 if [ $rc -eq 0 ]; then
1938 run_cmd "ip netns exec $ns1 ping -w1 -c1 -s 1500 172.16.104.1"
1954 set -e
1982 $IP ro ls vrf red | grep -q 172.16.105.0/24
1985 $IP ro ls | grep -q 172.16.105.0/24
1992 $IP ro ls | grep -q 172.16.105.0/24
1995 $IP ro ls vrf red | grep -q 172.16.105.0/24
2003 $IP ro ls vrf red | grep -q 172.16.106.0/24
2006 $IP ro ls | grep -q 172.16.106.0/24
2013 $IP ro ls | grep -q 172.16.106.0/24
2016 $IP ro ls vrf red | grep -q 172.16.106.0/24
2024 $IP ro ls | grep -q 172.16.107.0/24
2039 set -e
2040 for i in $(seq 6); do
2046 for i in $(seq 4 6); do
2051 $IP addr add dev dummy1 2001:db8:101::1/64
2052 $IP addr add dev dummy1 2001:db8:101::10/64
2053 $IP addr add dev dummy1 2001:db8:101::11/64
2054 $IP addr add dev dummy1 2001:db8:101::12/64
2055 $IP addr add dev dummy1 2001:db8:101::13/64
2056 $IP addr add dev dummy1 2001:db8:101::14/64
2057 $IP addr add dev dummy1 2001:db8:101::15/64
2059 $IP addr add dev dummy2 2001:db8:101::1/64
2060 $IP addr add dev dummy2 2001:db8:101::11/64
2063 $IP addr add dev dummy4 2001:db8:101::1/64
2064 $IP addr add dev dummy4 2001:db8:101::10/64
2065 $IP addr add dev dummy4 2001:db8:101::11/64
2066 $IP addr add dev dummy4 2001:db8:101::12/64
2067 $IP addr add dev dummy4 2001:db8:101::13/64
2068 $IP addr add dev dummy4 2001:db8:101::14/64
2069 $IP addr add dev dummy5 2001:db8:101::1/64
2070 $IP addr add dev dummy5 2001:db8:101::11/64
2073 $IP route add 2001:db8:110::/64 dev dummy3 src 2001:db8:101::10
2075 $IP route add 2001:db8:111::/64 dev dummy3 src 2001:db8:101::11
2077 $IP route add vrf red 2001:db8:110::/64 dev dummy6 src 2001:db8:101::10
2079 $IP route add vrf red 2001:db8:111::/64 dev dummy6 src 2001:db8:101::11
2081 $IP route add 2001:db8:112::/64 dev dummy3 src 2001:db8:101::12
2082 $IP route add vrf red 2001:db8:112::/64 dev dummy6 src 2001:db8:101::12
2084 $IP route add 2001:db8:113::/64 dev lo src 2001:db8:101::13
2085 $IP route add vrf red 2001:db8:113::/64 dev lo src 2001:db8:101::13
2087 $IP route add table 0 2001:db8:115::/64 via 2001:db8:101::2 src 2001:db8:101::15
2089 $IP route add 2001:db8:116::/64 dev dummy2 src fe80::1
2090 $IP route add 2001:db8:117::/64 dev dummy3 src fe80::1
2095 $IP addr del dev dummy1 2001:db8:101::10/64
2096 $IP -6 route show | grep -q "src 2001:db8:101::10 "
2101 $IP addr del dev dummy1 2001:db8:101::11/64
2102 $IP -6 route show | grep -q "src 2001:db8:101::11 "
2105 $IP addr del dev dummy2 2001:db8:101::11/64
2106 $IP -6 route show | grep -q "src 2001:db8:101::11 "
2111 $IP addr del dev dummy4 2001:db8:101::10/64
2112 $IP -6 route show vrf red | grep -q "src 2001:db8:101::10 "
2117 $IP addr del dev dummy4 2001:db8:101::11/64
2118 $IP -6 route show vrf red | grep -q "src 2001:db8:101::11 "
2121 $IP addr del dev dummy5 2001:db8:101::11/64
2122 $IP -6 route show vrf red | grep -q "src 2001:db8:101::11 "
2127 $IP addr del dev dummy4 2001:db8:101::12/64
2128 $IP -6 route show vrf red | grep -q "src 2001:db8:101::12 "
2130 $IP -6 route show | grep -q " src 2001:db8:101::12 "
2133 $IP addr add dev dummy4 2001:db8:101::12/64
2134 $IP route replace vrf red 2001:db8:112::/64 dev dummy6 src 2001:db8:101::12
2135 $IP addr del dev dummy1 2001:db8:101::12/64
2136 $IP -6 route show vrf red | grep -q "src 2001:db8:101::12 "
2138 $IP -6 route show | grep -q " src 2001:db8:101::12 "
2143 $IP addr del dev dummy4 2001:db8:101::13/64
2144 $IP -6 route show vrf red | grep -q "src 2001:db8:101::13 "
2146 $IP -6 route show | grep -q "src 2001:db8:101::13 "
2149 $IP addr add dev dummy4 2001:db8:101::13/64
2150 $IP addr del dev dummy1 2001:db8:101::13/64
2151 $IP -6 route show vrf red | grep -q "src 2001:db8:101::13 "
2153 $IP -6 route show | grep -q "src 2001:db8:101::13 "
2158 $IP addr del dev dummy1 2001:db8:101::15/64
2159 $IP -6 route show | grep -q "src 2001:db8:101::15"
2164 $IP -6 route show | grep -q "2001:db8:116::/64 dev dummy2 src fe80::1"
2167 $IP -6 route show | grep -q "2001:db8:116::/64 dev dummy2 src fe80::1"
2169 $IP -6 route show | grep -q "2001:db8:117::/64 dev dummy3 src fe80::1"
2173 $IP -6 route show | grep -q "2001:db8:117::/64 dev dummy3 src fe80::1"
2176 for i in $(seq 6); do
2198 if [ $rc -eq 0 ]; then
2202 run_cmd "ip netns exec $ns1 ping -w1 -c1 172.16.104.1"
2203 log_test $rc 0 "Single path route with IPv6 gateway - ping"
2208 if [ $rc -eq 0 ]; then
2213 # multipath - v6 then v4
2217 log_test $rc 0 "Multipath route add - v6 nexthop then v4"
2218 if [ $rc -eq 0 ]; then
2223 log_test $? 2 " Multipath route delete - nexthops in wrong order"
2229 # multipath - v4 then v6
2233 log_test $rc 0 "Multipath route add - v4 nexthop then v6"
2234 if [ $rc -eq 0 ]; then
2239 log_test $? 2 " Multipath route delete - nexthops in wrong order"
2249 if [ ! -x "$(command -v socat)" ]; then
2259 iptables -t mangle -L OUTPUT &> /dev/null
2260 if [ $? -ne 0 ]; then
2270 ip6tables -t mangle -L OUTPUT &> /dev/null
2271 if [ $? -ne 0 ]; then
2293 ip netns exec $ns2 socat UDP4-LISTEN:54321,fork $tmp_file &
2311 $NS_EXEC iptables -t mangle -A OUTPUT -j MARK --set-mark 1
2314 log_test $? 0 " Connection with correct parameters - mangling"
2318 $NS_EXEC iptables -t mangle -D OUTPUT -j MARK --set-mark 1
2321 log_test $? 0 " Connection with correct parameters - no mangling"
2324 [[ $(cat $tmp_file | wc -l) -eq 3 ]]
2325 log_test $? 0 " Connection check - server side"
2351 ip netns exec $ns2 socat UDP6-LISTEN:54321,fork $tmp_file &
2355 $IP -6 rule add pref 100 ipproto udp sport 12345 dport 54321 table 123
2356 $IP -6 route add table 123 2001:db8:101::/64 dev veth1
2360 $IP -6 route add unreachable 2001:db8:101::2/128
2369 $NS_EXEC ip6tables -t mangle -A OUTPUT -j MARK --set-mark 1
2372 log_test $? 0 " Connection with correct parameters - mangling"
2376 $NS_EXEC ip6tables -t mangle -D OUTPUT -j MARK --set-mark 1
2379 log_test $? 0 " Connection with correct parameters - no mangling"
2382 [[ $(cat $tmp_file | wc -l) -eq 3 ]]
2383 log_test $? 0 " Connection check - server side"
2385 $IP -6 route del unreachable 2001:db8:101::2/128
2386 $IP -6 route del table 123 2001:db8:101::/64 dev veth1
2387 $IP -6 rule del pref 100
2397 ip neigh help 2>&1 | grep -q 'ip neigh get'
2398 if [ $? -ne 0 ]; then
2417 set -e
2452 if [ ! -x "$(command -v mausezahn)" ]; then
2457 if [ ! -x "$(command -v jq)" ]; then
2462 if [ ! -x "$(command -v bc)" ]; then
2467 if [ ! -x "$(command -v perf)" ]; then
2472 perf list fib:* | grep -q fib_table_lookup
2473 if [ $? -ne 0 ]; then
2478 perf list fib6:* | grep -q fib6_table_lookup
2479 if [ $? -ne 0 ]; then
2494 ip -n $ns -j -s link show dev $dev \
2503 local count=$(tail -n 1 $file | jq '.["counter-value"] | tonumber | floor')
2504 local ratio=$(echo "scale=2; $count / $expected" | bc -l)
2506 [[ $res -eq 1 ]]
2519 set -e
2520 run_cmd "ip netns exec $ns1 ethtool -K veth1 tcp-segmentation-offload off"
2522 run_cmd "ip netns exec $ns2 bash -c \"echo 20000 > /sys/class/net/veth2/gro_flush_timeout\""
2523 run_cmd "ip netns exec $ns2 bash -c \"echo 1 > /sys/class/net/veth2/napi_defer_hard_irqs\""
2524 run_cmd "ip netns exec $ns2 ethtool -K veth2 generic-receive-offload on"
2525 run_cmd "ip -n $ns2 link add name nh1 up type dummy"
2526 run_cmd "ip -n $ns2 link add name nh2 up type dummy"
2527 run_cmd "ip -n $ns2 address add 172.16.201.1/24 dev nh1"
2528 run_cmd "ip -n $ns2 address add 172.16.202.1/24 dev nh2"
2529 run_cmd "ip -n $ns2 neigh add 172.16.201.2 lladdr 00:11:22:33:44:55 nud perm dev nh1"
2530 run_cmd "ip -n $ns2 neigh add 172.16.202.2 lladdr 00:aa:bb:cc:dd:ee nud perm dev nh2"
2531 run_cmd "ip -n $ns2 route add 203.0.113.0/24
2533 run_cmd "ip netns exec $ns2 sysctl -qw net.ipv4.fib_multipath_hash_policy=1"
2534 run_cmd "ip netns exec $ns2 sysctl -qw net.ipv4.conf.veth2.rp_filter=0"
2535 run_cmd "ip netns exec $ns2 sysctl -qw net.ipv4.conf.all.rp_filter=0"
2536 run_cmd "ip netns exec $ns2 sysctl -qw net.ipv4.conf.default.rp_filter=0"
2539 local dmac=$(ip -n $ns2 -j link show dev veth2 | jq -r '.[]["address"]')
2541 local cmd="ip netns exec $ns1 mausezahn veth1 -a own -b $dmac
2542 -A 172.16.101.1 -B 203.0.113.1 -t udp 'sp=12345,dp=0-65535' -q"
2549 run_cmd "perf stat -a -e fib:fib_table_lookup --filter 'err == 0' -j -o $tmp_file -- $cmd"
2551 local diff=$(echo $t1_rx_pkts - $t0_rx_pkts | bc -l)
2567 set -e
2568 run_cmd "ip netns exec $ns1 ethtool -K veth1 tcp-segmentation-offload off"
2570 run_cmd "ip netns exec $ns2 bash -c \"echo 20000 > /sys/class/net/veth2/gro_flush_timeout\""
2571 run_cmd "ip netns exec $ns2 bash -c \"echo 1 > /sys/class/net/veth2/napi_defer_hard_irqs\""
2572 run_cmd "ip netns exec $ns2 ethtool -K veth2 generic-receive-offload on"
2573 run_cmd "ip -n $ns2 link add name nh1 up type dummy"
2574 run_cmd "ip -n $ns2 link add name nh2 up type dummy"
2575 run_cmd "ip -n $ns2 -6 address add 2001:db8:201::1/64 dev nh1"
2576 run_cmd "ip -n $ns2 -6 address add 2001:db8:202::1/64 dev nh2"
2577 run_cmd "ip -n $ns2 -6 neigh add 2001:db8:201::2 lladdr 00:11:22:33:44:55 nud perm dev nh1"
2578 run_cmd "ip -n $ns2 -6 neigh add 2001:db8:202::2 lladdr 00:aa:bb:cc:dd:ee nud perm dev nh2"
2579 run_cmd "ip -n $ns2 -6 route add 2001:db8:301::/64
2581 run_cmd "ip netns exec $ns2 sysctl -qw net.ipv6.fib_multipath_hash_policy=1"
2584 local dmac=$(ip -n $ns2 -j link show dev veth2 | jq -r '.[]["address"]')
2586 local cmd="ip netns exec $ns1 mausezahn -6 veth1 -a own -b $dmac
2587 -A 2001:db8:101::1 -B 2001:db8:301::1 -t udp 'sp=12345,dp=0-65535' -q"
2594 run_cmd "perf stat -a -e fib6:fib6_table_lookup --filter 'err == 0' -j -o $tmp_file -- $cmd"
2596 local diff=$(echo $t1_rx_pkts - $t0_rx_pkts | bc -l)
2611 -t <test> Test(s) to run (default: all)
2613 -p Pause on fail
2614 -P Pause after each test before cleanup
2615 -v verbose mode (show commands and output)
2641 if [ "$(id -u)" -ne 0 ];then
2646 if [ ! -x "$(command -v ip)" ]; then
2651 ip route help 2>&1 | grep -q fibmatch
2652 if [ $? -ne 0 ]; then