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 ARR_IF0_IP=($(ip -o -4 a s ${INTERFACES[0]} |
1168 awk '{print $4}' | sed 's/\/.*//'))
1169 echo "Total IP for ${INTERFACES[0]} found [${#ARR_IF0_IP[@]}]"
1170 echo "Interface:IP are"
1171 for i in ${ARR_IF0_IP[@]}; do
1172 echo "${INTERFACES[0]}:$i"
1174 IF0_IP=${ARR_IF0_IP[0]}
1175 IF0_NET=$(awk -F. '{print $1"."$2"."$3}'<<<"${IF0_IP}")
1176 IF0_HOSTNUM=$(awk -F. '{print $4}'<<<"${IF0_IP}")
1177 if (((IF0_HOSTNUM + 5) > 254)); then
1180 GW_HOSTNUM=$((IF0_HOSTNUM + 1))
1182 GW_NID="${IF0_NET}.${GW_HOSTNUM}@${NETTYPE}"
1183 echo "Using GW_NID:$GW_NID"
1186 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
1188 reinit_dlc || return $?
1189 add_net "${NETTYPE}" "${INTERFACES[0]}"
1190 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
1192 - net type: ${NETTYPE}
1197 append_net_tunables tcp
1198 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
1204 health_sensitivity: 1
1206 - primary nid: ${GW_NID}
1212 compare_route_add "tcp7" "${GW_NID}"
1214 run_test 100 "Add route with single gw (tcp)"
1217 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
1219 reinit_dlc || return $?
1220 add_net "${NETTYPE}" "${INTERFACES[0]}"
1221 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
1223 - net type: ${NETTYPE}
1228 append_net_tunables tcp
1230 echo "route:" >> $TMP/sanity-lnet-$testnum-expected.yaml
1231 for i in $(seq $GW_HOSTNUM $((GW_HOSTNUM + 4))); do
1232 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
1234 gateway: ${IF0_NET}.${i}@tcp
1237 health_sensitivity: 1
1241 echo "peer:" >> $TMP/sanity-lnet-$testnum-expected.yaml
1242 for i in $(seq $GW_HOSTNUM $((GW_HOSTNUM + 4))); do
1243 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
1244 - primary nid: ${IF0_NET}.${i}@tcp
1247 - nid: ${IF0_NET}.${i}@tcp
1252 local gw="${IF0_NET}.[$GW_HOSTNUM-$((GW_HOSTNUM + 4))]@tcp"
1254 compare_route_add "tcp8" "${gw}"
1256 run_test 101 "Add route with multiple gw (tcp)"
1258 compare_route_del() {
1262 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
1264 do_lnetctl route del --net ${rnet} --gateway ${gw} ||
1265 error "route del failed $?"
1266 $LNETCTL export --backup > $actual ||
1267 error "export failed $?"
1268 validate_gateway_nids
1274 if [[ ${net} =~ (tcp|o2ib)[0-9]* ]]; then
1277 echo "$((${testnum} % 255))@${net}"
1282 reinit_dlc || return $?
1283 add_net "${NETTYPE}" "${INTERFACES[0]}"
1284 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
1286 local gwnid=$(generate_gw_nid ${NETTYPE})
1288 do_lnetctl route add --net ${NETTYPE}2 --gateway ${gwnid} ||
1289 error "route add failed $?"
1290 compare_route_del "${NETTYPE}2" "${gwnid}"
1292 run_test 102 "Delete route with single gw"
1294 IP_NID_EXPR='103.103.103.[103-120/4]'
1295 NUM_NID_EXPR='[103-120/4]'
1297 reinit_dlc || return $?
1298 add_net "${NETTYPE}" "${INTERFACES[0]}"
1299 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
1303 if [[ $NETTYPE =~ (tcp|o2ib)[0-9]* ]]; then
1304 nid_expr="${IF0_NET}.[$GW_HOSTNUM-$((GW_HOSTNUM+5))/2]"
1306 nid_expr="${NUM_NID_EXPR}"
1309 do_lnetctl route add --net ${NETTYPE}103 \
1310 --gateway ${nid_expr}@${NETTYPE} ||
1311 error "route add failed $?"
1312 compare_route_del "${NETTYPE}103" "${nid_expr}@${NETTYPE}"
1314 run_test 103 "Delete route with multiple gw"
1317 local tyaml="$TMP/sanity-lnet-$testnum-expected.yaml"
1319 reinit_dlc || return $?
1321 # Default value is '3'
1322 local val=$($LNETCTL global show | awk '/response_tracking/{print $NF}')
1324 error "Expect 3 found $val"
1326 echo "Set < 0; Should fail"
1327 do_lnetctl set response_tracking -1 &&
1328 error "should have failed $?"
1330 reinit_dlc || return $?
1333 response_tracking: -10
1335 do_lnetctl import < $tyaml &&
1336 error "should have failed $?"
1338 echo "Check valid values; Should succeed"
1340 for ((i = 0; i < 4; i++)); do
1341 reinit_dlc || return $?
1342 do_lnetctl set response_tracking $i ||
1343 error "should have succeeded $?"
1344 $LNETCTL global show | grep -q "response_tracking: $i" ||
1345 error "Failed to set response_tracking to $i"
1346 reinit_dlc || return $?
1349 response_tracking: $i
1351 do_lnetctl import < $tyaml ||
1352 error "should have succeeded $?"
1353 $LNETCTL global show | grep -q "response_tracking: $i" ||
1354 error "Failed to set response_tracking to $i"
1357 reinit_dlc || return $?
1358 echo "Set > 3; Should fail"
1359 do_lnetctl set response_tracking 4 &&
1360 error "should have failed $?"
1362 reinit_dlc || return $?
1365 response_tracking: 10
1367 do_lnetctl import < $tyaml &&
1368 error "should have failed $?"
1371 run_test 104 "Set/check response_tracking param"
1374 reinit_dlc || return $?
1375 add_net "${NETTYPE}" "${INTERFACES[0]}"
1377 local gwnid=$(generate_gw_nid ${NETTYPE})
1379 do_lnetctl route add --net ${NETTYPE}105 --gateway ${gwnid} ||
1380 error "route add failed $?"
1381 do_lnetctl peer add --prim ${gwnid} &&
1382 error "peer add should fail"
1386 run_test 105 "Adding duplicate GW peer should fail"
1389 reinit_dlc || return $?
1390 add_net "${NETTYPE}" "${INTERFACES[0]}"
1392 local gwnid=$(generate_gw_nid ${NETTYPE})
1394 do_lnetctl route add --net ${NETTYPE}106 --gateway ${gwnid} ||
1395 error "route add failed $?"
1396 do_lnetctl peer del --prim ${gwnid} &&
1397 error "peer del should fail"
1401 run_test 106 "Deleting GW peer should fail"
1404 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
1406 cleanup_netns || error "Failed to cleanup netns before test execution"
1407 cleanup_lnet || error "Failed to unload modules before test execution"
1409 setup_fakeif || error "Failed to add fake IF"
1410 have_interface "$FAKE_IF" ||
1411 error "Expect $FAKE_IF configured but not found"
1413 reinit_dlc || return $?
1415 add_net "tcp" "${INTERFACES[0]}" || return $?
1416 add_net "tcp" "$FAKE_IF" || return $?
1418 del_net "tcp" "$FAKE_IF" || return $?
1424 run_test 107 "Deleting extra interface doesn't crash node"
1427 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
1429 cleanup_netns || error "Failed to cleanup netns before test execution"
1430 cleanup_lnet || error "Failed to unload modules before test execution"
1432 setup_fakeif || error "Failed to add fake IF"
1433 have_interface "$FAKE_IF" ||
1434 error "Expect $FAKE_IF configured but not found"
1436 reinit_dlc || return $?
1438 add_net "tcp" "${INTERFACES[0]}" || return $?
1439 $LNETCTL net show > $TMP/sanity-lnet-$testnum-expected.yaml
1440 add_net "tcp" "$FAKE_IF" || return $?
1442 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
1443 - nid: ${FAKE_IP}@tcp
1448 $LNETCTL net show > $TMP/sanity-lnet-$testnum-actual.yaml
1449 compare_yaml_files || error "not all interfaces were setup"
1457 run_test 108 "Check Multi-Rail setup"
1460 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
1462 cleanup_netns || error "Failed to cleanup netns before test execution"
1463 cleanup_lnet || error "Failed to unload modules before test execution"
1465 setup_fakeif || error "Failed to add fake IF"
1466 have_interface "$FAKE_IF" ||
1467 error "Expect $FAKE_IF configured but not found"
1469 FAKE_IF_ALIAS="${FAKE_IF}"
1472 ifconfig "$FAKE_IF_ALIAS" "$FAKE_IP_ALIAS" up ||
1473 error "Failed to add fake IF alias"
1475 reinit_dlc || return $?
1477 # add interface with longer name first
1478 add_net "tcp" "$FAKE_IF_ALIAS" || return $?
1479 add_net "tcp" "$FAKE_IF" || return $?
1481 del_net "tcp" "$FAKE_IF" || return $?
1482 del_net "tcp" "$FAKE_IF_ALIAS" || return $?
1484 # add interface with shorter name first
1485 add_net "tcp" "$FAKE_IF" || return $?
1486 add_net "tcp" "$FAKE_IF_ALIAS" || return $?
1488 ifconfig "$FAKE_IF_ALIAS" "$FAKE_IP_ALIAS" down ||
1489 error "Failed to clean up fake IF alias"
1495 run_test 109 "Add NI using a network interface alias (LU-16859)"
1498 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
1500 cleanup_netns || error "Failed to cleanup netns before test execution"
1501 cleanup_lnet || error "Failed to unload modules before test execution"
1503 configure_dlc || error "Failed to configure DLC rc = $?"
1505 LOCAL_ADDR_LIST=$(local_addr_list)
1506 set -- $LOCAL_ADDR_LIST
1507 do_lnetctl net add --nid $2@tcp ||
1508 error "Failed to add net tcp for IP $2@tcp"
1510 $LNETCTL net show --net tcp | grep -q "nid: $2@tcp" ||
1511 error "Failed to configure $2@tcp"
1513 do_lnetctl net del --nid $2@tcp ||
1514 error "Failed to del net tcp for IP $2@tcp"
1516 $LNETCTL net show | grep -q "nid: $2@tcp"&&
1517 error "$2@tcp should have been deleted"
1522 run_test 110 "Add NI using a specific TCP / IP address"
1525 [[ ${NETTYPE} == tcp* ]] ||
1526 skip "Need tcp NETTYPE"
1527 cleanup_lnet || exit 1
1528 load_lnet "networks=\"\""
1529 do_ns $LNETCTL lnet configure --all || exit 1
1530 $LNETCTL net show --net tcp | grep -q "nid: ${FAKE_IP}@tcp$"
1532 run_test 200 "load lnet w/o module option, configure in a non-default namespace"
1535 [[ ${NETTYPE} == tcp* ]] ||
1536 skip "Need tcp NETTYPE"
1537 cleanup_lnet || exit 1
1538 load_lnet "networks=tcp($FAKE_IF)"
1539 do_ns $LNETCTL lnet configure --all || exit 1
1540 $LNETCTL net show --net tcp | grep -q "nid: ${FAKE_IP}@tcp$"
1542 run_test 201 "load lnet using networks module options in a non-default namespace"
1545 [[ ${NETTYPE} == tcp* ]] ||
1546 skip "Need tcp NETTYPE"
1547 cleanup_lnet || exit 1
1548 load_lnet "networks=\"\" ip2nets=\"tcp0($FAKE_IF) ${FAKE_IP}\""
1549 do_ns $LNETCTL lnet configure --all || exit 1
1550 $LNETCTL net show | grep -q "nid: ${FAKE_IP}@tcp$"
1552 run_test 202 "load lnet using ip2nets in a non-default namespace"
1555 ### Add the interfaces in the target namespace
1558 [[ ${NETTYPE} == tcp* ]] ||
1559 skip "Need tcp NETTYPE"
1560 cleanup_lnet || exit 1
1562 do_lnetctl lnet configure || exit 1
1563 do_ns $LNETCTL net add --net tcp0 --if $FAKE_IF
1565 run_test 203 "add a network using an interface in the non-default namespace"
1567 LNET_PARAMS_FILE="$TMP/$TESTSUITE.parameters"
1568 function save_lnet_params() {
1569 $LNETCTL global show | egrep -v '^global:$' |
1570 sed 's/://' > $LNET_PARAMS_FILE
1573 function restore_lnet_params() {
1575 while read param value; do
1576 [[ $param == max_intf ]] && continue
1577 [[ $param == lnd_timeout ]] && continue
1578 $LNETCTL set ${param} ${value} ||
1579 error "Failed to restore ${param} to ${value}"
1580 done < $LNET_PARAMS_FILE
1583 function lnet_health_pre() {
1586 # Lower transaction timeout to speed up test execution
1587 $LNETCTL set transaction_timeout 10 ||
1588 error "Failed to set transaction_timeout $?"
1590 RETRY_PARAM=$($LNETCTL global show | awk '/retry_count/{print $NF}')
1591 RSND_PRE=$($LNETCTL stats show | awk '/resend_count/{print $NF}')
1592 LO_HVAL_PRE=$($LNETCTL net show -v 2 | awk '/health value/{print $NF}' |
1593 xargs echo | sed 's/ /+/g' | bc -l)
1595 RMT_HVAL_PRE=$($LNETCTL peer show --nid ${RNIDS[0]} -v 2 2>/dev/null |
1596 awk '/health value/{print $NF}' | xargs echo |
1597 sed 's/ /+/g' | bc -l)
1599 # Might not have any peers so initialize to zero.
1600 RMT_HVAL_PRE=${RMT_HVAL_PRE:-0}
1605 function lnet_health_post() {
1606 RSND_POST=$($LNETCTL stats show | awk '/resend_count/{print $NF}')
1607 LO_HVAL_POST=$($LNETCTL net show -v 2 |
1608 awk '/health value/{print $NF}' |
1609 xargs echo | sed 's/ /+/g' | bc -l)
1611 RMT_HVAL_POST=$($LNETCTL peer show --nid ${RNIDS[0]} -v 2 2>/dev/null |
1612 awk '/health value/{print $NF}' | xargs echo |
1613 sed 's/ /+/g' | bc -l)
1615 # Might not have any peers so initialize to zero.
1616 RMT_HVAL_POST=${RMT_HVAL_POST:-0}
1619 echo "Pre resends: $RSND_PRE" &&
1620 echo "Post resends: $RSND_POST" &&
1621 echo "Resends delta: $((RSND_POST - RSND_PRE))" &&
1622 echo "Pre local health: $LO_HVAL_PRE" &&
1623 echo "Post local health: $LO_HVAL_POST" &&
1624 echo "Pre remote health: $RMT_HVAL_PRE" &&
1625 echo "Post remote health: $RMT_HVAL_POST"
1629 do_lnetctl peer set --health 1000 --all
1630 do_lnetctl net set --health 1000 --all
1635 function check_no_resends() {
1636 echo "Check that no resends took place"
1637 [[ $RSND_POST -ne $RSND_PRE ]] &&
1638 error "Found resends: $RSND_POST != $RSND_PRE"
1643 function check_resends() {
1644 local delta=$((RSND_POST - RSND_PRE))
1646 echo "Check that $RETRY_PARAM resends took place"
1647 [[ $delta -ne $RETRY_PARAM ]] &&
1648 error "Expected $RETRY_PARAM resends found $delta"
1653 function check_no_local_health() {
1654 echo "Check that local NI health is unchanged"
1655 [[ $LO_HVAL_POST -ne $LO_HVAL_PRE ]] &&
1656 error "Local health changed: $LO_HVAL_POST != $LO_HVAL_PRE"
1661 function check_local_health() {
1662 echo "Check that local NI health has been changed"
1663 [[ $LO_HVAL_POST -eq $LO_HVAL_PRE ]] &&
1664 error "Local health unchanged: $LO_HVAL_POST == $LO_HVAL_PRE"
1669 function check_no_remote_health() {
1670 echo "Check that remote NI health is unchanged"
1671 [[ $RMT_HVAL_POST -ne $RMT_HVAL_PRE ]] &&
1672 error "Remote health changed: $RMT_HVAL_POST != $RMT_HVAL_PRE"
1677 function check_remote_health() {
1678 echo "Check that remote NI health has been changed"
1679 [[ $RMT_HVAL_POST -eq $RMT_HVAL_PRE ]] &&
1680 error "Remote health unchanged: $RMT_HVAL_POST == $RMT_HVAL_PRE"
1690 setup_health_test() {
1694 [[ ${NETTYPE} == kfi* ]] && skip "kfi doesn't support drop rules"
1696 local rnodes=$(remote_nodes_list)
1697 [[ -z $rnodes ]] && skip "Need at least 1 remote node"
1699 cleanup_lnet || error "Failed to cleanup before test execution"
1701 # Loading modules should configure LNet with the appropriate
1702 # test-framework configuration
1703 load_lnet "config_on_load=1" || error "Failed to load modules"
1705 LNIDS=( $($LCTL list_nids | xargs echo) )
1707 RNODE=$(awk '{print $1}' <<<$rnodes)
1708 RNIDS=( $(do_node $RNODE $LCTL list_nids | xargs echo) )
1710 if [[ -z ${RNIDS[@]} ]]; then
1711 do_rpc_nodes $RNODE load_lnet "config_on_load=1"
1713 RNIDS=( $(do_node $RNODE $LCTL list_nids | xargs echo) )
1716 [[ ${#LNIDS[@]} -lt 1 ]] &&
1717 error "No NIDs configured for local host $HOSTNAME"
1718 [[ ${#RNIDS[@]} -lt 1 ]] &&
1719 error "No NIDs configured for remote host $RNODE"
1721 # Ensure all peer NIs are local (i.e. non-routed config)
1722 local rnid rnet lnid lnet
1724 for rnid in ${RNIDS[@]}; do
1726 for lnid in ${LNIDS[@]}; do
1728 [[ ${lnet} == ${rnet} ]] &&
1731 [[ ${lnet} != ${rnet} ]] &&
1732 skip "Need non-routed configuration"
1735 do_lnetctl discover ${RNIDS[0]} ||
1736 error "Unable to discover ${RNIDS[0]}"
1738 local mr=$($LNETCTL peer show --nid ${RNIDS[0]} |
1739 awk '/Multi-Rail/{print $NF}')
1741 if ${need_mr} && [[ $mr == False ]]; then
1742 cleanup_health_test || return $?
1746 if ( ! ${need_mr} && [[ ${#RNIDS[@]} -gt 1 ]] ) ||
1747 ( ! ${need_mr} && [[ ${#LNIDS[@]} -gt 1 ]] ); then
1748 cleanup_health_test || return $?
1752 if ${need_mr} && [[ ${#RNIDS[@]} -lt 2 ]]; then
1753 # Add a second, reachable NID to rnode.
1754 local net=${RNIDS[0]}
1758 local if=$(do_rpc_nodes --quiet $RNODE lnet_if_list)
1760 error "Failed to determine interface for $RNODE"
1762 do_rpc_nodes $RNODE "$LNETCTL lnet configure"
1763 do_rpc_nodes $RNODE "$LNETCTL net add --net $net --if $if" ||
1765 if [[ $rc -ne 0 ]]; then
1766 error "Failed to add interface to $RNODE rc=$?"
1768 RNIDS[1]="${RNIDS[0]}1"
1769 NET_DEL_ARGS="--net $net --if $if"
1773 if ${need_mr} && [[ ${#LNIDS[@]} -lt 2 ]]; then
1774 local net=${LNIDS[0]}
1777 do_lnetctl lnet configure &&
1778 do_lnetctl net add --net $net --if ${INTERFACES[0]} ||
1780 if [[ $rc -ne 0 ]]; then
1781 error "Failed to add interface rc=$?"
1783 LNIDS[1]="${LNIDS[0]}1"
1789 $LNETCTL peer show -v 2 | egrep -e nid -e health
1791 $LCTL set_param debug=+net
1797 cleanup_health_test() {
1800 if [[ -n $NET_DEL_ARGS ]]; then
1801 do_rpc_nodes $RNODE \
1802 "$LNETCTL net del $NET_DEL_ARGS" ||
1807 unload_modules || rc=$?
1810 do_rpc_nodes $RNODE unload_modules_local ||
1816 error "Failed cleanup"
1821 add_health_test_drop_rules() {
1822 local args="-m GET -r 1 -e ${1}"
1825 for src in "${LNIDS[@]}"; do
1826 for dst in "${RNIDS[@]}" "${LNIDS[@]}"; do
1827 $LCTL net_drop_add -s $src -d $dst ${args} ||
1828 error "Failed to add drop rule $src $dst $args"
1833 do_lnet_health_ping_test() {
1836 echo "Simulate $hstatus"
1838 lnet_health_pre || return $?
1840 add_health_test_drop_rules ${hstatus}
1841 do_lnetctl ping ${RNIDS[0]} &&
1842 error "Should have failed"
1846 $LCTL net_drop_del -a
1851 # See lnet/lnet/lib-msg.c:lnet_health_check()
1852 LNET_LOCAL_RESEND_STATUSES="local_interrupt local_dropped local_aborted"
1853 LNET_LOCAL_RESEND_STATUSES+=" local_no_route local_timeout"
1854 LNET_LOCAL_NO_RESEND_STATUSES="local_error"
1856 setup_health_test false || return $?
1859 for hstatus in ${LNET_LOCAL_RESEND_STATUSES} \
1860 ${LNET_LOCAL_NO_RESEND_STATUSES}; do
1861 do_lnet_health_ping_test "${hstatus}" || return $?
1862 check_no_resends || return $?
1863 check_no_local_health || return $?
1866 cleanup_health_test || return $?
1870 run_test 204 "Check no health or resends for single-rail local failures"
1873 (( $MDS1_VERSION >= $(version_code 2.14.58) )) ||
1874 skip "need at least 2.14.58"
1876 setup_health_test true || return $?
1879 for hstatus in ${LNET_LOCAL_RESEND_STATUSES}; do
1880 do_lnet_health_ping_test "${hstatus}" || return $?
1881 check_resends || return $?
1882 check_local_health || return $?
1885 for hstatus in ${LNET_LOCAL_NO_RESEND_STATUSES}; do
1886 do_lnet_health_ping_test "${hstatus}" || return $?
1887 check_no_resends || return $?
1888 check_local_health || return $?
1891 cleanup_health_test || return $?
1895 run_test 205 "Check health and resends for multi-rail local failures"
1897 # See lnet/lnet/lib-msg.c:lnet_health_check()
1898 LNET_REMOTE_RESEND_STATUSES="remote_dropped"
1899 LNET_REMOTE_NO_RESEND_STATUSES="remote_error remote_timeout"
1901 setup_health_test false || return $?
1904 for hstatus in ${LNET_REMOTE_RESEND_STATUSES} \
1905 ${LNET_REMOTE_NO_RESEND_STATUSES}; do
1906 do_lnet_health_ping_test "${hstatus}" || return $?
1907 check_no_resends || return $?
1908 check_no_local_health || return $?
1909 check_no_remote_health || return $?
1912 cleanup_health_test || return $?
1916 run_test 206 "Check no health or resends for single-rail remote failures"
1919 (( $MDS1_VERSION >= $(version_code 2.14.58) )) ||
1920 skip "need at least 2.14.58"
1922 setup_health_test true || return $?
1925 for hstatus in ${LNET_REMOTE_RESEND_STATUSES}; do
1926 do_lnet_health_ping_test "${hstatus}" || return $?
1927 check_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=$?"
1933 for hstatus in ${LNET_REMOTE_NO_RESEND_STATUSES}; do
1934 do_lnet_health_ping_test "${hstatus}" || return $?
1935 check_no_resends || return $?
1936 check_no_local_health || return $?
1937 check_remote_health || return $?
1938 do_lnetctl peer set --health 1000 --all ||
1939 error "Unable to reset health rc=$?"
1942 cleanup_health_test || return $?
1946 run_test 207 "Check health and resends for multi-rail remote errors"
1948 test_208_load_and_check_lnet() {
1952 local num_expected=1
1954 load_lnet "networks=\"\" ip2nets=\"${ip2nets_str}\""
1957 error "Failed to load LNet with ip2nets \"${ip2nets_str}\""
1963 nids=( $($LCTL list_nids) )
1965 [[ ${#nids[@]} -ne ${num_expected} ]] &&
1966 error "Expect ${num_expected} NIDs found ${#nids[@]}"
1968 [[ ${nids[0]} == ${p_nid} ]] ||
1969 error "Expect NID \"${p_nid}\" found \"${nids[0]}\""
1971 [[ -n $s_nid ]] && [[ ${nids[1]} != ${s_nid} ]] &&
1972 error "Expect second NID \"${s_nid}\" found \"${nids[1]}\""
1974 $LCTL net down &>/dev/null
1979 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
1981 cleanup_netns || error "Failed to cleanup netns before test execution"
1982 cleanup_lnet || error "Failed to unload modules before test execution"
1983 setup_fakeif || error "Failed to add fake IF"
1985 have_interface "$FAKE_IF" ||
1986 error "Expect $FAKE_IF configured but not found"
1988 local if0_ip=$(ip --oneline addr show dev ${INTERFACES[0]} |
1989 awk '/inet /{print $4}' |
1991 if0_ip=($(echo "${if0_ip[@]}" | tr ' ' '\n' | uniq | tr '\n' ' '))
1992 local ip2nets_str="tcp(${INTERFACES[0]}) $if0_ip"
1994 echo "Configure single NID \"$ip2nets_str\""
1995 test_208_load_and_check_lnet "${ip2nets_str}" "${if0_ip}@tcp"
1997 ip2nets_str="tcp(${INTERFACES[0]}) $if0_ip; tcp1($FAKE_IF) $FAKE_IP"
1998 echo "Configure two NIDs; two NETs \"$ip2nets_str\""
1999 test_208_load_and_check_lnet "${ip2nets_str}" "${if0_ip}@tcp" \
2002 ip2nets_str="tcp(${INTERFACES[0]}) $if0_ip; tcp($FAKE_IF) $FAKE_IP"
2003 echo "Configure two NIDs; one NET \"$ip2nets_str\""
2004 test_208_load_and_check_lnet "${ip2nets_str}" "${if0_ip}@tcp" \
2006 local addr1=( ${if0_ip//./ } )
2007 local addr2=( ${FAKE_IP//./ } )
2008 local range="[${addr1[0]},${addr2[0]}]"
2011 for i in $(seq 1 3); do
2012 range+=".[${addr1[$i]},${addr2[$i]}]"
2014 ip2nets_str="tcp(${INTERFACES[0]},${FAKE_IF}) ${range}"
2016 echo "Configured two NIDs; one NET alt syntax \"$ip2nets_str\""
2017 test_208_load_and_check_lnet "${ip2nets_str}" "${if0_ip}@tcp" \
2022 echo "alt syntax with missing IF \"$ip2nets_str\""
2023 load_lnet "networks=\"\" ip2nets=\"${ip2nets_str}\""
2025 echo "$LCTL net up should fail"
2027 error "LNet bring up should have failed"
2031 run_test 208 "Test various kernel ip2nets configurations"
2034 (( $MDS1_VERSION >= $(version_code 2.14.58) )) ||
2035 skip "need at least 2.14.58"
2037 setup_health_test false || return $?
2039 echo "Simulate network_timeout w/SR config"
2042 add_health_test_drop_rules network_timeout
2044 do_lnetctl discover ${RNIDS[0]} &&
2045 error "Should have failed"
2049 check_no_resends || return $?
2050 check_no_local_health || return $?
2051 check_no_remote_health || return $?
2053 cleanup_health_test || return $?
2055 setup_health_test true || return $?
2057 echo "Simulate network_timeout w/MR config"
2061 add_health_test_drop_rules network_timeout
2063 do_lnetctl discover ${RNIDS[0]} &&
2064 error "Should have failed"
2068 check_no_resends || return $?
2069 check_local_health || return $?
2070 check_remote_health || return $?
2072 cleanup_health_test || return $?
2076 run_test 209 "Check health, but not resends, for network timeout"
2078 check_nid_in_recovq() {
2082 local max_wait="${4:-10}"
2086 echo "$queue recovery queue should be empty" ||
2087 echo "$queue recovery queue should have $nid"
2089 wait_update $HOSTNAME \
2090 "$LNETCTL debug recovery $queue | \
2091 grep -wc \"nid-0: $nid\"" \
2092 "$expect" "$max_wait"
2094 do_lnetctl debug recovery $queue
2096 error "Expect $expect NIDs in recovery."
2101 # First ping is sent at time 0.
2102 # 2nd at 0 + 2^1 = 2
2103 # 3rd at 2 + 2^2 = 6
2104 # 4th at 6 + 2^3 = 14
2105 # 5th at 14 + 2^4 = 30
2106 # e.g. after 10 seconds we would expect 3 pings to have been sent, and the
2107 # NI will have been enqueued for the 4th ping.
2109 # If the recovery limit is 10 seconds, then after the 4th ping is sent
2110 # we expect the peer NI to have aged out, so it will not actually be
2111 # queued for a 5th ping.
2112 # If max_recovery_ping_interval is set to 4 then:
2113 # First ping is sent at time 0
2114 # 2nd at 0 + min(2^1, 4) = 2
2115 # 3rd at 2 + min(2^2, 4) = 6
2116 # 4th at 6 + min(2^3, 4) = 10
2117 # 5th at 10 + min(2^4, 4) = 14
2118 # 6th at 14 + min(2^5, 4) = 18
2119 # 7th at 18 + min(2^6, 4) = 22
2120 # e.g. after 4 seconds we would expect 2 pings to have been sent, and
2121 # after 13 seconds we would expect 4 pings to have been sent
2122 check_ping_count() {
2128 echo "Check ping counts:"
2131 if [[ $queue == "ni" ]]; then
2132 wait_update $HOSTNAME \
2133 "$LNETCTL net show -v 2 | \
2134 grep -e $nid -e ping_count | grep -wA1 $nid | \
2135 awk '/ping_count/{print \\\$NF}'" "$expect" "$max_wait"
2137 $LNETCTL net show -v 2 | grep -e $nid -e ping_count
2138 elif [[ $queue == peer_ni ]]; then
2139 wait_update $HOSTNAME \
2140 "$LNETCTL peer show -v 2 --nid $nid | \
2142 grep -e $nid -e ping_count | grep -wA1 $nid | \
2143 awk '/ping_count/{print \\\$NF}'" "$expect" "$max_wait"
2145 $LNETCTL peer show -v 2 --nid $nid | grep -v primary |
2146 grep -e $nid -e ping_count
2148 error "Unrecognized queue \"$queue\""
2152 ((rc == 0)) || error "Unexpected ping count"
2158 [[ ${NETTYPE} == kfi* ]] && skip "kfi doesn't support drop rules"
2160 reinit_dlc || return $?
2161 add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
2162 add_net "${NETTYPE}1" "${INTERFACES[0]}" || return $?
2164 local prim_nid=$($LCTL list_nids | head -n 1)
2166 do_lnetctl discover $prim_nid ||
2167 error "failed to discover myself"
2169 local default=$($LNETCTL global show |
2170 awk '/recovery_limit/{print $NF}')
2171 # Set recovery limit to 10 seconds.
2172 do_lnetctl set recovery_limit 10 ||
2173 error "failed to set recovery_limit"
2175 $LCTL set_param debug=+net
2176 $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -m GET -r 1 \
2178 error "Failed to add drop rule"
2179 $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -m GET -r 1 \
2181 error "Failed to add drop rule"
2182 $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -r 1 ||
2183 error "Failed to add drop rule"
2184 $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -r 1 ||
2185 error "Failed to add drop rule"
2186 do_lnetctl net set --health 0 --nid $prim_nid
2188 check_ping_count "ni" "$prim_nid" "2" "10"
2189 check_nid_in_recovq "-l" "$prim_nid" "1"
2191 check_ping_count "ni" "$prim_nid" "3" "10"
2192 check_nid_in_recovq "-l" "$prim_nid" "1"
2194 $LCTL net_drop_del -a
2196 reinit_dlc || return $?
2197 add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
2198 add_net "${NETTYPE}1" "${INTERFACES[0]}" || return $?
2200 local prim_nid=$($LCTL list_nids | head -n 1)
2202 do_lnetctl discover $prim_nid ||
2203 error "failed to discover myself"
2205 do_lnetctl set recovery_limit $default ||
2206 error "failed to set recovery_limit"
2208 default=$($LNETCTL global show |
2209 awk '/max_recovery_ping_interval/{print $NF}')
2210 do_lnetctl set max_recovery_ping_interval 4 ||
2211 error "failed to set max_recovery_ping_interval"
2213 $LCTL set_param debug=+net
2214 $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -m GET -r 1 \
2216 error "Failed to add drop rule"
2217 $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -m GET -r 1 \
2219 error "Failed to add drop rule"
2220 $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -r 1 ||
2221 error "Failed to add drop rule"
2222 $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -r 1 ||
2223 error "Failed to add drop rule"
2224 do_lnetctl net set --health 0 --nid $prim_nid
2226 check_ping_count "ni" "$prim_nid" "2" "10"
2227 check_nid_in_recovq "-l" "$prim_nid" "1"
2229 check_ping_count "ni" "$prim_nid" "4" "10"
2230 check_nid_in_recovq "-l" "$prim_nid" "1"
2232 $LCTL net_drop_del -a
2234 do_lnetctl set max_recovery_ping_interval $default ||
2235 error "failed to set max_recovery_ping_interval"
2239 run_test 210 "Local NI recovery checks"
2242 [[ ${NETTYPE} == kfi* ]] && skip "kfi doesn't support drop rules"
2244 reinit_dlc || return $?
2245 add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
2246 add_net "${NETTYPE}1" "${INTERFACES[0]}" || return $?
2248 local prim_nid=$($LCTL list_nids | head -n 1)
2250 do_lnetctl discover $prim_nid ||
2251 error "failed to discover myself"
2253 local default=$($LNETCTL global show |
2254 awk '/recovery_limit/{print $NF}')
2255 # Set recovery limit to 10 seconds.
2256 do_lnetctl set recovery_limit 10 ||
2257 error "failed to set recovery_limit"
2259 $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -m GET -r 1 \
2261 error "Failed to add drop rule"
2262 $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -m GET -r 1 \
2264 error "Failed to add drop rule"
2265 $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -r 1 ||
2266 error "Failed to add drop rule"
2267 $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -r 1 ||
2268 error "Failed to add drop rule"
2270 # Set health to 0 on one interface. This forces it onto the recovery
2272 do_lnetctl peer set --nid $prim_nid --health 0
2274 check_nid_in_recovq "-p" "$prim_nid" "1"
2276 # The peer should age out in 10-20 seconds
2277 check_nid_in_recovq "-p" "$prim_nid" "0" "20"
2278 # Ping count should reset to 0 when peer ages out
2279 check_ping_count "peer_ni" "$prim_nid" "0"
2281 $LCTL net_drop_del -a
2283 # Set health to force it back onto the recovery queue. Set to 500 means
2284 # in ~5 seconds it should be back at maximum value.
2285 # NB: we reset the recovery limit to 0 (indefinite) so the peer NI is
2287 do_lnetctl set recovery_limit 0 ||
2288 error "failed to set recovery_limit"
2290 do_lnetctl peer set --nid $prim_nid --health 500
2292 check_nid_in_recovq "-p" "$prim_nid" "1"
2293 check_nid_in_recovq "-p" "$prim_nid" "0" "20"
2295 reinit_dlc || return $?
2296 add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
2297 add_net "${NETTYPE}1" "${INTERFACES[0]}" || return $?
2299 local prim_nid=$($LCTL list_nids | head -n 1)
2301 do_lnetctl discover $prim_nid ||
2302 error "failed to discover myself"
2304 do_lnetctl set recovery_limit $default ||
2305 error "failed to set recovery_limit"
2307 default=$($LNETCTL global show |
2308 awk '/max_recovery_ping_interval/{print $NF}')
2309 do_lnetctl set max_recovery_ping_interval 4 ||
2310 error "failed to set max_recovery_ping_interval"
2312 $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -m GET -r 1 \
2314 error "Failed to add drop rule"
2315 $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -m GET -r 1 \
2317 error "Failed to add drop rule"
2318 $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -r 1 ||
2319 error "Failed to add drop rule"
2320 $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -r 1 ||
2321 error "Failed to add drop rule"
2323 # Set health to 0 on one interface. This forces it onto the recovery
2325 do_lnetctl peer set --nid $prim_nid --health 0
2327 check_ping_count "peer_ni" "$prim_nid" "1" "4"
2328 check_nid_in_recovq "-p" "$prim_nid" "1"
2330 # After we detect the 1st ping above, the 4th ping should be sent after
2332 check_ping_count "peer_ni" "$prim_nid" "4" "14"
2333 check_nid_in_recovq "-p" "$prim_nid" "1"
2335 $LCTL net_drop_del -a
2337 do_lnetctl set max_recovery_ping_interval $default ||
2338 error "failed to set max_recovery_ping_interval"
2342 run_test 211 "Remote NI recovery checks"
2345 [[ ${NETTYPE} == kfi* ]] && skip "kfi doesn't support drop rules"
2347 local rnodes=$(remote_nodes_list)
2348 [[ -z $rnodes ]] && skip "Need at least 1 remote node"
2350 cleanup_lnet || error "Failed to cleanup before test execution"
2352 # Loading modules should configure LNet with the appropriate
2353 # test-framework configuration
2354 load_lnet "config_on_load=1" || error "Failed to load modules"
2356 local my_nid=$($LCTL list_nids | head -n 1)
2358 error "Failed to get primary NID for local host $HOSTNAME"
2360 local rnode=$(awk '{print $1}' <<<$rnodes)
2361 local rnodenids=$(do_node $rnode $LCTL list_nids | xargs echo)
2364 if [[ -z $rnodenids ]]; then
2365 do_rpc_nodes $rnode load_lnet "config_on_load=1"
2367 rnodenids=$(do_node $rnode $LCTL list_nids | xargs echo)
2370 local rnodepnid=$(awk '{print $1}' <<< $rnodenids)
2372 [[ -z $rnodepnid ]] &&
2373 error "Failed to get primary NID for remote host $rnode"
2375 log "Initial discovery"
2376 do_lnetctl discover --force $rnodepnid ||
2377 error "Failed to discover $rnodepnid"
2379 do_node $rnode "$LNETCTL discover --force $my_nid" ||
2380 error "$rnode failed to discover $my_nid"
2382 log "Fail local discover ping to set LNET_PEER_REDISCOVER flag"
2383 $LCTL net_drop_add -s "*@$NETTYPE" -d "*@$NETTYPE" -r 1 \
2385 error "Failed to add drop rule"
2386 do_lnetctl discover --force $rnodepnid &&
2387 error "Discovery should have failed"
2388 $LCTL net_drop_del -a
2391 for nid in $rnodenids; do
2392 # We need GET (PING) delay just long enough so we can trigger
2393 # discovery on the remote peer
2394 $LCTL net_delay_add -s "*@$NETTYPE" -d $nid -r 1 -m GET -l 3 ||
2395 error "Failed to add delay rule"
2396 $LCTL net_drop_add -s "*@$NETTYPE" -d $nid -r 1 -m GET \
2398 error "Failed to add drop rule"
2399 # We need PUT (PUSH) delay just long enough so we can process
2401 $LCTL net_delay_add -s "*@$NETTYPE" -d $nid -r 1 -m PUT -l 6 ||
2402 error "Failed to add delay rule"
2405 log "Force $HOSTNAME to discover $rnodepnid (in background)"
2406 # We want to get a PING sent that we know will eventually fail.
2407 # The delay rules we added will ensure the ping is not sent until
2408 # the PUSH is also in flight (see below), and the drop rule ensures that
2409 # when the PING is eventually sent it will error out
2410 do_lnetctl discover --force $rnodepnid &
2413 # We want a discovery PUSH from rnode to put rnode back on our
2414 # discovery queue. This should cause us to try and send a PUSH to rnode
2415 # while the PING is still outstanding.
2416 log "Force $rnode to discover $my_nid"
2417 do_node $rnode $LNETCTL discover --force $my_nid
2419 # At this point we'll have both PING_SENT and PUSH_SENT set for the
2420 # rnode peer. Wait for the PING to error out which should terminate the
2421 # discovery process that we backgrounded.
2422 log "Wait for $pid1"
2424 log "Finished wait on $pid1"
2426 # The PING send failure clears the PING_SENT flag and puts the peer back
2427 # on the discovery queue. When discovery thread processes the peer it
2428 # will mistakenly clear the PUSH_SENT flag (and set PUSH_FAILED).
2429 # Discovery will then complete for this peer even though we have an
2431 # When PUSH is actually unlinked it will be forced back onto the
2432 # discovery queue, but we no longer have a ref on the peer. When
2433 # discovery completes again, we'll trip the ASSERT in
2434 # lnet_destroy_peer_locked()
2436 # Delete the delay rules to send the PUSH
2437 $LCTL net_delay_del -a
2438 # Delete the drop rules
2439 $LCTL net_drop_del -a
2442 error "Failed to unload modules"
2444 do_rpc_nodes $rnode unload_modules_local ||
2445 error "Failed to unload modules on $rnode"
2450 run_test 212 "Check discovery refcount loss bug (LU-14627)"
2453 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
2455 cleanup_netns || error "Failed to cleanup netns before test execution"
2456 cleanup_lnet || error "Failed to unload modules before test execution"
2458 setup_fakeif || error "Failed to add fake IF"
2459 have_interface "$FAKE_IF" ||
2460 error "Expect $FAKE_IF configured but not found"
2462 reinit_dlc || return $?
2464 add_net "tcp" "${INTERFACES[0]}" || return $?
2465 add_net "tcp" "$FAKE_IF" || return $?
2467 local nid1=$(lctl list_nids | head -n 1)
2468 local nid2=$(lctl list_nids | tail --lines 1)
2470 [[ $(lctl which_nid $nid1 $nid2) == $nid1 ]] ||
2471 error "Expect nid1 \"$nid1\" to be preferred"
2473 [[ $(lctl which_nid $nid2 $nid1) == $nid2 ]] ||
2474 error "Expect nid2 \"$nid2\" to be preferred"
2478 run_test 213 "Check LNetDist calculation for multiple local NIDs"
2480 function check_ni_status() {
2484 local status=$($LNETCTL net show |
2486 awk '/status/{print $NF}')
2488 echo "NI ${nid} expect status \"${expect}\" found \"${status}\""
2489 if [[ $status != $expect ]]; then
2490 error "Error: Expect NI status \"$expect\" for NID \"$nid\" but found \"$status\""
2497 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
2499 cleanup_netns || error "Failed to cleanup netns before test execution"
2500 cleanup_lnet || error "Failed to unload modules before test execution"
2502 setup_fakeif || error "Failed to add fake IF"
2503 have_interface "$FAKE_IF" ||
2504 error "Expect $FAKE_IF configured but not found"
2506 reinit_dlc || return $?
2508 add_net "tcp" "${INTERFACES[0]}" || return $?
2509 add_net "tcp" "$FAKE_IF" || return $?
2511 local nid1=$(lctl list_nids | head -n 1)
2512 local nid2=$(lctl list_nids | tail --lines 1)
2514 check_ni_status "0@lo" up
2515 check_ni_status "$nid1" up
2516 check_ni_status "$nid2" up
2518 do_lnetctl ping --source $nid2 $nid1 ||
2519 error "$LNETCTL ping --source $nid2 $nid1 failed"
2521 echo "Set $FAKE_IF down"
2522 echo "ip link set dev $FAKE_IF down"
2523 ip link set dev $FAKE_IF down
2524 check_ni_status "0@lo" up
2525 check_ni_status "$nid1" up
2526 check_ni_status "$nid2" down
2528 run_test 214 "Check local NI status when link is downed"
2534 $LNETCTL net show -v 2 |
2535 egrep -e nid -e $stat |
2537 awk '/'$stat':/{print $NF}'
2542 for nidvar in nid1 nid2; do
2543 for stat in send_count recv_count; do
2544 s=$(get_ni_stat ${!nidvar} $stat)
2545 eval ${nidvar}_pre_${stat}=$s
2552 for nidvar in nid1 nid2; do
2553 for stat in send_count recv_count; do
2554 s=$(get_ni_stat ${!nidvar} $stat)
2555 eval ${nidvar}_post_${stat}=$s
2565 eval pre=\${${nidvar}_pre_${stat}}
2566 eval post=\${${nidvar}_post_${stat}}
2568 echo "${!nidvar} pre ${stat} $pre post ${stat} $post"
2570 [[ $pre -ne $post ]]
2574 cleanup_netns || error "Failed to cleanup netns before test execution"
2575 cleanup_lnet || error "Failed to unload modules before test execution"
2577 reinit_dlc || return $?
2579 add_net "${NETTYPE}1" "${INTERFACES[0]}" || return $?
2580 add_net "${NETTYPE}2" "${INTERFACES[0]}" || return $?
2582 local nid1=$($LCTL list_nids | head -n 1)
2583 local nid2=$($LCTL list_nids | tail --lines 1)
2585 do_lnetctl peer add --prim $nid1 --nid $nid2 ||
2586 error "Failed to add peer"
2590 for nidvarA in nid1 nid2; do
2593 for nidvarB in nid1 nid2; do
2594 [[ $nidvarA == $nidvarB ]] && continue
2598 echo "$LNETCTL ping $dst x $npings"
2599 for i in $(seq 1 $npings); do
2600 $LNETCTL ping $dst &>/dev/null ||
2601 error "$LNETCTL ping $dst failed"
2606 # No source specified, sends to either NID should cause
2607 # counts to increase across both NIs
2608 for nidvar in nid1 nid2; do
2609 for stat in send_count recv_count; do
2610 ni_stat_changed $nidvar $stat ||
2611 error "$stat unchanged for ${!nidvar}"
2617 echo "$LNETCTL ping --source $src $dst x $npings"
2618 for i in $(seq 1 $npings); do
2619 $LNETCTL ping --source $src $dst &>/dev/null ||
2620 error "$LNETCTL ping --source $src $dst failed"
2625 # src nid == dest nid means stats for the _other_ NI
2626 # should be unchanged
2627 for nidvar in nid1 nid2; do
2628 for stat in send_count recv_count; do
2629 if [[ ${!nidvar} == $src ]]; then
2630 ni_stat_changed $nidvar $stat ||
2631 error "$stat unchanged for ${!nidvar}"
2633 ni_stat_changed $nidvar $stat &&
2634 error "$stat changed for ${!nidvar}"
2639 # Double number of pings for next iteration because the net
2640 # sequence numbers will have diverged
2641 npings=$(($npings * 2))
2644 # Ping from nid1 to nid2 should fail
2645 do_lnetctl ping --source $nid1 $nid2 &&
2646 error "ping from $nid1 to $nid2 should fail"
2648 # Ping from nid2 to nid1 should fail
2649 do_lnetctl ping --source $nid2 $nid1 &&
2650 error "ping from $nid2 to $nid1 should fail"
2654 run_test 215 "Test lnetctl ping --source option"
2657 [[ ${NETTYPE} == kfi* ]] && skip "kfi doesn't support drop rules"
2661 reinit_dlc || return $?
2663 add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
2664 add_net "${NETTYPE}1" "${INTERFACES[0]}" || return $?
2666 local nids=( $($LCTL list_nids | xargs echo) )
2668 do_lnetctl discover ${nids[0]} ||
2669 error "Initial discovery failed"
2671 do_lnetctl ping --source ${nids[0]} ${nids[0]} ||
2672 error "Initial ping failed $?"
2674 do_lnetctl ping --source ${nids[1]} ${nids[1]} ||
2675 error "Initial ping failed $?"
2678 for src in "${nids[@]}"; do
2679 for dst in "${nids[@]}"; do
2680 $LCTL net_drop_add -r 1 -s $src -d $dst \
2681 -e network_timeout ||
2682 error "Failed to add drop rule"
2686 do_lnetctl ping ${nids[0]} || rc=$?
2688 $LCTL net_drop_del -a
2691 error "expected ping to fail"
2693 check_nid_in_recovq "-p" "${nids[0]}" "0"
2694 check_nid_in_recovq "-l" "${nids[0]}" "1"
2698 run_test 216 "Failed send to peer NI owned by local host should not trigger peer NI recovery"
2701 reinit_dlc || return $?
2703 [[ $($LNETCTL net show | grep -c nid) -ne 1 ]] &&
2704 error "Unexpected number of NIs after initalizing DLC"
2706 do_lnetctl discover 0@lo ||
2707 error "Failed to discover 0@lo"
2711 run_test 217 "Don't leak memory when discovering peer with nnis <= 1"
2714 [[ ${NETTYPE} == kfi* ]] && skip "kfi doesn't support drop rules"
2716 reinit_dlc || return $?
2718 [[ ${#INTERFACES[@]} -lt 2 ]] &&
2719 skip "Need two LNet interfaces"
2721 add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
2723 local nid1=$($LCTL list_nids | head -n 1)
2725 do_lnetctl ping $nid1 ||
2728 add_net "${NETTYPE}" "${INTERFACES[1]}" || return $?
2730 local nid2=$($LCTL list_nids | tail --lines 1)
2732 do_lnetctl ping $nid2 ||
2735 $LCTL net_drop_add -s $nid1 -d $nid1 -e local_error -r 1 ||
2736 error "Failed to add drop rule"
2738 do_lnetctl ping --source $nid1 $nid1 &&
2739 error "ping should have failed"
2741 local health_recovered
2744 for i in $(seq 1 5); do
2745 health_recovered=$($LNETCTL net show -v 2 |
2746 grep -c 'health value: 1000')
2748 if [[ $health_recovered -ne 2 ]]; then
2749 echo "Wait 1 second for health to recover"
2756 health_recovered=$($LNETCTL net show -v 2 |
2757 grep -c 'health value: 1000')
2759 $LCTL net_drop_del -a
2761 [[ $health_recovered -ne 2 ]] &&
2762 do_lnetctl net show -v 2 | egrep -e nid -e health &&
2763 error "Health hasn't recovered"
2767 run_test 218 "Local recovery pings should exercise all available paths"
2770 reinit_dlc || return $?
2771 add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
2772 add_net "${NETTYPE}1" "${INTERFACES[0]}" || return $?
2774 local nid1=$(lctl list_nids | head -n 1)
2775 local nid2=$(lctl list_nids | tail --lines 1)
2777 do_lnetctl ping $nid1 ||
2778 error "Ping failed $?"
2779 do_lnetctl ping $nid2 ||
2780 error "Ping failed $?"
2782 do_lnetctl discover $nid2 ||
2783 error "Discovery failed"
2785 $LNETCTL peer show --nid $nid1 | grep -q $nid2 ||
2786 error "$nid2 is not listed under $nid1"
2788 run_test 219 "Consolidate peer entries"
2795 do_rpc_nodes $node "$LNETCTL net add --net $net --if $if" ||
2796 error "add $net on interface $if on node $node failed rc=$?"
2804 do_node $node "$LNETCTL route add --net $net --gateway $gw" ||
2805 error "route add to $net via $gw failed rc=$?"
2809 ROUTER_INTERFACES=()
2812 init_router_test_vars() {
2813 local rnodes=$(remote_nodes_list)
2814 [[ -z $rnodes || $(wc -w <<<$rnodes) -lt 2 ]] &&
2815 skip "Need at least 2 remote nodes found \"$rnodes\""
2817 ROUTER=$(awk '{print $1}' <<<$rnodes)
2818 RPEER=$(awk '{print $2}' <<<$rnodes)
2820 rnodes=$(comma_list $ROUTER $RPEER)
2821 local all_nodes=$(comma_list $rnodes $HOSTNAME)
2823 do_nodes $rnodes $LUSTRE_RMMOD ||
2824 error "failed to unload modules"
2826 do_rpc_nodes $rnodes "load_lnet config_on_load=1" ||
2827 error "Failed to load and configure LNet"
2829 ROUTER_INTERFACES=( $(do_rpc_nodes --quiet $ROUTER lnet_if_list) )
2831 RPEER_INTERFACES=( $(do_rpc_nodes --quiet $RPEER lnet_if_list) )
2833 do_nodes $all_nodes $LUSTRE_RMMOD ||
2834 error "Failed to unload modules"
2836 [[ ${#INTERFACES[@]} -eq 0 ]] &&
2837 error "No interfaces configured for local host $HOSTNAME"
2838 [[ ${#ROUTER_INTERFACES[@]} -eq 0 ]] &&
2839 error "No interfaces configured for router $ROUTER"
2840 [[ ${#RPEER_INTERFACES[@]} -eq 0 ]] &&
2841 error "No interfaces configured for remote peer $RPEER"
2849 LOCAL_NET=${NETTYPE}1
2850 REMOTE_NET=${NETTYPE}2
2851 setup_router_test() {
2854 (( $MDS1_VERSION >= $(version_code 2.15.0) )) ||
2855 skip "need at least 2.15.0 for load_lnet"
2857 if [[ ${#RPEER_INTERFACES[@]} -eq 0 ]]; then
2858 init_router_test_vars ||
2862 local all_nodes=$(comma_list $ROUTER $RPEER $HOSTNAME)
2864 do_nodes $all_nodes $LUSTRE_RMMOD ||
2865 error "failed to unload modules"
2867 mod_opts+=" alive_router_check_interval=5"
2868 mod_opts+=" router_ping_timeout=5"
2869 mod_opts+=" large_router_buffers=4"
2870 mod_opts+=" small_router_buffers=8"
2871 mod_opts+=" tiny_router_buffers=16"
2872 do_rpc_nodes $all_nodes load_lnet "${mod_opts}" ||
2873 error "Failed to load lnet"
2875 do_nodes $all_nodes "$LNETCTL lnet configure" ||
2876 error "Failed to initialize DLC"
2878 do_net_add $ROUTER $LOCAL_NET ${ROUTER_INTERFACES[0]} ||
2881 do_net_add $ROUTER $REMOTE_NET ${ROUTER_INTERFACES[0]} ||
2884 do_net_add $RPEER $REMOTE_NET ${RPEER_INTERFACES[0]} ||
2887 add_net $LOCAL_NET ${INTERFACES[0]} ||
2890 ROUTER_NIDS=( $(do_node $ROUTER $LCTL list_nids 2>/dev/null |
2892 RPEER_NIDS=( $(do_node $RPEER $LCTL list_nids 2>/dev/null |
2894 LNIDS=( $($LCTL list_nids 2>/dev/null | xargs echo) )
2902 do_nodesv $node "if $LNETCTL route show --net $net --gateway $gw; then \
2903 $LNETCTL route del --net $net --gateway $gw; \
2909 cleanup_router_test() {
2910 local all_nodes=$(comma_list $HOSTNAME $ROUTER $RPEER)
2912 do_route_del $HOSTNAME $REMOTE_NET ${ROUTER_NIDS[0]} ||
2913 error "Failed to delete $REMOTE_NET route"
2915 do_route_del $RPEER $LOCAL_NET ${ROUTER_NIDS[1]} ||
2916 error "Failed to delete $LOCAL_NET route"
2918 do_nodes $all_nodes $LUSTRE_RMMOD ||
2919 error "failed to unload modules"
2924 check_route_aliveness() {
2929 local lnetctl_actual
2933 chk_intvl=$(cat /sys/module/lnet/parameters/alive_router_check_interval)
2935 lctl_actual=$(do_node $node $LCTL show_route | awk '{print $7}')
2936 lnetctl_actual=$(do_node $node $LNETCTL route show -v |
2937 awk '/state/{print $NF}')
2939 for ((i = 0; i < $chk_intvl; i++)); do
2940 if [[ $lctl_actual == $expected ]] &&
2941 [[ $lnetctl_actual == $expected ]]; then
2945 echo "wait 1s for route state change"
2948 lctl_actual=$(do_node $node $LCTL show_route | awk '{print $7}')
2949 lnetctl_actual=$(do_node $node $LNETCTL route show -v |
2950 awk '/state/{print $NF}')
2953 [[ $lctl_actual != $expected ]] &&
2954 error "Wanted \"$expected\" lctl found \"$lctl_actual\""
2956 [[ $lnetctl_actual != $expected ]] &&
2957 error "Wanted \"$expected\" lnetctl found \"$lnetctl_actual\""
2962 check_router_ni_status() {
2963 local expected_local="$1"
2964 local expected_remote="$2"
2972 chk_intvl=$(cat /sys/module/lnet/parameters/alive_router_check_interval)
2973 timeout=$(cat /sys/module/lnet/parameters/router_ping_timeout)
2975 actual_local=$(do_node $ROUTER "$LNETCTL net show --net $LOCAL_NET" |
2976 awk '/status/{print $NF}')
2977 actual_remote=$(do_node $ROUTER "$LNETCTL net show --net $REMOTE_NET" |
2978 awk '/status/{print $NF}')
2980 for ((i = 0; i < $((chk_intvl + timeout)); i++)); do
2981 if [[ $actual_local == $expected_local ]] &&
2982 [[ $actual_remote == $expected_remote ]]; then
2986 echo "wait 1s for NI state change"
2989 actual_local=$(do_node $ROUTER \
2990 "$LNETCTL net show --net $LOCAL_NET" |
2991 awk '/status/{print $NF}')
2992 actual_remote=$(do_node $ROUTER \
2993 "$LNETCTL net show --net $REMOTE_NET" |
2994 awk '/status/{print $NF}')
2997 [[ $actual_local == $expected_local ]] ||
2998 error "$LOCAL_NET should be $expected_local"
3000 [[ $actual_remote == $expected_remote ]] ||
3001 error "$REMOTE_NET should be $expected_remote"
3006 do_basic_rtr_test() {
3007 do_node $ROUTER "$LNETCTL set routing 1" ||
3008 error "Unable to enable routing on $ROUTER"
3010 do_route_add $HOSTNAME $REMOTE_NET ${ROUTER_NIDS[0]} ||
3013 do_route_add $RPEER $LOCAL_NET ${ROUTER_NIDS[1]} ||
3016 check_route_aliveness "$HOSTNAME" "up" ||
3019 check_route_aliveness "$RPEER" "up" ||
3022 do_lnetctl ping ${RPEER_NIDS[0]} ||
3023 error "Failed to ping ${RPEER_NIDS[0]}"
3025 do_node $RPEER "$LNETCTL ping ${LNIDS[0]}" ||
3026 error "$RPEER failed to ping ${LNIDS[0]}"
3032 setup_router_test || return $?
3034 do_basic_rtr_test || return $?
3036 do_rpc_nodes $HOSTNAME,$RPEER load_module ../lnet/selftest/lnet_selftest ||
3037 error "Failed to load lnet-selftest module"
3039 $LSTSH -H -t $HOSTNAME -f $RPEER -m rw -s 4k ||
3042 $LSTSH -H -t $HOSTNAME -f $RPEER -m rw ||
3045 cleanup_router_test || return $?
3047 run_test 220 "Add routes w/default options - check aliveness"
3050 setup_router_test lnet_peer_discovery_disabled=1 || return $?
3052 do_basic_rtr_test || return $?
3054 cleanup_router_test || return $?
3056 run_test 221 "Add routes w/DD disabled - check aliveness"
3058 do_aarf_enabled_test() {
3059 do_node $ROUTER "$LNETCTL set routing 1" ||
3060 error "Unable to enable routing on $ROUTER"
3062 check_router_ni_status "down" "down"
3064 do_lnetctl ping ${RPEER_NIDS[0]} &&
3065 error "Ping should fail"
3067 do_node $RPEER "$LNETCTL ping ${LNIDS[0]}" &&
3068 error "$RPEER ping should fail"
3070 # Adding a route should cause the router's NI on LOCAL_NET to get up
3071 do_route_add $HOSTNAME $REMOTE_NET ${ROUTER_NIDS[0]} ||
3074 check_router_ni_status "up" "down" ||
3077 # But route should still be down because of avoid_asym_router_failure
3078 check_route_aliveness "$HOSTNAME" "down" ||
3081 do_lnetctl ping ${RPEER_NIDS[0]} &&
3082 error "Ping should fail"
3084 do_node $RPEER "$LNETCTL ping ${LNIDS[0]}" &&
3085 error "$RPEER ping should fail"
3087 # Adding the symmetric route should cause the remote NI to go up and
3089 do_route_add $RPEER $LOCAL_NET ${ROUTER_NIDS[1]} ||
3092 check_router_ni_status "up" "up" ||
3095 check_route_aliveness "$HOSTNAME" "up" ||
3098 check_route_aliveness "$RPEER" "up" ||
3101 do_lnetctl ping ${RPEER_NIDS[0]} ||
3102 error "Failed to ping ${RPEER_NIDS[0]}"
3104 do_node $RPEER "$LNETCTL ping ${LNIDS[0]}" ||
3105 error "$RPEER failed to ping ${LNIDS[0]}"
3107 # Stop LNet on local host
3108 do_lnetctl lnet unconfigure ||
3109 error "Failed to stop LNet rc=$?"
3111 check_router_ni_status "down" "up" ||
3114 check_route_aliveness "$RPEER" "down" ||
3117 do_lnetctl ping ${RPEER_NIDS[0]} &&
3118 error "Ping should fail"
3120 do_node $RPEER "$LNETCTL ping ${LNIDS[0]}" &&
3121 error "$RPEER ping should fail"
3127 setup_router_test avoid_asym_router_failure=1 || return $?
3129 do_aarf_enabled_test || return $?
3131 cleanup_router_test || return $?
3133 run_test 222 "Check avoid_asym_router_failure=1"
3136 local opts="avoid_asym_router_failure=1 lnet_peer_discovery_disabled=1"
3138 setup_router_test $opts || return $?
3140 do_aarf_enabled_test || return $?
3142 cleanup_router_test || return $?
3144 run_test 223 "Check avoid_asym_router_failure=1 w/DD disabled"
3146 do_aarf_disabled_test() {
3147 do_node $ROUTER "$LNETCTL set routing 1" ||
3148 error "Unable to enable routing on $ROUTER"
3150 check_router_ni_status "down" "down"
3152 do_route_add $HOSTNAME $REMOTE_NET ${ROUTER_NIDS[0]} ||
3155 check_router_ni_status "up" "down" ||
3158 check_route_aliveness "$HOSTNAME" "up" ||
3161 do_route_add $RPEER $LOCAL_NET ${ROUTER_NIDS[1]} ||
3164 check_router_ni_status "up" "up" ||
3167 check_route_aliveness "$HOSTNAME" "up" ||
3170 check_route_aliveness "$RPEER" "up" ||
3173 do_lnetctl ping ${RPEER_NIDS[0]} ||
3174 error "Failed to ping ${RPEER_NIDS[0]}"
3176 do_node $RPEER "$LNETCTL ping ${LNIDS[0]}" ||
3177 error "$RPEER failed to ping ${LNIDS[0]}"
3179 # Stop LNet on local host
3180 do_lnetctl lnet unconfigure ||
3181 error "Failed to stop LNet rc=$?"
3183 check_router_ni_status "down" "up" ||
3186 check_route_aliveness "$RPEER" "up" ||
3193 setup_router_test avoid_asym_router_failure=0 ||
3196 do_aarf_disabled_test ||
3199 cleanup_router_test ||
3202 run_test 224 "Check avoid_asym_router_failure=0"
3205 local opts="avoid_asym_router_failure=0 lnet_peer_discovery_disabled=1"
3207 setup_router_test $opts || return $?
3209 do_aarf_disabled_test || return $?
3211 cleanup_router_test ||
3214 run_test 225 "Check avoid_asym_router_failure=0 w/DD disabled"
3217 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
3220 echo "Check valid values; Should succeed"
3224 for ((i = 4; i < 16; i+=1)); do
3225 reinit_dlc || return $?
3226 add_net "tcp" "${INTERFACES[0]}" || return $?
3227 do_lnetctl net set --all --conns-per-peer $i ||
3228 error "should have succeeded $?"
3229 $LNETCTL net show -v 1 | grep -q "conns_per_peer: $i" ||
3230 error "failed to set conns-per-peer to $i"
3231 lnid="$(lctl list_nids | head -n 1)"
3232 do_lnetctl ping "$lnid" ||
3233 error "failed to ping myself"
3235 # "lctl --net tcp conn_list" prints the list of active
3236 # connections. Since we're pinging ourselves, there should be
3237 # 2 Control connections plus 2*conns_per_peer connections
3238 # created (one Bulk Input, one Bulk Output in each pair).
3239 # Here's the sample output for conns_per_peer set to 1:
3240 # 12345-1.1.1.1@tcp I[0]host01->host01:988 2626560/1061296 nonagle
3241 # 12345-1.1.1.1@tcp O[0]host01->host01:1022 2626560/1061488 nonagle
3242 # 12345-1.1.1.1@tcp C[0]host01->host01:988 2626560/1061296 nonagle
3243 # 12345-1.1.1.1@tcp C[0]host01->host01:1023 2626560/1061488 nonagle
3244 cmd="printf 'network tcp\nconn_list\n' | lctl | grep -c '$lnid'"
3246 # Expect 2+conns_per_peer*2 connections. Wait no longer
3248 wait_update $HOSTNAME "$cmd" "$((2+i*2))" 2 ||
3249 error "expected number of tcp connections $((2+i*2))"
3252 reinit_dlc || return $?
3253 add_net "tcp" "${INTERFACES[0]}" || return $?
3254 echo "Set > 127; Should fail"
3255 do_lnetctl net set --all --conns-per-peer 128 &&
3256 error "should have failed $?"
3258 reinit_dlc || return $?
3259 add_net "tcp" "${INTERFACES[0]}" || return $?
3261 local default=$($LNETCTL net show -v 1 |
3262 awk '/conns_per_peer/{print $NF}')
3264 echo "Set < 0; Should be ignored"
3265 do_lnetctl net set --all --conns-per-peer -1 ||
3266 error "should have succeeded $?"
3267 $LNETCTL net show -v 1 | grep -q "conns_per_peer: ${default}" ||
3268 error "Did not stay at default"
3270 run_test 230 "Test setting conns-per-peer"
3273 reinit_dlc || return $?
3275 local net=${NETTYPE}231
3277 do_lnetctl net add --net $net --if ${INTERFACES[0]} ||
3278 error "Failed to add net"
3280 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
3281 sed -i 's/peer_timeout: .*$/peer_timeout: 0/' \
3282 $TMP/sanity-lnet-$testnum-expected.yaml
3284 reinit_dlc || return $?
3286 do_lnetctl import $TMP/sanity-lnet-$testnum-expected.yaml ||
3287 error "Failed to import configuration"
3289 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
3291 compare_yaml_files || error "Wrong config after import"
3293 do_lnetctl net del --net $net --if ${INTERFACES[0]} ||
3294 error "Failed to delete net $net"
3296 do_lnetctl net add --net $net --if ${INTERFACES[0]} --peer-timeout=0 ||
3297 error "Failed to add net with peer-timeout=0"
3299 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
3301 compare_yaml_files || error "Wrong config after lnetctl net add"
3303 reinit_dlc || return $?
3305 # lnet/include/lnet/lib-lnet.h defines DEFAULT_PEER_TIMEOUT 180
3306 sed -i 's/peer_timeout: .*$/peer_timeout: 180/' \
3307 $TMP/sanity-lnet-$testnum-expected.yaml
3309 sed -i '/^.*peer_timeout:.*$/d' $TMP/sanity-lnet-$testnum-actual.yaml
3311 do_lnetctl import $TMP/sanity-lnet-$testnum-actual.yaml ||
3312 error "Failed to import config without peer_timeout"
3314 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
3318 run_test 231 "Check DLC handling of peer_timeout parameter"
3320 ### Test that linux route is added for each ni
3324 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
3326 reinit_dlc || return $?
3327 add_net "tcp" "${INTERFACES[0]}" || return $?
3329 skip_param=$(cat /sys/module/ksocklnd/parameters/skip_mr_route_setup)
3330 [[ ${skip_param:-0} -ne 0 ]] &&
3331 skip "Need skip_mr_route_setup=0 found $skip_param"
3333 ip route show table ${INTERFACES[0]} | grep -q "${INTERFACES[0]}"
3335 run_test 250 "test that linux routes are added"
3338 [[ ${NETTYPE} =~ kfi* ]] ||
3339 skip "Need kfi NETTYPE"
3341 reinit_dlc || return $?
3342 add_net "kfi" "${INTERFACES[0]}" || return $?
3343 add_net "kfi1" "${INTERFACES[0]}" || return $?
3344 add_net "kfi10" "${INTERFACES[0]}" || return $?
3347 run_test 251 "Define multiple kfi networks on single interface"
3350 setup_health_test false || return $?
3354 do_rpc_nodes $RNODE unload_modules_local || rc=$?
3356 if [[ $rc -ne 0 ]]; then
3357 cleanup_health_test || return $?
3359 error "Failed to unload modules on $RNODE rc=$rc"
3364 local ts1=$(date +%s)
3366 do_lnetctl ping --timeout 15 ${RNIDS[0]} &&
3367 error "Expected ping ${RNIDS[0]} to fail"
3369 local ts2=$(date +%s)
3371 local delta=$(echo "$ts2 - $ts1" | bc)
3373 [[ $delta -lt 15 ]] ||
3374 error "Ping took longer than expected to fail: $delta"
3378 run_test 252 "Ping to down peer should unlink quickly"
3380 do_expired_message_drop_test() {
3381 local rnid lnid old_tto
3383 old_tto=$($LNETCTL global show |
3384 awk '/transaction_timeout:/{print $NF}')
3386 [[ -z $old_tto ]] &&
3387 error "Cannot determine LNet transaction timeout"
3391 do_lnetctl set transaction_timeout "${tto}" ||
3392 error "Failed to set transaction_timeout"
3394 # We want to consume all peer credits for at least transaction_timeout
3400 for lnid in "${LNIDS[@]}"; do
3401 for rnid in "${RNIDS[@]}"; do
3402 $LCTL net_delay_add -s "${lnid}" -d "${rnid}" \
3403 -l "${delay}" -r 1 -m GET ||
3404 error "Failed to add delay rule"
3410 pcs=( $($LNETCTL peer show -v --nid "${RNIDS[0]}" |
3411 awk '/max_ni_tx_credits:/{print $NF}' |
3414 [[ ${#RNIDS[@]} -ne ${#pcs[@]} ]] &&
3415 error "Expect ${#RNIDS[@]} peer credit values found ${#pcs[@]}"
3417 local rnet lnid lnet i j
3419 # Need to use --source for multi-rail configs to ensure we consume
3420 # all available peer credits
3421 for ((i = 0; i < ${#RNIDS[@]}; i++)); do
3422 local ping_args="--timeout $((delay+2))"
3424 rnet=${RNIDS[i]##*@}
3425 for lnid in ${LNIDS[@]}; do
3427 [[ $rnet == $lnet ]] && break
3430 ping_args+=" --source ${lnid} ${RNIDS[i]}"
3431 for j in $(seq 1 "${pcs[i]}"); do
3432 $LNETCTL ping ${ping_args} 1>/dev/null &
3435 echo "Issued ${pcs[i]} pings to ${RNIDS[i]} from $lnid"
3438 # This ping should be queued on peer NI tx credit
3439 $LNETCTL ping --timeout $((delay+2)) "${RNIDS[0]}" &
3443 $LCTL net_delay_del -a
3447 # Messages sent from the delay list do not go through
3448 # lnet_post_send_locked(), thus we should only have a single drop
3451 dropped=$($LNETCTL peer show -v 2 --nid "${RNIDS[0]}" |
3452 grep -A 2 dropped_stats |
3453 awk '/get:/{print $2}' |
3455 sed 's/ /\+/g' | bc)
3457 [[ $dropped -ne 1 ]] &&
3458 error "Expect 1 dropped GET but found $dropped"
3460 do_lnetctl set transaction_timeout "${old_tto}"
3466 setup_health_test false || return $?
3468 do_expired_message_drop_test || return $?
3472 run_test 253 "Message delayed beyond deadline should be dropped (single-rail)"
3475 setup_health_test true || return $?
3477 do_expired_message_drop_test || return $?
3481 run_test 254 "Message delayed beyond deadline should be dropped (multi-rail)"
3484 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
3486 reinit_dlc || return $?
3488 cleanup_lnet || return $?
3490 local routes_str="o2ib ${IF0_NET}.[$GW_HOSTNUM-$((GW_HOSTNUM+4))]"
3491 local network_str="${NETTYPE}(${INTERFACES[0]})"
3493 load_lnet "networks=\"${network_str}\" routes=\"${routes_str}\"" ||
3494 error "Failed to load LNet"
3497 error "Failed to load LNet with networks=\"${network_str}\" routes=\"${routes_str}\""
3499 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
3501 - net type: ${NETTYPE}
3506 append_net_tunables tcp
3508 echo "route:" >> $TMP/sanity-lnet-$testnum-expected.yaml
3509 for i in $(seq $GW_HOSTNUM $((GW_HOSTNUM + 4))); do
3510 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
3512 gateway: ${IF0_NET}.${i}@${NETTYPE}
3515 health_sensitivity: 1
3519 echo "peer:" >> $TMP/sanity-lnet-$testnum-expected.yaml
3520 for i in $(seq $GW_HOSTNUM $((GW_HOSTNUM + 4))); do
3521 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
3522 - primary nid: ${IF0_NET}.${i}@${NETTYPE}
3525 - nid: ${IF0_NET}.${i}@${NETTYPE}
3531 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml ||
3532 error "export failed $?"
3534 validate_gateway_nids
3536 # Since we have an complex YAML config file we can test import
3537 do_lnetctl lnet unconfigure ||
3538 error "Failed to stop LNet rc=$?"
3539 do_lnetctl import < ${GLOBAL_YAML_FILE} || error "Import failed $?"
3541 run_test 255 "Use lnet routes param with pdsh syntax"
3546 local out=$TMP/$tfile
3547 local prefix=/usr/include/linux/lnet
3549 # We use a hard coded prefix so that this test will not fail
3552 if ! which $CC > /dev/null 2>&1; then
3553 skip_env "$CC is not installed"
3556 cleanup_lnet || exit 1
3559 local cc_args="-Wall -Werror -std=c99 -c -x c /dev/null -o $out"
3560 if ! [[ -d $prefix ]]; then
3561 # Assume we're running in tree and fixup the include path.
3562 prefix=$LUSTRE/../lnet/include/uapi/linux/lnet
3563 cc_args+=" -I $LUSTRE/../lnet/include/uapi"
3566 for header in $prefix/*.h; do
3567 if ! [[ -f "$header" ]]; then
3571 echo "$CC $cc_args -include $header"
3572 $CC $cc_args -include $header ||
3573 error "cannot compile '$header'"
3577 run_test 300 "packaged LNet UAPI headers can be compiled"
3579 # LU-16081 lnet: Memory leak on adding existing interface
3582 reinit_dlc || return $?
3583 do_lnetctl net add --net ${NETTYPE} --if ${INTERFACES[0]} ||
3584 error "Failed to add net"
3585 do_lnetctl net add --net ${NETTYPE} --if ${INTERFACES[0]} &&
3586 error "add net should have failed"
3587 do_lnetctl net del --net ${NETTYPE} --if ${INTERFACES[0]} ||
3588 error "Failed to del net"
3591 run_test 301 "Check for dynamic adds of same/wrong interface (memory leak)"
3594 ! [[ $NETTYPE =~ (tcp|o2ib) ]] && skip "Need tcp or o2ib NETTYPE"
3596 reinit_dlc || return $?
3598 add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
3600 local nid=$($LCTL list_nids)
3602 do_lnetctl ping ${nid} ||
3603 error "pinging self failed $?"
3604 do_lnetctl debug peer --nid ${nid} ||
3605 error "failed to dump peer debug info $?"
3607 run_test 302 "Check that peer debug info can be dumped"
3610 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
3612 setup_health_test true || return $?
3614 cleanup_netns || error "Failed to cleanup netns before test execution"
3615 setup_fakeif || error "Failed to add fake IF"
3616 have_interface "$FAKE_IF" ||
3617 error "Expect $FAKE_IF configured but not found"
3619 add_net "${NETTYPE}99" "$FAKE_IF" || return $?
3621 local nid=$($LCTL list_nids | tail --lines 1)
3623 # Our updated config should be pushed to RNODE
3624 local found=$(do_node $RNODE "$LNETCTL peer show --nid $nid")
3626 [[ -z $found ]] && error "Peer not updated on $RNODE"
3628 local prim=$($LCTL list_nids | head -n 1)
3630 if ! grep -q -- " primary nid: $prim"<<<"${found}"; then
3632 error "Wrong primary nid"
3635 echo "Set $FAKE_IF down"
3636 echo "ip link set dev $FAKE_IF down"
3637 ip link set dev $FAKE_IF down
3638 check_ni_status "$nid" down
3640 local hval=$(do_node $RNODE "$LNETCTL peer show --nid $nid -v 2 | \
3641 grep -e '- nid:' -e 'health value:'")
3643 hval=$(grep -A 1 $nid<<<"$hval" | tail -n 1 | awk '{print $NF}')
3644 (( hval < 1000 )) ||
3645 error "Expect $hval < 1000"
3649 run_test 303 "Check peer NI health after link down"
3652 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
3654 cleanup_netns || error "Failed to cleanup netns before test execution"
3655 cleanup_lnet || error "Failed to unload modules before test execution"
3657 setup_fakeif || error "Failed to add fake IF"
3658 have_interface "$FAKE_IF" ||
3659 error "Expect $FAKE_IF configured but not found"
3661 reinit_dlc || return $?
3663 add_net "tcp" "${INTERFACES[0]}" || return $?
3664 add_net "tcp" "$FAKE_IF" || return $?
3666 local nid1=$(lctl list_nids | head -n 1)
3667 local nid2=$(lctl list_nids | tail --lines 1)
3669 check_ni_status "$nid1" up
3670 check_ni_status "$nid2" up
3672 do_lnetctl peer add --prim_nid ${nid2} --lock_prim ||
3673 error "peer add failed $?"
3674 local locked_peer_state=($(do_lnetctl peer show -v 4 --nid ${nid2} |
3675 awk '/peer state/{print $NF}'))
3677 # Expect peer state bits:
3678 # LNET_PEER_MULTI_RAIL(0) | LNET_PEER_CONFIGURED(3) |
3679 # LNET_PEER_LOCK_PRIMARY(20)
3680 (( $locked_peer_state != "1048585")) &&
3681 error "Wrong peer state \"$locked_peer_state\" expected 1048585"
3683 # Clear LNET_PEER_CONFIGURED bit and verify
3684 do_lnetctl peer set --nid ${nid2} --state 1048577 ||
3685 error "peer add failed $?"
3686 locked_peer_state=($(do_lnetctl peer show -v 4 --nid ${nid2} |
3687 awk '/peer state/{print $NF}'))
3688 (( $locked_peer_state != "1048577")) &&
3689 error "Wrong peer state \"$locked_peer_state\" expected 1048577"
3690 do_lnetctl discover ${nid1} ||
3691 error "Failed to discover peer"
3693 # Expect nid2 and nid1 peer entries to be consolidated,
3694 # nid2 to stay primary
3695 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
3697 - primary nid: ${nid2}
3705 $LNETCTL peer show > $TMP/sanity-lnet-$testnum-actual.yaml
3706 compare_yaml_files ||
3707 error "Unexpected peer configuration"
3709 locked_peer_state=($(do_lnetctl peer show -v 4 --nid ${nid2} |
3710 awk '/peer state/{print $NF}'))
3711 # Expect peer state bits to be added:
3712 # LNET_PEER_DISCOVERED(4) | LNET_PEER_NIDS_UPTODATE(8)
3713 (( $locked_peer_state != "1048849")) &&
3714 error "Wrong peer state \"$locked_peer_state\" expected 1048849"
3717 run_test 304 "Check locked primary peer nid consolidation"
3723 echo "check parameter ${para} value ${value}"
3725 return $(( $(do_lnetctl net show -v | \
3727 grep -c "^ \+${para}: ${value}$") != ${#INTERFACES[@]} ))
3734 cleanup_lnet || error "Failed to cleanup LNet"
3736 load_module ../libcfs/libcfs/libcfs ||
3737 error "Failed to load module libcfs rc = $?"
3739 load_module ../lnet/lnet/lnet ||
3740 error "Failed to load module lnet rc = $?"
3742 echo "loading ${module} ${setting} type ${NETTYPE}"
3743 load_module "${module}" "${setting}" ||
3744 error "Failed to load module ${module} rc = $?"
3746 do_lnetctl lnet configure --all || error "lnet configure failed rc = $?"
3754 if [[ ${NETTYPE} == tcp* ]];then
3755 static_config "../lnet/klnds/socklnd/ksocklnd" \
3756 "sock_timeout=${value}"
3757 elif [[ ${NETTYPE} == o2ib* ]]; then
3758 static_config "../lnet/klnds/o2iblnd/ko2iblnd" \
3760 elif [[ ${NETTYPE} == gni* ]]; then
3761 static_config "../lnet/klnds/gnilnd/kgnilnd" \
3764 skip "NETTYPE ${NETTYPE} not supported"
3767 check_parameter "timeout" $value
3771 run_test 310 "Set timeout and verify"
3774 [[ $NETTYPE == kfi* ]] ||
3775 skip "Need kfi network type"
3777 setupall || error "setupall failed"
3779 mkdir -p $DIR/$tdir || error "mkdir failed"
3780 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 oflag=direct ||
3781 error "dd write failed"
3783 local list=$(comma_list $(osts_nodes))
3785 #define CFS_KFI_FAIL_WAIT_SEND_COMP1 0xF115
3786 do_nodes $list $LCTL set_param fail_loc=0x8000F115
3787 dd if=$DIR/$tdir/$tfile of=/dev/null bs=1M count=1 ||
3788 error "dd read failed"
3790 rm -f $DIR/$tdir/$tfile
3793 cleanupall || error "Failed cleanup"
3795 run_test 311 "Fail bulk put in send wait completion"
3798 [[ $NETTYPE == kfi* ]] ||
3799 skip "Need kfi network type"
3801 setupall || error "setupall failed"
3803 mkdir -p $DIR/$tdir || error "mkdir failed"
3805 local list=$(comma_list $(osts_nodes))
3807 #define CFS_KFI_FAIL_WAIT_SEND_COMP3 0xF117
3808 do_nodes $list $LCTL set_param fail_loc=0x8000F117
3809 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 oflag=direct ||
3810 error "dd write failed"
3812 local tfile2="$DIR/$tdir/testfile2"
3814 do_nodes $list $LCTL set_param fail_loc=0x8000F117
3815 dd if=$DIR/$tdir/$tfile of=$tfile2 bs=1M count=1 oflag=direct ||
3816 error "dd read failed"
3818 rm -f $DIR/$tdir/$tfile
3822 cleanupall || error "Failed cleanup"
3824 run_test 312 "TAG_RX_OK is possible after TX_FAIL"
3827 local target_net="${1}"
3828 local target_nid="${2}"
3829 local expect_net="${3}"
3830 local expect_nid="${4}"
3834 declare -a net_prios
3835 declare -a nid_prios
3837 nids=( $($LNETCTL ${type} show -v 5 | awk '/-\s+nid:/{print $NF}' |
3840 net_prios=( $($LNETCTL ${type} show -v 5 |
3841 awk '/net priority:/{print $NF}' | xargs echo) )
3843 nid_prios=( $($LNETCTL ${type} show -v 5 |
3844 awk '/nid priority:/{print $NF}' | xargs echo) )
3846 (( ${#nids[@]} != ${#net_prios[@]} )) &&
3847 error "Wrong # net prios ${#nids[@]} != ${#net_prios[@]}"
3849 (( ${#nids[@]} != ${#nid_prios[@]} )) &&
3850 error "Wrong # nid prios ${#nids[@]} != ${#nid_prios[@]}"
3854 for ((i = 0; i < ${#nids[@]}; i++)); do
3855 [[ -n ${target_net} ]] &&
3856 [[ ${nids[i]##*@} != "${target_net}" ]] &&
3858 [[ -n ${target_nid} ]] &&
3859 [[ ${nids[i]} != "${target_nid}" ]] &&
3862 echo "${nids[i]}: net_prio ${net_prios[i]} expect ${expect_net}"
3863 (( net_prios[i] != expect_net )) &&
3864 error "Wrong net priority \"${net_prios[i]}\" expect ${expect_net}"
3866 echo "${nids[i]}: nid_prio ${nid_prios[i]} expect ${expect_nid}"
3867 (( nid_prios[i] != expect_nid )) &&
3868 error "Wrong nid priority \"${nid_prios[i]}\" expect ${expect_nid}"
3874 check_peer_udsp_prio() {
3875 check_udsp_prio "${1}" "${2}" "${3}" "${4}" "peer"
3878 check_net_udsp_prio() {
3879 check_udsp_prio "${1}" "${2}" "${3}" "${4}" "net"
3883 reinit_dlc || return $?
3885 do_lnetctl udsp add --src tcp --priority 0 ||
3886 error "Failed to add udsp rule"
3887 do_lnetctl udsp del --idx 0 ||
3888 error "Failed to del udsp rule"
3891 run_test 400 "Check for udsp add/delete net rule without net num"
3894 reinit_dlc || return $?
3896 do_lnetctl net add --net ${NETTYPE} --if ${INTERFACES[0]} ||
3897 error "Failed to add net"
3899 do_lnetctl udsp add --dst ${NETTYPE} --prio 1 ||
3900 error "Failed to add peer net priority rule"
3902 do_lnetctl discover $($LCTL list_nids | head -n 1) ||
3903 error "Failed to discover peer"
3905 check_peer_udsp_prio "${NETTYPE}" "" "1" "-1"
3909 run_test 401 "Discover peer after adding peer net UDSP rule"
3912 reinit_dlc || return $?
3914 do_lnetctl udsp add --dst kfi --priority 0 ||
3915 error "Failed to add UDSP rule"
3917 do_lnetctl peer add --prim 402@kfi ||
3918 error "Failed to add peer"
3922 run_test 402 "Destination net rule should not panic"
3925 reinit_dlc || return $?
3927 cleanup_netns || error "Failed to cleanup netns before test execution"
3928 setup_fakeif || error "Failed to add fake IF"
3929 have_interface "$FAKE_IF" ||
3930 error "Expect $FAKE_IF configured but not found"
3932 add_net "tcp" "${INTERFACES[0]}"
3933 add_net "tcp" "${FAKE_IF}"
3935 do_lnetctl discover $($LCTL list_nids | head -n 1) ||
3936 error "Failed to discover self"
3938 $LCTL net_delay_add -s *@tcp -d *@tcp -r 1 -l 1 -m PUT ||
3939 error "Failed to add delay rule"
3941 $LCTL net_drop_add -s *@tcp -d $($LCTL list_nids | head -n 1) -m PUT \
3942 -e local_timeout -r 1 ||
3943 error "Failed to add drop rule"
3944 $LCTL net_drop_add -s *@tcp -d $($LCTL list_nids | tail -n 1) -m PUT \
3945 -e local_timeout -r 1 ||
3946 error "Failed to add drop rule"
3948 ip link set $FAKE_IF down ||
3949 error "Failed to set link down"
3950 ip link set $FAKE_IF up ||
3951 error "Failed to set link up"
3955 run_test 500 "Check deadlock on ping target update"
3957 do_peer_set_health_test() {
3964 if [[ ${nid_arg} == --all ]]; then
3965 max_hval=$($LNETCTL peer show -v 2 2>/dev/null |
3966 awk '/health value/{print $NF}' | xargs echo |
3967 sed 's/ /+/g' | bc -l)
3969 max_hval=$($LNETCTL peer show ${nid_arg} -v 2 2>/dev/null |
3970 awk '/health value/{print $NF}' | xargs echo |
3971 sed 's/ /+/g' | bc -l)
3974 (( max_hval >= 1000 )) && (( max_hval % 1000 == 0)) ||
3975 error "Unexpected max health value $max_hval"
3977 lnet_health_pre || return $?
3979 do_lnetctl peer set --health $test_val ${nid_arg} ||
3980 error "failed to set health value"
3982 lnet_health_post || return $?
3986 if [[ ${nid_arg} == --all ]]; then
3987 hval=$($LNETCTL peer show -v 2 2>/dev/null |
3988 awk '/health value/{print $NF}' | xargs echo |
3989 sed 's/ /+/g' | bc -l)
3991 hval=$($LNETCTL peer show ${nid_arg} -v 2 2>/dev/null |
3992 awk '/health value/{print $NF}' | xargs echo |
3993 sed 's/ /+/g' | bc -l)
3996 check_remote_health || return $?
3998 echo "hval: $hval max_hval: $max_hval"
3999 (( hval == max_hval )) || error "Failed to reset health to max"
4005 reinit_dlc || return $?
4007 setup_health_test false || return $?
4009 $LCTL set_param debug=-1
4011 $LCTL net_drop_add -s *@tcp -d *@tcp -r 1 ||
4012 error "Failed to add drop rule"
4016 for test_val in 0 500; do
4017 do_peer_set_health_test $test_val --nid ${RNIDS[0]} || return $?
4018 do_peer_set_health_test $test_val --all || return $?
4023 run_test 501 "Verify lnetctl peer set --health (SR)"
4026 reinit_dlc || return $?
4028 setup_health_test true || return $?
4030 $LCTL set_param debug=-1
4032 $LCTL net_drop_add -s *@tcp -d *@tcp -r 1 ||
4033 error "Failed to add drop rule"
4037 for test_val in 0 500; do
4038 do_peer_set_health_test $test_val --nid ${RNIDS[0]} || return $?
4039 do_peer_set_health_test $test_val --all || return $?
4044 run_test 502 "Verify lnetctl peer set --health (MR)"
4046 complete_test $SECONDS