3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
11 # bug number for skipped test:
12 ALWAYS_EXCEPT="$SANITY_LNET_EXCEPT 253 254"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 [ "$SLOW" = "no" ] && EXCEPT_SLOW=""
17 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
19 . $LUSTRE/tests/test-framework.sh
23 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
26 [[ -z $LNETCTL ]] && skip "Need lnetctl"
30 if is_mounted $MOUNT || is_mounted $MOUNT2; then
31 cleanupall || error "Failed cleanup prior to test execution"
36 echo "Cleaning up LNet"
37 lsmod | grep -q lnet &&
38 $LNETCTL lnet unconfigure 2>/dev/null
43 if module_loaded lnet ; then
44 cleanup_lnet || error "Failed to unload modules before test execution"
50 # Cleanup any tmp files created by the sub tests
51 rm -f $TMP/sanity-lnet-*.yaml $LNET_PARAMS_FILE
54 if $restore_mounts; then
55 setupall || error "Failed to setup Lustre after test execution"
56 elif $restore_modules; then
58 error "Couldn't load modules after test execution"
66 FAKE_IP_ALIAS="10.1.2.31"
68 echo "ip netns exec $TESTNS $*"
69 ip netns exec $TESTNS "$@"
77 netns_arg="netns $netns"
79 ip link add 'test1pl' type veth peer name $FAKE_IF $netns_arg
80 ip link set 'test1pl' up
81 if [[ -n $netns ]]; then
82 do_ns ip addr add "${FAKE_IP}/31" dev $FAKE_IF
83 do_ns ip link set $FAKE_IF up
85 ip addr add "${FAKE_IP}/31" dev $FAKE_IF
86 ip link set $FAKE_IF up
91 ip link show test1pl >& /dev/null && ip link del test1pl || return 0
102 (ip netns list | grep -q $TESTNS) && ip netns del $TESTNS
107 echo "Loading LNet and configuring DLC"
108 load_lnet || return $?
109 do_lnetctl lnet configure
112 GLOBAL_YAML_FILE=$TMP/sanity-lnet-global.yaml
113 define_global_yaml() {
114 $LNETCTL export --backup >${GLOBAL_YAML_FILE} ||
115 error "Failed to export global yaml $?"
119 if lsmod | grep -q lnet; then
120 do_lnetctl lnet unconfigure ||
121 error "lnetctl lnet unconfigure failed $?"
122 do_lnetctl lnet configure ||
123 error "lnetctl lnet configure failed $?"
125 configure_dlc || error "configure_dlc failed $?"
130 append_global_yaml() {
131 [[ ! -e ${GLOBAL_YAML_FILE} ]] &&
132 error "Missing global yaml at ${GLOBAL_YAML_FILE}"
134 cat ${GLOBAL_YAML_FILE} >> $TMP/sanity-lnet-$testnum-expected.yaml
137 create_base_yaml_file() {
141 compare_yaml_files() {
142 local expected="$TMP/sanity-lnet-$testnum-expected.yaml"
143 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
145 ! [[ -e $expected ]] && echo "$expected not found" && return 1
146 ! [[ -e $actual ]] && echo "$actual not found" && return 1
147 if [ verify_yaml_available ]; then
148 verify_compare_yaml $actual $expected || rc=$?
150 diff -upN ${actual} ${expected} || rc=$?
161 local net="${nid//*@/}"
162 local addr="${nid//@*/}"
164 local num_re='[0-9]+'
165 local ip_re="[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"
167 if [[ $net =~ (gni|kfi)[0-9]* ]]; then
168 [[ $addr =~ ${num_re} ]] && return 0
170 [[ $addr =~ ${ip_re} ]] && return 0
175 local yfile=$TMP/sanity-lnet-$testnum-actual.yaml
176 local primary_nids=$(awk '/- primary nid:/{print $NF}' $yfile | xargs echo)
177 local secondary_nids=$(awk '/- nid:/{print $NF}' $yfile | xargs echo)
178 local gateway_nids=$(awk '/gateway:/{print $NF}' $yfile | xargs echo)
181 for nid in $primary_nids $secondary_nids; do
182 validate_nid "$nid" || error "Bad NID \"${nid}\""
187 validate_peer_nids() {
189 local nids_per_peer="$2"
191 local expect_p="$num_peers"
192 # The primary nid also shows up in the list of secondary nids
193 local expect_s="$(($num_peers + $(($nids_per_peer*$num_peers))))"
195 local actual_p=$(awk '/-\s+primary nid:/{print $NF}' $TMP/sanity-lnet-$testnum-actual.yaml | wc -l)
196 local actual_s=$(awk '/-\s+nid:/{print $NF}' $TMP/sanity-lnet-$testnum-actual.yaml | wc -l)
197 if [[ $expect_p -ne $actual_p ]]; then
199 error "Expected $expect_p but found $actual_p primary nids"
200 elif [[ $expect_s -ne $actual_s ]]; then
202 error "Expected $expect_s but found $actual_s secondary nids"
207 validate_gateway_nids() {
208 local expect_gw=$(grep -c -- 'gateway:' $TMP/sanity-lnet-$testnum-expected.yaml)
209 local actual_gw=$(grep -c -- 'gateway:' $TMP/sanity-lnet-$testnum-actual.yaml)
210 if [[ $expect_gw -ne $actual_gw ]]; then
212 error "Expected $expect_gw gateways but found $actual_gw gateways"
215 local expect_gwnids=$(awk '/gateway:/{print $NF}' $TMP/sanity-lnet-$testnum-expected.yaml |
218 for nid in ${expect_gwnids}; do
219 if ! grep -q "gateway: ${nid}" $TMP/sanity-lnet-$testnum-actual.yaml; then
220 error "${nid} not configured as gateway"
227 # TODO: Switch to ipcalc if/when we need more sophisticated validation
229 local ipv4_re='^([0-9]{1,3}\.){3,3}[0-9]{1,3}$'
231 if ! [[ $1 =~ $ipv4_re ]]; then
235 local quads=(${1//\./ })
237 (( ${#quads[@]} == 4)) || return 1
239 (( quads[0] < 256 && quads[1] < 256 &&
240 quads[2] < 256 && quads[3] < 256 )) || return 1
246 local addr=$(ip -o -4 a s "$1" | awk '{print $4}' | head -n 1 |
253 setup_netns || error "setup_netns failed with $?"
255 # Determine the local interface(s) used for LNet
256 load_lnet "config_on_load=1" || error "Failed to load modules"
261 INTERFACES=( $(lnet_if_list) )
263 if [[ -z ${INTERFACES[@]} ]]; then
264 error "Did not identify any LNet interfaces"
267 if [[ $NETTYPE =~ (tcp|o2ib)[0-9]* ]]; then
268 if ! intf_has_ipv4 "${INTERFACES[0]}"; then
269 always_except LU-5960 230
270 always_except LU-9680 204
271 always_except LU-9680 205
272 always_except LU-9680 206
273 always_except LU-9680 207
274 always_except LU-9680 209
275 always_except LU-9680 210
276 always_except LU-9680 211
277 always_except LU-9680 212
278 always_except LU-9680 213
279 always_except LU-9680 216
280 always_except LU-9680 218
281 always_except LU-9680 231
282 always_except LU-9680 302
283 always_except LU-9680 500
284 always_except LU-14288 101
285 always_except LU-14288 103
286 always_except LU-16822 100
287 always_except LU-16822 102
288 always_except LU-16822 105
289 always_except LU-16822 106
290 always_except LU-17458 220
291 always_except LU-17455 250
292 always_except LU-17457 208
293 always_except LU-17457 255
294 always_except LU-17460 214
300 cleanup_lnet || error "Failed to cleanup LNet"
302 stack_trap 'cleanup_testsuite' EXIT
305 configure_dlc || error "Failed to configure DLC rc = $?"
307 reinit_dlc || return $?
308 do_lnetctl import < ${GLOBAL_YAML_FILE} || error "Import failed $?"
309 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
310 create_base_yaml_file
311 compare_yaml_files || error "Configuration changed after import"
313 run_test 0 "Export empty config, import the config, compare"
316 local prim_nid="${1:+--prim_nid $1}"
317 local nid="${2:+--nid $2}"
319 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
321 do_lnetctl peer add ${prim_nid} ${nid} || error "peer add failed $?"
322 $LNETCTL export --backup > $actual || error "export failed $?"
328 reinit_dlc || return $?
329 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
331 - primary nid: 1.1.1.1@tcp
337 compare_peer_add "1.1.1.1@tcp"
339 run_test 1 "Add peer with single nid (tcp)"
342 reinit_dlc || return $?
343 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
345 - primary nid: 2.2.2.2@o2ib
351 compare_peer_add "2.2.2.2@o2ib"
353 run_test 2 "Add peer with single nid (o2ib)"
356 reinit_dlc || return $?
357 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
359 - primary nid: 3.3.3.3@tcp
366 compare_peer_add "3.3.3.3@tcp" "3.3.3.3@o2ib"
368 run_test 3 "Add peer with tcp primary o2ib secondary"
371 reinit_dlc || return $?
372 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
374 - primary nid: 4.4.4.4@tcp
383 echo "Add peer with nidrange (tcp)"
384 compare_peer_add "4.4.4.4@tcp" "4.4.4.[1-3]@tcp"
386 echo "Add peer with nidrange that overlaps primary nid (tcp)"
387 compare_peer_add "4.4.4.4@tcp" "4.4.4.[1-4]@tcp"
389 run_test 4 "Add peer with nidrange (tcp)"
392 reinit_dlc || return $?
393 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
395 - primary nid: 5.5.5.5@o2ib
405 echo "Add peer with nidrange (o2ib)"
406 compare_peer_add "5.5.5.5@o2ib" "5.5.5.[1-4]@o2ib"
408 echo "Add peer with nidranage that overlaps primary nid (o2ib)"
409 compare_peer_add "5.5.5.5@o2ib" "5.5.5.[1-4]@o2ib"
411 echo "Add peer with nidranage that contain , plus primary nid (o2ib)"
412 compare_peer_add "5.5.5.5@o2ib" "5.5.5.[1,2,3-4]@o2ib"
414 run_test 5 "Add peer with nidrange (o2ib)"
417 reinit_dlc || return $?
418 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
420 - primary nid: 6.6.6.6@tcp
443 local nid_expr="6.6.[6-7].[0-4/2]@tcp"
444 nid_expr+=",6.6.[1-4/2].[0-6/3]@o2ib"
445 nid_expr+=",[6-12/4]@gni"
446 nid_expr+=",[6-12/4]@kfi"
448 compare_peer_add "6.6.6.6@tcp" "${nid_expr}"
450 run_test 6 "Add peer with multiple nidranges"
453 local prim_nid="${1:+--prim_nid $1}"
454 local nid="${2:+--nid $2}"
456 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
458 do_lnetctl peer del ${prim_nid} ${nid} || error "peer del failed $?"
459 $LNETCTL export --backup > $actual || error "export failed $?"
465 reinit_dlc || return $?
466 create_base_yaml_file
468 echo "Delete peer with single nid (tcp)"
469 do_lnetctl peer add --prim_nid 7.7.7.7@tcp || error "Peer add failed $?"
470 compare_peer_del "7.7.7.7@tcp"
472 echo "Delete peer with single nid (o2ib)"
473 do_lnetctl peer add --prim_nid 7.7.7.7@o2ib || error "Peer add failed $?"
474 compare_peer_del "7.7.7.7@o2ib"
476 echo "Delete peer that has multiple nids (tcp)"
477 do_lnetctl peer add --prim_nid 7.7.7.7@tcp --nid 7.7.7.[8-12]@tcp ||
478 error "Peer add failed $?"
479 compare_peer_del "7.7.7.7@tcp"
481 echo "Delete peer that has multiple nids (o2ib)"
482 do_lnetctl peer add --prim_nid 7.7.7.7@o2ib --nid 7.7.7.[8-12]@o2ib ||
483 error "Peer add failed $?"
484 compare_peer_del "7.7.7.7@o2ib"
486 echo "Delete peer that has both tcp and o2ib nids"
487 do_lnetctl peer add --prim_nid 7.7.7.7@tcp \
488 --nid 7.7.7.[9-12]@tcp,7.7.7.[13-15]@o2ib ||
489 error "Peer add failed $?"
490 compare_peer_del "7.7.7.7@tcp"
492 echo "Delete peer with single nid (gni)"
493 do_lnetctl peer add --prim_nid 7@gni || error "Peer add failed $?"
494 compare_peer_del "7@gni"
496 echo "Delete peer that has multiple nids (gni)"
497 do_lnetctl peer add --prim_nid 7@gni --nid [8-12]@gni ||
498 error "Peer add failed $?"
499 compare_peer_del "7@gni"
501 echo "Delete peer with single nid (kfi)"
502 do_lnetctl peer add --prim_nid 7@kfi || error "Peer add failed $?"
503 compare_peer_del "7@kfi"
505 echo "Delete peer that has multiple nids (kfi)"
506 do_lnetctl peer add --prim_nid 7@kfi --nid [8-12]@kfi ||
507 error "Peer add failed $?"
508 compare_peer_del "7@kfi"
510 echo "Delete peer that has tcp, o2ib, gni and kfi nids"
511 do_lnetctl peer add --prim_nid 7@gni \
512 --nid [8-12]@gni,7.7.7.[1-4]@tcp,7.7.7.[5-9]@o2ib,[1-5]@kfi ||
513 error "Peer add failed $?"
514 compare_peer_del "7@gni"
516 echo "Delete peer that contains nid equal to primary nid"
517 do_lnetctl peer add --prim 1.1.1.1@tcp \
518 --nid 1.1.1.1@tcp,2.2.2.2@tcp,3.3.3.3@tcp,4.4.4.4@tcp ||
519 error "Peer add failed $?"
520 compare_peer_del "1.1.1.1@tcp" "1.1.1.1@tcp,2.2.2.2@tcp,3.3.3.3@tcp,4.4.4.4@tcp"
522 run_test 7 "Various peer delete tests"
525 reinit_dlc || return $?
527 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
529 - primary nid: 8.8.8.8@tcp
541 do_lnetctl peer add --prim_nid 8.8.8.8@tcp --nid 8.8.8.[10-15]@tcp ||
542 error "Peer add failed $?"
543 compare_peer_del "8.8.8.8@tcp" "8.8.8.13@tcp"
545 run_test 8 "Delete single secondary nid from peer (tcp)"
548 reinit_dlc || return $?
550 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
552 - primary nid: 9.9.9.9@tcp
559 do_lnetctl peer add --prim_nid 9.9.9.9@tcp \
560 --nid 9.9.9.[11-16]@tcp || error "Peer add failed $?"
561 compare_peer_del "9.9.9.9@tcp" "9.9.9.[11-16]@tcp"
563 run_test 9 "Delete all secondary nids from peer (tcp)"
566 reinit_dlc || return $?
568 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
570 - primary nid: 10.10.10.10@tcp
573 - nid: 10.10.10.10@tcp
574 - nid: 10.10.10.12@tcp
575 - nid: 10.10.10.13@tcp
576 - nid: 10.10.10.15@tcp
577 - nid: 10.10.10.16@tcp
580 do_lnetctl peer add --prim_nid 10.10.10.10@tcp \
581 --nid 10.10.10.[12-16]@tcp || error "Peer add failed $?"
582 compare_peer_del "10.10.10.10@tcp" "10.10.10.14@tcp"
584 run_test 10 "Delete single secondary nid from peer (o2ib)"
587 reinit_dlc || return $?
589 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
591 - primary nid: 11.11.11.11@tcp
594 - nid: 11.11.11.11@tcp
597 do_lnetctl peer add --prim_nid 11.11.11.11@tcp \
598 --nid 11.11.11.[13-17]@tcp || error "Peer add failed $?"
599 compare_peer_del "11.11.11.11@tcp" "11.11.11.[13-17]@tcp"
601 run_test 11 "Delete all secondary nids from peer (o2ib)"
604 reinit_dlc || return $?
606 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
608 - primary nid: 12.12.12.12@o2ib
611 - nid: 12.12.12.12@o2ib
612 - nid: 13.13.13.13@o2ib
613 - nid: 14.13.13.13@o2ib
614 - nid: 14.15.13.13@o2ib
616 - nid: 15.17.1.10@tcp
617 - nid: 15.17.1.20@tcp
620 do_lnetctl peer add --prim_nid 12.12.12.12@o2ib \
621 --nid [13-14/1].[13-15/2].13.13@o2ib,[15-16/3].[17-19/4].[1].[5-20/5]@tcp ||
622 error "Peer add failed $?"
623 compare_peer_del "12.12.12.12@o2ib" "13.15.13.13@o2ib,15.17.1.15@tcp"
625 run_test 12 "Delete a secondary nid from peer (tcp and o2ib)"
628 reinit_dlc || return $?
630 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
632 - primary nid: 13.13.13.13@o2ib
635 - nid: 13.13.13.13@o2ib
638 do_lnetctl peer add --prim_nid 13.13.13.13@o2ib \
639 --nid [14-15].[1-2/1].[1].[100-254/10]@tcp,14.14.[254].14@o2ib ||
640 error "Peer add failed $?"
641 compare_peer_del "13.13.13.13@o2ib" \
642 "[14-15].[1-2/1].[1].[100-254/10]@tcp,14.14.[254].14@o2ib"
644 run_test 13 "Delete all secondary nids from peer (tcp and o2ib)"
650 if [[ $net =~ gni* ]] || [[ $net =~ kfi* ]]; then
653 echo "${num}.${num}.${num}.${num}@${net}"
657 create_mr_peer_yaml() {
659 local secondary_nids="$2"
662 echo "Generating peer yaml for $num_peers peers with $secondary_nids secondary nids"
663 echo "peer:" >> $TMP/sanity-lnet-$testnum-expected.yaml
665 local total_nids=$((num_peers + $((num_peers * secondary_nids))))
668 while [[ $created -lt $num_peers ]]; do
669 local primary=$(create_nid ${nidnum} ${net})
670 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
671 - primary nid: $primary
677 local start=$((nidnum + 1))
678 local end=$((nidnum + $secondary_nids))
679 for j in $(seq ${start} ${end}); do
680 local nid=$(create_nid $j ${net})
681 echo " - nid: $nid" >> $TMP/sanity-lnet-$testnum-expected.yaml
689 reinit_dlc || return $?
691 echo "Create single peer, single nid, using import"
692 create_mr_peer_yaml 1 0 tcp
693 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
694 error "Import failed $?"
696 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
699 echo "Delete single peer using import --del"
700 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
701 error "Import failed $?"
702 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
703 create_base_yaml_file
704 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
707 run_test 14 "import peer create/delete with single nid"
710 reinit_dlc || return $?
712 echo "Create multiple peers, single nid per peer, using import"
713 create_mr_peer_yaml 5 0 o2ib
714 # The ordering of nids for this use-case is non-deterministic, so we
715 # we can't just diff the expected/actual output.
716 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
717 error "Import failed $?"
718 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
719 validate_peer_nids 5 0
721 echo "Delete multiple peers, single nid per peer, using import --del"
722 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
723 error "Import failed $?"
724 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
725 create_base_yaml_file
726 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
729 run_test 15 "import multi peer create/delete with single nid per peer"
732 reinit_dlc || return $?
734 echo "Create single peer, multiple nids, using import"
735 create_mr_peer_yaml 1 5 tcp
736 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
737 error "Import failed $?"
738 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
739 validate_peer_nids 1 5
741 echo "Delete single peer, multiple nids, using import --del"
742 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
743 error "Import failed $?"
744 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
745 create_base_yaml_file
746 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
749 run_test 16 "import peer create/delete with multiple nids"
752 reinit_dlc || return $?
754 echo "Create multiple peers, multiple nids per peer, using import"
755 create_mr_peer_yaml 5 7 o2ib
756 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
757 error "Import failed $?"
758 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
759 validate_peer_nids 5 7
761 echo "Delete multiple peers, multiple nids per peer, using import --del"
762 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
763 error "Import failed $?"
764 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
765 create_base_yaml_file
766 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
769 run_test 17 "import multi peer create/delete with multiple nids"
772 reinit_dlc || return $?
774 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
776 - primary nid: 1.1.1.1@tcp
785 echo "Import peer with 5 nids"
786 cat $TMP/sanity-lnet-$testnum-expected.yaml
787 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
788 error "Import failed $?"
789 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
791 - primary nid: 1.1.1.1@tcp
798 echo "Delete three of the nids"
799 cat $TMP/sanity-lnet-$testnum-expected.yaml
800 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml
801 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
803 - primary nid: 1.1.1.1@tcp
809 echo "Check peer has expected nids remaining"
810 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
814 run_test 18a "Delete a subset of nids from a single peer using import --del"
817 reinit_dlc || return $?
819 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
821 - primary nid: 1.1.1.1@tcp
829 - primary nid: 6.6.6.6@o2ib
838 echo "Import two peers with 5 nids each"
839 cat $TMP/sanity-lnet-$testnum-expected.yaml
840 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
841 error "Import failed $?"
842 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
844 - primary nid: 1.1.1.1@tcp
850 - primary nid: 6.6.6.6@o2ib
857 echo "Delete three of the nids from each peer"
858 cat $TMP/sanity-lnet-$testnum-expected.yaml
859 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml
860 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
862 - primary nid: 6.6.6.6@o2ib
867 - primary nid: 1.1.1.1@tcp
874 echo "Check peers have expected nids remaining"
875 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
877 validate_peer_nids 2 1
879 run_test 18b "Delete multiple nids from multiple peers using import --del"
882 reinit_dlc || return $?
883 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
885 - primary nid: 19@gni
891 compare_peer_add "19@gni"
893 run_test 19 "Add peer with single nid (gni)"
896 reinit_dlc || return $?
897 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
899 - primary nid: 20@gni
903 - nid: 20.20.20.20@tcp
904 - nid: 20.20.20.20@o2ib
907 compare_peer_add "20@gni" "20.20.20.20@tcp,20.20.20.20@o2ib"
909 run_test 20 "Add peer with gni primary and tcp, o2ib secondary"
912 reinit_dlc || return $?
913 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
915 - primary nid: 21@gni
925 echo "Add peer with nidrange (gni)"
926 compare_peer_add "21@gni" "[22-25]@gni" || error
927 echo "Add peer with nidrange that overlaps primary nid (gni)"
928 compare_peer_add "21@gni" "[21-25]@gni"
930 run_test 21 "Add peer with nidrange (gni)"
933 reinit_dlc || return $?
934 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
936 - primary nid: 22@gni
947 do_lnetctl peer add --prim_nid 22@gni --nid [24-29]@gni ||
948 error "Peer add failed $?"
949 compare_peer_del "22@gni" "26@gni"
951 run_test 22 "Delete single secondary nid from peer (gni)"
954 reinit_dlc || return $?
955 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
957 - primary nid: 23@gni
964 do_lnetctl peer add --prim_nid 23@gni --nid [25-29]@gni ||
965 error "Peer add failed $?"
966 compare_peer_del "23@gni" "[25-29]@gni"
968 run_test 23 "Delete all secondary nids from peer (gni)"
971 reinit_dlc || return $?
972 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
974 - primary nid: 24@gni
979 - nid: 13.13.13.13@o2ib
980 - nid: 14.13.13.13@o2ib
981 - nid: 14.15.13.13@o2ib
983 - nid: 15.17.1.10@tcp
984 - nid: 15.17.1.20@tcp
987 do_lnetctl peer add --prim_nid 24@gni \
988 --nid [13-14/1].[13-15/2].13.13@o2ib,[15-16/3].[17-19/4].[1].[5-20/5]@tcp,[5-12/6]@gni ||
989 error "Peer add failed $?"
990 compare_peer_del "24@gni" "5@gni,13.15.13.13@o2ib,15.17.1.15@tcp"
992 run_test 24 "Delete a secondary nid from peer (tcp, o2ib and gni)"
995 reinit_dlc || return $?
996 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
998 - primary nid: 25@gni
1004 do_lnetctl peer add --prim_nid 25@gni \
1005 --nid [26-27].[4-10/3].26.26@tcp,26.26.26.26@o2ib,[30-35]@gni ||
1006 error "Peer add failed $?"
1007 compare_peer_del "25@gni" \
1008 "[26-27].[4-10/3].26.26@tcp,26.26.26.26@o2ib,[30-35]@gni"
1010 run_test 25 "Delete all secondary nids from peer (tcp, gni and o2ib)"
1013 reinit_dlc || return $?
1015 do_lnetctl peer add --prim_nid 1.1.1.1@tcp --lock_prim ||
1016 error "Peer add with --lock_prim option failed $?"
1017 local peer_state=$($LNETCTL peer show -v 4 --nid 1.1.1.1@tcp |
1018 awk '/peer state/ {print $NF}')
1019 # This relies on the following peer state definition:
1020 # #define LNET_PEER_LOCK_PRIMARY BIT(20)
1021 if ((!("$peer_state" & (1 << 20)))); then
1022 error "Peer state does not have 'locked' bit set: $peer_state"
1024 do_lnetctl peer del --prim_nid 1.1.1.1@tcp ||
1025 error "Peer del failed $?"
1026 $LNETCTL peer show --nid 1.1.1.1@tcp | grep -q 1.1.1.1@tcp ||
1027 error "1.1.1.1@tcp is not listed"
1028 do_lnetctl peer del --prim_nid 1.1.1.1@tcp --force ||
1029 error "Peer del --force failed $?"
1030 do_lnetctl peer show --nid 1.1.1.1@tcp &&
1031 error "failed to delete 1.1.1.1@tcp"
1035 run_test 26 "Delete peer with primary nid locked"
1038 reinit_dlc || return $?
1040 echo "Invalid prim_nid - peer add"
1041 do_lnetctl peer add --prim_nid foobar &&
1042 error "Command should have failed"
1044 echo "Invalid prim_nid - peer del"
1045 do_lnetctl peer del --prim_nid foobar &&
1046 error "Command should have failed"
1048 echo "Delete non-existing peer"
1049 do_lnetctl peer del --prim_nid 1.1.1.1@o2ib &&
1050 error "Command should have failed"
1052 echo "Don't provide mandatory argument for peer del"
1053 do_lnetctl peer del --nid 1.1.1.1@tcp &&
1054 error "Command should have failed"
1056 echo "Don't provide mandatory argument for peer add"
1057 do_lnetctl peer add --nid 1.1.1.1@tcp &&
1058 error "Command should have failed"
1060 echo "Don't provide mandatory arguments peer add"
1061 do_lnetctl peer add &&
1062 error "Command should have failed"
1064 echo "Invalid secondary nids"
1065 do_lnetctl peer add --prim_nid 1.1.1.1@tcp --nid foobar &&
1066 error "Command should have failed"
1068 echo "Exceed max nids per peer"
1069 do_lnetctl peer add --prim_nid 1.1.1.1@tcp --nid 1.1.1.[2-255]@tcp &&
1070 error "Command should have failed"
1072 echo "Invalid net type"
1073 do_lnetctl peer add --prim_nid 1@foo &&
1074 error "Command should have failed"
1076 echo "Invalid nid format"
1077 local invalid_nids="1@tcp 1@o2ib 1.1.1.1@gni"
1080 for nid in ${invalid_nids}; do
1081 echo "Check invalid primary nid - '$nid'"
1082 do_lnetctl peer add --prim_nid $nid &&
1083 error "Command should have failed"
1086 local invalid_strs="[2-1]@gni [a-f/x]@gni 256.256.256.256@tcp"
1087 invalid_strs+=" 1.1.1.1.[2-5/f]@tcp 1.]2[.3.4@o2ib"
1088 invalid_strs+="1.[2-4,[5-6],7-8].1.1@tcp foobar"
1091 for nidstr in ${invalid_strs}; do
1092 echo "Check invalid nidstring - '$nidstr'"
1093 do_lnetctl peer add --prim_nid 1.1.1.1@tcp --nid $nidstr &&
1094 error "Command should have failed"
1097 echo "Add non-local gateway"
1098 do_lnetctl route add --net tcp --gateway 1@gni &&
1099 error "Command should have failed"
1103 run_test 99a "Check various invalid inputs to lnetctl peer"
1106 reinit_dlc || return $?
1108 create_base_yaml_file
1110 cat <<EOF > $TMP/sanity-lnet-$testnum-invalid.yaml
1112 - primary nid: 99.99.99.99@tcp
1115 - nid: 99.99.99.99@tcp
1117 do_lnetctl import < $TMP/sanity-lnet-$testnum-invalid.yaml &&
1118 error "import should have failed"
1119 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
1122 run_test 99b "Invalid value for Multi-Rail in yaml import"
1126 local ip=$(ip addr show dev $if | awk '/ inet /{print $2}')
1134 do_lnetctl net add --net ${net} --if ${if} ||
1135 error "Failed to add net ${net} on if ${if}"
1142 do_lnetctl net del --net ${net} --if ${if} ||
1143 error "Failed to del net ${net} on if ${if}"
1146 compare_route_add() {
1150 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
1152 do_lnetctl route add --net ${rnet} --gateway ${gw} ||
1153 error "route add failed $?"
1154 $LNETCTL export --backup > $actual ||
1155 error "export failed $?"
1156 validate_gateway_nids
1160 append_net_tunables() {
1163 $LNETCTL net show -v --net ${net} | grep -v 'dev cpt' |
1164 awk '/^\s+tunables:$/,/^\s+CPT:/' >> $TMP/sanity-lnet-$testnum-expected.yaml
1167 IF0_IP=$(ip -o -4 a s ${INTERFACES[0]} |
1168 awk '{print $4}' | sed 's/\/.*//')
1169 IF0_NET=$(awk -F. '{print $1"."$2"."$3}'<<<"${IF0_IP}")
1170 IF0_HOSTNUM=$(awk -F. '{print $4}'<<<"${IF0_IP}")
1171 if (((IF0_HOSTNUM + 5) > 254)); then
1174 GW_HOSTNUM=$((IF0_HOSTNUM + 1))
1176 GW_NID="${IF0_NET}.${GW_HOSTNUM}@${NETTYPE}"
1178 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
1180 reinit_dlc || return $?
1181 add_net "${NETTYPE}" "${INTERFACES[0]}"
1182 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
1184 - net type: ${NETTYPE}
1189 append_net_tunables tcp
1190 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
1196 health_sensitivity: 1
1198 - primary nid: ${GW_NID}
1204 compare_route_add "tcp7" "${GW_NID}"
1206 run_test 100 "Add route with single gw (tcp)"
1209 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
1211 reinit_dlc || return $?
1212 add_net "${NETTYPE}" "${INTERFACES[0]}"
1213 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
1215 - net type: ${NETTYPE}
1220 append_net_tunables tcp
1222 echo "route:" >> $TMP/sanity-lnet-$testnum-expected.yaml
1223 for i in $(seq $GW_HOSTNUM $((GW_HOSTNUM + 4))); do
1224 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
1226 gateway: ${IF0_NET}.${i}@tcp
1229 health_sensitivity: 1
1233 echo "peer:" >> $TMP/sanity-lnet-$testnum-expected.yaml
1234 for i in $(seq $GW_HOSTNUM $((GW_HOSTNUM + 4))); do
1235 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
1236 - primary nid: ${IF0_NET}.${i}@tcp
1239 - nid: ${IF0_NET}.${i}@tcp
1244 local gw="${IF0_NET}.[$GW_HOSTNUM-$((GW_HOSTNUM + 4))]@tcp"
1246 compare_route_add "tcp8" "${gw}"
1248 run_test 101 "Add route with multiple gw (tcp)"
1250 compare_route_del() {
1254 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
1256 do_lnetctl route del --net ${rnet} --gateway ${gw} ||
1257 error "route del failed $?"
1258 $LNETCTL export --backup > $actual ||
1259 error "export failed $?"
1260 validate_gateway_nids
1266 if [[ ${net} =~ (tcp|o2ib)[0-9]* ]]; then
1269 echo "$((${testnum} % 255))@${net}"
1274 reinit_dlc || return $?
1275 add_net "${NETTYPE}" "${INTERFACES[0]}"
1276 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
1278 local gwnid=$(generate_gw_nid ${NETTYPE})
1280 do_lnetctl route add --net ${NETTYPE}2 --gateway ${gwnid} ||
1281 error "route add failed $?"
1282 compare_route_del "${NETTYPE}2" "${gwnid}"
1284 run_test 102 "Delete route with single gw"
1286 IP_NID_EXPR='103.103.103.[103-120/4]'
1287 NUM_NID_EXPR='[103-120/4]'
1289 reinit_dlc || return $?
1290 add_net "${NETTYPE}" "${INTERFACES[0]}"
1291 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
1295 if [[ $NETTYPE =~ (tcp|o2ib)[0-9]* ]]; then
1296 nid_expr="${IF0_NET}.[$GW_HOSTNUM-$((GW_HOSTNUM+5))/2]"
1298 nid_expr="${NUM_NID_EXPR}"
1301 do_lnetctl route add --net ${NETTYPE}103 \
1302 --gateway ${nid_expr}@${NETTYPE} ||
1303 error "route add failed $?"
1304 compare_route_del "${NETTYPE}103" "${nid_expr}@${NETTYPE}"
1306 run_test 103 "Delete route with multiple gw"
1309 local tyaml="$TMP/sanity-lnet-$testnum-expected.yaml"
1311 reinit_dlc || return $?
1313 # Default value is '3'
1314 local val=$($LNETCTL global show | awk '/response_tracking/{print $NF}')
1316 error "Expect 3 found $val"
1318 echo "Set < 0; Should fail"
1319 do_lnetctl set response_tracking -1 &&
1320 error "should have failed $?"
1322 reinit_dlc || return $?
1325 response_tracking: -10
1327 do_lnetctl import < $tyaml &&
1328 error "should have failed $?"
1330 echo "Check valid values; Should succeed"
1332 for ((i = 0; i < 4; i++)); do
1333 reinit_dlc || return $?
1334 do_lnetctl set response_tracking $i ||
1335 error "should have succeeded $?"
1336 $LNETCTL global show | grep -q "response_tracking: $i" ||
1337 error "Failed to set response_tracking to $i"
1338 reinit_dlc || return $?
1341 response_tracking: $i
1343 do_lnetctl import < $tyaml ||
1344 error "should have succeeded $?"
1345 $LNETCTL global show | grep -q "response_tracking: $i" ||
1346 error "Failed to set response_tracking to $i"
1349 reinit_dlc || return $?
1350 echo "Set > 3; Should fail"
1351 do_lnetctl set response_tracking 4 &&
1352 error "should have failed $?"
1354 reinit_dlc || return $?
1357 response_tracking: 10
1359 do_lnetctl import < $tyaml &&
1360 error "should have failed $?"
1363 run_test 104 "Set/check response_tracking param"
1366 reinit_dlc || return $?
1367 add_net "${NETTYPE}" "${INTERFACES[0]}"
1369 local gwnid=$(generate_gw_nid ${NETTYPE})
1371 do_lnetctl route add --net ${NETTYPE}105 --gateway ${gwnid} ||
1372 error "route add failed $?"
1373 do_lnetctl peer add --prim ${gwnid} &&
1374 error "peer add should fail"
1378 run_test 105 "Adding duplicate GW peer should fail"
1381 reinit_dlc || return $?
1382 add_net "${NETTYPE}" "${INTERFACES[0]}"
1384 local gwnid=$(generate_gw_nid ${NETTYPE})
1386 do_lnetctl route add --net ${NETTYPE}106 --gateway ${gwnid} ||
1387 error "route add failed $?"
1388 do_lnetctl peer del --prim ${gwnid} &&
1389 error "peer del should fail"
1393 run_test 106 "Deleting GW peer should fail"
1396 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
1398 cleanup_netns || error "Failed to cleanup netns before test execution"
1399 cleanup_lnet || error "Failed to unload modules before test execution"
1401 setup_fakeif || error "Failed to add fake IF"
1402 have_interface "$FAKE_IF" ||
1403 error "Expect $FAKE_IF configured but not found"
1405 reinit_dlc || return $?
1407 add_net "tcp" "${INTERFACES[0]}" || return $?
1408 add_net "tcp" "$FAKE_IF" || return $?
1410 del_net "tcp" "$FAKE_IF" || return $?
1416 run_test 107 "Deleting extra interface doesn't crash node"
1419 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
1421 cleanup_netns || error "Failed to cleanup netns before test execution"
1422 cleanup_lnet || error "Failed to unload modules before test execution"
1424 setup_fakeif || error "Failed to add fake IF"
1425 have_interface "$FAKE_IF" ||
1426 error "Expect $FAKE_IF configured but not found"
1428 reinit_dlc || return $?
1430 add_net "tcp" "${INTERFACES[0]}" || return $?
1431 $LNETCTL net show > $TMP/sanity-lnet-$testnum-expected.yaml
1432 add_net "tcp" "$FAKE_IF" || return $?
1434 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
1435 - nid: ${FAKE_IP}@tcp
1440 $LNETCTL net show > $TMP/sanity-lnet-$testnum-actual.yaml
1441 compare_yaml_files || error "not all interfaces were setup"
1449 run_test 108 "Check Multi-Rail setup"
1452 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
1454 cleanup_netns || error "Failed to cleanup netns before test execution"
1455 cleanup_lnet || error "Failed to unload modules before test execution"
1457 setup_fakeif || error "Failed to add fake IF"
1458 have_interface "$FAKE_IF" ||
1459 error "Expect $FAKE_IF configured but not found"
1461 FAKE_IF_ALIAS="${FAKE_IF}"
1464 ifconfig "$FAKE_IF_ALIAS" "$FAKE_IP_ALIAS" up ||
1465 error "Failed to add fake IF alias"
1467 reinit_dlc || return $?
1469 # add interface with longer name first
1470 add_net "tcp" "$FAKE_IF_ALIAS" || return $?
1471 add_net "tcp" "$FAKE_IF" || return $?
1473 del_net "tcp" "$FAKE_IF" || return $?
1474 del_net "tcp" "$FAKE_IF_ALIAS" || return $?
1476 # add interface with shorter name first
1477 add_net "tcp" "$FAKE_IF" || return $?
1478 add_net "tcp" "$FAKE_IF_ALIAS" || return $?
1480 ifconfig "$FAKE_IF_ALIAS" "$FAKE_IP_ALIAS" down ||
1481 error "Failed to clean up fake IF alias"
1487 run_test 109 "Add NI using a network interface alias (LU-16859)"
1490 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
1492 cleanup_netns || error "Failed to cleanup netns before test execution"
1493 cleanup_lnet || error "Failed to unload modules before test execution"
1495 configure_dlc || error "Failed to configure DLC rc = $?"
1497 LOCAL_ADDR_LIST=$(local_addr_list)
1498 set -- $LOCAL_ADDR_LIST
1499 do_lnetctl net add --nid $2@tcp ||
1500 error "Failed to add net tcp for IP $2@tcp"
1502 $LNETCTL net show --net tcp | grep -q "nid: $2@tcp" ||
1503 error "Failed to configure $2@tcp"
1505 do_lnetctl net del --nid $2@tcp ||
1506 error "Failed to del net tcp for IP $2@tcp"
1508 $LNETCTL net show | grep -q "nid: $2@tcp"&&
1509 error "$2@tcp should have been deleted"
1514 run_test 110 "Add NI using a specific TCP / IP address"
1517 [[ ${NETTYPE} == tcp* ]] ||
1518 skip "Need tcp NETTYPE"
1519 cleanup_lnet || exit 1
1520 load_lnet "networks=\"\""
1521 do_ns $LNETCTL lnet configure --all || exit 1
1522 $LNETCTL net show --net tcp | grep -q "nid: ${FAKE_IP}@tcp$"
1524 run_test 200 "load lnet w/o module option, configure in a non-default namespace"
1527 [[ ${NETTYPE} == tcp* ]] ||
1528 skip "Need tcp NETTYPE"
1529 cleanup_lnet || exit 1
1530 load_lnet "networks=tcp($FAKE_IF)"
1531 do_ns $LNETCTL lnet configure --all || exit 1
1532 $LNETCTL net show --net tcp | grep -q "nid: ${FAKE_IP}@tcp$"
1534 run_test 201 "load lnet using networks module options in a non-default namespace"
1537 [[ ${NETTYPE} == tcp* ]] ||
1538 skip "Need tcp NETTYPE"
1539 cleanup_lnet || exit 1
1540 load_lnet "networks=\"\" ip2nets=\"tcp0($FAKE_IF) ${FAKE_IP}\""
1541 do_ns $LNETCTL lnet configure --all || exit 1
1542 $LNETCTL net show | grep -q "nid: ${FAKE_IP}@tcp$"
1544 run_test 202 "load lnet using ip2nets in a non-default namespace"
1547 ### Add the interfaces in the target namespace
1550 [[ ${NETTYPE} == tcp* ]] ||
1551 skip "Need tcp NETTYPE"
1552 cleanup_lnet || exit 1
1554 do_lnetctl lnet configure || exit 1
1555 do_ns $LNETCTL net add --net tcp0 --if $FAKE_IF
1557 run_test 203 "add a network using an interface in the non-default namespace"
1559 LNET_PARAMS_FILE="$TMP/$TESTSUITE.parameters"
1560 function save_lnet_params() {
1561 $LNETCTL global show | egrep -v '^global:$' |
1562 sed 's/://' > $LNET_PARAMS_FILE
1565 function restore_lnet_params() {
1567 while read param value; do
1568 [[ $param == max_intf ]] && continue
1569 [[ $param == lnd_timeout ]] && continue
1570 $LNETCTL set ${param} ${value} ||
1571 error "Failed to restore ${param} to ${value}"
1572 done < $LNET_PARAMS_FILE
1575 function lnet_health_pre() {
1578 # Lower transaction timeout to speed up test execution
1579 $LNETCTL set transaction_timeout 10 ||
1580 error "Failed to set transaction_timeout $?"
1582 RETRY_PARAM=$($LNETCTL global show | awk '/retry_count/{print $NF}')
1583 RSND_PRE=$($LNETCTL stats show | awk '/resend_count/{print $NF}')
1584 LO_HVAL_PRE=$($LNETCTL net show -v 2 | awk '/health value/{print $NF}' |
1585 xargs echo | sed 's/ /+/g' | bc -l)
1587 RMT_HVAL_PRE=$($LNETCTL peer show --nid ${RNIDS[0]} -v 2 2>/dev/null |
1588 awk '/health value/{print $NF}' | xargs echo |
1589 sed 's/ /+/g' | bc -l)
1591 # Might not have any peers so initialize to zero.
1592 RMT_HVAL_PRE=${RMT_HVAL_PRE:-0}
1597 function lnet_health_post() {
1598 RSND_POST=$($LNETCTL stats show | awk '/resend_count/{print $NF}')
1599 LO_HVAL_POST=$($LNETCTL net show -v 2 |
1600 awk '/health value/{print $NF}' |
1601 xargs echo | sed 's/ /+/g' | bc -l)
1603 RMT_HVAL_POST=$($LNETCTL peer show --nid ${RNIDS[0]} -v 2 2>/dev/null |
1604 awk '/health value/{print $NF}' | xargs echo |
1605 sed 's/ /+/g' | bc -l)
1607 # Might not have any peers so initialize to zero.
1608 RMT_HVAL_POST=${RMT_HVAL_POST:-0}
1611 echo "Pre resends: $RSND_PRE" &&
1612 echo "Post resends: $RSND_POST" &&
1613 echo "Resends delta: $((RSND_POST - RSND_PRE))" &&
1614 echo "Pre local health: $LO_HVAL_PRE" &&
1615 echo "Post local health: $LO_HVAL_POST" &&
1616 echo "Pre remote health: $RMT_HVAL_PRE" &&
1617 echo "Post remote health: $RMT_HVAL_POST"
1621 do_lnetctl peer set --health 1000 --all
1622 do_lnetctl net set --health 1000 --all
1627 function check_no_resends() {
1628 echo "Check that no resends took place"
1629 [[ $RSND_POST -ne $RSND_PRE ]] &&
1630 error "Found resends: $RSND_POST != $RSND_PRE"
1635 function check_resends() {
1636 local delta=$((RSND_POST - RSND_PRE))
1638 echo "Check that $RETRY_PARAM resends took place"
1639 [[ $delta -ne $RETRY_PARAM ]] &&
1640 error "Expected $RETRY_PARAM resends found $delta"
1645 function check_no_local_health() {
1646 echo "Check that local NI health is unchanged"
1647 [[ $LO_HVAL_POST -ne $LO_HVAL_PRE ]] &&
1648 error "Local health changed: $LO_HVAL_POST != $LO_HVAL_PRE"
1653 function check_local_health() {
1654 echo "Check that local NI health has been changed"
1655 [[ $LO_HVAL_POST -eq $LO_HVAL_PRE ]] &&
1656 error "Local health unchanged: $LO_HVAL_POST == $LO_HVAL_PRE"
1661 function check_no_remote_health() {
1662 echo "Check that remote NI health is unchanged"
1663 [[ $RMT_HVAL_POST -ne $RMT_HVAL_PRE ]] &&
1664 error "Remote health changed: $RMT_HVAL_POST != $RMT_HVAL_PRE"
1669 function check_remote_health() {
1670 echo "Check that remote NI health has been changed"
1671 [[ $RMT_HVAL_POST -eq $RMT_HVAL_PRE ]] &&
1672 error "Remote health unchanged: $RMT_HVAL_POST == $RMT_HVAL_PRE"
1682 setup_health_test() {
1686 [[ ${NETTYPE} == kfi* ]] && skip "kfi doesn't support drop rules"
1688 local rnodes=$(remote_nodes_list)
1689 [[ -z $rnodes ]] && skip "Need at least 1 remote node"
1691 cleanup_lnet || error "Failed to cleanup before test execution"
1693 # Loading modules should configure LNet with the appropriate
1694 # test-framework configuration
1695 load_lnet "config_on_load=1" || error "Failed to load modules"
1697 LNIDS=( $($LCTL list_nids | xargs echo) )
1699 RNODE=$(awk '{print $1}' <<<$rnodes)
1700 RNIDS=( $(do_node $RNODE $LCTL list_nids | xargs echo) )
1702 if [[ -z ${RNIDS[@]} ]]; then
1703 do_rpc_nodes $RNODE load_lnet "config_on_load=1"
1705 RNIDS=( $(do_node $RNODE $LCTL list_nids | xargs echo) )
1708 [[ ${#LNIDS[@]} -lt 1 ]] &&
1709 error "No NIDs configured for local host $HOSTNAME"
1710 [[ ${#RNIDS[@]} -lt 1 ]] &&
1711 error "No NIDs configured for remote host $RNODE"
1713 # Ensure all peer NIs are local (i.e. non-routed config)
1714 local rnid rnet lnid lnet
1716 for rnid in ${RNIDS[@]}; do
1718 for lnid in ${LNIDS[@]}; do
1720 [[ ${lnet} == ${rnet} ]] &&
1723 [[ ${lnet} != ${rnet} ]] &&
1724 skip "Need non-routed configuration"
1727 do_lnetctl discover ${RNIDS[0]} ||
1728 error "Unable to discover ${RNIDS[0]}"
1730 local mr=$($LNETCTL peer show --nid ${RNIDS[0]} |
1731 awk '/Multi-Rail/{print $NF}')
1733 if ${need_mr} && [[ $mr == False ]]; then
1734 cleanup_health_test || return $?
1738 if ( ! ${need_mr} && [[ ${#RNIDS[@]} -gt 1 ]] ) ||
1739 ( ! ${need_mr} && [[ ${#LNIDS[@]} -gt 1 ]] ); then
1740 cleanup_health_test || return $?
1744 if ${need_mr} && [[ ${#RNIDS[@]} -lt 2 ]]; then
1745 # Add a second, reachable NID to rnode.
1746 local net=${RNIDS[0]}
1750 local if=$(do_rpc_nodes --quiet $RNODE lnet_if_list)
1752 error "Failed to determine interface for $RNODE"
1754 do_rpc_nodes $RNODE "$LNETCTL lnet configure"
1755 do_rpc_nodes $RNODE "$LNETCTL net add --net $net --if $if" ||
1757 if [[ $rc -ne 0 ]]; then
1758 error "Failed to add interface to $RNODE rc=$?"
1760 RNIDS[1]="${RNIDS[0]}1"
1761 NET_DEL_ARGS="--net $net --if $if"
1765 if ${need_mr} && [[ ${#LNIDS[@]} -lt 2 ]]; then
1766 local net=${LNIDS[0]}
1769 do_lnetctl lnet configure &&
1770 do_lnetctl net add --net $net --if ${INTERFACES[0]} ||
1772 if [[ $rc -ne 0 ]]; then
1773 error "Failed to add interface rc=$?"
1775 LNIDS[1]="${LNIDS[0]}1"
1781 $LNETCTL peer show -v 2 | egrep -e nid -e health
1783 $LCTL set_param debug=+net
1789 cleanup_health_test() {
1792 if [[ -n $NET_DEL_ARGS ]]; then
1793 do_rpc_nodes $RNODE \
1794 "$LNETCTL net del $NET_DEL_ARGS" ||
1799 unload_modules || rc=$?
1802 do_rpc_nodes $RNODE unload_modules_local ||
1808 error "Failed cleanup"
1813 add_health_test_drop_rules() {
1814 local args="-m GET -r 1 -e ${1}"
1817 for src in "${LNIDS[@]}"; do
1818 for dst in "${RNIDS[@]}" "${LNIDS[@]}"; do
1819 $LCTL net_drop_add -s $src -d $dst ${args} ||
1820 error "Failed to add drop rule $src $dst $args"
1825 do_lnet_health_ping_test() {
1828 echo "Simulate $hstatus"
1830 lnet_health_pre || return $?
1832 add_health_test_drop_rules ${hstatus}
1833 do_lnetctl ping ${RNIDS[0]} &&
1834 error "Should have failed"
1838 $LCTL net_drop_del -a
1843 # See lnet/lnet/lib-msg.c:lnet_health_check()
1844 LNET_LOCAL_RESEND_STATUSES="local_interrupt local_dropped local_aborted"
1845 LNET_LOCAL_RESEND_STATUSES+=" local_no_route local_timeout"
1846 LNET_LOCAL_NO_RESEND_STATUSES="local_error"
1848 setup_health_test false || return $?
1851 for hstatus in ${LNET_LOCAL_RESEND_STATUSES} \
1852 ${LNET_LOCAL_NO_RESEND_STATUSES}; do
1853 do_lnet_health_ping_test "${hstatus}" || return $?
1854 check_no_resends || return $?
1855 check_no_local_health || return $?
1858 cleanup_health_test || return $?
1862 run_test 204 "Check no health or resends for single-rail local failures"
1865 (( $MDS1_VERSION >= $(version_code 2.14.58) )) ||
1866 skip "need at least 2.14.58"
1868 setup_health_test true || return $?
1871 for hstatus in ${LNET_LOCAL_RESEND_STATUSES}; do
1872 do_lnet_health_ping_test "${hstatus}" || return $?
1873 check_resends || return $?
1874 check_local_health || return $?
1877 for hstatus in ${LNET_LOCAL_NO_RESEND_STATUSES}; do
1878 do_lnet_health_ping_test "${hstatus}" || return $?
1879 check_no_resends || return $?
1880 check_local_health || return $?
1883 cleanup_health_test || return $?
1887 run_test 205 "Check health and resends for multi-rail local failures"
1889 # See lnet/lnet/lib-msg.c:lnet_health_check()
1890 LNET_REMOTE_RESEND_STATUSES="remote_dropped"
1891 LNET_REMOTE_NO_RESEND_STATUSES="remote_error remote_timeout"
1893 setup_health_test false || return $?
1896 for hstatus in ${LNET_REMOTE_RESEND_STATUSES} \
1897 ${LNET_REMOTE_NO_RESEND_STATUSES}; do
1898 do_lnet_health_ping_test "${hstatus}" || return $?
1899 check_no_resends || return $?
1900 check_no_local_health || return $?
1901 check_no_remote_health || return $?
1904 cleanup_health_test || return $?
1908 run_test 206 "Check no health or resends for single-rail remote failures"
1911 (( $MDS1_VERSION >= $(version_code 2.14.58) )) ||
1912 skip "need at least 2.14.58"
1914 setup_health_test true || return $?
1917 for hstatus in ${LNET_REMOTE_RESEND_STATUSES}; do
1918 do_lnet_health_ping_test "${hstatus}" || return $?
1919 check_resends || return $?
1920 check_no_local_health || return $?
1921 check_remote_health || return $?
1922 do_lnetctl peer set --health 1000 --all ||
1923 error "Unable to reset health rc=$?"
1925 for hstatus in ${LNET_REMOTE_NO_RESEND_STATUSES}; do
1926 do_lnet_health_ping_test "${hstatus}" || return $?
1927 check_no_resends || return $?
1928 check_no_local_health || return $?
1929 check_remote_health || return $?
1930 do_lnetctl peer set --health 1000 --all ||
1931 error "Unable to reset health rc=$?"
1934 cleanup_health_test || return $?
1938 run_test 207 "Check health and resends for multi-rail remote errors"
1940 test_208_load_and_check_lnet() {
1944 local num_expected=1
1946 load_lnet "networks=\"\" ip2nets=\"${ip2nets_str}\""
1949 error "Failed to load LNet with ip2nets \"${ip2nets_str}\""
1955 nids=( $($LCTL list_nids) )
1957 [[ ${#nids[@]} -ne ${num_expected} ]] &&
1958 error "Expect ${num_expected} NIDs found ${#nids[@]}"
1960 [[ ${nids[0]} == ${p_nid} ]] ||
1961 error "Expect NID \"${p_nid}\" found \"${nids[0]}\""
1963 [[ -n $s_nid ]] && [[ ${nids[1]} != ${s_nid} ]] &&
1964 error "Expect second NID \"${s_nid}\" found \"${nids[1]}\""
1966 $LCTL net down &>/dev/null
1971 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
1973 cleanup_netns || error "Failed to cleanup netns before test execution"
1974 cleanup_lnet || error "Failed to unload modules before test execution"
1975 setup_fakeif || error "Failed to add fake IF"
1977 have_interface "$FAKE_IF" ||
1978 error "Expect $FAKE_IF configured but not found"
1980 local if0_ip=$(ip --oneline addr show dev ${INTERFACES[0]} |
1981 awk '/inet /{print $4}' |
1983 if0_ip=($(echo "${if0_ip[@]}" | tr ' ' '\n' | uniq | tr '\n' ' '))
1984 local ip2nets_str="tcp(${INTERFACES[0]}) $if0_ip"
1986 echo "Configure single NID \"$ip2nets_str\""
1987 test_208_load_and_check_lnet "${ip2nets_str}" "${if0_ip}@tcp"
1989 ip2nets_str="tcp(${INTERFACES[0]}) $if0_ip; tcp1($FAKE_IF) $FAKE_IP"
1990 echo "Configure two NIDs; two NETs \"$ip2nets_str\""
1991 test_208_load_and_check_lnet "${ip2nets_str}" "${if0_ip}@tcp" \
1994 ip2nets_str="tcp(${INTERFACES[0]}) $if0_ip; tcp($FAKE_IF) $FAKE_IP"
1995 echo "Configure two NIDs; one NET \"$ip2nets_str\""
1996 test_208_load_and_check_lnet "${ip2nets_str}" "${if0_ip}@tcp" \
1998 local addr1=( ${if0_ip//./ } )
1999 local addr2=( ${FAKE_IP//./ } )
2000 local range="[${addr1[0]},${addr2[0]}]"
2003 for i in $(seq 1 3); do
2004 range+=".[${addr1[$i]},${addr2[$i]}]"
2006 ip2nets_str="tcp(${INTERFACES[0]},${FAKE_IF}) ${range}"
2008 echo "Configured two NIDs; one NET alt syntax \"$ip2nets_str\""
2009 test_208_load_and_check_lnet "${ip2nets_str}" "${if0_ip}@tcp" \
2014 echo "alt syntax with missing IF \"$ip2nets_str\""
2015 load_lnet "networks=\"\" ip2nets=\"${ip2nets_str}\""
2017 echo "$LCTL net up should fail"
2019 error "LNet bring up should have failed"
2023 run_test 208 "Test various kernel ip2nets configurations"
2026 (( $MDS1_VERSION >= $(version_code 2.14.58) )) ||
2027 skip "need at least 2.14.58"
2029 setup_health_test false || return $?
2031 echo "Simulate network_timeout w/SR config"
2034 add_health_test_drop_rules network_timeout
2036 do_lnetctl discover ${RNIDS[0]} &&
2037 error "Should have failed"
2041 check_no_resends || return $?
2042 check_no_local_health || return $?
2043 check_no_remote_health || return $?
2045 cleanup_health_test || return $?
2047 setup_health_test true || return $?
2049 echo "Simulate network_timeout w/MR config"
2053 add_health_test_drop_rules network_timeout
2055 do_lnetctl discover ${RNIDS[0]} &&
2056 error "Should have failed"
2060 check_no_resends || return $?
2061 check_local_health || return $?
2062 check_remote_health || return $?
2064 cleanup_health_test || return $?
2068 run_test 209 "Check health, but not resends, for network timeout"
2070 check_nid_in_recovq() {
2074 local max_wait="${4:-10}"
2078 echo "$queue recovery queue should be empty" ||
2079 echo "$queue recovery queue should have $nid"
2081 wait_update $HOSTNAME \
2082 "$LNETCTL debug recovery $queue | \
2083 grep -wc \"nid-0: $nid\"" \
2084 "$expect" "$max_wait"
2086 do_lnetctl debug recovery $queue
2088 error "Expect $expect NIDs in recovery."
2093 # First ping is sent at time 0.
2094 # 2nd at 0 + 2^1 = 2
2095 # 3rd at 2 + 2^2 = 6
2096 # 4th at 6 + 2^3 = 14
2097 # 5th at 14 + 2^4 = 30
2098 # e.g. after 10 seconds we would expect 3 pings to have been sent, and the
2099 # NI will have been enqueued for the 4th ping.
2101 # If the recovery limit is 10 seconds, then after the 4th ping is sent
2102 # we expect the peer NI to have aged out, so it will not actually be
2103 # queued for a 5th ping.
2104 # If max_recovery_ping_interval is set to 4 then:
2105 # First ping is sent at time 0
2106 # 2nd at 0 + min(2^1, 4) = 2
2107 # 3rd at 2 + min(2^2, 4) = 6
2108 # 4th at 6 + min(2^3, 4) = 10
2109 # 5th at 10 + min(2^4, 4) = 14
2110 # 6th at 14 + min(2^5, 4) = 18
2111 # 7th at 18 + min(2^6, 4) = 22
2112 # e.g. after 4 seconds we would expect 2 pings to have been sent, and
2113 # after 13 seconds we would expect 4 pings to have been sent
2114 check_ping_count() {
2120 echo "Check ping counts:"
2123 if [[ $queue == "ni" ]]; then
2124 wait_update $HOSTNAME \
2125 "$LNETCTL net show -v 2 | \
2126 grep -e $nid -e ping_count | grep -wA1 $nid | \
2127 awk '/ping_count/{print \\\$NF}'" "$expect" "$max_wait"
2129 $LNETCTL net show -v 2 | grep -e $nid -e ping_count
2130 elif [[ $queue == peer_ni ]]; then
2131 wait_update $HOSTNAME \
2132 "$LNETCTL peer show -v 2 --nid $nid | \
2134 grep -e $nid -e ping_count | grep -wA1 $nid | \
2135 awk '/ping_count/{print \\\$NF}'" "$expect" "$max_wait"
2137 $LNETCTL peer show -v 2 --nid $nid | grep -v primary |
2138 grep -e $nid -e ping_count
2140 error "Unrecognized queue \"$queue\""
2144 ((rc == 0)) || error "Unexpected ping count"
2150 [[ ${NETTYPE} == kfi* ]] && skip "kfi doesn't support drop rules"
2152 reinit_dlc || return $?
2153 add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
2154 add_net "${NETTYPE}1" "${INTERFACES[0]}" || return $?
2156 local prim_nid=$($LCTL list_nids | head -n 1)
2158 do_lnetctl discover $prim_nid ||
2159 error "failed to discover myself"
2161 local default=$($LNETCTL global show |
2162 awk '/recovery_limit/{print $NF}')
2163 # Set recovery limit to 10 seconds.
2164 do_lnetctl set recovery_limit 10 ||
2165 error "failed to set recovery_limit"
2167 $LCTL set_param debug=+net
2168 $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -m GET -r 1 \
2170 error "Failed to add drop rule"
2171 $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -m GET -r 1 \
2173 error "Failed to add drop rule"
2174 $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -r 1 ||
2175 error "Failed to add drop rule"
2176 $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -r 1 ||
2177 error "Failed to add drop rule"
2178 do_lnetctl net set --health 0 --nid $prim_nid
2180 check_ping_count "ni" "$prim_nid" "2" "10"
2181 check_nid_in_recovq "-l" "$prim_nid" "1"
2183 check_ping_count "ni" "$prim_nid" "3" "10"
2184 check_nid_in_recovq "-l" "$prim_nid" "1"
2186 $LCTL net_drop_del -a
2188 reinit_dlc || return $?
2189 add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
2190 add_net "${NETTYPE}1" "${INTERFACES[0]}" || return $?
2192 local prim_nid=$($LCTL list_nids | head -n 1)
2194 do_lnetctl discover $prim_nid ||
2195 error "failed to discover myself"
2197 do_lnetctl set recovery_limit $default ||
2198 error "failed to set recovery_limit"
2200 default=$($LNETCTL global show |
2201 awk '/max_recovery_ping_interval/{print $NF}')
2202 do_lnetctl set max_recovery_ping_interval 4 ||
2203 error "failed to set max_recovery_ping_interval"
2205 $LCTL set_param debug=+net
2206 $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -m GET -r 1 \
2208 error "Failed to add drop rule"
2209 $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -m GET -r 1 \
2211 error "Failed to add drop rule"
2212 $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -r 1 ||
2213 error "Failed to add drop rule"
2214 $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -r 1 ||
2215 error "Failed to add drop rule"
2216 do_lnetctl net set --health 0 --nid $prim_nid
2218 check_ping_count "ni" "$prim_nid" "2" "10"
2219 check_nid_in_recovq "-l" "$prim_nid" "1"
2221 check_ping_count "ni" "$prim_nid" "4" "10"
2222 check_nid_in_recovq "-l" "$prim_nid" "1"
2224 $LCTL net_drop_del -a
2226 do_lnetctl set max_recovery_ping_interval $default ||
2227 error "failed to set max_recovery_ping_interval"
2231 run_test 210 "Local NI recovery checks"
2234 [[ ${NETTYPE} == kfi* ]] && skip "kfi doesn't support drop rules"
2236 reinit_dlc || return $?
2237 add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
2238 add_net "${NETTYPE}1" "${INTERFACES[0]}" || return $?
2240 local prim_nid=$($LCTL list_nids | head -n 1)
2242 do_lnetctl discover $prim_nid ||
2243 error "failed to discover myself"
2245 local default=$($LNETCTL global show |
2246 awk '/recovery_limit/{print $NF}')
2247 # Set recovery limit to 10 seconds.
2248 do_lnetctl set recovery_limit 10 ||
2249 error "failed to set recovery_limit"
2251 $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -m GET -r 1 \
2253 error "Failed to add drop rule"
2254 $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -m GET -r 1 \
2256 error "Failed to add drop rule"
2257 $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -r 1 ||
2258 error "Failed to add drop rule"
2259 $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -r 1 ||
2260 error "Failed to add drop rule"
2262 # Set health to 0 on one interface. This forces it onto the recovery
2264 do_lnetctl peer set --nid $prim_nid --health 0
2266 check_nid_in_recovq "-p" "$prim_nid" "1"
2268 # The peer should age out in 10-20 seconds
2269 check_nid_in_recovq "-p" "$prim_nid" "0" "20"
2270 # Ping count should reset to 0 when peer ages out
2271 check_ping_count "peer_ni" "$prim_nid" "0"
2273 $LCTL net_drop_del -a
2275 # Set health to force it back onto the recovery queue. Set to 500 means
2276 # in ~5 seconds it should be back at maximum value.
2277 # NB: we reset the recovery limit to 0 (indefinite) so the peer NI is
2279 do_lnetctl set recovery_limit 0 ||
2280 error "failed to set recovery_limit"
2282 do_lnetctl peer set --nid $prim_nid --health 500
2284 check_nid_in_recovq "-p" "$prim_nid" "1"
2285 check_nid_in_recovq "-p" "$prim_nid" "0" "20"
2287 reinit_dlc || return $?
2288 add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
2289 add_net "${NETTYPE}1" "${INTERFACES[0]}" || return $?
2291 local prim_nid=$($LCTL list_nids | head -n 1)
2293 do_lnetctl discover $prim_nid ||
2294 error "failed to discover myself"
2296 do_lnetctl set recovery_limit $default ||
2297 error "failed to set recovery_limit"
2299 default=$($LNETCTL global show |
2300 awk '/max_recovery_ping_interval/{print $NF}')
2301 do_lnetctl set max_recovery_ping_interval 4 ||
2302 error "failed to set max_recovery_ping_interval"
2304 $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -m GET -r 1 \
2306 error "Failed to add drop rule"
2307 $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -m GET -r 1 \
2309 error "Failed to add drop rule"
2310 $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -r 1 ||
2311 error "Failed to add drop rule"
2312 $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -r 1 ||
2313 error "Failed to add drop rule"
2315 # Set health to 0 on one interface. This forces it onto the recovery
2317 do_lnetctl peer set --nid $prim_nid --health 0
2319 check_ping_count "peer_ni" "$prim_nid" "1" "4"
2320 check_nid_in_recovq "-p" "$prim_nid" "1"
2322 # After we detect the 1st ping above, the 4th ping should be sent after
2324 check_ping_count "peer_ni" "$prim_nid" "4" "14"
2325 check_nid_in_recovq "-p" "$prim_nid" "1"
2327 $LCTL net_drop_del -a
2329 do_lnetctl set max_recovery_ping_interval $default ||
2330 error "failed to set max_recovery_ping_interval"
2334 run_test 211 "Remote NI recovery checks"
2337 [[ ${NETTYPE} == kfi* ]] && skip "kfi doesn't support drop rules"
2339 local rnodes=$(remote_nodes_list)
2340 [[ -z $rnodes ]] && skip "Need at least 1 remote node"
2342 cleanup_lnet || error "Failed to cleanup before test execution"
2344 # Loading modules should configure LNet with the appropriate
2345 # test-framework configuration
2346 load_lnet "config_on_load=1" || error "Failed to load modules"
2348 local my_nid=$($LCTL list_nids | head -n 1)
2350 error "Failed to get primary NID for local host $HOSTNAME"
2352 local rnode=$(awk '{print $1}' <<<$rnodes)
2353 local rnodenids=$(do_node $rnode $LCTL list_nids | xargs echo)
2356 if [[ -z $rnodenids ]]; then
2357 do_rpc_nodes $rnode load_lnet "config_on_load=1"
2359 rnodenids=$(do_node $rnode $LCTL list_nids | xargs echo)
2362 local rnodepnid=$(awk '{print $1}' <<< $rnodenids)
2364 [[ -z $rnodepnid ]] &&
2365 error "Failed to get primary NID for remote host $rnode"
2367 log "Initial discovery"
2368 do_lnetctl discover --force $rnodepnid ||
2369 error "Failed to discover $rnodepnid"
2371 do_node $rnode "$LNETCTL discover --force $my_nid" ||
2372 error "$rnode failed to discover $my_nid"
2374 log "Fail local discover ping to set LNET_PEER_REDISCOVER flag"
2375 $LCTL net_drop_add -s "*@$NETTYPE" -d "*@$NETTYPE" -r 1 \
2377 error "Failed to add drop rule"
2378 do_lnetctl discover --force $rnodepnid &&
2379 error "Discovery should have failed"
2380 $LCTL net_drop_del -a
2383 for nid in $rnodenids; do
2384 # We need GET (PING) delay just long enough so we can trigger
2385 # discovery on the remote peer
2386 $LCTL net_delay_add -s "*@$NETTYPE" -d $nid -r 1 -m GET -l 3 ||
2387 error "Failed to add delay rule"
2388 $LCTL net_drop_add -s "*@$NETTYPE" -d $nid -r 1 -m GET \
2390 error "Failed to add drop rule"
2391 # We need PUT (PUSH) delay just long enough so we can process
2393 $LCTL net_delay_add -s "*@$NETTYPE" -d $nid -r 1 -m PUT -l 6 ||
2394 error "Failed to add delay rule"
2397 log "Force $HOSTNAME to discover $rnodepnid (in background)"
2398 # We want to get a PING sent that we know will eventually fail.
2399 # The delay rules we added will ensure the ping is not sent until
2400 # the PUSH is also in flight (see below), and the drop rule ensures that
2401 # when the PING is eventually sent it will error out
2402 do_lnetctl discover --force $rnodepnid &
2405 # We want a discovery PUSH from rnode to put rnode back on our
2406 # discovery queue. This should cause us to try and send a PUSH to rnode
2407 # while the PING is still outstanding.
2408 log "Force $rnode to discover $my_nid"
2409 do_node $rnode $LNETCTL discover --force $my_nid
2411 # At this point we'll have both PING_SENT and PUSH_SENT set for the
2412 # rnode peer. Wait for the PING to error out which should terminate the
2413 # discovery process that we backgrounded.
2414 log "Wait for $pid1"
2416 log "Finished wait on $pid1"
2418 # The PING send failure clears the PING_SENT flag and puts the peer back
2419 # on the discovery queue. When discovery thread processes the peer it
2420 # will mistakenly clear the PUSH_SENT flag (and set PUSH_FAILED).
2421 # Discovery will then complete for this peer even though we have an
2423 # When PUSH is actually unlinked it will be forced back onto the
2424 # discovery queue, but we no longer have a ref on the peer. When
2425 # discovery completes again, we'll trip the ASSERT in
2426 # lnet_destroy_peer_locked()
2428 # Delete the delay rules to send the PUSH
2429 $LCTL net_delay_del -a
2430 # Delete the drop rules
2431 $LCTL net_drop_del -a
2434 error "Failed to unload modules"
2436 do_rpc_nodes $rnode unload_modules_local ||
2437 error "Failed to unload modules on $rnode"
2442 run_test 212 "Check discovery refcount loss bug (LU-14627)"
2445 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
2447 cleanup_netns || error "Failed to cleanup netns before test execution"
2448 cleanup_lnet || error "Failed to unload modules before test execution"
2450 setup_fakeif || error "Failed to add fake IF"
2451 have_interface "$FAKE_IF" ||
2452 error "Expect $FAKE_IF configured but not found"
2454 reinit_dlc || return $?
2456 add_net "tcp" "${INTERFACES[0]}" || return $?
2457 add_net "tcp" "$FAKE_IF" || return $?
2459 local nid1=$(lctl list_nids | head -n 1)
2460 local nid2=$(lctl list_nids | tail --lines 1)
2462 [[ $(lctl which_nid $nid1 $nid2) == $nid1 ]] ||
2463 error "Expect nid1 \"$nid1\" to be preferred"
2465 [[ $(lctl which_nid $nid2 $nid1) == $nid2 ]] ||
2466 error "Expect nid2 \"$nid2\" to be preferred"
2470 run_test 213 "Check LNetDist calculation for multiple local NIDs"
2472 function check_ni_status() {
2476 local status=$($LNETCTL net show |
2478 awk '/status/{print $NF}')
2480 echo "NI ${nid} expect status \"${expect}\" found \"${status}\""
2481 if [[ $status != $expect ]]; then
2482 error "Error: Expect NI status \"$expect\" for NID \"$nid\" but found \"$status\""
2489 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
2491 cleanup_netns || error "Failed to cleanup netns before test execution"
2492 cleanup_lnet || error "Failed to unload modules before test execution"
2494 setup_fakeif || error "Failed to add fake IF"
2495 have_interface "$FAKE_IF" ||
2496 error "Expect $FAKE_IF configured but not found"
2498 reinit_dlc || return $?
2500 add_net "tcp" "${INTERFACES[0]}" || return $?
2501 add_net "tcp" "$FAKE_IF" || return $?
2503 local nid1=$(lctl list_nids | head -n 1)
2504 local nid2=$(lctl list_nids | tail --lines 1)
2506 check_ni_status "0@lo" up
2507 check_ni_status "$nid1" up
2508 check_ni_status "$nid2" up
2510 do_lnetctl ping --source $nid2 $nid1 ||
2511 error "$LNETCTL ping --source $nid2 $nid1 failed"
2513 echo "Set $FAKE_IF down"
2514 echo "ip link set dev $FAKE_IF down"
2515 ip link set dev $FAKE_IF down
2516 check_ni_status "0@lo" up
2517 check_ni_status "$nid1" up
2518 check_ni_status "$nid2" down
2520 run_test 214 "Check local NI status when link is downed"
2526 $LNETCTL net show -v 2 |
2527 egrep -e nid -e $stat |
2529 awk '/'$stat':/{print $NF}'
2534 for nidvar in nid1 nid2; do
2535 for stat in send_count recv_count; do
2536 s=$(get_ni_stat ${!nidvar} $stat)
2537 eval ${nidvar}_pre_${stat}=$s
2544 for nidvar in nid1 nid2; do
2545 for stat in send_count recv_count; do
2546 s=$(get_ni_stat ${!nidvar} $stat)
2547 eval ${nidvar}_post_${stat}=$s
2557 eval pre=\${${nidvar}_pre_${stat}}
2558 eval post=\${${nidvar}_post_${stat}}
2560 echo "${!nidvar} pre ${stat} $pre post ${stat} $post"
2562 [[ $pre -ne $post ]]
2566 cleanup_netns || error "Failed to cleanup netns before test execution"
2567 cleanup_lnet || error "Failed to unload modules before test execution"
2569 reinit_dlc || return $?
2571 add_net "${NETTYPE}1" "${INTERFACES[0]}" || return $?
2572 add_net "${NETTYPE}2" "${INTERFACES[0]}" || return $?
2574 local nid1=$($LCTL list_nids | head -n 1)
2575 local nid2=$($LCTL list_nids | tail --lines 1)
2577 do_lnetctl peer add --prim $nid1 --nid $nid2 ||
2578 error "Failed to add peer"
2582 for nidvarA in nid1 nid2; do
2585 for nidvarB in nid1 nid2; do
2586 [[ $nidvarA == $nidvarB ]] && continue
2590 echo "$LNETCTL ping $dst x $npings"
2591 for i in $(seq 1 $npings); do
2592 $LNETCTL ping $dst &>/dev/null ||
2593 error "$LNETCTL ping $dst failed"
2598 # No source specified, sends to either NID should cause
2599 # counts to increase across both NIs
2600 for nidvar in nid1 nid2; do
2601 for stat in send_count recv_count; do
2602 ni_stat_changed $nidvar $stat ||
2603 error "$stat unchanged for ${!nidvar}"
2609 echo "$LNETCTL ping --source $src $dst x $npings"
2610 for i in $(seq 1 $npings); do
2611 $LNETCTL ping --source $src $dst &>/dev/null ||
2612 error "$LNETCTL ping --source $src $dst failed"
2617 # src nid == dest nid means stats for the _other_ NI
2618 # should be unchanged
2619 for nidvar in nid1 nid2; do
2620 for stat in send_count recv_count; do
2621 if [[ ${!nidvar} == $src ]]; then
2622 ni_stat_changed $nidvar $stat ||
2623 error "$stat unchanged for ${!nidvar}"
2625 ni_stat_changed $nidvar $stat &&
2626 error "$stat changed for ${!nidvar}"
2631 # Double number of pings for next iteration because the net
2632 # sequence numbers will have diverged
2633 npings=$(($npings * 2))
2636 # Ping from nid1 to nid2 should fail
2637 do_lnetctl ping --source $nid1 $nid2 &&
2638 error "ping from $nid1 to $nid2 should fail"
2640 # Ping from nid2 to nid1 should fail
2641 do_lnetctl ping --source $nid2 $nid1 &&
2642 error "ping from $nid2 to $nid1 should fail"
2646 run_test 215 "Test lnetctl ping --source option"
2649 [[ ${NETTYPE} == kfi* ]] && skip "kfi doesn't support drop rules"
2653 reinit_dlc || return $?
2655 add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
2656 add_net "${NETTYPE}1" "${INTERFACES[0]}" || return $?
2658 local nids=( $($LCTL list_nids | xargs echo) )
2660 do_lnetctl discover ${nids[0]} ||
2661 error "Initial discovery failed"
2663 do_lnetctl ping --source ${nids[0]} ${nids[0]} ||
2664 error "Initial ping failed $?"
2666 do_lnetctl ping --source ${nids[1]} ${nids[1]} ||
2667 error "Initial ping failed $?"
2670 for src in "${nids[@]}"; do
2671 for dst in "${nids[@]}"; do
2672 $LCTL net_drop_add -r 1 -s $src -d $dst \
2673 -e network_timeout ||
2674 error "Failed to add drop rule"
2678 do_lnetctl ping ${nids[0]} || rc=$?
2680 $LCTL net_drop_del -a
2683 error "expected ping to fail"
2685 check_nid_in_recovq "-p" "${nids[0]}" "0"
2686 check_nid_in_recovq "-l" "${nids[0]}" "1"
2690 run_test 216 "Failed send to peer NI owned by local host should not trigger peer NI recovery"
2693 reinit_dlc || return $?
2695 [[ $($LNETCTL net show | grep -c nid) -ne 1 ]] &&
2696 error "Unexpected number of NIs after initalizing DLC"
2698 do_lnetctl discover 0@lo ||
2699 error "Failed to discover 0@lo"
2703 run_test 217 "Don't leak memory when discovering peer with nnis <= 1"
2706 [[ ${NETTYPE} == kfi* ]] && skip "kfi doesn't support drop rules"
2708 reinit_dlc || return $?
2710 [[ ${#INTERFACES[@]} -lt 2 ]] &&
2711 skip "Need two LNet interfaces"
2713 add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
2715 local nid1=$($LCTL list_nids | head -n 1)
2717 do_lnetctl ping $nid1 ||
2720 add_net "${NETTYPE}" "${INTERFACES[1]}" || return $?
2722 local nid2=$($LCTL list_nids | tail --lines 1)
2724 do_lnetctl ping $nid2 ||
2727 $LCTL net_drop_add -s $nid1 -d $nid1 -e local_error -r 1 ||
2728 error "Failed to add drop rule"
2730 do_lnetctl ping --source $nid1 $nid1 &&
2731 error "ping should have failed"
2733 local health_recovered
2736 for i in $(seq 1 5); do
2737 health_recovered=$($LNETCTL net show -v 2 |
2738 grep -c 'health value: 1000')
2740 if [[ $health_recovered -ne 2 ]]; then
2741 echo "Wait 1 second for health to recover"
2748 health_recovered=$($LNETCTL net show -v 2 |
2749 grep -c 'health value: 1000')
2751 $LCTL net_drop_del -a
2753 [[ $health_recovered -ne 2 ]] &&
2754 do_lnetctl net show -v 2 | egrep -e nid -e health &&
2755 error "Health hasn't recovered"
2759 run_test 218 "Local recovery pings should exercise all available paths"
2762 reinit_dlc || return $?
2763 add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
2764 add_net "${NETTYPE}1" "${INTERFACES[0]}" || return $?
2766 local nid1=$(lctl list_nids | head -n 1)
2767 local nid2=$(lctl list_nids | tail --lines 1)
2769 do_lnetctl ping $nid1 ||
2770 error "Ping failed $?"
2771 do_lnetctl ping $nid2 ||
2772 error "Ping failed $?"
2774 do_lnetctl discover $nid2 ||
2775 error "Discovery failed"
2777 $LNETCTL peer show --nid $nid1 | grep -q $nid2 ||
2778 error "$nid2 is not listed under $nid1"
2780 run_test 219 "Consolidate peer entries"
2787 do_rpc_nodes $node "$LNETCTL net add --net $net --if $if" ||
2788 error "add $net on interface $if on node $node failed rc=$?"
2796 do_node $node "$LNETCTL route add --net $net --gateway $gw" ||
2797 error "route add to $net via $gw failed rc=$?"
2801 ROUTER_INTERFACES=()
2804 init_router_test_vars() {
2805 local rnodes=$(remote_nodes_list)
2806 [[ -z $rnodes || $(wc -w <<<$rnodes) -lt 2 ]] &&
2807 skip "Need at least 2 remote nodes found \"$rnodes\""
2809 ROUTER=$(awk '{print $1}' <<<$rnodes)
2810 RPEER=$(awk '{print $2}' <<<$rnodes)
2812 rnodes=$(comma_list $ROUTER $RPEER)
2813 local all_nodes=$(comma_list $rnodes $HOSTNAME)
2815 do_nodes $rnodes $LUSTRE_RMMOD ||
2816 error "failed to unload modules"
2818 do_rpc_nodes $rnodes "load_lnet config_on_load=1" ||
2819 error "Failed to load and configure LNet"
2821 ROUTER_INTERFACES=( $(do_rpc_nodes --quiet $ROUTER lnet_if_list) )
2823 RPEER_INTERFACES=( $(do_rpc_nodes --quiet $RPEER lnet_if_list) )
2825 do_nodes $all_nodes $LUSTRE_RMMOD ||
2826 error "Failed to unload modules"
2828 [[ ${#INTERFACES[@]} -eq 0 ]] &&
2829 error "No interfaces configured for local host $HOSTNAME"
2830 [[ ${#ROUTER_INTERFACES[@]} -eq 0 ]] &&
2831 error "No interfaces configured for router $ROUTER"
2832 [[ ${#RPEER_INTERFACES[@]} -eq 0 ]] &&
2833 error "No interfaces configured for remote peer $RPEER"
2841 LOCAL_NET=${NETTYPE}1
2842 REMOTE_NET=${NETTYPE}2
2843 setup_router_test() {
2846 (( $MDS1_VERSION >= $(version_code 2.15.0) )) ||
2847 skip "need at least 2.15.0 for load_lnet"
2849 if [[ ${#RPEER_INTERFACES[@]} -eq 0 ]]; then
2850 init_router_test_vars ||
2854 local all_nodes=$(comma_list $ROUTER $RPEER $HOSTNAME)
2856 do_nodes $all_nodes $LUSTRE_RMMOD ||
2857 error "failed to unload modules"
2859 mod_opts+=" alive_router_check_interval=5"
2860 mod_opts+=" router_ping_timeout=5"
2861 mod_opts+=" large_router_buffers=4"
2862 mod_opts+=" small_router_buffers=8"
2863 mod_opts+=" tiny_router_buffers=16"
2864 do_rpc_nodes $all_nodes load_lnet "${mod_opts}" ||
2865 error "Failed to load lnet"
2867 do_nodes $all_nodes "$LNETCTL lnet configure" ||
2868 error "Failed to initialize DLC"
2870 do_net_add $ROUTER $LOCAL_NET ${ROUTER_INTERFACES[0]} ||
2873 do_net_add $ROUTER $REMOTE_NET ${ROUTER_INTERFACES[0]} ||
2876 do_net_add $RPEER $REMOTE_NET ${RPEER_INTERFACES[0]} ||
2879 add_net $LOCAL_NET ${INTERFACES[0]} ||
2882 ROUTER_NIDS=( $(do_node $ROUTER $LCTL list_nids 2>/dev/null |
2884 RPEER_NIDS=( $(do_node $RPEER $LCTL list_nids 2>/dev/null |
2886 LNIDS=( $($LCTL list_nids 2>/dev/null | xargs echo) )
2894 do_nodesv $node "if $LNETCTL route show --net $net --gateway $gw; then \
2895 $LNETCTL route del --net $net --gateway $gw; \
2901 cleanup_router_test() {
2902 local all_nodes=$(comma_list $HOSTNAME $ROUTER $RPEER)
2904 do_route_del $HOSTNAME $REMOTE_NET ${ROUTER_NIDS[0]} ||
2905 error "Failed to delete $REMOTE_NET route"
2907 do_route_del $RPEER $LOCAL_NET ${ROUTER_NIDS[1]} ||
2908 error "Failed to delete $LOCAL_NET route"
2910 do_nodes $all_nodes $LUSTRE_RMMOD ||
2911 error "failed to unload modules"
2916 check_route_aliveness() {
2921 local lnetctl_actual
2925 chk_intvl=$(cat /sys/module/lnet/parameters/alive_router_check_interval)
2927 lctl_actual=$(do_node $node $LCTL show_route | awk '{print $7}')
2928 lnetctl_actual=$(do_node $node $LNETCTL route show -v |
2929 awk '/state/{print $NF}')
2931 for ((i = 0; i < $chk_intvl; i++)); do
2932 if [[ $lctl_actual == $expected ]] &&
2933 [[ $lnetctl_actual == $expected ]]; then
2937 echo "wait 1s for route state change"
2940 lctl_actual=$(do_node $node $LCTL show_route | awk '{print $7}')
2941 lnetctl_actual=$(do_node $node $LNETCTL route show -v |
2942 awk '/state/{print $NF}')
2945 [[ $lctl_actual != $expected ]] &&
2946 error "Wanted \"$expected\" lctl found \"$lctl_actual\""
2948 [[ $lnetctl_actual != $expected ]] &&
2949 error "Wanted \"$expected\" lnetctl found \"$lnetctl_actual\""
2954 check_router_ni_status() {
2955 local expected_local="$1"
2956 local expected_remote="$2"
2964 chk_intvl=$(cat /sys/module/lnet/parameters/alive_router_check_interval)
2965 timeout=$(cat /sys/module/lnet/parameters/router_ping_timeout)
2967 actual_local=$(do_node $ROUTER "$LNETCTL net show --net $LOCAL_NET" |
2968 awk '/status/{print $NF}')
2969 actual_remote=$(do_node $ROUTER "$LNETCTL net show --net $REMOTE_NET" |
2970 awk '/status/{print $NF}')
2972 for ((i = 0; i < $((chk_intvl + timeout)); i++)); do
2973 if [[ $actual_local == $expected_local ]] &&
2974 [[ $actual_remote == $expected_remote ]]; then
2978 echo "wait 1s for NI state change"
2981 actual_local=$(do_node $ROUTER \
2982 "$LNETCTL net show --net $LOCAL_NET" |
2983 awk '/status/{print $NF}')
2984 actual_remote=$(do_node $ROUTER \
2985 "$LNETCTL net show --net $REMOTE_NET" |
2986 awk '/status/{print $NF}')
2989 [[ $actual_local == $expected_local ]] ||
2990 error "$LOCAL_NET should be $expected_local"
2992 [[ $actual_remote == $expected_remote ]] ||
2993 error "$REMOTE_NET should be $expected_remote"
2998 do_basic_rtr_test() {
2999 do_node $ROUTER "$LNETCTL set routing 1" ||
3000 error "Unable to enable routing on $ROUTER"
3002 do_route_add $HOSTNAME $REMOTE_NET ${ROUTER_NIDS[0]} ||
3005 do_route_add $RPEER $LOCAL_NET ${ROUTER_NIDS[1]} ||
3008 check_route_aliveness "$HOSTNAME" "up" ||
3011 check_route_aliveness "$RPEER" "up" ||
3014 do_lnetctl ping ${RPEER_NIDS[0]} ||
3015 error "Failed to ping ${RPEER_NIDS[0]}"
3017 do_node $RPEER "$LNETCTL ping ${LNIDS[0]}" ||
3018 error "$RPEER failed to ping ${LNIDS[0]}"
3024 setup_router_test || return $?
3026 do_basic_rtr_test || return $?
3028 do_rpc_nodes $HOSTNAME,$RPEER load_module ../lnet/selftest/lnet_selftest ||
3029 error "Failed to load lnet-selftest module"
3031 $LSTSH -H -t $HOSTNAME -f $RPEER -m rw -s 4k ||
3034 $LSTSH -H -t $HOSTNAME -f $RPEER -m rw ||
3037 cleanup_router_test || return $?
3039 run_test 220 "Add routes w/default options - check aliveness"
3042 setup_router_test lnet_peer_discovery_disabled=1 || return $?
3044 do_basic_rtr_test || return $?
3046 cleanup_router_test || return $?
3048 run_test 221 "Add routes w/DD disabled - check aliveness"
3050 do_aarf_enabled_test() {
3051 do_node $ROUTER "$LNETCTL set routing 1" ||
3052 error "Unable to enable routing on $ROUTER"
3054 check_router_ni_status "down" "down"
3056 do_lnetctl ping ${RPEER_NIDS[0]} &&
3057 error "Ping should fail"
3059 do_node $RPEER "$LNETCTL ping ${LNIDS[0]}" &&
3060 error "$RPEER ping should fail"
3062 # Adding a route should cause the router's NI on LOCAL_NET to get up
3063 do_route_add $HOSTNAME $REMOTE_NET ${ROUTER_NIDS[0]} ||
3066 check_router_ni_status "up" "down" ||
3069 # But route should still be down because of avoid_asym_router_failure
3070 check_route_aliveness "$HOSTNAME" "down" ||
3073 do_lnetctl ping ${RPEER_NIDS[0]} &&
3074 error "Ping should fail"
3076 do_node $RPEER "$LNETCTL ping ${LNIDS[0]}" &&
3077 error "$RPEER ping should fail"
3079 # Adding the symmetric route should cause the remote NI to go up and
3081 do_route_add $RPEER $LOCAL_NET ${ROUTER_NIDS[1]} ||
3084 check_router_ni_status "up" "up" ||
3087 check_route_aliveness "$HOSTNAME" "up" ||
3090 check_route_aliveness "$RPEER" "up" ||
3093 do_lnetctl ping ${RPEER_NIDS[0]} ||
3094 error "Failed to ping ${RPEER_NIDS[0]}"
3096 do_node $RPEER "$LNETCTL ping ${LNIDS[0]}" ||
3097 error "$RPEER failed to ping ${LNIDS[0]}"
3099 # Stop LNet on local host
3100 do_lnetctl lnet unconfigure ||
3101 error "Failed to stop LNet rc=$?"
3103 check_router_ni_status "down" "up" ||
3106 check_route_aliveness "$RPEER" "down" ||
3109 do_lnetctl ping ${RPEER_NIDS[0]} &&
3110 error "Ping should fail"
3112 do_node $RPEER "$LNETCTL ping ${LNIDS[0]}" &&
3113 error "$RPEER ping should fail"
3119 setup_router_test avoid_asym_router_failure=1 || return $?
3121 do_aarf_enabled_test || return $?
3123 cleanup_router_test || return $?
3125 run_test 222 "Check avoid_asym_router_failure=1"
3128 local opts="avoid_asym_router_failure=1 lnet_peer_discovery_disabled=1"
3130 setup_router_test $opts || return $?
3132 do_aarf_enabled_test || return $?
3134 cleanup_router_test || return $?
3136 run_test 223 "Check avoid_asym_router_failure=1 w/DD disabled"
3138 do_aarf_disabled_test() {
3139 do_node $ROUTER "$LNETCTL set routing 1" ||
3140 error "Unable to enable routing on $ROUTER"
3142 check_router_ni_status "down" "down"
3144 do_route_add $HOSTNAME $REMOTE_NET ${ROUTER_NIDS[0]} ||
3147 check_router_ni_status "up" "down" ||
3150 check_route_aliveness "$HOSTNAME" "up" ||
3153 do_route_add $RPEER $LOCAL_NET ${ROUTER_NIDS[1]} ||
3156 check_router_ni_status "up" "up" ||
3159 check_route_aliveness "$HOSTNAME" "up" ||
3162 check_route_aliveness "$RPEER" "up" ||
3165 do_lnetctl ping ${RPEER_NIDS[0]} ||
3166 error "Failed to ping ${RPEER_NIDS[0]}"
3168 do_node $RPEER "$LNETCTL ping ${LNIDS[0]}" ||
3169 error "$RPEER failed to ping ${LNIDS[0]}"
3171 # Stop LNet on local host
3172 do_lnetctl lnet unconfigure ||
3173 error "Failed to stop LNet rc=$?"
3175 check_router_ni_status "down" "up" ||
3178 check_route_aliveness "$RPEER" "up" ||
3185 setup_router_test avoid_asym_router_failure=0 ||
3188 do_aarf_disabled_test ||
3191 cleanup_router_test ||
3194 run_test 224 "Check avoid_asym_router_failure=0"
3197 local opts="avoid_asym_router_failure=0 lnet_peer_discovery_disabled=1"
3199 setup_router_test $opts || return $?
3201 do_aarf_disabled_test || return $?
3203 cleanup_router_test ||
3206 run_test 225 "Check avoid_asym_router_failure=0 w/DD disabled"
3209 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
3212 echo "Check valid values; Should succeed"
3216 for ((i = 4; i < 16; i+=1)); do
3217 reinit_dlc || return $?
3218 add_net "tcp" "${INTERFACES[0]}" || return $?
3219 do_lnetctl net set --all --conns-per-peer $i ||
3220 error "should have succeeded $?"
3221 $LNETCTL net show -v 1 | grep -q "conns_per_peer: $i" ||
3222 error "failed to set conns-per-peer to $i"
3223 lnid="$(lctl list_nids | head -n 1)"
3224 do_lnetctl ping "$lnid" ||
3225 error "failed to ping myself"
3227 # "lctl --net tcp conn_list" prints the list of active
3228 # connections. Since we're pinging ourselves, there should be
3229 # 2 Control connections plus 2*conns_per_peer connections
3230 # created (one Bulk Input, one Bulk Output in each pair).
3231 # Here's the sample output for conns_per_peer set to 1:
3232 # 12345-1.1.1.1@tcp I[0]host01->host01:988 2626560/1061296 nonagle
3233 # 12345-1.1.1.1@tcp O[0]host01->host01:1022 2626560/1061488 nonagle
3234 # 12345-1.1.1.1@tcp C[0]host01->host01:988 2626560/1061296 nonagle
3235 # 12345-1.1.1.1@tcp C[0]host01->host01:1023 2626560/1061488 nonagle
3236 cmd="printf 'network tcp\nconn_list\n' | lctl | grep -c '$lnid'"
3238 # Expect 2+conns_per_peer*2 connections. Wait no longer
3240 wait_update $HOSTNAME "$cmd" "$((2+i*2))" 2 ||
3241 error "expected number of tcp connections $((2+i*2))"
3244 reinit_dlc || return $?
3245 add_net "tcp" "${INTERFACES[0]}" || return $?
3246 echo "Set > 127; Should fail"
3247 do_lnetctl net set --all --conns-per-peer 128 &&
3248 error "should have failed $?"
3250 reinit_dlc || return $?
3251 add_net "tcp" "${INTERFACES[0]}" || return $?
3253 local default=$($LNETCTL net show -v 1 |
3254 awk '/conns_per_peer/{print $NF}')
3256 echo "Set < 0; Should be ignored"
3257 do_lnetctl net set --all --conns-per-peer -1 ||
3258 error "should have succeeded $?"
3259 $LNETCTL net show -v 1 | grep -q "conns_per_peer: ${default}" ||
3260 error "Did not stay at default"
3262 run_test 230 "Test setting conns-per-peer"
3265 reinit_dlc || return $?
3267 local net=${NETTYPE}231
3269 do_lnetctl net add --net $net --if ${INTERFACES[0]} ||
3270 error "Failed to add net"
3272 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
3273 sed -i 's/peer_timeout: .*$/peer_timeout: 0/' \
3274 $TMP/sanity-lnet-$testnum-expected.yaml
3276 reinit_dlc || return $?
3278 do_lnetctl import $TMP/sanity-lnet-$testnum-expected.yaml ||
3279 error "Failed to import configuration"
3281 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
3283 compare_yaml_files || error "Wrong config after import"
3285 do_lnetctl net del --net $net --if ${INTERFACES[0]} ||
3286 error "Failed to delete net $net"
3288 do_lnetctl net add --net $net --if ${INTERFACES[0]} --peer-timeout=0 ||
3289 error "Failed to add net with peer-timeout=0"
3291 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
3293 compare_yaml_files || error "Wrong config after lnetctl net add"
3295 reinit_dlc || return $?
3297 # lnet/include/lnet/lib-lnet.h defines DEFAULT_PEER_TIMEOUT 180
3298 sed -i 's/peer_timeout: .*$/peer_timeout: 180/' \
3299 $TMP/sanity-lnet-$testnum-expected.yaml
3301 sed -i '/^.*peer_timeout:.*$/d' $TMP/sanity-lnet-$testnum-actual.yaml
3303 do_lnetctl import $TMP/sanity-lnet-$testnum-actual.yaml ||
3304 error "Failed to import config without peer_timeout"
3306 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
3310 run_test 231 "Check DLC handling of peer_timeout parameter"
3312 ### Test that linux route is added for each ni
3316 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
3318 reinit_dlc || return $?
3319 add_net "tcp" "${INTERFACES[0]}" || return $?
3321 skip_param=$(cat /sys/module/ksocklnd/parameters/skip_mr_route_setup)
3322 [[ ${skip_param:-0} -ne 0 ]] &&
3323 skip "Need skip_mr_route_setup=0 found $skip_param"
3325 ip route show table ${INTERFACES[0]} | grep -q "${INTERFACES[0]}"
3327 run_test 250 "test that linux routes are added"
3330 [[ ${NETTYPE} =~ kfi* ]] ||
3331 skip "Need kfi NETTYPE"
3333 reinit_dlc || return $?
3334 add_net "kfi" "${INTERFACES[0]}" || return $?
3335 add_net "kfi1" "${INTERFACES[0]}" || return $?
3336 add_net "kfi10" "${INTERFACES[0]}" || return $?
3339 run_test 251 "Define multiple kfi networks on single interface"
3342 setup_health_test false || return $?
3346 do_rpc_nodes $RNODE unload_modules_local || rc=$?
3348 if [[ $rc -ne 0 ]]; then
3349 cleanup_health_test || return $?
3351 error "Failed to unload modules on $RNODE rc=$rc"
3356 local ts1=$(date +%s)
3358 do_lnetctl ping --timeout 15 ${RNIDS[0]} &&
3359 error "Expected ping ${RNIDS[0]} to fail"
3361 local ts2=$(date +%s)
3363 local delta=$(echo "$ts2 - $ts1" | bc)
3365 [[ $delta -lt 15 ]] ||
3366 error "Ping took longer than expected to fail: $delta"
3370 run_test 252 "Ping to down peer should unlink quickly"
3372 do_expired_message_drop_test() {
3373 local rnid lnid old_tto
3375 old_tto=$($LNETCTL global show |
3376 awk '/transaction_timeout:/{print $NF}')
3378 [[ -z $old_tto ]] &&
3379 error "Cannot determine LNet transaction timeout"
3383 do_lnetctl set transaction_timeout "${tto}" ||
3384 error "Failed to set transaction_timeout"
3386 # We want to consume all peer credits for at least transaction_timeout
3392 for lnid in "${LNIDS[@]}"; do
3393 for rnid in "${RNIDS[@]}"; do
3394 $LCTL net_delay_add -s "${lnid}" -d "${rnid}" \
3395 -l "${delay}" -r 1 -m GET ||
3396 error "Failed to add delay rule"
3402 pcs=( $($LNETCTL peer show -v --nid "${RNIDS[0]}" |
3403 awk '/max_ni_tx_credits:/{print $NF}' |
3406 [[ ${#RNIDS[@]} -ne ${#pcs[@]} ]] &&
3407 error "Expect ${#RNIDS[@]} peer credit values found ${#pcs[@]}"
3409 local rnet lnid lnet i j
3411 # Need to use --source for multi-rail configs to ensure we consume
3412 # all available peer credits
3413 for ((i = 0; i < ${#RNIDS[@]}; i++)); do
3414 local ping_args="--timeout $((delay+2))"
3416 rnet=${RNIDS[i]##*@}
3417 for lnid in ${LNIDS[@]}; do
3419 [[ $rnet == $lnet ]] && break
3422 ping_args+=" --source ${lnid} ${RNIDS[i]}"
3423 for j in $(seq 1 "${pcs[i]}"); do
3424 $LNETCTL ping ${ping_args} 1>/dev/null &
3427 echo "Issued ${pcs[i]} pings to ${RNIDS[i]} from $lnid"
3430 # This ping should be queued on peer NI tx credit
3431 $LNETCTL ping --timeout $((delay+2)) "${RNIDS[0]}" &
3435 $LCTL net_delay_del -a
3439 # Messages sent from the delay list do not go through
3440 # lnet_post_send_locked(), thus we should only have a single drop
3443 dropped=$($LNETCTL peer show -v 2 --nid "${RNIDS[0]}" |
3444 grep -A 2 dropped_stats |
3445 awk '/get:/{print $2}' |
3447 sed 's/ /\+/g' | bc)
3449 [[ $dropped -ne 1 ]] &&
3450 error "Expect 1 dropped GET but found $dropped"
3452 do_lnetctl set transaction_timeout "${old_tto}"
3458 setup_health_test false || return $?
3460 do_expired_message_drop_test || return $?
3464 run_test 253 "Message delayed beyond deadline should be dropped (single-rail)"
3467 setup_health_test true || return $?
3469 do_expired_message_drop_test || return $?
3473 run_test 254 "Message delayed beyond deadline should be dropped (multi-rail)"
3476 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
3478 reinit_dlc || return $?
3480 cleanup_lnet || return $?
3482 local routes_str="o2ib ${IF0_NET}.[$GW_HOSTNUM-$((GW_HOSTNUM+4))]"
3483 local network_str="${NETTYPE}(${INTERFACES[0]})"
3485 load_lnet "networks=\"${network_str}\" routes=\"${routes_str}\"" ||
3486 error "Failed to load LNet"
3489 error "Failed to load LNet with networks=\"${network_str}\" routes=\"${routes_str}\""
3491 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
3493 - net type: ${NETTYPE}
3498 append_net_tunables tcp
3500 echo "route:" >> $TMP/sanity-lnet-$testnum-expected.yaml
3501 for i in $(seq $GW_HOSTNUM $((GW_HOSTNUM + 4))); do
3502 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
3504 gateway: ${IF0_NET}.${i}@${NETTYPE}
3507 health_sensitivity: 1
3511 echo "peer:" >> $TMP/sanity-lnet-$testnum-expected.yaml
3512 for i in $(seq $GW_HOSTNUM $((GW_HOSTNUM + 4))); do
3513 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
3514 - primary nid: ${IF0_NET}.${i}@${NETTYPE}
3517 - nid: ${IF0_NET}.${i}@${NETTYPE}
3523 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml ||
3524 error "export failed $?"
3526 validate_gateway_nids
3528 run_test 255 "Use lnet routes param with pdsh syntax"
3533 local out=$TMP/$tfile
3534 local prefix=/usr/include/linux/lnet
3536 # We use a hard coded prefix so that this test will not fail
3539 if ! which $CC > /dev/null 2>&1; then
3540 skip_env "$CC is not installed"
3543 cleanup_lnet || exit 1
3546 local cc_args="-Wall -Werror -std=c99 -c -x c /dev/null -o $out"
3547 if ! [[ -d $prefix ]]; then
3548 # Assume we're running in tree and fixup the include path.
3549 prefix=$LUSTRE/../lnet/include/uapi/linux/lnet
3550 cc_args+=" -I $LUSTRE/../lnet/include/uapi"
3553 for header in $prefix/*.h; do
3554 if ! [[ -f "$header" ]]; then
3558 echo "$CC $cc_args -include $header"
3559 $CC $cc_args -include $header ||
3560 error "cannot compile '$header'"
3564 run_test 300 "packaged LNet UAPI headers can be compiled"
3566 # LU-16081 lnet: Memory leak on adding existing interface
3569 reinit_dlc || return $?
3570 do_lnetctl net add --net ${NETTYPE} --if ${INTERFACES[0]} ||
3571 error "Failed to add net"
3572 do_lnetctl net add --net ${NETTYPE} --if ${INTERFACES[0]} &&
3573 error "add net should have failed"
3574 do_lnetctl net del --net ${NETTYPE} --if ${INTERFACES[0]} ||
3575 error "Failed to del net"
3578 run_test 301 "Check for dynamic adds of same/wrong interface (memory leak)"
3581 ! [[ $NETTYPE =~ (tcp|o2ib) ]] && skip "Need tcp or o2ib NETTYPE"
3583 reinit_dlc || return $?
3585 add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
3587 local nid=$($LCTL list_nids)
3589 do_lnetctl ping ${nid} ||
3590 error "pinging self failed $?"
3591 do_lnetctl debug peer --nid ${nid} ||
3592 error "failed to dump peer debug info $?"
3594 run_test 302 "Check that peer debug info can be dumped"
3597 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
3599 setup_health_test true || return $?
3601 cleanup_netns || error "Failed to cleanup netns before test execution"
3602 setup_fakeif || error "Failed to add fake IF"
3603 have_interface "$FAKE_IF" ||
3604 error "Expect $FAKE_IF configured but not found"
3606 add_net "${NETTYPE}99" "$FAKE_IF" || return $?
3608 local nid=$($LCTL list_nids | tail --lines 1)
3610 # Our updated config should be pushed to RNODE
3611 local found=$(do_node $RNODE "$LNETCTL peer show --nid $nid")
3613 [[ -z $found ]] && error "Peer not updated on $RNODE"
3615 local prim=$($LCTL list_nids | head -n 1)
3617 if ! grep -q -- " primary nid: $prim"<<<"${found}"; then
3619 error "Wrong primary nid"
3622 echo "Set $FAKE_IF down"
3623 echo "ip link set dev $FAKE_IF down"
3624 ip link set dev $FAKE_IF down
3625 check_ni_status "$nid" down
3627 local hval=$(do_node $RNODE "$LNETCTL peer show --nid $nid -v 2 | \
3628 grep -e '- nid:' -e 'health value:'")
3630 hval=$(grep -A 1 $nid<<<"$hval" | tail -n 1 | awk '{print $NF}')
3631 (( hval < 1000 )) ||
3632 error "Expect $hval < 1000"
3636 run_test 303 "Check peer NI health after link down"
3639 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
3641 cleanup_netns || error "Failed to cleanup netns before test execution"
3642 cleanup_lnet || error "Failed to unload modules before test execution"
3644 setup_fakeif || error "Failed to add fake IF"
3645 have_interface "$FAKE_IF" ||
3646 error "Expect $FAKE_IF configured but not found"
3648 reinit_dlc || return $?
3650 add_net "tcp" "${INTERFACES[0]}" || return $?
3651 add_net "tcp" "$FAKE_IF" || return $?
3653 local nid1=$(lctl list_nids | head -n 1)
3654 local nid2=$(lctl list_nids | tail --lines 1)
3656 check_ni_status "$nid1" up
3657 check_ni_status "$nid2" up
3659 do_lnetctl peer add --prim_nid ${nid2} --lock_prim ||
3660 error "peer add failed $?"
3661 local locked_peer_state=($(do_lnetctl peer show -v 4 --nid ${nid2} |
3662 awk '/peer state/{print $NF}'))
3664 # Expect peer state bits:
3665 # LNET_PEER_MULTI_RAIL(0) | LNET_PEER_CONFIGURED(3) |
3666 # LNET_PEER_LOCK_PRIMARY(20)
3667 (( $locked_peer_state != "1048585")) &&
3668 error "Wrong peer state \"$locked_peer_state\" expected 1048585"
3670 # Clear LNET_PEER_CONFIGURED bit and verify
3671 do_lnetctl peer set --nid ${nid2} --state 1048577 ||
3672 error "peer add failed $?"
3673 locked_peer_state=($(do_lnetctl peer show -v 4 --nid ${nid2} |
3674 awk '/peer state/{print $NF}'))
3675 (( $locked_peer_state != "1048577")) &&
3676 error "Wrong peer state \"$locked_peer_state\" expected 1048577"
3677 do_lnetctl discover ${nid1} ||
3678 error "Failed to discover peer"
3680 # Expect nid2 and nid1 peer entries to be consolidated,
3681 # nid2 to stay primary
3682 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
3684 - primary nid: ${nid2}
3692 $LNETCTL peer show > $TMP/sanity-lnet-$testnum-actual.yaml
3693 compare_yaml_files ||
3694 error "Unexpected peer configuration"
3696 locked_peer_state=($(do_lnetctl peer show -v 4 --nid ${nid2} |
3697 awk '/peer state/{print $NF}'))
3698 # Expect peer state bits to be added:
3699 # LNET_PEER_DISCOVERED(4) | LNET_PEER_NIDS_UPTODATE(8)
3700 (( $locked_peer_state != "1048849")) &&
3701 error "Wrong peer state \"$locked_peer_state\" expected 1048849"
3704 run_test 304 "Check locked primary peer nid consolidation"
3710 echo "check parameter ${para} value ${value}"
3712 return $(( $(do_lnetctl net show -v | \
3714 grep -c "^ \+${para}: ${value}$") != ${#INTERFACES[@]} ))
3721 cleanup_lnet || error "Failed to cleanup LNet"
3723 load_module ../libcfs/libcfs/libcfs ||
3724 error "Failed to load module libcfs rc = $?"
3726 load_module ../lnet/lnet/lnet ||
3727 error "Failed to load module lnet rc = $?"
3729 echo "loading ${module} ${setting} type ${NETTYPE}"
3730 load_module "${module}" "${setting}" ||
3731 error "Failed to load module ${module} rc = $?"
3733 do_lnetctl lnet configure --all || error "lnet configure failed rc = $?"
3741 if [[ ${NETTYPE} == tcp* ]];then
3742 static_config "../lnet/klnds/socklnd/ksocklnd" \
3743 "sock_timeout=${value}"
3744 elif [[ ${NETTYPE} == o2ib* ]]; then
3745 static_config "../lnet/klnds/o2iblnd/ko2iblnd" \
3747 elif [[ ${NETTYPE} == gni* ]]; then
3748 static_config "../lnet/klnds/gnilnd/kgnilnd" \
3751 skip "NETTYPE ${NETTYPE} not supported"
3754 check_parameter "timeout" $value
3758 run_test 310 "Set timeout and verify"
3761 [[ $NETTYPE == kfi* ]] ||
3762 skip "Need kfi network type"
3764 setupall || error "setupall failed"
3766 mkdir -p $DIR/$tdir || error "mkdir failed"
3767 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 oflag=direct ||
3768 error "dd write failed"
3770 local list=$(comma_list $(osts_nodes))
3772 #define CFS_KFI_FAIL_WAIT_SEND_COMP1 0xF115
3773 do_nodes $list $LCTL set_param fail_loc=0x8000F115
3774 dd if=$DIR/$tdir/$tfile of=/dev/null bs=1M count=1 ||
3775 error "dd read failed"
3777 rm -f $DIR/$tdir/$tfile
3780 cleanupall || error "Failed cleanup"
3782 run_test 311 "Fail bulk put in send wait completion"
3785 [[ $NETTYPE == kfi* ]] ||
3786 skip "Need kfi network type"
3788 setupall || error "setupall failed"
3790 mkdir -p $DIR/$tdir || error "mkdir failed"
3792 local list=$(comma_list $(osts_nodes))
3794 #define CFS_KFI_FAIL_WAIT_SEND_COMP3 0xF117
3795 do_nodes $list $LCTL set_param fail_loc=0x8000F117
3796 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 oflag=direct ||
3797 error "dd write failed"
3799 local tfile2="$DIR/$tdir/testfile2"
3801 do_nodes $list $LCTL set_param fail_loc=0x8000F117
3802 dd if=$DIR/$tdir/$tfile of=$tfile2 bs=1M count=1 oflag=direct ||
3803 error "dd read failed"
3805 rm -f $DIR/$tdir/$tfile
3809 cleanupall || error "Failed cleanup"
3811 run_test 312 "TAG_RX_OK is possible after TX_FAIL"
3814 local target_net="${1}"
3815 local target_nid="${2}"
3816 local expect_net="${3}"
3817 local expect_nid="${4}"
3821 declare -a net_prios
3822 declare -a nid_prios
3824 nids=( $($LNETCTL ${type} show -v 5 | awk '/-\s+nid:/{print $NF}' |
3827 net_prios=( $($LNETCTL ${type} show -v 5 |
3828 awk '/net priority:/{print $NF}' | xargs echo) )
3830 nid_prios=( $($LNETCTL ${type} show -v 5 |
3831 awk '/nid priority:/{print $NF}' | xargs echo) )
3833 (( ${#nids[@]} != ${#net_prios[@]} )) &&
3834 error "Wrong # net prios ${#nids[@]} != ${#net_prios[@]}"
3836 (( ${#nids[@]} != ${#nid_prios[@]} )) &&
3837 error "Wrong # nid prios ${#nids[@]} != ${#nid_prios[@]}"
3841 for ((i = 0; i < ${#nids[@]}; i++)); do
3842 [[ -n ${target_net} ]] &&
3843 [[ ${nids[i]##*@} != "${target_net}" ]] &&
3845 [[ -n ${target_nid} ]] &&
3846 [[ ${nids[i]} != "${target_nid}" ]] &&
3849 echo "${nids[i]}: net_prio ${net_prios[i]} expect ${expect_net}"
3850 (( net_prios[i] != expect_net )) &&
3851 error "Wrong net priority \"${net_prios[i]}\" expect ${expect_net}"
3853 echo "${nids[i]}: nid_prio ${nid_prios[i]} expect ${expect_nid}"
3854 (( nid_prios[i] != expect_nid )) &&
3855 error "Wrong nid priority \"${nid_prios[i]}\" expect ${expect_nid}"
3861 check_peer_udsp_prio() {
3862 check_udsp_prio "${1}" "${2}" "${3}" "${4}" "peer"
3865 check_net_udsp_prio() {
3866 check_udsp_prio "${1}" "${2}" "${3}" "${4}" "net"
3870 reinit_dlc || return $?
3872 do_lnetctl udsp add --src tcp --priority 0 ||
3873 error "Failed to add udsp rule"
3874 do_lnetctl udsp del --idx 0 ||
3875 error "Failed to del udsp rule"
3878 run_test 400 "Check for udsp add/delete net rule without net num"
3881 reinit_dlc || return $?
3883 do_lnetctl net add --net ${NETTYPE} --if ${INTERFACES[0]} ||
3884 error "Failed to add net"
3886 do_lnetctl udsp add --dst ${NETTYPE} --prio 1 ||
3887 error "Failed to add peer net priority rule"
3889 do_lnetctl discover $($LCTL list_nids | head -n 1) ||
3890 error "Failed to discover peer"
3892 check_peer_udsp_prio "${NETTYPE}" "" "1" "-1"
3896 run_test 401 "Discover peer after adding peer net UDSP rule"
3899 reinit_dlc || return $?
3901 do_lnetctl udsp add --dst kfi --priority 0 ||
3902 error "Failed to add UDSP rule"
3904 do_lnetctl peer add --prim 402@kfi ||
3905 error "Failed to add peer"
3909 run_test 402 "Destination net rule should not panic"
3912 reinit_dlc || return $?
3914 cleanup_netns || error "Failed to cleanup netns before test execution"
3915 setup_fakeif || error "Failed to add fake IF"
3916 have_interface "$FAKE_IF" ||
3917 error "Expect $FAKE_IF configured but not found"
3919 add_net "tcp" "${INTERFACES[0]}"
3920 add_net "tcp" "${FAKE_IF}"
3922 do_lnetctl discover $($LCTL list_nids | head -n 1) ||
3923 error "Failed to discover self"
3925 $LCTL net_delay_add -s *@tcp -d *@tcp -r 1 -l 1 -m PUT ||
3926 error "Failed to add delay rule"
3928 $LCTL net_drop_add -s *@tcp -d $($LCTL list_nids | head -n 1) -m PUT \
3929 -e local_timeout -r 1 ||
3930 error "Failed to add drop rule"
3931 $LCTL net_drop_add -s *@tcp -d $($LCTL list_nids | tail -n 1) -m PUT \
3932 -e local_timeout -r 1 ||
3933 error "Failed to add drop rule"
3935 ip link set $FAKE_IF down ||
3936 error "Failed to set link down"
3937 ip link set $FAKE_IF up ||
3938 error "Failed to set link up"
3942 run_test 500 "Check deadlock on ping target update"
3944 do_peer_set_health_test() {
3951 if [[ ${nid_arg} == --all ]]; then
3952 max_hval=$($LNETCTL peer show -v 2 2>/dev/null |
3953 awk '/health value/{print $NF}' | xargs echo |
3954 sed 's/ /+/g' | bc -l)
3956 max_hval=$($LNETCTL peer show ${nid_arg} -v 2 2>/dev/null |
3957 awk '/health value/{print $NF}' | xargs echo |
3958 sed 's/ /+/g' | bc -l)
3961 (( max_hval >= 1000 )) && (( max_hval % 1000 == 0)) ||
3962 error "Unexpected max health value $max_hval"
3964 lnet_health_pre || return $?
3966 do_lnetctl peer set --health $test_val ${nid_arg} ||
3967 error "failed to set health value"
3969 lnet_health_post || return $?
3973 if [[ ${nid_arg} == --all ]]; then
3974 hval=$($LNETCTL peer show -v 2 2>/dev/null |
3975 awk '/health value/{print $NF}' | xargs echo |
3976 sed 's/ /+/g' | bc -l)
3978 hval=$($LNETCTL peer show ${nid_arg} -v 2 2>/dev/null |
3979 awk '/health value/{print $NF}' | xargs echo |
3980 sed 's/ /+/g' | bc -l)
3983 check_remote_health || return $?
3985 echo "hval: $hval max_hval: $max_hval"
3986 (( hval == max_hval )) || error "Failed to reset health to max"
3992 reinit_dlc || return $?
3994 setup_health_test false || return $?
3996 $LCTL set_param debug=-1
3998 $LCTL net_drop_add -s *@tcp -d *@tcp -r 1 ||
3999 error "Failed to add drop rule"
4003 for test_val in 0 500; do
4004 do_peer_set_health_test $test_val --nid ${RNIDS[0]} || return $?
4005 do_peer_set_health_test $test_val --all || return $?
4010 run_test 501 "Verify lnetctl peer set --health (SR)"
4013 reinit_dlc || return $?
4015 setup_health_test true || return $?
4017 $LCTL set_param debug=-1
4019 $LCTL net_drop_add -s *@tcp -d *@tcp -r 1 ||
4020 error "Failed to add drop rule"
4024 for test_val in 0 500; do
4025 do_peer_set_health_test $test_val --nid ${RNIDS[0]} || return $?
4026 do_peer_set_health_test $test_val --all || return $?
4031 run_test 502 "Verify lnetctl peer set --health (MR)"
4033 complete_test $SECONDS