Lines Matching +full:- +full:group

2 # SPDX-License-Identifier: GPL-2.0
7 # veth1 <---|---> veth2 |
8 # | veth5 <--|--> veth6 172.16.101.1
9 # veth3 <---|---> veth4 | 2001:db8:101::1
19 # Kselftest framework requirement - SKIP code is 4.
22 # all tests in this script. Can be overridden with -t option
75 if [ ${rc} -eq ${expected} ]; then
76 printf "TEST: %-60s [ OK ]\n" "${msg}"
79 if [[ $rc -eq $ksft_skip ]]; then
80 [[ $ret -eq 0 ]] && ret=$ksft_skip
82 printf "TEST: %-60s [SKIP]\n" "${msg}"
86 printf "TEST: %-60s [FAIL]\n" "${msg}"
124 if [ "$VERBOSE" = "1" -a -n "$out" ]; then
137 [ -n "$2" ] && ns="-netns $2"
138 addr=$(ip $ns -6 -br addr show dev ${dev} | \
148 [ -z "$addr" ] && return 1
159 set -e
161 ip netns exec ${n} sysctl -qw net.ipv4.ip_forward=1
162 ip netns exec ${n} sysctl -qw net.ipv4.fib_multipath_use_neigh=1
163 ip netns exec ${n} sysctl -qw net.ipv4.conf.default.ignore_routes_with_linkdown=1
164 ip netns exec ${n} sysctl -qw net.ipv6.conf.all.keep_addr_on_down=1
165 ip netns exec ${n} sysctl -qw net.ipv6.conf.all.forwarding=1
166 ip netns exec ${n} sysctl -qw net.ipv6.conf.default.forwarding=1
167 ip netns exec ${n} sysctl -qw net.ipv6.conf.default.ignore_routes_with_linkdown=1
168 ip netns exec ${n} sysctl -qw net.ipv6.conf.all.accept_dad=0
169 ip netns exec ${n} sysctl -qw net.ipv6.conf.default.accept_dad=0
183 IP="ip -netns $me"
184 BRIDGE="bridge -netns $me"
185 set -e
189 $IP -6 addr add 2001:db8:91::1/64 dev veth1 nodad
194 $IP -6 addr add 2001:db8:92::1/64 dev veth3 nodad
197 ip -netns $peer addr add 172.16.1.2/24 dev veth2
198 ip -netns $peer -6 addr add 2001:db8:91::2/64 dev veth2 nodad
201 ip -netns $peer addr add 172.16.2.2/24 dev veth4
202 ip -netns $peer -6 addr add 2001:db8:92::2/64 dev veth4 nodad
204 ip -netns $remote li add veth5 type veth peer name veth6
205 ip -netns $remote li set veth5 up
206 ip -netns $remote addr add dev veth5 172.16.101.1/24
207 ip -netns $remote -6 addr add dev veth5 2001:db8:101::1/64 nodad
208 ip -netns $remote ro add 172.16.0.0/22 via 172.16.101.2
209 ip -netns $remote -6 ro add 2001:db8:90::/40 via 2001:db8:101::2
211 ip -netns $remote li set veth6 netns $peer up
212 ip -netns $peer addr add dev veth6 172.16.101.2/24
213 ip -netns $peer -6 addr add dev veth6 2001:db8:101::2/64 nodad
234 if [ -z "${out}" ]; then
278 | sed s/idle_time\ [0-9.]*\ // 2>/dev/null)
300 out=$($IP -6 route ls match ${pfx} 2>/dev/null | sed -e 's/pref medium//')
318 if [ $ipv -eq 4 ]; then
330 while [ $iter -le $(($ecmp + 1)) ]
336 if [ $iter -le $ecmp ]; then
346 while [ $iter -le $grpnum ]
349 run_cmd "$IP nexthop add id $grpidstr group $grpstr"
350 check_nexthop "id $grpidstr" "id $grpidstr group $grpstr"
365 if [ $ipv -eq 4 ]; then
371 # create a resilient group with $buckets buckets and dump them
373 run_cmd "$IP nexthop add id 1000 group 100 type resilient buckets $buckets"
383 if out=$($IP -j route get "$pfx" | jq -re ".[0].dev"); then
418 lines=`wc -l $tmpfile | cut "-d " -f1`
419 test $lines -eq $el
421 rm -rf $tmpfile
428 $IP nexthop help 2>&1 | grep -q fdb
429 if [ $? -ne 0 ]; then
437 $IP nexthop help 2>&1 | grep -q resilient
438 if [ $? -ne 0 ]; then
439 echo "SKIP: iproute2 too old, missing resilient nexthop group support"
450 echo "--------------------------"
453 if [ $? -eq $ksft_skip ]; then
457 # create group with multiple nexthops
460 run_cmd "$IP nexthop add id 102 group 61/62 fdb"
461 check_nexthop "id 102" "id 102 group 61/62 fdb"
462 log_test $? 0 "Fdb Nexthop group with multiple nexthops"
464 ## get nexthop group
466 check_nexthop "id 102" "id 102 group 61/62 fdb"
467 log_test $? 0 "Get Fdb nexthop group by id"
469 # fdb nexthop group can only contain fdb nexthops
472 run_cmd "$IP nexthop add id 103 group 63/64 fdb"
473 log_test $? 2 "Fdb Nexthop group with non-fdb nexthops"
475 # Non fdb nexthop group can not contain fdb nexthops
478 run_cmd "$IP nexthop add id 104 group 65/66"
479 log_test $? 2 "Non-Fdb Nexthop group with fdb nexthops"
497 # Replace FDB nexthop to non-FDB and vice versa
500 log_test $? 0 "Replace FDB nexthop to non-FDB nexthop"
502 log_test $? 0 "Replace non-FDB nexthop to FDB nexthop"
504 # Replace FDB nexthop address while in a group
505 run_cmd "$IP nexthop add id 71 group 70 fdb"
507 log_test $? 0 "Replace FDB nexthop address while in a group"
509 # Cannot replace FDB nexthop to non-FDB and vice versa while in a group
511 log_test $? 2 "Replace FDB nexthop to non-FDB nexthop while in a group"
513 run_cmd "$IP nexthop add id 73 group 72"
515 log_test $? 2 "Replace non-FDB nexthop to FDB nexthop while in a group"
519 log_test $? 0 "Fdb mac add with nexthop group"
525 run_cmd "$IP -6 ro add 2001:db8:101::1/128 nhid 66"
528 run_cmd "$IP -6 ro add 2001:db8:101::1/128 nhid 103"
529 log_test $? 2 "Route add with fdb nexthop group"
539 log_test $? 254 "Fdb entry after deleting a nexthop group"
550 echo "--------------------------"
553 if [ $? -eq $ksft_skip ]; then
557 # create group with multiple nexthops
560 run_cmd "$IP nexthop add id 102 group 12/13 fdb"
561 check_nexthop "id 102" "id 102 group 12/13 fdb"
562 log_test $? 0 "Fdb Nexthop group with multiple nexthops"
564 # get nexthop group
566 check_nexthop "id 102" "id 102 group 12/13 fdb"
567 log_test $? 0 "Get Fdb nexthop group by id"
569 # fdb nexthop group can only contain fdb nexthops
572 run_cmd "$IP nexthop add id 103 group 14/15 fdb"
573 log_test $? 2 "Fdb Nexthop group with non-fdb nexthops"
575 # Non fdb nexthop group can not contain fdb nexthops
578 run_cmd "$IP nexthop add id 104 group 16/17"
579 log_test $? 2 "Non-Fdb Nexthop group with fdb nexthops"
597 # Replace FDB nexthop to non-FDB and vice versa
600 log_test $? 0 "Replace FDB nexthop to non-FDB nexthop"
602 log_test $? 0 "Replace non-FDB nexthop to FDB nexthop"
604 # Replace FDB nexthop address while in a group
605 run_cmd "$IP nexthop add id 19 group 18 fdb"
607 log_test $? 0 "Replace FDB nexthop address while in a group"
609 # Cannot replace FDB nexthop to non-FDB and vice versa while in a group
611 log_test $? 2 "Replace FDB nexthop to non-FDB nexthop while in a group"
613 run_cmd "$IP nexthop add id 21 group 20"
615 log_test $? 2 "Replace non-FDB nexthop to FDB nexthop while in a group"
619 log_test $? 0 "Fdb mac add with nexthop group"
629 log_test $? 2 "Route add with fdb nexthop group"
639 log_test $? 254 "Fdb entry after deleting a nexthop group"
650 echo "------------------------"
651 if [ ! -x "$(command -v jq)" ]; then
658 local -A gws
660 local -A other_dev
665 run_cmd "$IP nexthop add id 1001 group 1/2"
703 echo "------------------------"
704 if [ ! -x "$(command -v jq)" ]; then
711 local -A gws
713 local -A other_dev
718 run_cmd "$IP nexthop add id 1001 group 1/2"
761 echo "----------------------"
766 if [ $rc -ne 0 ]; then
782 # gw validation, no device - fails since dev required
784 log_test $? 2 "Create nexthop - gw only"
788 log_test $? 2 "Create nexthop - invalid gw+dev combination"
792 log_test $? 0 "Create nexthop - gw+dev and onlink"
795 set -e
796 run_cmd "$IP -6 nexthop add id 55 via 2001:db8:91::3 dev veth1"
807 if [ ! -x "$(command -v mausezahn)" ]; then
815 run_cmd "$IP -6 addr add 2001:db8:91::1/64 dev veth1.10"
816 run_cmd "$IP -6 addr add 2001:db8:92::1/64 dev veth1.20"
817 run_cmd "$IP -6 neigh add 2001:db8:91::2 lladdr 00:11:22:33:44:55 dev veth1.10"
818 run_cmd "$IP -6 neigh add 2001:db8:92::2 lladdr 00:11:22:33:44:55 dev veth1.20"
821 run_cmd "$IP nexthop add id 102 group 100"
824 # create per-cpu dsts through nh 100
825 …run_cmd "ip netns exec $me mausezahn -6 veth1.10 -B 2001:db8:101::1 -A 2001:db8:91::1 -c 5 -t tcp …
827 # remove nh 100 from the group to delete the route potentially leaving
828 # a stale per-cpu dst which holds a reference to the nexthop's net
830 run_cmd "$IP nexthop replace id 102 group 101"
833 # add both nexthops to the group so a reference is taken on them
834 run_cmd "$IP nexthop replace id 102 group 100/101"
836 # if the bug described in commit "net: nexthop: release IPv6 per-cpu
837 # dsts when replacing a nexthop group" exists at this point we have
839 # reference over the group so we delete the group which will again
844 # group with a ref to it and an unlinked IPv6 route with ref to the
845 # group, the nh will only be unlinked and not freed so the stale dst
851 timeout -s KILL 5 ip netns exec $me ip link del veth1.10 >/dev/null 2>&1
854 if [ $? -eq 137 ]; then
871 echo "----------------------"
873 # basic functionality: create a nexthop group, default weight
875 run_cmd "$IP nexthop add id 101 group 61"
876 log_test $? 0 "Create nexthop group with single nexthop"
878 # get nexthop group
880 log_test $? 0 "Get nexthop group by id"
881 check_nexthop "id 101" "id 101 group 61"
883 # delete nexthop group
885 log_test $? 0 "Delete nexthop group by id"
892 # create group with multiple nexthops - mix of gw and dev only
898 run_cmd "$IP nexthop add id 102 group 62/63/64/65"
899 log_test $? 0 "Nexthop group with multiple nexthops"
900 check_nexthop "id 102" "id 102 group 62/63/64/65"
902 # Delete nexthop in a group and group is updated
904 check_nexthop "id 102" "id 102 group 62/64/65"
905 log_test $? 0 "Nexthop group updated when entry is deleted"
907 # create group with multiple weighted nexthops
909 run_cmd "$IP nexthop add id 103 group 62/63,2/64,3/65,4"
910 log_test $? 0 "Nexthop group with weighted nexthops"
911 check_nexthop "id 103" "id 103 group 62/63,2/64,3/65,4"
913 # Delete nexthop in a weighted group and group is updated
915 check_nexthop "id 103" "id 103 group 62/64,3/65,4"
916 log_test $? 0 "Weighted nexthop group updated when entry is deleted"
918 # admin down - nexthop is removed from group
930 # group with nexthops using different devices
931 set -e
944 run_cmd "$IP nexthop add id 104 group 62"
945 run_cmd "$IP nexthop add id 105 group 62"
946 check_nexthop "group" "id 104 group 62 id 105 group 62"
950 [ $? -ne 0 ] && return 1
952 # on admin down of veth1, it should be removed from the group
953 run_cmd "$IP nexthop add id 105 group 62/63/72/73/64"
955 check_nexthop "id 105" "id 105 group 72/73"
956 log_test $? 0 "Nexthops in group removed on admin down - mixed group"
958 run_cmd "$IP nexthop add id 106 group 105/74"
959 log_test $? 2 "Nexthop group can not have a group as an entry"
961 # a group can have a blackhole entry only if it is the only
962 # nexthop in the group. Needed for atomic replace with an
963 # actual nexthop group
964 run_cmd "$IP -6 nexthop add id 31 blackhole"
965 run_cmd "$IP nexthop add id 107 group 31"
966 log_test $? 0 "Nexthop group with a blackhole entry"
968 run_cmd "$IP nexthop add id 108 group 31/24"
969 log_test $? 2 "Nexthop group can not have a blackhole and another nexthop"
972 log_test $? 0 "Nexthop group replace refcounts"
975 # 16-bit weights.
983 run_cmd "$IP nexthop add id 103 group 62,1000"
985 local GRP="id 103 group 62,254/63,255/64,256/65,257/66,65535"
995 log_test $rc 0 "16-bit weights"
1004 echo "--------------------------------"
1007 if [ $? -eq $ksft_skip ]; then
1012 # migration of nexthop buckets - equal weights
1016 run_cmd "$IP nexthop add id 102 group 62/63 type resilient buckets 2 idle_timer 0"
1020 "id 102 group 62 type resilient buckets 2 idle_timer 0 unbalanced_timer 0 unbalanced_time 0"
1021 log_test $? 0 "Nexthop group updated when entry is deleted"
1027 run_cmd "$IP nexthop replace id 102 group 62/63 type resilient buckets 2 idle_timer 0"
1029 "id 102 group 62/63 type resilient buckets 2 idle_timer 0 unbalanced_timer 0 unbalanced_time 0"
1030 log_test $? 0 "Nexthop group updated after replace"
1038 # migration of nexthop buckets - unequal weights
1042 run_cmd "$IP nexthop add id 102 group 62,3/63,1 type resilient buckets 4 idle_timer 0"
1046 "id 102 group 62,3 type resilient buckets 4 idle_timer 0 unbalanced_timer 0 unbalanced_time 0"
1047 log_test $? 0 "Nexthop group updated when entry is deleted - nECMP"
1050 log_test $? 0 "Nexthop buckets updated when entry is deleted - nECMP"
1053 run_cmd "$IP nexthop replace id 102 group 62,3/63,1 type resilient buckets 4 idle_timer 0"
1055 "id 102 group 62,3/63 type resilient buckets 4 idle_timer 0 unbalanced_timer 0 unbalanced_time 0"
1056 log_test $? 0 "Nexthop group updated after replace - nECMP"
1059 log_test $? 0 "Nexthop buckets updated after replace - nECMP"
1062 # 16-bit weights.
1070 run_cmd "$IP nexthop add id 103 group 62,1000 type resilient buckets 32"
1072 local GRP="id 103 group 62,254/63,255/64,256/65,257/66,65535 $(:
1084 log_test $rc 0 "16-bit weights"
1093 echo "-----------------------"
1096 # IPv6 - the basics
1106 run_cmd "ip netns exec $me ping -c1 -w$PING_TIMEOUT 2001:db8:101::1"
1110 run_cmd "$IP nexthop add id 122 group 81/82"
1112 run_cmd "ip netns exec $me ping -c1 -w$PING_TIMEOUT 2001:db8:101::1"
1113 log_test $? 0 "Ping - multipath"
1118 run_cmd "$IP -6 nexthop add id 83 blackhole"
1120 run_cmd "ip netns exec $me ping -c1 -w$PING_TIMEOUT 2001:db8:101::1"
1121 log_test $? 2 "Ping - blackhole"
1124 run_cmd "ip netns exec $me ping -c1 -w$PING_TIMEOUT 2001:db8:101::1"
1125 log_test $? 0 "Ping - blackhole replaced with gateway"
1127 run_cmd "$IP -6 nexthop replace id 83 blackhole"
1128 run_cmd "ip netns exec $me ping -c1 -w$PING_TIMEOUT 2001:db8:101::1"
1129 log_test $? 2 "Ping - gateway replaced by blackhole"
1132 run_cmd "ip netns exec $me ping -c1 -w$PING_TIMEOUT 2001:db8:101::1"
1133 if [ $? -eq 0 ]; then
1134 run_cmd "$IP nexthop replace id 122 group 83"
1135 run_cmd "ip netns exec $me ping -c1 -w$PING_TIMEOUT 2001:db8:101::1"
1136 log_test $? 2 "Ping - group with blackhole"
1138 run_cmd "$IP nexthop replace id 122 group 81/82"
1139 run_cmd "ip netns exec $me ping -c1 -w$PING_TIMEOUT 2001:db8:101::1"
1140 log_test $? 0 "Ping - group blackhole replaced with gateways"
1142 log_test 2 0 "Ping - multipath failed"
1148 run_cmd "$IP -6 nexthop add id 85 dev veth1"
1153 run_cmd "$IP nexthop add id 123 group 81/85"
1155 log_test $? 0 "IPv6 multipath route with nexthop mix - dev only + gw"
1159 # IPv6 route with v4 nexthop - not allowed
1168 log_test $? 2 "Nexthop replace - v6 route, v4 nexthop"
1172 log_test $? 2 "Nexthop replace of group entry - v6 route, v4 nexthop"
1177 run_cmd "$IP nexthop add id 124 group 86/87/88"
1179 log_test $? 2 "IPv6 route can not have a group with v4 and v6 gateways"
1183 log_test $? 2 "IPv6 route can not have a group with v4 and v6 gateways"
1187 log_test $? 0 "IPv6 route using a group after removing v4 gateways"
1192 run_cmd "$IP nexthop replace id 124 group 86/87/88"
1194 log_test $? 2 "IPv6 route can not have a group with v4 and v6 gateways"
1198 log_test $? 2 "IPv6 route can not have a group with v4 and v6 gateways"
1202 log_test $? 0 "IPv6 route using a group after replacing v4 gateways"
1222 run_cmd "ip netns exec $me ip6tables -t mangle -I PREROUTING 1 -m rpfilter --invert -j DROP"
1225 run_cmd "$IP nexthop add id 93 group 91/92"
1226 run_cmd "$IP -6 ro add default nhid 91"
1227 run_cmd "ip netns exec $me ping -c1 -w$PING_TIMEOUT 2001:db8:101::1"
1229 run_cmd "$IP -6 ro replace default nhid 93"
1230 run_cmd "ip netns exec $me ping -c1 -w$PING_TIMEOUT 2001:db8:101::1"
1233 # TO-DO:
1237 # route with src address and using nexthop - not allowed
1246 echo "---------------------"
1256 echo "IPv6 large resilient group (128k buckets)"
1257 echo "-----------------------------------------"
1260 if [ $? -eq $ksft_skip ]; then
1280 $IP nexthop replace id 102 group 100/101
1294 echo "--------------------"
1295 if [ ! -x "$(command -v mausezahn)" ]; then
1302 run_cmd "$IP nexthop add id 102 group 100/101"
1310 ip netns exec $me ping -f 2001:db8:101::1 >/dev/null 2>&1 &
1312 ip netns exec $me ping -f 2001:db8:101::2 >/dev/null 2>&1 &
1314 …ip netns exec $me mausezahn -6 veth1 -B 2001:db8:101::2 -A 2001:db8:91::1 -c 0 -t tcp "dp=1-1023, …
1318 kill -9 $pid1 $pid2 $pid3 $pid4 $pid5
1328 $IP nexthop replace id 102 group 100/101 type resilient
1341 echo "IPv6 runtime resilient nexthop group torture"
1342 echo "--------------------------------------------"
1345 if [ $? -eq $ksft_skip ]; then
1349 if [ ! -x "$(command -v mausezahn)" ]; then
1356 run_cmd "$IP nexthop add id 102 group 100/101 type resilient buckets 512 idle_timer 0"
1364 ip netns exec $me ping -f 2001:db8:101::1 >/dev/null 2>&1 &
1366 ip netns exec $me ping -f 2001:db8:101::2 >/dev/null 2>&1 &
1368 ip netns exec $me mausezahn -6 veth1 \
1369 -B 2001:db8:101::2 -A 2001:db8:91::1 -c 0 \
1370 -t tcp "dp=1-1023, flags=syn" >/dev/null 2>&1 &
1374 kill -9 $pid1 $pid2 $pid3 $pid4 $pid5
1378 log_test 0 0 "IPv6 resilient nexthop group torture test"
1387 echo "----------------------"
1390 # basic IPv4 ops - add, get, delete
1395 if [ $rc -ne 0 ]; then
1411 # gw validation, no device - fails since dev is required
1413 log_test $? 2 "Create nexthop - gw only"
1417 log_test $? 2 "Create nexthop - invalid gw+dev combination"
1421 log_test $? 0 "Create nexthop - gw+dev and onlink"
1424 set -e
1437 out1=`dmesg | grep "WARNING:.*fib_nh_match.*" | wc -l`
1440 out2=`dmesg | grep "WARNING:.*fib_nh_match.*" | wc -l`
1441 [ $out1 -eq $out2 ]
1470 echo "----------------------"
1472 # basic functionality: create a nexthop group, default weight
1474 run_cmd "$IP nexthop add id 101 group 11"
1475 log_test $? 0 "Create nexthop group with single nexthop"
1477 # get nexthop group
1479 log_test $? 0 "Get nexthop group by id"
1480 check_nexthop "id 101" "id 101 group 11"
1482 # delete nexthop group
1484 log_test $? 0 "Delete nexthop group by id"
1490 # create group with multiple nexthops
1495 run_cmd "$IP nexthop add id 102 group 12/13/14/15"
1496 log_test $? 0 "Nexthop group with multiple nexthops"
1497 check_nexthop "id 102" "id 102 group 12/13/14/15"
1499 # Delete nexthop in a group and group is updated
1501 check_nexthop "id 102" "id 102 group 12/14/15"
1502 log_test $? 0 "Nexthop group updated when entry is deleted"
1504 # create group with multiple weighted nexthops
1506 run_cmd "$IP nexthop add id 103 group 12/13,2/14,3/15,4"
1507 log_test $? 0 "Nexthop group with weighted nexthops"
1508 check_nexthop "id 103" "id 103 group 12/13,2/14,3/15,4"
1510 # Delete nexthop in a weighted group and group is updated
1512 check_nexthop "id 103" "id 103 group 12/14,3/15,4"
1513 log_test $? 0 "Weighted nexthop group updated when entry is deleted"
1515 # admin down - nexthop is removed from group
1527 # group with nexthops using different devices
1528 set -e
1541 run_cmd "$IP nexthop add id 104 group 12"
1542 run_cmd "$IP nexthop add id 105 group 12"
1543 check_nexthop "group" "id 104 group 12 id 105 group 12"
1547 [ $? -ne 0 ] && return 1
1549 # on admin down of veth1, it should be removed from the group
1550 run_cmd "$IP nexthop add id 105 group 12/13/22/23/14"
1552 check_nexthop "id 105" "id 105 group 22/23"
1553 log_test $? 0 "Nexthops in group removed on admin down - mixed group"
1555 run_cmd "$IP nexthop add id 106 group 105/24"
1556 log_test $? 2 "Nexthop group can not have a group as an entry"
1558 # a group can have a blackhole entry only if it is the only
1559 # nexthop in the group. Needed for atomic replace with an
1560 # actual nexthop group
1562 run_cmd "$IP nexthop add id 107 group 31"
1563 log_test $? 0 "Nexthop group with a blackhole entry"
1565 run_cmd "$IP nexthop add id 108 group 31/24"
1566 log_test $? 2 "Nexthop group can not have a blackhole and another nexthop"
1575 echo "--------------------------------"
1578 if [ $? -eq $ksft_skip ]; then
1583 # migration of nexthop buckets - equal weights
1587 run_cmd "$IP nexthop add id 102 group 12/13 type resilient buckets 2 idle_timer 0"
1591 "id 102 group 12 type resilient buckets 2 idle_timer 0 unbalanced_timer 0 unbalanced_time 0"
1592 log_test $? 0 "Nexthop group updated when entry is deleted"
1598 run_cmd "$IP nexthop replace id 102 group 12/13 type resilient buckets 2 idle_timer 0"
1600 "id 102 group 12/13 type resilient buckets 2 idle_timer 0 unbalanced_timer 0 unbalanced_time 0"
1601 log_test $? 0 "Nexthop group updated after replace"
1609 # migration of nexthop buckets - unequal weights
1613 run_cmd "$IP nexthop add id 102 group 12,3/13,1 type resilient buckets 4 idle_timer 0"
1617 "id 102 group 12,3 type resilient buckets 4 idle_timer 0 unbalanced_timer 0 unbalanced_time 0"
1618 log_test $? 0 "Nexthop group updated when entry is deleted - nECMP"
1621 log_test $? 0 "Nexthop buckets updated when entry is deleted - nECMP"
1624 run_cmd "$IP nexthop replace id 102 group 12,3/13,1 type resilient buckets 4 idle_timer 0"
1626 "id 102 group 12,3/13 type resilient buckets 4 idle_timer 0 unbalanced_timer 0 unbalanced_time 0"
1627 log_test $? 0 "Nexthop group updated after replace - nECMP"
1630 log_test $? 0 "Nexthop buckets updated after replace - nECMP"
1637 set -e
1645 set -e
1647 run_cmd "$IP nexthop add id 101 group 11/12"
1669 echo "-----------------------"
1684 log_test $? 2 "Route add - scope conflict with nexthop"
1700 run_cmd "ip netns exec $me ping -c1 -w$PING_TIMEOUT 172.16.101.1"
1704 run_cmd "$IP nexthop add id 122 group 21/22"
1706 run_cmd "ip netns exec $me ping -c1 -w$PING_TIMEOUT 172.16.101.1"
1707 log_test $? 0 "Ping - multipath"
1713 # - tests fib_select_default
1717 run_cmd "ip netns exec $me ping -c1 -w$PING_TIMEOUT 172.16.101.1"
1718 log_test $? 0 "Ping - multiple default routes, nh first"
1726 run_cmd "ip netns exec $me ping -c1 -w$PING_TIMEOUT 172.16.101.1"
1727 log_test $? 0 "Ping - multiple default routes, nh second"
1737 run_cmd "ip netns exec $me ping -c1 -w$PING_TIMEOUT 172.16.101.1"
1738 log_test $? 2 "Ping - blackhole"
1741 run_cmd "ip netns exec $me ping -c1 -w$PING_TIMEOUT 172.16.101.1"
1742 log_test $? 0 "Ping - blackhole replaced with gateway"
1745 run_cmd "ip netns exec $me ping -c1 -w$PING_TIMEOUT 172.16.101.1"
1746 log_test $? 2 "Ping - gateway replaced by blackhole"
1749 run_cmd "ip netns exec $me ping -c1 -w$PING_TIMEOUT 172.16.101.1"
1750 if [ $? -eq 0 ]; then
1751 run_cmd "$IP nexthop replace id 122 group 23"
1752 run_cmd "ip netns exec $me ping -c1 -w$PING_TIMEOUT 172.16.101.1"
1753 log_test $? 2 "Ping - group with blackhole"
1755 run_cmd "$IP nexthop replace id 122 group 21/22"
1756 run_cmd "ip netns exec $me ping -c1 -w$PING_TIMEOUT 172.16.101.1"
1757 log_test $? 0 "Ping - group blackhole replaced with gateways"
1759 log_test 2 0 "Ping - multipath failed"
1770 run_cmd "$IP nexthop add id 123 group 21/85"
1772 log_test $? 0 "IPv4 multipath route with nexthop mix - dev only + gw"
1778 set -e
1783 run_cmd "ip netns exec $me ping -c1 -w$PING_TIMEOUT 172.16.101.1"
1786 $IP neigh sh | grep -q "${lladdr} dev veth1"
1787 if [ $? -eq 1 ]; then
1792 $IP neigh sh | grep -q "172.16.101.1 dev eth1"
1793 if [ $? -eq 0 ]; then
1798 set -e
1800 run_cmd "$IP nexthop add id 101 group 24/25"
1803 log_test $? 0 "IPv4 route with mixed v4-v6 multipath route"
1807 run_cmd "ip netns exec $me ping -c1 -w$PING_TIMEOUT 172.16.101.1"
1811 run_cmd "ip netns exec $me ping -c1 -w$PING_TIMEOUT 172.16.101.1"
1814 $IP neigh sh | grep -q "${lladdr} dev veth1"
1815 if [ $? -eq 1 ]; then
1820 $IP neigh sh | grep -q "172.16.101.1 dev eth1"
1821 if [ $? -eq 0 ]; then
1827 run_cmd "$IP -4 ro add default via inet6 ${lladdr} dev veth1"
1828 run_cmd "ip netns exec $me ping -c1 -w$PING_TIMEOUT 172.16.101.1"
1837 log_test $? 0 "IPv4 route with MPLS encap - check"
1842 log_test $? 0 "IPv4 route with MPLS encap, v6 gw - check"
1851 echo "---------------------"
1861 echo "IPv4 large resilient group (128k buckets)"
1862 echo "-----------------------------------------"
1865 if [ $? -eq $ksft_skip ]; then
1881 $IPE sysctl -q $sysctlname 2>&1 >/dev/null
1882 if [ $? -ne 0 ]; then
1900 out=$($IPE sysctl -w $sysctlname=$mode)
1901 log_test $? 0 "$lprefix set compat mode - $mode"
1911 echo "--------------------------------"
1914 if [ $? -eq $ksft_skip ]; then
1920 run_cmd "$IP nexthop add id 122 group 62/63"
1923 run_cmd "$IP -6 ro add 2001:db8:101::1/128 nhid 122"
1926 log_test $? 0 "IPv6 compat mode on - route add notification"
1930 log_test $? 0 "IPv6 compat mode on - route dump"
1932 # change in nexthop group should generate route notification
1935 run_cmd "$IP nexthop replace id 122 group 62/64"
1938 log_test $? 0 "IPv6 compat mode on - nexthop change"
1943 run_cmd "$IP -6 ro del 2001:db8:101::1/128 nhid 122"
1947 run_cmd "$IP nexthop add id 122 group 62/63"
1950 run_cmd "$IP -6 ro add 2001:db8:101::1/128 nhid 122"
1953 log_test $? 0 "IPv6 compat mode off - route add notification"
1957 log_test $? 0 "IPv6 compat mode off - route dump"
1959 # change in nexthop group should not generate route notification
1962 run_cmd "$IP nexthop replace id 122 group 62/64"
1964 log_test $? 0 "IPv6 compat mode off - nexthop change"
1970 log_test $? 0 "IPv6 compat mode off - nexthop delete"
1982 echo "----------------------------"
1985 if [ $? -eq $ksft_skip ]; then
1991 run_cmd "$IP nexthop add id 122 group 21/22"
1998 log_test $? 0 "IPv4 compat mode on - route add notification"
2002 log_test $? 0 "IPv4 compat mode on - route dump"
2004 # change in nexthop group should generate route notification
2007 run_cmd "$IP nexthop replace id 122 group 21/23"
2009 log_test $? 0 "IPv4 compat mode on - nexthop change"
2020 log_test $? 0 "IPv4 compat mode off - route add notification"
2024 log_test $? 0 "IPv4 compat mode off - route dump"
2026 # change in nexthop group should not generate route notification
2028 run_cmd "$IP nexthop replace id 122 group 21/22"
2030 log_test $? 0 "IPv4 compat mode off - nexthop change"
2036 log_test $? 0 "IPv4 compat mode off - nexthop delete"
2052 $IP nexthop replace id 102 group 100/101
2066 echo "--------------------"
2067 if [ ! -x "$(command -v mausezahn)" ]; then
2074 run_cmd "$IP nexthop add id 102 group 100/101"
2082 ip netns exec $me ping -f 172.16.101.1 >/dev/null 2>&1 &
2084 ip netns exec $me ping -f 172.16.101.2 >/dev/null 2>&1 &
2086 …ip netns exec $me mausezahn veth1 -B 172.16.101.2 -A 172.16.1.1 -c 0 -t tcp "dp=1-1023, flags=syn"…
2090 kill -9 $pid1 $pid2 $pid3 $pid4 $pid5
2100 $IP nexthop replace id 102 group 100/101 type resilient
2113 echo "IPv4 runtime resilient nexthop group torture"
2114 echo "--------------------------------------------"
2117 if [ $? -eq $ksft_skip ]; then
2121 if [ ! -x "$(command -v mausezahn)" ]; then
2128 run_cmd "$IP nexthop add id 102 group 100/101 type resilient buckets 512 idle_timer 0"
2136 ip netns exec $me ping -f 172.16.101.1 >/dev/null 2>&1 &
2138 ip netns exec $me ping -f 172.16.101.2 >/dev/null 2>&1 &
2141 -B 172.16.101.2 -A 172.16.1.1 -c 0 \
2142 -t tcp "dp=1-1023, flags=syn" >/dev/null 2>&1 &
2146 kill -9 $pid1 $pid2 $pid3 $pid4 $pid5
2150 log_test 0 0 "IPv4 resilient nexthop group torture test"
2157 echo "----------------------"
2162 log_test $? 2 "Nexthop get on non-existent id"
2165 log_test $? 2 "Nexthop del with non-existent id"
2167 run_cmd "$IP nexthop del id 1 group 1/2/3/4/5/6/7/8"
2168 log_test $? 2 "Nexthop del with non-existent id and extra attributes"
2170 # attempt to create nh without a device or gw - fails
2174 # attempt to create nh with down device - fails
2179 # create nh with linkdown device - fails
2181 ip -netns $peer li set veth2 down
2184 ip -netns $peer li set veth2 up
2211 run_cmd "$IP nexthop add id $((2**32-1)) blackhole"
2219 run_cmd "$IP nexthop add id 101 group 1"
2220 log_test $? 0 "Create group"
2222 run_cmd "$IP nexthop add id 102 group 2"
2223 log_test $? 0 "Create group with blackhole nexthop"
2225 # multipath group can not have a blackhole as 1 path
2226 run_cmd "$IP nexthop add id 103 group 1/2"
2227 log_test $? 2 "Create multipath group where 1 path is a blackhole"
2229 # multipath group can not have a member replaced by a blackhole
2231 run_cmd "$IP nexthop replace id 102 group 1/2"
2233 log_test $? 2 "Multipath group can not have a member replaced by blackhole"
2235 # attempt to create group with non-existent nexthop
2236 run_cmd "$IP nexthop add id 103 group 12"
2237 log_test $? 2 "Create group with non-existent nexthop"
2239 # attempt to create group with same nexthop
2240 run_cmd "$IP nexthop add id 103 group 1/1"
2241 log_test $? 2 "Create group with same nexthop multiple times"
2243 # replace nexthop with a group - fails
2244 run_cmd "$IP nexthop replace id 2 group 1"
2245 log_test $? 2 "Replace nexthop with nexthop group"
2247 # replace nexthop group with a nexthop - fails
2249 log_test $? 2 "Replace nexthop group with nexthop"
2251 # nexthop group with other attributes fail
2252 run_cmd "$IP nexthop add id 104 group 1 dev veth1"
2253 log_test $? 2 "Nexthop group and device"
2269 run_cmd "$IP nexthop add id 104 group 1 blackhole"
2270 log_test $? 2 "Nexthop group and blackhole"
2274 # Test to ensure that flushing with a multi-part nexthop dump works as
2282 $IP -b $batch_file
2284 [[ $($IP nexthop | wc -l) -eq 0 ]]
2300 count=$($IP -j nexthop bucket ${nharg} ${selector} | jq length)
2314 echo "Basic resilient nexthop group functional tests"
2315 echo "----------------------------------------------"
2318 if [ $? -eq $ksft_skip ]; then
2325 # resilient nexthop group addition
2328 run_cmd "$IP nexthop add id 101 group 1 type resilient buckets 8"
2329 log_test $? 0 "Add a nexthop group with default parameters"
2333 "id 101 group 1 type resilient buckets 8 idle_timer 120 unbalanced_timer 0 unbalanced_time 0"
2334 log_test $? 0 "Get a nexthop group with default parameters"
2336 run_cmd "$IP nexthop add id 102 group 1 type resilient
2340 "id 102 group 1 type resilient buckets 4 idle_timer 100 unbalanced_timer 5 unbalanced_time 0"
2341 log_test $? 0 "Get a nexthop group with non-default parameters"
2343 run_cmd "$IP nexthop add id 103 group 1 type resilient buckets 0"
2344 log_test $? 2 "Add a nexthop group with 0 buckets"
2347 # resilient nexthop group replacement
2350 run_cmd "$IP nexthop replace id 101 group 1 type resilient
2352 log_test $? 0 "Replace nexthop group parameters"
2354 "id 101 group 1 type resilient buckets 8 idle_timer 240 unbalanced_timer 80 unbalanced_time 0"
2355 log_test $? 0 "Get a nexthop group after replacing parameters"
2357 run_cmd "$IP nexthop replace id 101 group 1 type resilient idle_timer 512"
2360 "id 101 group 1 type resilient buckets 8 idle_timer 512 unbalanced_timer 80 unbalanced_time 0"
2361 log_test $? 0 "Get a nexthop group after replacing idle timer"
2363 run_cmd "$IP nexthop replace id 101 group 1 type resilient unbalanced_timer 256"
2366 "id 101 group 1 type resilient buckets 8 idle_timer 512 unbalanced_timer 256 unbalanced_time 0"
2367 log_test $? 0 "Get a nexthop group after replacing unbalanced timer"
2369 run_cmd "$IP nexthop replace id 101 group 1 type resilient"
2372 "id 101 group 1 type resilient buckets 8 idle_timer 512 unbalanced_timer 256 unbalanced_time 0"
2373 log_test $? 0 "Get a nexthop group after replacing no parameters"
2375 run_cmd "$IP nexthop replace id 101 group 1"
2376 log_test $? 2 "Replace nexthop group type - implicit"
2378 run_cmd "$IP nexthop replace id 101 group 1 type mpath"
2379 log_test $? 2 "Replace nexthop group type - explicit"
2381 run_cmd "$IP nexthop replace id 101 group 1 type resilient buckets 1024"
2385 "id 101 group 1 type resilient buckets 8 idle_timer 512 unbalanced_timer 256 unbalanced_time 0"
2386 log_test $? 0 "Get a nexthop group after replacing with invalid parameters"
2395 run_cmd "$IP nexthop add id 101 group 1/2 type resilient buckets 4"
2396 run_cmd "$IP nexthop add id 201 group 1/2"
2404 log_test $? 0 "Dump all nexthop buckets in a group"
2407 (( $($IP -j nexthop bucket list id 101 |
2410 log_test $? 0 "All nexthop buckets report a positive near-zero idle time"
2421 log_test $? 2 "Dump all nexthop buckets in a non-existent group"
2424 log_test $? 2 "Dump all nexthop buckets in a non-resilient group"
2427 log_test $? 255 "Dump all nexthop buckets using a non-existent device"
2436 run_cmd "$IP nexthop add id $((2**32-1)) group 1/2 type resilient buckets 4"
2448 log_test $? 2 "Get a nexthop bucket with valid group, but invalid index"
2451 log_test $? 2 "Get a nexthop bucket from a non-resilient group"
2454 log_test $? 2 "Get a nexthop bucket from a non-existent group"
2465 group 1/2 type resilient buckets 10
2474 group 1,2/2,3 type resilient"
2482 group 1,2/2,3 type resilient
2485 group 1/2 type resilient"
2502 -t <test> Test(s) to run (default: all)
2504 -4 IPv4 tests only
2505 -6 IPv6 tests only
2506 -p Pause on fail
2507 -P Pause after each test before cleanup
2508 -v verbose mode (show commands and output)
2509 -w Timeout for ping
2512 -n num Number of nexthops to target
2513 -N Use new style to install routes in DUT
2540 if [ "$(id -u)" -ne 0 ];then
2545 if [ ! -x "$(command -v ip)" ]; then
2550 ip help 2>&1 | grep -q nexthop
2551 if [ $? -ne 0 ]; then
2556 out=$(ip nexthop ls 2>&1 | grep -q "Operation not supported")
2557 if [ $? -eq 0 ]; then
2565 none) IP="ip -netns $peer"; setup; exit 0;;