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=$?"
2810 declare -A ROUTER_INTERFACES
2813 declare -A RPEER_INTERFACES
2814 init_router_test_vars() {
2815 local rnodes_required
2816 ((rnodes_required=ROUTERS_REQUIRED+RPEERS_REQUIRED))
2817 # all remote nodes, including some that may not be used
2818 local rnodes_all=( $(remote_nodes_list) )
2819 [[ -z $rnodes_all || "${#rnodes_all[@]}" -lt $rnodes_required ]] &&
2820 skip "Need at least $rnodes_required remote nodes" \
2821 "found \"${rnodes_all[@]}\""
2823 ROUTERS=( "${rnodes_all[@]:0:${ROUTERS_REQUIRED}}" )
2824 RPEERS=( "${rnodes_all[@]:${ROUTERS_REQUIRED}:${RPEERS_REQUIRED}}" )
2826 local rnodes=$(comma_list ${ROUTERS[@]} ${RPEERS[@]})
2827 local all_nodes=$(comma_list ${ROUTERS[@]} ${RPEERS[@]} $HOSTNAME)
2829 do_nodes $rnodes $LUSTRE_RMMOD ||
2830 error "failed to unload modules"
2832 do_rpc_nodes $rnodes "load_lnet config_on_load=1" ||
2833 error "Failed to load and configure LNet"
2835 for router in ${ROUTERS[@]}; do
2836 ROUTER_INTERFACES[$router]=$(do_rpc_nodes --quiet \
2837 $router lnet_if_list)
2840 for rpeer in ${RPEERS[@]}; do
2841 RPEER_INTERFACES[$rpeer]=$(do_rpc_nodes --quiet \
2842 $rpeer lnet_if_list)
2845 do_nodes $all_nodes $LUSTRE_RMMOD ||
2846 error "Failed to unload modules"
2848 [[ ${#INTERFACES[@]} -eq 0 ]] &&
2849 error "No interfaces configured for local host $HOSTNAME"
2850 for router in ${!ROUTER_INTERFACES[@]}; do
2851 [[ -z "${ROUTER_INTERFACES[$router]}" ]] &&
2852 error "No interfaces configured for router $router"
2854 for rpeer in ${!RPEER_INTERFACES[@]}; do
2855 [[ -z "${RPEER_INTERFACES[$rpeer]}" ]] &&
2856 error "No interfaces configured for remote peer $rpeer"
2862 declare -A ROUTER_NIDS
2863 declare -A RPEER_NIDS
2865 LOCAL_NET=${NETTYPE}1
2866 REMOTE_NET=${NETTYPE}2
2867 setup_router_test() {
2870 (( $MDS1_VERSION >= $(version_code 2.15.0) )) ||
2871 skip "need at least 2.15.0 for load_lnet"
2873 if [[ ${#RPEER_INTERFACES[@]} -eq 0 ]]; then
2874 init_router_test_vars ||
2878 local all_nodes=$(comma_list ${ROUTERS[@]} ${RPEERS[@]} $HOSTNAME)
2880 do_nodes $all_nodes $LUSTRE_RMMOD ||
2881 error "failed to unload modules"
2883 mod_opts+=" alive_router_check_interval=5"
2884 mod_opts+=" router_ping_timeout=5"
2885 mod_opts+=" large_router_buffers=4"
2886 mod_opts+=" small_router_buffers=8"
2887 mod_opts+=" tiny_router_buffers=16"
2888 do_rpc_nodes $all_nodes load_lnet "${mod_opts}" ||
2889 error "Failed to load lnet"
2891 do_nodes $all_nodes "$LNETCTL lnet configure" ||
2892 error "Failed to initialize DLC"
2894 for router in ${!ROUTER_INTERFACES[@]}; do
2895 local router_interfaces=( ${ROUTER_INTERFACES[$router]} )
2897 do_net_add $router $LOCAL_NET ${router_interfaces[0]} ||
2899 do_net_add $router $REMOTE_NET ${router_interfaces[0]} ||
2903 for rpeer in ${!RPEER_INTERFACES[@]}; do
2904 local rpeer_interfaces=( ${RPEER_INTERFACES[$rpeer]} )
2906 do_net_add $rpeer $REMOTE_NET ${rpeer_interfaces[0]} ||
2910 add_net $LOCAL_NET ${INTERFACES[0]} ||
2913 for router in ${!ROUTER_INTERFACES[@]}; do
2914 ROUTER_NIDS[$router]=$(do_node $router $LCTL list_nids
2915 2>/dev/null | xargs echo)
2918 for rpeer in ${!RPEER_INTERFACES[@]}; do
2919 RPEER_NIDS[$rpeer]=$(do_node $rpeer $LCTL list_nids
2920 2>/dev/null | xargs echo)
2923 LNIDS=( $($LCTL list_nids 2>/dev/null | xargs echo) )
2932 'output="$($LNETCTL route show --net $net --gateway $gw 2>/dev/null)"; \
2933 if [[ "x${lnetctl_text}x" != "xx" ]]; then \
2934 $LNETCTL route del --net $net --gateway $gw; \
2940 cleanup_router_test() {
2941 local all_nodes=$(comma_list $HOSTNAME ${ROUTERS[@]} ${RPEERS[@]})
2943 for router in ${!ROUTER_NIDS[@]}; do
2944 local router_nids=( ${ROUTER_NIDS[$router]} )
2946 do_route_del $HOSTNAME $REMOTE_NET ${router_nids[0]} ||
2947 error "Failed to delete $HOSTNAME -> "\
2948 "$REMOTE_NET via ${router_nids[0]} route"
2951 for router in ${!ROUTER_INTERFACES[@]}; do
2952 local router_nids=( ${ROUTER_NIDS[$router]} )
2954 do_route_del $rpeer $LOCAL_NET ${router_nids[1]} ||
2955 error "Failed to delete $rpeer -> "\
2956 "$LOCAL_NET via ${router_nids[1]} route"
2959 do_nodes $all_nodes $LUSTRE_RMMOD ||
2960 error "failed to unload modules"
2965 # check that all routes are up
2966 check_route_aliveness() {
2971 local lnetctl_actual
2975 chk_intvl=$(cat /sys/module/lnet/parameters/alive_router_check_interval)
2977 lctl_actual=$(do_node $node $LCTL show_route |
2978 awk '{print $7}' | sort -u | xargs)
2979 lnetctl_actual=$(do_node $node $LNETCTL route show -v |
2980 awk '/state/{print $NF}' | sort -u | xargs)
2982 for ((i = 0; i < $chk_intvl; i++)); do
2983 if [[ $lctl_actual == $expected ]] &&
2984 [[ $lnetctl_actual == $expected ]]; then
2988 echo "wait 1s for route state change"
2991 lctl_actual=$(do_node $node $LCTL show_route |
2992 awk '{print $7}' | sort -u | xargs)
2993 lnetctl_actual=$(do_node $node $LNETCTL route show -v |
2994 awk '/state/{print $NF}' | sort -u | xargs)
2997 [[ $lctl_actual != $expected ]] &&
2998 error "Wanted \"$expected\" lctl found \"$lctl_actual\""
3000 [[ $lnetctl_actual != $expected ]] &&
3001 error "Wanted \"$expected\" lnetctl found \"$lnetctl_actual\""
3006 check_router_ni_status() {
3008 local expected_local="$2"
3009 local expected_remote="$3"
3017 chk_intvl=$(cat /sys/module/lnet/parameters/alive_router_check_interval)
3018 timeout=$(cat /sys/module/lnet/parameters/router_ping_timeout)
3020 actual_local=$(do_node $router "$LNETCTL net show --net $LOCAL_NET" |
3021 awk '/status/{print $NF}')
3022 actual_remote=$(do_node $router "$LNETCTL net show --net $REMOTE_NET" |
3023 awk '/status/{print $NF}')
3025 for ((i = 0; i < $((chk_intvl + timeout)); i++)); do
3026 if [[ $actual_local == $expected_local ]] &&
3027 [[ $actual_remote == $expected_remote ]]; then
3031 echo "wait 1s for NI state change"
3034 actual_local=$(do_node $router \
3035 "$LNETCTL net show --net $LOCAL_NET" |
3036 awk '/status/{print $NF}')
3037 actual_remote=$(do_node $router \
3038 "$LNETCTL net show --net $REMOTE_NET" |
3039 awk '/status/{print $NF}')
3042 [[ $actual_local == $expected_local ]] ||
3043 error "$LOCAL_NET should be $expected_local"
3045 [[ $actual_remote == $expected_remote ]] ||
3046 error "$REMOTE_NET should be $expected_remote"
3052 do_basic_rtr_test() {
3053 for router in ${!ROUTER_INTERFACES[@]}; do
3054 do_node $router "$LNETCTL set routing 1" ||
3055 error "Unable to enable routing on $router"
3058 for router in ${!ROUTER_NIDS[@]}; do
3059 local router_nids=( ${ROUTER_NIDS[$router]} )
3061 do_route_add $HOSTNAME $REMOTE_NET ${router_nids[0]} ||
3062 error "Failed to add route $HOSTNAME -> "\
3063 "$REMOTE_NET via ${router_nids[0]}"
3066 for router in ${!ROUTER_INTERFACES[@]}; do
3067 local router_nids=( ${ROUTER_NIDS[$router]} )
3069 for rpeer in ${!RPEER_INTERFACES[@]}; do
3070 do_route_add $rpeer $LOCAL_NET ${router_nids[1]} ||
3071 error "Failed to add route $rpeer -> "\
3072 "$LOCAL_NET via ${router_nids[1]}"
3076 check_route_aliveness "$HOSTNAME" "up" ||
3079 for rpeer in ${RPEERS[@]}; do
3080 check_route_aliveness "$rpeer" "up" ||
3084 for rpeer in ${!RPEER_NIDS[@]}; do
3085 local rpeer_nids=( ${RPEER_NIDS[$rpeer]} )
3087 do_lnetctl ping ${rpeer_nids[0]} ||
3088 error "Failed to ping ${rpeer_nids[0]}"
3091 for rpeer in ${RPEERS[@]}; do
3092 do_node $rpeer "$LNETCTL ping ${LNIDS[0]}" ||
3093 error "$rpeer failed to ping ${LNIDS[0]}"
3103 setup_router_test || return $?
3105 do_basic_rtr_test || return $?
3107 do_rpc_nodes $HOSTNAME,${RPEERS[0]} load_module \
3108 ../lnet/selftest/lnet_selftest ||
3109 error "Failed to load lnet-selftest module"
3111 $LSTSH -H -t $HOSTNAME -f ${RPEERS[0]} -m rw -s 4k ||
3114 $LSTSH -H -t $HOSTNAME -f ${RPEERS[0]} -m rw ||
3117 cleanup_router_test || return $?
3119 run_test 220 "Add routes w/default options - check aliveness"
3125 setup_router_test lnet_peer_discovery_disabled=1 || return $?
3127 do_basic_rtr_test || return $?
3129 cleanup_router_test || return $?
3131 run_test 221 "Add routes w/DD disabled - check aliveness"
3133 # assumes 1 router, 1 peer
3134 do_aarf_enabled_test() {
3136 local router=${ROUTERS[0]}
3137 local router_nids=( ${ROUTER_NIDS[$router]} )
3138 local rpeer=${RPEERS[0]}
3139 local rpeer_nids=( ${RPEER_NIDS[$rpeer]} )
3141 do_node $router "$LNETCTL set routing 1" ||
3142 error "Unable to enable routing on $ROUTER"
3144 check_router_ni_status $router "down" "down"
3146 do_lnetctl ping ${rpeer_nids[0]} &&
3147 error "Ping should fail"
3149 do_node $rpeer "$LNETCTL ping ${LNIDS[0]}" &&
3150 error "$rpeer ping should fail"
3152 # Adding a route should cause the router's NI on LOCAL_NET to get up
3153 do_route_add $HOSTNAME $REMOTE_NET ${router_nids[0]} ||
3156 check_router_ni_status $router "up" "down" ||
3159 # But route should still be down because of avoid_asym_router_failure
3160 check_route_aliveness "$HOSTNAME" "down" ||
3163 do_lnetctl ping ${rpeer_nids[0]} &&
3164 error "Ping should fail"
3166 do_node $rpeer "$LNETCTL ping ${LNIDS[0]}" &&
3167 error "$rpeer ping should fail"
3169 # Adding the symmetric route should cause the remote NI to go up and
3171 do_route_add $rpeer $LOCAL_NET ${router_nids[1]} ||
3174 check_router_ni_status $router "up" "up" ||
3177 check_route_aliveness "$HOSTNAME" "up" ||
3180 check_route_aliveness "$rpeer" "up" ||
3183 do_lnetctl ping ${rpeer_nids[0]} ||
3184 error "Failed to ping ${rpeer_nids[0]}"
3186 do_node $rpeer "$LNETCTL ping ${LNIDS[0]}" ||
3187 error "$rpeer failed to ping ${LNIDS[0]}"
3189 # Stop LNet on local host
3190 do_lnetctl lnet unconfigure ||
3191 error "Failed to stop LNet rc=$?"
3193 check_router_ni_status $router "down" "up" ||
3196 check_route_aliveness "$rpeer" "down" ||
3199 do_lnetctl ping ${rpeer_nids[0]} &&
3200 error "Ping should fail"
3202 do_node $rpeer "$LNETCTL ping ${LNIDS[0]}" &&
3203 error "$rpeer ping should fail"
3212 setup_router_test avoid_asym_router_failure=1 || return $?
3214 do_aarf_enabled_test || return $?
3216 cleanup_router_test || return $?
3218 run_test 222 "Check avoid_asym_router_failure=1"
3224 local opts="avoid_asym_router_failure=1 lnet_peer_discovery_disabled=1"
3226 setup_router_test $opts || return $?
3228 do_aarf_enabled_test || return $?
3230 cleanup_router_test || return $?
3232 run_test 223 "Check avoid_asym_router_failure=1 w/DD disabled"
3234 do_aarf_disabled_test() {
3235 local router=${ROUTERS[0]}
3236 local router_nids=( ${ROUTER_NIDS[$router]} )
3237 local rpeer=${RPEERS[0]}
3238 local rpeer_nids=( ${RPEER_NIDS[$rpeer]} )
3240 do_node $router "$LNETCTL set routing 1" ||
3241 error "Unable to enable routing on $router"
3243 check_router_ni_status $router "down" "down"
3245 do_route_add $HOSTNAME $REMOTE_NET ${router_nids[0]} ||
3248 check_router_ni_status $router "up" "down" ||
3251 check_route_aliveness "$HOSTNAME" "up" ||
3254 do_route_add $rpeer $LOCAL_NET ${router_nids[1]} ||
3257 check_router_ni_status $router "up" "up" ||
3261 check_route_aliveness "$HOSTNAME" "up" ||
3264 check_route_aliveness "$rpeer" "up" ||
3267 do_lnetctl ping ${rpeer_nids[0]} ||
3268 error "Failed to ping ${rpeer_nids[0]}"
3270 do_node $rpeer "$LNETCTL ping ${LNIDS[0]}" ||
3271 error "$rpeer failed to ping ${LNIDS[0]}"
3273 # Stop LNet on local host
3274 do_lnetctl lnet unconfigure ||
3275 error "Failed to stop LNet rc=$?"
3277 check_router_ni_status $router "down" "up" ||
3280 check_route_aliveness "$rpeer" "up" ||
3290 setup_router_test avoid_asym_router_failure=0 ||
3293 do_aarf_disabled_test ||
3296 cleanup_router_test ||
3299 run_test 224 "Check avoid_asym_router_failure=0"
3305 local opts="avoid_asym_router_failure=0 lnet_peer_discovery_disabled=1"
3307 setup_router_test $opts || return $?
3309 do_aarf_disabled_test || return $?
3311 cleanup_router_test ||
3314 run_test 225 "Check avoid_asym_router_failure=0 w/DD disabled"
3320 setup_router_test || return $?
3322 do_basic_rtr_test || return $?
3324 # ping the peer from host to make sure it works
3325 local rpeer=${RPEERS[0]}
3326 local rpeer_nids=( ${RPEER_NIDS[$rpeer]} )
3329 do_lnetctl ping ${rpeer_nids[0]} ||
3330 error "Failed to ping ${rpeer_nids[0]} on try $i"
3333 # remove a route from the peer
3334 local router_nids=( ${ROUTER_NIDS[${ROUTERS[0]}]} )
3336 do_route_del $rpeer $LOCAL_NET ${router_nids[0]}
3338 # should attempt to use both routes due to round-robin
3339 # failure case here is an LBUG on $rpeer
3341 do_lnetctl ping ${rpeer_nids[0]}
3344 cleanup_router_test || return $?
3346 run_test 226 "test missing route for 1 of 2 routers"
3349 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
3352 echo "Check valid values; Should succeed"
3356 for ((i = 4; i < 16; i+=1)); do
3357 reinit_dlc || return $?
3358 add_net "tcp" "${INTERFACES[0]}" || return $?
3359 do_lnetctl net set --all --conns-per-peer $i ||
3360 error "should have succeeded $?"
3361 $LNETCTL net show -v 1 | grep -q "conns_per_peer: $i" ||
3362 error "failed to set conns-per-peer to $i"
3363 lnid="$(lctl list_nids | head -n 1)"
3364 do_lnetctl ping "$lnid" ||
3365 error "failed to ping myself"
3367 # "lctl --net tcp conn_list" prints the list of active
3368 # connections. Since we're pinging ourselves, there should be
3369 # 2 Control connections plus 2*conns_per_peer connections
3370 # created (one Bulk Input, one Bulk Output in each pair).
3371 # Here's the sample output for conns_per_peer set to 1:
3372 # 12345-1.1.1.1@tcp I[0]host01->host01:988 2626560/1061296 nonagle
3373 # 12345-1.1.1.1@tcp O[0]host01->host01:1022 2626560/1061488 nonagle
3374 # 12345-1.1.1.1@tcp C[0]host01->host01:988 2626560/1061296 nonagle
3375 # 12345-1.1.1.1@tcp C[0]host01->host01:1023 2626560/1061488 nonagle
3376 cmd="printf 'network tcp\nconn_list\n' | lctl | grep -c '$lnid'"
3378 # Expect 2+conns_per_peer*2 connections. Wait no longer
3380 wait_update $HOSTNAME "$cmd" "$((2+i*2))" 2 ||
3381 error "expected number of tcp connections $((2+i*2))"
3384 reinit_dlc || return $?
3385 add_net "tcp" "${INTERFACES[0]}" || return $?
3386 echo "Set > 127; Should fail"
3387 do_lnetctl net set --all --conns-per-peer 128 &&
3388 error "should have failed $?"
3390 reinit_dlc || return $?
3391 add_net "tcp" "${INTERFACES[0]}" || return $?
3393 local default=$($LNETCTL net show -v 1 |
3394 awk '/conns_per_peer/{print $NF}')
3396 echo "Set < 0; Should be ignored"
3397 do_lnetctl net set --all --conns-per-peer -1 ||
3398 error "should have succeeded $?"
3399 $LNETCTL net show -v 1 | grep -q "conns_per_peer: ${default}" ||
3400 error "Did not stay at default"
3402 run_test 230 "Test setting conns-per-peer"
3405 reinit_dlc || return $?
3407 local net=${NETTYPE}231
3409 do_lnetctl net add --net $net --if ${INTERFACES[0]} ||
3410 error "Failed to add net"
3412 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
3413 sed -i 's/peer_timeout: .*$/peer_timeout: 0/' \
3414 $TMP/sanity-lnet-$testnum-expected.yaml
3416 reinit_dlc || return $?
3418 do_lnetctl import $TMP/sanity-lnet-$testnum-expected.yaml ||
3419 error "Failed to import configuration"
3421 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
3423 compare_yaml_files || error "Wrong config after import"
3425 do_lnetctl net del --net $net --if ${INTERFACES[0]} ||
3426 error "Failed to delete net $net"
3428 do_lnetctl net add --net $net --if ${INTERFACES[0]} --peer-timeout=0 ||
3429 error "Failed to add net with peer-timeout=0"
3431 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
3433 compare_yaml_files || error "Wrong config after lnetctl net add"
3435 reinit_dlc || return $?
3437 # lnet/include/lnet/lib-lnet.h defines DEFAULT_PEER_TIMEOUT 180
3438 sed -i 's/peer_timeout: .*$/peer_timeout: 180/' \
3439 $TMP/sanity-lnet-$testnum-expected.yaml
3441 sed -i '/^.*peer_timeout:.*$/d' $TMP/sanity-lnet-$testnum-actual.yaml
3443 do_lnetctl import $TMP/sanity-lnet-$testnum-actual.yaml ||
3444 error "Failed to import config without peer_timeout"
3446 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
3450 run_test 231 "Check DLC handling of peer_timeout parameter"
3453 [[ ${NETTYPE} =~ ^(tcp|o2ib) ]] ||
3454 skip "Need tcp or o2ib NETTYPE"
3458 local net=${NETTYPE}232
3460 reinit_dlc || return $?
3461 if [[ ${NETTYPE} == tcp* ]];then
3462 modparam=$(cat "/sys/module/ksocklnd/parameters/tos")
3463 elif [[ ${NETTYPE} == o2ib* ]]; then
3464 modparam=$(cat "/sys/module/ko2iblnd/parameters/tos")
3467 do_lnetctl net add --net $net --if ${INTERFACES[0]} ||
3468 error "Failed to add net (no ToS)"
3469 do_lnetctl net show --net $net -v 1 | grep -q "tos: $modparam" ||
3470 error "Failed ToS value should inherit from module parameter $modparam"
3471 do_lnetctl net del --net $net --if ${INTERFACES[0]} ||
3472 error "Failed to delete net $net"
3474 for i in -1 104 106; do
3475 do_lnetctl net add --net $net --if ${INTERFACES[0]} --tos $i ||
3476 error "Failed to add net (ToS: $i)"
3477 do_lnetctl net show --net $net -v 1 | grep -q "tos: $i" ||
3478 error "Failed to set ToS value to 104"
3479 do_lnetctl net del --net $net --if ${INTERFACES[0]} ||
3480 error "Failed to delete net $net"
3483 ! do_lnetctl net add --net $net --if ${INTERFACES[0]} --tos 300 ||
3484 error "lnetctl should reject invalid ToS value (>255)"
3486 run_test 232 "Test setting ToS value"
3488 ### Test that linux route is added for each ni
3492 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
3494 reinit_dlc || return $?
3495 add_net "tcp" "${INTERFACES[0]}" || return $?
3497 skip_param=$(cat /sys/module/ksocklnd/parameters/skip_mr_route_setup)
3498 [[ ${skip_param:-0} -ne 0 ]] &&
3499 skip "Need skip_mr_route_setup=0 found $skip_param"
3501 ip route show table ${INTERFACES[0]} | grep -q "${INTERFACES[0]}"
3503 run_test 250 "test that linux routes are added"
3506 [[ ${NETTYPE} =~ kfi* ]] ||
3507 skip "Need kfi NETTYPE"
3509 reinit_dlc || return $?
3510 add_net "kfi" "${INTERFACES[0]}" || return $?
3511 add_net "kfi1" "${INTERFACES[0]}" || return $?
3512 add_net "kfi10" "${INTERFACES[0]}" || return $?
3515 run_test 251 "Define multiple kfi networks on single interface"
3518 setup_health_test false || return $?
3522 do_rpc_nodes $RNODE unload_modules_local || rc=$?
3524 if [[ $rc -ne 0 ]]; then
3525 cleanup_health_test || return $?
3527 error "Failed to unload modules on $RNODE rc=$rc"
3532 local ts1=$(date +%s)
3534 do_lnetctl ping --timeout 15 ${RNIDS[0]} &&
3535 error "Expected ping ${RNIDS[0]} to fail"
3537 local ts2=$(date +%s)
3539 local delta=$(echo "$ts2 - $ts1" | bc)
3541 [[ $delta -lt 15 ]] ||
3542 error "Ping took longer than expected to fail: $delta"
3546 run_test 252 "Ping to down peer should unlink quickly"
3548 do_expired_message_drop_test() {
3549 local rnid lnid old_tto
3551 old_tto=$($LNETCTL global show |
3552 awk '/transaction_timeout:/{print $NF}')
3554 [[ -z $old_tto ]] &&
3555 error "Cannot determine LNet transaction timeout"
3559 do_lnetctl set transaction_timeout "${tto}" ||
3560 error "Failed to set transaction_timeout"
3562 # We want to consume all peer credits for at least transaction_timeout
3568 for lnid in "${LNIDS[@]}"; do
3569 for rnid in "${RNIDS[@]}"; do
3570 $LCTL net_delay_add -s "${lnid}" -d "${rnid}" \
3571 -l "${delay}" -r 1 -m GET ||
3572 error "Failed to add delay rule"
3578 pcs=( $($LNETCTL peer show -v --nid "${RNIDS[0]}" |
3579 awk '/max_ni_tx_credits:/{print $NF}' |
3582 [[ ${#RNIDS[@]} -ne ${#pcs[@]} ]] &&
3583 error "Expect ${#RNIDS[@]} peer credit values found ${#pcs[@]}"
3585 local rnet lnid lnet i j
3587 # Need to use --source for multi-rail configs to ensure we consume
3588 # all available peer credits
3589 for ((i = 0; i < ${#RNIDS[@]}; i++)); do
3590 local ping_args="--timeout $((delay+2))"
3592 rnet=${RNIDS[i]##*@}
3593 for lnid in ${LNIDS[@]}; do
3595 [[ $rnet == $lnet ]] && break
3598 ping_args+=" --source ${lnid} ${RNIDS[i]}"
3599 for j in $(seq 1 "${pcs[i]}"); do
3600 $LNETCTL ping ${ping_args} 1>/dev/null &
3603 echo "Issued ${pcs[i]} pings to ${RNIDS[i]} from $lnid"
3606 # This ping should be queued on peer NI tx credit
3607 $LNETCTL ping --timeout $((delay+2)) "${RNIDS[0]}" &
3611 $LCTL net_delay_del -a
3615 # Messages sent from the delay list do not go through
3616 # lnet_post_send_locked(), thus we should only have a single drop
3619 dropped=$($LNETCTL peer show -v 2 --nid "${RNIDS[0]}" |
3620 grep -A 2 dropped_stats |
3621 awk '/get:/{print $2}' |
3623 sed 's/ /\+/g' | bc)
3625 [[ $dropped -ne 1 ]] &&
3626 error "Expect 1 dropped GET but found $dropped"
3628 do_lnetctl set transaction_timeout "${old_tto}"
3634 setup_health_test false || return $?
3636 do_expired_message_drop_test || return $?
3640 run_test 253 "Message delayed beyond deadline should be dropped (single-rail)"
3643 setup_health_test true || return $?
3645 do_expired_message_drop_test || return $?
3649 run_test 254 "Message delayed beyond deadline should be dropped (multi-rail)"
3652 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
3654 reinit_dlc || return $?
3656 cleanup_lnet || return $?
3658 local routes_str="o2ib ${IF0_NET}.[$GW_HOSTNUM-$((GW_HOSTNUM+4))]"
3659 local network_str="${NETTYPE}(${INTERFACES[0]})"
3661 load_lnet "networks=\"${network_str}\" routes=\"${routes_str}\"" ||
3662 error "Failed to load LNet"
3665 error "Failed to load LNet with networks=\"${network_str}\" routes=\"${routes_str}\""
3667 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
3669 - net type: ${NETTYPE}
3674 append_net_tunables tcp
3676 echo "route:" >> $TMP/sanity-lnet-$testnum-expected.yaml
3677 for i in $(seq $GW_HOSTNUM $((GW_HOSTNUM + 4))); do
3678 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
3680 gateway: ${IF0_NET}.${i}@${NETTYPE}
3683 health_sensitivity: 1
3687 echo "peer:" >> $TMP/sanity-lnet-$testnum-expected.yaml
3688 for i in $(seq $GW_HOSTNUM $((GW_HOSTNUM + 4))); do
3689 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
3690 - primary nid: ${IF0_NET}.${i}@${NETTYPE}
3693 - nid: ${IF0_NET}.${i}@${NETTYPE}
3699 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml ||
3700 error "export failed $?"
3702 validate_gateway_nids
3704 # Since we have an complex YAML config file we can test import
3705 do_lnetctl lnet unconfigure ||
3706 error "Failed to stop LNet rc=$?"
3707 do_lnetctl import < ${GLOBAL_YAML_FILE} || error "Import failed $?"
3709 run_test 255 "Use lnet routes param with pdsh syntax"
3714 local out=$TMP/$tfile
3715 local prefix=/usr/include/linux/lnet
3717 # We use a hard coded prefix so that this test will not fail
3720 if ! which $CC > /dev/null 2>&1; then
3721 skip_env "$CC is not installed"
3724 cleanup_lnet || exit 1
3727 local cc_args="-Wall -Werror -std=c99 -c -x c /dev/null -o $out"
3728 if ! [[ -d $prefix ]]; then
3729 # Assume we're running in tree and fixup the include path.
3730 prefix=$LUSTRE/../lnet/include/uapi/linux/lnet
3731 cc_args+=" -I $LUSTRE/../lnet/include/uapi"
3734 for header in $prefix/*.h; do
3735 if ! [[ -f "$header" ]]; then
3739 echo "$CC $cc_args -include $header"
3740 $CC $cc_args -include $header ||
3741 error "cannot compile '$header'"
3745 run_test 300 "packaged LNet UAPI headers can be compiled"
3747 # LU-16081 lnet: Memory leak on adding existing interface
3750 reinit_dlc || return $?
3751 do_lnetctl net add --net ${NETTYPE} --if ${INTERFACES[0]} ||
3752 error "Failed to add net"
3753 do_lnetctl net add --net ${NETTYPE} --if ${INTERFACES[0]} &&
3754 error "add net should have failed"
3755 do_lnetctl net del --net ${NETTYPE} --if ${INTERFACES[0]} ||
3756 error "Failed to del net"
3759 run_test 301 "Check for dynamic adds of same/wrong interface (memory leak)"
3762 ! [[ $NETTYPE =~ (tcp|o2ib) ]] && skip "Need tcp or o2ib NETTYPE"
3764 reinit_dlc || return $?
3766 add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
3768 local nid=$($LCTL list_nids)
3770 do_lnetctl ping ${nid} ||
3771 error "pinging self failed $?"
3772 do_lnetctl debug peer --nid ${nid} ||
3773 error "failed to dump peer debug info $?"
3775 run_test 302 "Check that peer debug info can be dumped"
3778 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
3780 setup_health_test true || return $?
3782 cleanup_netns || error "Failed to cleanup netns before test execution"
3783 setup_fakeif || error "Failed to add fake IF"
3784 have_interface "$FAKE_IF" ||
3785 error "Expect $FAKE_IF configured but not found"
3787 add_net "${NETTYPE}99" "$FAKE_IF" || return $?
3789 local nid=$($LCTL list_nids | tail --lines 1)
3791 # Our updated config should be pushed to RNODE
3792 local found=$(do_node $RNODE "$LNETCTL peer show --nid $nid")
3794 [[ -z $found ]] && error "Peer not updated on $RNODE"
3796 local prim=$($LCTL list_nids | head -n 1)
3798 if ! grep -q -- " primary nid: $prim"<<<"${found}"; then
3800 error "Wrong primary nid"
3803 echo "Set $FAKE_IF down"
3804 echo "ip link set dev $FAKE_IF down"
3805 ip link set dev $FAKE_IF down
3806 check_ni_status "$nid" down
3808 local hval=$(do_node $RNODE "$LNETCTL peer show --nid $nid -v 2 | \
3809 grep -e '- nid:' -e 'health value:'")
3811 hval=$(grep -A 1 $nid<<<"$hval" | tail -n 1 | awk '{print $NF}')
3812 (( hval < 1000 )) ||
3813 error "Expect $hval < 1000"
3817 run_test 303 "Check peer NI health after link down"
3820 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
3822 cleanup_netns || error "Failed to cleanup netns before test execution"
3823 cleanup_lnet || error "Failed to unload modules before test execution"
3825 setup_fakeif || error "Failed to add fake IF"
3826 have_interface "$FAKE_IF" ||
3827 error "Expect $FAKE_IF configured but not found"
3829 reinit_dlc || return $?
3831 add_net "tcp" "${INTERFACES[0]}" || return $?
3832 add_net "tcp" "$FAKE_IF" || return $?
3834 local nid1=$(lctl list_nids | head -n 1)
3835 local nid2=$(lctl list_nids | tail --lines 1)
3837 check_ni_status "$nid1" up
3838 check_ni_status "$nid2" up
3840 do_lnetctl peer add --prim_nid ${nid2} --lock_prim ||
3841 error "peer add failed $?"
3842 local locked_peer_state=($(do_lnetctl peer show -v 4 --nid ${nid2} |
3843 awk '/peer state/{print $NF}'))
3845 # Expect peer state bits:
3846 # LNET_PEER_MULTI_RAIL(0) | LNET_PEER_CONFIGURED(3) |
3847 # LNET_PEER_LOCK_PRIMARY(20)
3848 (( $locked_peer_state != "1048585")) &&
3849 error "Wrong peer state \"$locked_peer_state\" expected 1048585"
3851 # Clear LNET_PEER_CONFIGURED bit and verify
3852 do_lnetctl peer set --nid ${nid2} --state 1048577 ||
3853 error "peer add failed $?"
3854 locked_peer_state=($(do_lnetctl peer show -v 4 --nid ${nid2} |
3855 awk '/peer state/{print $NF}'))
3856 (( $locked_peer_state != "1048577")) &&
3857 error "Wrong peer state \"$locked_peer_state\" expected 1048577"
3858 do_lnetctl discover ${nid1} ||
3859 error "Failed to discover peer"
3861 # Expect nid2 and nid1 peer entries to be consolidated,
3862 # nid2 to stay primary
3863 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
3865 - primary nid: ${nid2}
3873 $LNETCTL peer show > $TMP/sanity-lnet-$testnum-actual.yaml
3874 compare_yaml_files ||
3875 error "Unexpected peer configuration"
3877 locked_peer_state=($(do_lnetctl peer show -v 4 --nid ${nid2} |
3878 awk '/peer state/{print $NF}'))
3879 # Expect peer state bits to be added:
3880 # LNET_PEER_DISCOVERED(4) | LNET_PEER_NIDS_UPTODATE(8)
3881 (( $locked_peer_state != "1048849")) &&
3882 error "Wrong peer state \"$locked_peer_state\" expected 1048849"
3885 run_test 304 "Check locked primary peer nid consolidation"
3891 echo "check parameter ${para} value ${value}"
3893 return $(( $(do_lnetctl net show -v | \
3895 grep -c "^ \+${para}: ${value}$") != ${#INTERFACES[@]} ))
3902 cleanup_lnet || error "Failed to cleanup LNet"
3904 load_module ../libcfs/libcfs/libcfs ||
3905 error "Failed to load module libcfs rc = $?"
3907 load_module ../lnet/lnet/lnet ||
3908 error "Failed to load module lnet rc = $?"
3910 echo "loading ${module} ${setting} type ${NETTYPE}"
3911 load_module "${module}" "${setting}" ||
3912 error "Failed to load module ${module} rc = $?"
3914 do_lnetctl lnet configure --all || error "lnet configure failed rc = $?"
3922 if [[ ${NETTYPE} == tcp* ]];then
3923 static_config "../lnet/klnds/socklnd/ksocklnd" \
3924 "sock_timeout=${value}"
3925 elif [[ ${NETTYPE} == o2ib* ]]; then
3926 static_config "../lnet/klnds/o2iblnd/ko2iblnd" \
3928 elif [[ ${NETTYPE} == gni* ]]; then
3929 static_config "../lnet/klnds/gnilnd/kgnilnd" \
3932 skip "NETTYPE ${NETTYPE} not supported"
3935 check_parameter "timeout" $value
3939 run_test 310 "Set timeout and verify"
3942 [[ $NETTYPE == kfi* ]] ||
3943 skip "Need kfi network type"
3945 setupall || error "setupall failed"
3947 mkdir -p $DIR/$tdir || error "mkdir failed"
3948 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 oflag=direct ||
3949 error "dd write failed"
3951 local list=$(comma_list $(osts_nodes))
3953 #define CFS_KFI_FAIL_WAIT_SEND_COMP1 0xF115
3954 do_nodes $list $LCTL set_param fail_loc=0x8000F115
3955 dd if=$DIR/$tdir/$tfile of=/dev/null bs=1M count=1 ||
3956 error "dd read failed"
3958 rm -f $DIR/$tdir/$tfile
3961 cleanupall || error "Failed cleanup"
3963 run_test 311 "Fail bulk put in send wait completion"
3966 [[ $NETTYPE == kfi* ]] ||
3967 skip "Need kfi network type"
3969 setupall || error "setupall failed"
3971 mkdir -p $DIR/$tdir || error "mkdir failed"
3973 local list=$(comma_list $(osts_nodes))
3975 #define CFS_KFI_FAIL_WAIT_SEND_COMP3 0xF117
3976 do_nodes $list $LCTL set_param fail_loc=0x8000F117
3977 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 oflag=direct ||
3978 error "dd write failed"
3980 local tfile2="$DIR/$tdir/testfile2"
3982 do_nodes $list $LCTL set_param fail_loc=0x8000F117
3983 dd if=$DIR/$tdir/$tfile of=$tfile2 bs=1M count=1 oflag=direct ||
3984 error "dd read failed"
3986 rm -f $DIR/$tdir/$tfile
3990 cleanupall || error "Failed cleanup"
3992 run_test 312 "TAG_RX_OK is possible after TX_FAIL"
3995 local target_net="${1}"
3996 local target_nid="${2}"
3997 local expect_net="${3}"
3998 local expect_nid="${4}"
4002 declare -a net_prios
4003 declare -a nid_prios
4005 nids=( $($LNETCTL ${type} show -v 5 | awk '/-\s+nid:/{print $NF}' |
4008 net_prios=( $($LNETCTL ${type} show -v 5 |
4009 awk '/net priority:/{print $NF}' | xargs echo) )
4011 nid_prios=( $($LNETCTL ${type} show -v 5 |
4012 awk '/nid priority:/{print $NF}' | xargs echo) )
4014 (( ${#nids[@]} != ${#net_prios[@]} )) &&
4015 error "Wrong # net prios ${#nids[@]} != ${#net_prios[@]}"
4017 (( ${#nids[@]} != ${#nid_prios[@]} )) &&
4018 error "Wrong # nid prios ${#nids[@]} != ${#nid_prios[@]}"
4022 for ((i = 0; i < ${#nids[@]}; i++)); do
4023 [[ -n ${target_net} ]] &&
4024 [[ ${nids[i]##*@} != "${target_net}" ]] &&
4026 [[ -n ${target_nid} ]] &&
4027 [[ ${nids[i]} != "${target_nid}" ]] &&
4030 echo "${nids[i]}: net_prio ${net_prios[i]} expect ${expect_net}"
4031 (( net_prios[i] != expect_net )) &&
4032 error "Wrong net priority \"${net_prios[i]}\" expect ${expect_net}"
4034 echo "${nids[i]}: nid_prio ${nid_prios[i]} expect ${expect_nid}"
4035 (( nid_prios[i] != expect_nid )) &&
4036 error "Wrong nid priority \"${nid_prios[i]}\" expect ${expect_nid}"
4042 check_peer_udsp_prio() {
4043 check_udsp_prio "${1}" "${2}" "${3}" "${4}" "peer"
4046 check_net_udsp_prio() {
4047 check_udsp_prio "${1}" "${2}" "${3}" "${4}" "net"
4051 reinit_dlc || return $?
4053 do_lnetctl udsp add --src tcp --priority 0 ||
4054 error "Failed to add udsp rule"
4055 do_lnetctl udsp del --idx 0 ||
4056 error "Failed to del udsp rule"
4059 run_test 400 "Check for udsp add/delete net rule without net num"
4062 reinit_dlc || return $?
4064 do_lnetctl net add --net ${NETTYPE} --if ${INTERFACES[0]} ||
4065 error "Failed to add net"
4067 do_lnetctl udsp add --dst ${NETTYPE} --prio 1 ||
4068 error "Failed to add peer net priority rule"
4070 do_lnetctl discover $($LCTL list_nids | head -n 1) ||
4071 error "Failed to discover peer"
4073 check_peer_udsp_prio "${NETTYPE}" "" "1" "-1"
4077 run_test 401 "Discover peer after adding peer net UDSP rule"
4080 reinit_dlc || return $?
4082 do_lnetctl udsp add --dst kfi --priority 0 ||
4083 error "Failed to add UDSP rule"
4085 do_lnetctl peer add --prim 402@kfi ||
4086 error "Failed to add peer"
4090 run_test 402 "Destination net rule should not panic"
4093 reinit_dlc || return $?
4095 cleanup_netns || error "Failed to cleanup netns before test execution"
4096 setup_fakeif || error "Failed to add fake IF"
4097 have_interface "$FAKE_IF" ||
4098 error "Expect $FAKE_IF configured but not found"
4100 add_net "tcp" "${INTERFACES[0]}"
4101 add_net "tcp" "${FAKE_IF}"
4103 do_lnetctl discover $($LCTL list_nids | head -n 1) ||
4104 error "Failed to discover self"
4106 $LCTL net_delay_add -s *@tcp -d *@tcp -r 1 -l 1 -m PUT ||
4107 error "Failed to add delay rule"
4109 $LCTL net_drop_add -s *@tcp -d $($LCTL list_nids | head -n 1) -m PUT \
4110 -e local_timeout -r 1 ||
4111 error "Failed to add drop rule"
4112 $LCTL net_drop_add -s *@tcp -d $($LCTL list_nids | tail -n 1) -m PUT \
4113 -e local_timeout -r 1 ||
4114 error "Failed to add drop rule"
4116 ip link set $FAKE_IF down ||
4117 error "Failed to set link down"
4118 ip link set $FAKE_IF up ||
4119 error "Failed to set link up"
4123 run_test 500 "Check deadlock on ping target update"
4125 do_peer_set_health_test() {
4132 if [[ ${nid_arg} == --all ]]; then
4133 max_hval=$($LNETCTL peer show -v 2 2>/dev/null |
4134 awk '/health value/{print $NF}' | xargs echo |
4135 sed 's/ /+/g' | bc -l)
4137 max_hval=$($LNETCTL peer show ${nid_arg} -v 2 2>/dev/null |
4138 awk '/health value/{print $NF}' | xargs echo |
4139 sed 's/ /+/g' | bc -l)
4142 (( max_hval >= 1000 )) && (( max_hval % 1000 == 0)) ||
4143 error "Unexpected max health value $max_hval"
4145 lnet_health_pre || return $?
4147 do_lnetctl peer set --health $test_val ${nid_arg} ||
4148 error "failed to set health value"
4150 lnet_health_post || return $?
4154 if [[ ${nid_arg} == --all ]]; then
4155 hval=$($LNETCTL peer show -v 2 2>/dev/null |
4156 awk '/health value/{print $NF}' | xargs echo |
4157 sed 's/ /+/g' | bc -l)
4159 hval=$($LNETCTL peer show ${nid_arg} -v 2 2>/dev/null |
4160 awk '/health value/{print $NF}' | xargs echo |
4161 sed 's/ /+/g' | bc -l)
4164 check_remote_health || return $?
4166 echo "hval: $hval max_hval: $max_hval"
4167 (( hval == max_hval )) || error "Failed to reset health to max"
4173 reinit_dlc || return $?
4175 setup_health_test false || return $?
4177 $LCTL set_param debug=-1
4179 $LCTL net_drop_add -s *@tcp -d *@tcp -r 1 ||
4180 error "Failed to add drop rule"
4184 for test_val in 0 500; do
4185 do_peer_set_health_test $test_val --nid ${RNIDS[0]} || return $?
4186 do_peer_set_health_test $test_val --all || return $?
4191 run_test 501 "Verify lnetctl peer set --health (SR)"
4194 reinit_dlc || return $?
4196 setup_health_test true || return $?
4198 $LCTL set_param debug=-1
4200 $LCTL net_drop_add -s *@tcp -d *@tcp -r 1 ||
4201 error "Failed to add drop rule"
4205 for test_val in 0 500; do
4206 do_peer_set_health_test $test_val --nid ${RNIDS[0]} || return $?
4207 do_peer_set_health_test $test_val --all || return $?
4212 run_test 502 "Verify lnetctl peer set --health (MR)"
4214 complete_test $SECONDS