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 "
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}
28 [[ -z $LNETCTL ]] && skip "Need lnetctl"
32 if is_mounted $MOUNT || is_mounted $MOUNT2; then
33 cleanupall || error "Failed cleanup prior to test execution"
38 echo "Cleaning up LNet"
39 lsmod | grep -q lnet &&
40 $LNETCTL lnet unconfigure 2>/dev/null
45 if module_loaded lnet ; then
46 cleanup_lnet || error "Failed to unload modules before test execution"
52 # Cleanup any tmp files created by the sub tests
53 rm -f $TMP/sanity-lnet-*.yaml $LNET_PARAMS_FILE
56 if $restore_mounts; then
57 setupall || error "Failed to setup Lustre after test execution"
58 elif $restore_modules; then
60 error "Couldn't load modules after test execution"
69 echo "ip netns exec $TESTNS $*"
70 ip netns exec $TESTNS "$@"
78 netns_arg="netns $netns"
80 ip link add 'test1pl' type veth peer name $FAKE_IF $netns_arg
81 ip link set 'test1pl' up
82 if [[ -n $netns ]]; then
83 do_ns ip addr add "${FAKE_IP}/31" dev $FAKE_IF
84 do_ns ip link set $FAKE_IF up
86 ip addr add "${FAKE_IP}/31" dev $FAKE_IF
87 ip link set $FAKE_IF up
92 ip link show test1pl >& /dev/null && ip link del test1pl || return 0
103 (ip netns list | grep -q $TESTNS) && ip netns del $TESTNS
108 echo "Loading LNet and configuring DLC"
109 load_lnet || return $?
110 do_lnetctl lnet configure
113 GLOBAL_YAML_FILE=$TMP/sanity-lnet-global.yaml
114 define_global_yaml() {
115 $LNETCTL export --backup >${GLOBAL_YAML_FILE} ||
116 error "Failed to export global yaml $?"
120 if lsmod | grep -q lnet; then
121 do_lnetctl lnet unconfigure ||
122 error "lnetctl lnet unconfigure failed $?"
123 do_lnetctl lnet configure ||
124 error "lnetctl lnet configure failed $?"
126 configure_dlc || error "configure_dlc failed $?"
131 append_global_yaml() {
132 [[ ! -e ${GLOBAL_YAML_FILE} ]] &&
133 error "Missing global yaml at ${GLOBAL_YAML_FILE}"
135 cat ${GLOBAL_YAML_FILE} >> $TMP/sanity-lnet-$testnum-expected.yaml
138 create_base_yaml_file() {
142 compare_yaml_files() {
143 local expected="$TMP/sanity-lnet-$testnum-expected.yaml"
144 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
146 ! [[ -e $expected ]] && echo "$expected not found" && return 1
147 ! [[ -e $actual ]] && echo "$actual not found" && return 1
148 if [ verify_yaml_available ]; then
149 verify_compare_yaml $actual $expected || rc=$?
151 diff -upN ${actual} ${expected} || rc=$?
162 local net="${nid//*@/}"
163 local addr="${nid//@*/}"
165 local num_re='[0-9]+'
166 local ip_re="[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"
168 if [[ $net =~ (gni|kfi)[0-9]* ]]; then
169 [[ $addr =~ ${num_re} ]] && return 0
171 [[ $addr =~ ${ip_re} ]] && return 0
176 local yfile=$TMP/sanity-lnet-$testnum-actual.yaml
177 local primary_nids=$(awk '/- primary nid:/{print $NF}' $yfile | xargs echo)
178 local secondary_nids=$(awk '/- nid:/{print $NF}' $yfile | xargs echo)
179 local gateway_nids=$(awk '/gateway:/{print $NF}' $yfile | xargs echo)
182 for nid in $primary_nids $secondary_nids; do
183 validate_nid "$nid" || error "Bad NID \"${nid}\""
188 validate_peer_nids() {
190 local nids_per_peer="$2"
192 local expect_p="$num_peers"
193 # The primary nid also shows up in the list of secondary nids
194 local expect_s="$(($num_peers + $(($nids_per_peer*$num_peers))))"
196 local actual_p=$(grep -c -- '- primary nid:' $TMP/sanity-lnet-$testnum-actual.yaml)
197 local actual_s=$(grep -c -- '- nid:' $TMP/sanity-lnet-$testnum-actual.yaml)
198 if [[ $expect_p -ne $actual_p ]]; then
200 error "Expected $expect_p but found $actual_p primary nids"
201 elif [[ $expect_s -ne $actual_s ]]; then
203 error "Expected $expect_s but found $actual_s secondary nids"
208 validate_gateway_nids() {
209 local expect_gw=$(grep -c -- 'gateway:' $TMP/sanity-lnet-$testnum-expected.yaml)
210 local actual_gw=$(grep -c -- 'gateway:' $TMP/sanity-lnet-$testnum-actual.yaml)
211 if [[ $expect_gw -ne $actual_gw ]]; then
213 error "Expected $expect_gw gateways but found $actual_gw gateways"
216 local expect_gwnids=$(awk '/gateway:/{print $NF}' $TMP/sanity-lnet-$testnum-expected.yaml |
219 for nid in ${expect_gwnids}; do
220 if ! grep -q "gateway: ${nid}" $TMP/sanity-lnet-$testnum-actual.yaml; then
221 error "${nid} not configured as gateway"
229 setup_netns || error "setup_netns failed with $?"
231 # Determine the local interface(s) used for LNet
232 load_lnet "config_on_load=1" || error "Failed to load modules"
237 INTERFACES=( $(lnet_if_list) )
239 cleanup_lnet || error "Failed to cleanup LNet"
241 stack_trap 'cleanup_testsuite' EXIT
244 configure_dlc || error "Failed to configure DLC rc = $?"
246 reinit_dlc || return $?
247 do_lnetctl import < ${GLOBAL_YAML_FILE} || error "Import failed $?"
248 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
249 create_base_yaml_file
250 compare_yaml_files || error "Configuration changed after import"
252 run_test 0 "Export empty config, import the config, compare"
255 local prim_nid="${1:+--prim_nid $1}"
256 local nid="${2:+--nid $2}"
258 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
260 do_lnetctl peer add ${prim_nid} ${nid} || error "peer add failed $?"
261 $LNETCTL export --backup > $actual || error "export failed $?"
267 reinit_dlc || return $?
268 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
270 - primary nid: 1.1.1.1@tcp
276 compare_peer_add "1.1.1.1@tcp"
278 run_test 1 "Add peer with single nid (tcp)"
281 reinit_dlc || return $?
282 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
284 - primary nid: 2.2.2.2@o2ib
290 compare_peer_add "2.2.2.2@o2ib"
292 run_test 2 "Add peer with single nid (o2ib)"
295 reinit_dlc || return $?
296 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
298 - primary nid: 3.3.3.3@tcp
305 compare_peer_add "3.3.3.3@tcp" "3.3.3.3@o2ib"
307 run_test 3 "Add peer with tcp primary o2ib secondary"
310 reinit_dlc || return $?
311 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
313 - primary nid: 4.4.4.4@tcp
322 echo "Add peer with nidrange (tcp)"
323 compare_peer_add "4.4.4.4@tcp" "4.4.4.[1-3]@tcp"
325 echo "Add peer with nidrange that overlaps primary nid (tcp)"
326 compare_peer_add "4.4.4.4@tcp" "4.4.4.[1-4]@tcp"
328 run_test 4 "Add peer with nidrange (tcp)"
331 reinit_dlc || return $?
332 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
334 - primary nid: 5.5.5.5@o2ib
344 echo "Add peer with nidrange (o2ib)"
345 compare_peer_add "5.5.5.5@o2ib" "5.5.5.[1-4]@o2ib"
347 echo "Add peer with nidranage that overlaps primary nid (o2ib)"
348 compare_peer_add "5.5.5.5@o2ib" "5.5.5.[1-4]@o2ib"
350 run_test 5 "Add peer with nidrange (o2ib)"
353 reinit_dlc || return $?
354 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
356 - primary nid: 6.6.6.6@tcp
379 local nid_expr="6.6.[6-7].[0-4/2]@tcp"
380 nid_expr+=",6.6.[1-4/2].[0-6/3]@o2ib"
381 nid_expr+=",[6-12/4]@gni"
382 nid_expr+=",[6-12/4]@kfi"
384 compare_peer_add "6.6.6.6@tcp" "${nid_expr}"
386 run_test 6 "Add peer with multiple nidranges"
389 local prim_nid="${1:+--prim_nid $1}"
390 local nid="${2:+--nid $2}"
392 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
394 do_lnetctl peer del ${prim_nid} ${nid} || error "peer del failed $?"
395 $LNETCTL export --backup > $actual || error "export failed $?"
401 reinit_dlc || return $?
402 create_base_yaml_file
404 echo "Delete peer with single nid (tcp)"
405 do_lnetctl peer add --prim_nid 7.7.7.7@tcp || error "Peer add failed $?"
406 compare_peer_del "7.7.7.7@tcp"
408 echo "Delete peer with single nid (o2ib)"
409 do_lnetctl peer add --prim_nid 7.7.7.7@o2ib || error "Peer add failed $?"
410 compare_peer_del "7.7.7.7@o2ib"
412 echo "Delete peer that has multiple nids (tcp)"
413 do_lnetctl peer add --prim_nid 7.7.7.7@tcp --nid 7.7.7.[8-12]@tcp ||
414 error "Peer add failed $?"
415 compare_peer_del "7.7.7.7@tcp"
417 echo "Delete peer that has multiple nids (o2ib)"
418 do_lnetctl peer add --prim_nid 7.7.7.7@o2ib --nid 7.7.7.[8-12]@o2ib ||
419 error "Peer add failed $?"
420 compare_peer_del "7.7.7.7@o2ib"
422 echo "Delete peer that has both tcp and o2ib nids"
423 do_lnetctl peer add --prim_nid 7.7.7.7@tcp \
424 --nid 7.7.7.[9-12]@tcp,7.7.7.[13-15]@o2ib ||
425 error "Peer add failed $?"
426 compare_peer_del "7.7.7.7@tcp"
428 echo "Delete peer with single nid (gni)"
429 do_lnetctl peer add --prim_nid 7@gni || error "Peer add failed $?"
430 compare_peer_del "7@gni"
432 echo "Delete peer that has multiple nids (gni)"
433 do_lnetctl peer add --prim_nid 7@gni --nid [8-12]@gni ||
434 error "Peer add failed $?"
435 compare_peer_del "7@gni"
437 echo "Delete peer with single nid (kfi)"
438 do_lnetctl peer add --prim_nid 7@kfi || error "Peer add failed $?"
439 compare_peer_del "7@kfi"
441 echo "Delete peer that has multiple nids (kfi)"
442 do_lnetctl peer add --prim_nid 7@kfi --nid [8-12]@kfi ||
443 error "Peer add failed $?"
444 compare_peer_del "7@kfi"
446 echo "Delete peer that has tcp, o2ib, gni and kfi nids"
447 do_lnetctl peer add --prim_nid 7@gni \
448 --nid [8-12]@gni,7.7.7.[1-4]@tcp,7.7.7.[5-9]@o2ib,[1-5]@kfi ||
449 error "Peer add failed $?"
450 compare_peer_del "7@gni"
452 run_test 7 "Various peer delete tests"
455 reinit_dlc || return $?
457 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
459 - primary nid: 8.8.8.8@tcp
471 do_lnetctl peer add --prim_nid 8.8.8.8@tcp --nid 8.8.8.[10-15]@tcp ||
472 error "Peer add failed $?"
473 compare_peer_del "8.8.8.8@tcp" "8.8.8.13@tcp"
475 run_test 8 "Delete single secondary nid from peer (tcp)"
478 reinit_dlc || return $?
480 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
482 - primary nid: 9.9.9.9@tcp
489 do_lnetctl peer add --prim_nid 9.9.9.9@tcp \
490 --nid 9.9.9.[11-16]@tcp || error "Peer add failed $?"
491 compare_peer_del "9.9.9.9@tcp" "9.9.9.[11-16]@tcp"
493 run_test 9 "Delete all secondary nids from peer (tcp)"
496 reinit_dlc || return $?
498 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
500 - primary nid: 10.10.10.10@tcp
503 - nid: 10.10.10.10@tcp
504 - nid: 10.10.10.12@tcp
505 - nid: 10.10.10.13@tcp
506 - nid: 10.10.10.15@tcp
507 - nid: 10.10.10.16@tcp
510 do_lnetctl peer add --prim_nid 10.10.10.10@tcp \
511 --nid 10.10.10.[12-16]@tcp || error "Peer add failed $?"
512 compare_peer_del "10.10.10.10@tcp" "10.10.10.14@tcp"
514 run_test 10 "Delete single secondary nid from peer (o2ib)"
517 reinit_dlc || return $?
519 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
521 - primary nid: 11.11.11.11@tcp
524 - nid: 11.11.11.11@tcp
527 do_lnetctl peer add --prim_nid 11.11.11.11@tcp \
528 --nid 11.11.11.[13-17]@tcp || error "Peer add failed $?"
529 compare_peer_del "11.11.11.11@tcp" "11.11.11.[13-17]@tcp"
531 run_test 11 "Delete all secondary nids from peer (o2ib)"
534 reinit_dlc || return $?
536 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
538 - primary nid: 12.12.12.12@o2ib
541 - nid: 12.12.12.12@o2ib
542 - nid: 13.13.13.13@o2ib
543 - nid: 14.13.13.13@o2ib
544 - nid: 14.15.13.13@o2ib
546 - nid: 15.17.1.10@tcp
547 - nid: 15.17.1.20@tcp
550 do_lnetctl peer add --prim_nid 12.12.12.12@o2ib \
551 --nid [13-14/1].[13-15/2].13.13@o2ib,[15-16/3].[17-19/4].[1].[5-20/5]@tcp ||
552 error "Peer add failed $?"
553 compare_peer_del "12.12.12.12@o2ib" "13.15.13.13@o2ib,15.17.1.15@tcp"
555 run_test 12 "Delete a secondary nid from peer (tcp and o2ib)"
558 reinit_dlc || return $?
560 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
562 - primary nid: 13.13.13.13@o2ib
565 - nid: 13.13.13.13@o2ib
568 do_lnetctl peer add --prim_nid 13.13.13.13@o2ib \
569 --nid [14-15].[1-2/1].[1].[100-254/10]@tcp,14.14.[254].14@o2ib ||
570 error "Peer add failed $?"
571 compare_peer_del "13.13.13.13@o2ib" \
572 "[14-15].[1-2/1].[1].[100-254/10]@tcp,14.14.[254].14@o2ib"
574 run_test 13 "Delete all secondary nids from peer (tcp and o2ib)"
580 if [[ $net =~ gni* ]] || [[ $net =~ kfi* ]]; then
583 echo "${num}.${num}.${num}.${num}@${net}"
587 create_mr_peer_yaml() {
589 local secondary_nids="$2"
592 echo "Generating peer yaml for $num_peers peers with $secondary_nids secondary nids"
593 echo "peer:" >> $TMP/sanity-lnet-$testnum-expected.yaml
595 local total_nids=$((num_peers + $((num_peers * secondary_nids))))
598 while [[ $created -lt $num_peers ]]; do
599 local primary=$(create_nid ${nidnum} ${net})
600 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
601 - primary nid: $primary
607 local start=$((nidnum + 1))
608 local end=$((nidnum + $secondary_nids))
609 for j in $(seq ${start} ${end}); do
610 local nid=$(create_nid $j ${net})
611 echo " - nid: $nid" >> $TMP/sanity-lnet-$testnum-expected.yaml
619 reinit_dlc || return $?
621 echo "Create single peer, single nid, using import"
622 create_mr_peer_yaml 1 0 tcp
623 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
624 error "Import failed $?"
626 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
629 echo "Delete single peer using import --del"
630 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
631 error "Import failed $?"
632 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
633 create_base_yaml_file
634 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
637 run_test 14 "import peer create/delete with single nid"
640 reinit_dlc || return $?
642 echo "Create multiple peers, single nid per peer, using import"
643 create_mr_peer_yaml 5 0 o2ib
644 # The ordering of nids for this use-case is non-deterministic, so we
645 # we can't just diff the expected/actual output.
646 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
647 error "Import failed $?"
648 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
649 validate_peer_nids 5 0
651 echo "Delete multiple peers, single nid per peer, using import --del"
652 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
653 error "Import failed $?"
654 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
655 create_base_yaml_file
656 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
659 run_test 15 "import multi peer create/delete with single nid per peer"
662 reinit_dlc || return $?
664 echo "Create single peer, multiple nids, using import"
665 create_mr_peer_yaml 1 5 tcp
666 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
667 error "Import failed $?"
668 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
669 validate_peer_nids 1 5
671 echo "Delete single peer, multiple nids, using import --del"
672 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
673 error "Import failed $?"
674 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
675 create_base_yaml_file
676 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
679 run_test 16 "import peer create/delete with multiple nids"
682 reinit_dlc || return $?
684 echo "Create multiple peers, multiple nids per peer, using import"
685 create_mr_peer_yaml 5 7 o2ib
686 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
687 error "Import failed $?"
688 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
689 validate_peer_nids 5 7
691 echo "Delete multiple peers, multiple nids per peer, using import --del"
692 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
693 error "Import failed $?"
694 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
695 create_base_yaml_file
696 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
699 run_test 17 "import multi peer create/delete with multiple nids"
702 reinit_dlc || return $?
704 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
706 - primary nid: 1.1.1.1@tcp
715 echo "Import peer with 5 nids"
716 cat $TMP/sanity-lnet-$testnum-expected.yaml
717 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
718 error "Import failed $?"
719 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
721 - primary nid: 1.1.1.1@tcp
728 echo "Delete three of the nids"
729 cat $TMP/sanity-lnet-$testnum-expected.yaml
730 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml
731 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
733 - primary nid: 1.1.1.1@tcp
739 echo "Check peer has expected nids remaining"
740 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
744 run_test 18a "Delete a subset of nids from a single peer using import --del"
747 reinit_dlc || return $?
749 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
751 - primary nid: 1.1.1.1@tcp
759 - primary nid: 6.6.6.6@o2ib
768 echo "Import two peers with 5 nids each"
769 cat $TMP/sanity-lnet-$testnum-expected.yaml
770 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
771 error "Import failed $?"
772 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
774 - primary nid: 1.1.1.1@tcp
780 - primary nid: 6.6.6.6@o2ib
787 echo "Delete three of the nids from each peer"
788 cat $TMP/sanity-lnet-$testnum-expected.yaml
789 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml
790 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
792 - primary nid: 6.6.6.6@o2ib
797 - primary nid: 1.1.1.1@tcp
804 echo "Check peers have expected nids remaining"
805 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
807 validate_peer_nids 2 1
809 run_test 18b "Delete multiple nids from multiple peers using import --del"
812 reinit_dlc || return $?
813 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
815 - primary nid: 19@gni
821 compare_peer_add "19@gni"
823 run_test 19 "Add peer with single nid (gni)"
826 reinit_dlc || return $?
827 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
829 - primary nid: 20@gni
833 - nid: 20.20.20.20@tcp
834 - nid: 20.20.20.20@o2ib
837 compare_peer_add "20@gni" "20.20.20.20@tcp,20.20.20.20@o2ib"
839 run_test 20 "Add peer with gni primary and tcp, o2ib secondary"
842 reinit_dlc || return $?
843 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
845 - primary nid: 21@gni
855 echo "Add peer with nidrange (gni)"
856 compare_peer_add "21@gni" "[22-25]@gni" || error
857 echo "Add peer with nidrange that overlaps primary nid (gni)"
858 compare_peer_add "21@gni" "[21-25]@gni"
860 run_test 21 "Add peer with nidrange (gni)"
863 reinit_dlc || return $?
864 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
866 - primary nid: 22@gni
877 do_lnetctl peer add --prim_nid 22@gni --nid [24-29]@gni ||
878 error "Peer add failed $?"
879 compare_peer_del "22@gni" "26@gni"
881 run_test 22 "Delete single secondary nid from peer (gni)"
884 reinit_dlc || return $?
885 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
887 - primary nid: 23@gni
894 do_lnetctl peer add --prim_nid 23@gni --nid [25-29]@gni ||
895 error "Peer add failed $?"
896 compare_peer_del "23@gni" "[25-29]@gni"
898 run_test 23 "Delete all secondary nids from peer (gni)"
901 reinit_dlc || return $?
902 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
904 - primary nid: 24@gni
909 - nid: 13.13.13.13@o2ib
910 - nid: 14.13.13.13@o2ib
911 - nid: 14.15.13.13@o2ib
913 - nid: 15.17.1.10@tcp
914 - nid: 15.17.1.20@tcp
917 do_lnetctl peer add --prim_nid 24@gni \
918 --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 ||
919 error "Peer add failed $?"
920 compare_peer_del "24@gni" "5@gni,13.15.13.13@o2ib,15.17.1.15@tcp"
922 run_test 24 "Delete a secondary nid from peer (tcp, o2ib and gni)"
925 reinit_dlc || return $?
926 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
928 - primary nid: 25@gni
934 do_lnetctl peer add --prim_nid 25@gni \
935 --nid [26-27].[4-10/3].26.26@tcp,26.26.26.26@o2ib,[30-35]@gni ||
936 error "Peer add failed $?"
937 compare_peer_del "25@gni" \
938 "[26-27].[4-10/3].26.26@tcp,26.26.26.26@o2ib,[30-35]@gni"
940 run_test 25 "Delete all secondary nids from peer (tcp, gni and o2ib)"
943 reinit_dlc || return $?
945 do_lnetctl peer add --prim_nid 1.1.1.1@tcp --lock_prim ||
946 error "Peer add with --lock_prim option failed $?"
947 local peer_state=$($LNETCTL peer show -v 4 --nid 1.1.1.1@tcp |
948 awk '/peer state/ {print $NF}')
949 # This relies on the following peer state definition:
950 # #define LNET_PEER_LOCK_PRIMARY BIT(20)
951 if ((!("$peer_state" & (1 << 20)))); then
952 error "Peer state does not have 'locked' bit set: $peer_state"
954 do_lnetctl peer del --prim_nid 1.1.1.1@tcp ||
955 error "Peer del failed $?"
956 $LNETCTL peer show --nid 1.1.1.1@tcp | grep -q 1.1.1.1@tcp ||
957 error "1.1.1.1@tcp is not listed"
958 do_lnetctl peer del --prim_nid 1.1.1.1@tcp --force ||
959 error "Peer del --force failed $?"
960 do_lnetctl peer show --nid 1.1.1.1@tcp &&
961 error "failed to delete 1.1.1.1@tcp"
965 run_test 26 "Delete peer with primary nid locked"
968 reinit_dlc || return $?
970 echo "Invalid prim_nid - peer add"
971 do_lnetctl peer add --prim_nid foobar &&
972 error "Command should have failed"
974 echo "Invalid prim_nid - peer del"
975 do_lnetctl peer del --prim_nid foobar &&
976 error "Command should have failed"
978 echo "Delete non-existing peer"
979 do_lnetctl peer del --prim_nid 1.1.1.1@o2ib &&
980 error "Command should have failed"
982 echo "Don't provide mandatory argument for peer del"
983 do_lnetctl peer del --nid 1.1.1.1@tcp &&
984 error "Command should have failed"
986 echo "Don't provide mandatory argument for peer add"
987 do_lnetctl peer add --nid 1.1.1.1@tcp &&
988 error "Command should have failed"
990 echo "Don't provide mandatory arguments peer add"
991 do_lnetctl peer add &&
992 error "Command should have failed"
994 echo "Invalid secondary nids"
995 do_lnetctl peer add --prim_nid 1.1.1.1@tcp --nid foobar &&
996 error "Command should have failed"
998 echo "Exceed max nids per peer"
999 do_lnetctl peer add --prim_nid 1.1.1.1@tcp --nid 1.1.1.[2-255]@tcp &&
1000 error "Command should have failed"
1002 echo "Invalid net type"
1003 do_lnetctl peer add --prim_nid 1@foo &&
1004 error "Command should have failed"
1006 echo "Invalid nid format"
1007 local invalid_nids="1@tcp 1@o2ib 1.1.1.1@gni"
1010 for nid in ${invalid_nids}; do
1011 echo "Check invalid primary nid - '$nid'"
1012 do_lnetctl peer add --prim_nid $nid &&
1013 error "Command should have failed"
1016 local invalid_strs="[2-1]@gni [a-f/x]@gni 256.256.256.256@tcp"
1017 invalid_strs+=" 1.1.1.1.[2-5/f]@tcp 1.]2[.3.4@o2ib"
1018 invalid_strs+="1.[2-4,[5-6],7-8].1.1@tcp foobar"
1021 for nidstr in ${invalid_strs}; do
1022 echo "Check invalid nidstring - '$nidstr'"
1023 do_lnetctl peer add --prim_nid 1.1.1.1@tcp --nid $nidstr &&
1024 error "Command should have failed"
1027 echo "Add non-local gateway"
1028 do_lnetctl route add --net tcp --gateway 1@gni &&
1029 error "Command should have failed"
1033 run_test 99a "Check various invalid inputs to lnetctl peer"
1036 reinit_dlc || return $?
1038 create_base_yaml_file
1040 cat <<EOF > $TMP/sanity-lnet-$testnum-invalid.yaml
1042 - primary nid: 99.99.99.99@tcp
1045 - nid: 99.99.99.99@tcp
1047 do_lnetctl import < $TMP/sanity-lnet-$testnum-invalid.yaml &&
1048 error "import should have failed"
1049 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
1052 run_test 99b "Invalid value for Multi-Rail in yaml import"
1056 local ip=$(ip addr show dev $if | awk '/ inet /{print $2}')
1064 do_lnetctl net add --net ${net} --if ${if} ||
1065 error "Failed to add net ${net} on if ${if}"
1072 do_lnetctl net del --net ${net} --if ${if} ||
1073 error "Failed to del net ${net} on if ${if}"
1076 compare_route_add() {
1080 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
1082 do_lnetctl route add --net ${rnet} --gateway ${gw} ||
1083 error "route add failed $?"
1084 $LNETCTL export --backup > $actual ||
1085 error "export failed $?"
1086 validate_gateway_nids
1090 append_net_tunables() {
1093 $LNETCTL net show -v --net ${net} | grep -v 'dev cpt' |
1094 awk '/^\s+tunables:$/,/^\s+CPT:/' >> $TMP/sanity-lnet-$testnum-expected.yaml
1097 IF0_IP=$(ip -o -4 a s ${INTERFACES[0]} |
1098 awk '{print $4}' | sed 's/\/.*//')
1099 IF0_NET=$(awk -F. '{print $1"."$2"."$3}'<<<"${IF0_IP}")
1100 IF0_HOSTNUM=$(awk -F. '{print $4}'<<<"${IF0_IP}")
1101 if (((IF0_HOSTNUM + 5) > 254)); then
1104 GW_HOSTNUM=$((IF0_HOSTNUM + 1))
1106 GW_NID="${IF0_NET}.${GW_HOSTNUM}@${NETTYPE}"
1108 [[ ${NETTYPE} == tcp* ]] ||
1109 skip "Need tcp NETTYPE"
1110 reinit_dlc || return $?
1111 add_net "${NETTYPE}" "${INTERFACES[0]}"
1112 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
1114 - net type: ${NETTYPE}
1119 append_net_tunables tcp
1120 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
1126 health_sensitivity: 1
1128 - primary nid: ${GW_NID}
1134 compare_route_add "tcp7" "${GW_NID}"
1136 run_test 100 "Add route with single gw (tcp)"
1139 [[ ${NETTYPE} == tcp* ]] ||
1140 skip "Need tcp NETTYPE"
1141 reinit_dlc || return $?
1142 add_net "${NETTYPE}" "${INTERFACES[0]}"
1143 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
1145 - net type: ${NETTYPE}
1150 append_net_tunables tcp
1152 echo "route:" >> $TMP/sanity-lnet-$testnum-expected.yaml
1153 for i in $(seq $GW_HOSTNUM $((GW_HOSTNUM + 4))); do
1154 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
1156 gateway: ${IF0_NET}.${i}@tcp
1159 health_sensitivity: 1
1163 echo "peer:" >> $TMP/sanity-lnet-$testnum-expected.yaml
1164 for i in $(seq $GW_HOSTNUM $((GW_HOSTNUM + 4))); do
1165 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
1166 - primary nid: ${IF0_NET}.${i}@tcp
1169 - nid: ${IF0_NET}.${i}@tcp
1174 local gw="${IF0_NET}.[$GW_HOSTNUM-$((GW_HOSTNUM + 4))]@tcp"
1176 compare_route_add "tcp8" "${gw}"
1178 run_test 101 "Add route with multiple gw (tcp)"
1180 compare_route_del() {
1184 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
1186 do_lnetctl route del --net ${rnet} --gateway ${gw} ||
1187 error "route del failed $?"
1188 $LNETCTL export --backup > $actual ||
1189 error "export failed $?"
1190 validate_gateway_nids
1196 if [[ ${net} =~ (tcp|o2ib)[0-9]* ]]; then
1199 echo "$((${testnum} % 255))@${net}"
1204 reinit_dlc || return $?
1205 add_net "${NETTYPE}" "${INTERFACES[0]}"
1206 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
1208 local gwnid=$(generate_gw_nid ${NETTYPE})
1210 do_lnetctl route add --net ${NETTYPE}2 --gateway ${gwnid} ||
1211 error "route add failed $?"
1212 compare_route_del "${NETTYPE}2" "${gwnid}"
1214 run_test 102 "Delete route with single gw"
1216 IP_NID_EXPR='103.103.103.[103-120/4]'
1217 NUM_NID_EXPR='[103-120/4]'
1219 reinit_dlc || return $?
1220 add_net "${NETTYPE}" "${INTERFACES[0]}"
1221 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
1225 if [[ $NETTYPE =~ (tcp|o2ib)[0-9]* ]]; then
1226 nid_expr="${IF0_NET}.[$GW_HOSTNUM-$((GW_HOSTNUM+5))/2]"
1228 nid_expr="${NUM_NID_EXPR}"
1231 do_lnetctl route add --net ${NETTYPE}103 \
1232 --gateway ${nid_expr}@${NETTYPE} ||
1233 error "route add failed $?"
1234 compare_route_del "${NETTYPE}103" "${nid_expr}@${NETTYPE}"
1236 run_test 103 "Delete route with multiple gw"
1239 local tyaml="$TMP/sanity-lnet-$testnum-expected.yaml"
1241 reinit_dlc || return $?
1243 # Default value is '3'
1244 local val=$($LNETCTL global show | awk '/response_tracking/{print $NF}')
1246 error "Expect 3 found $val"
1248 echo "Set < 0; Should fail"
1249 do_lnetctl set response_tracking -1 &&
1250 error "should have failed $?"
1252 reinit_dlc || return $?
1255 response_tracking: -10
1257 do_lnetctl import < $tyaml &&
1258 error "should have failed $?"
1260 echo "Check valid values; Should succeed"
1262 for ((i = 0; i < 4; i++)); do
1263 reinit_dlc || return $?
1264 do_lnetctl set response_tracking $i ||
1265 error "should have succeeded $?"
1266 $LNETCTL global show | grep -q "response_tracking: $i" ||
1267 error "Failed to set response_tracking to $i"
1268 reinit_dlc || return $?
1271 response_tracking: $i
1273 do_lnetctl import < $tyaml ||
1274 error "should have succeeded $?"
1275 $LNETCTL global show | grep -q "response_tracking: $i" ||
1276 error "Failed to set response_tracking to $i"
1279 reinit_dlc || return $?
1280 echo "Set > 3; Should fail"
1281 do_lnetctl set response_tracking 4 &&
1282 error "should have failed $?"
1284 reinit_dlc || return $?
1287 response_tracking: 10
1289 do_lnetctl import < $tyaml &&
1290 error "should have failed $?"
1293 run_test 104 "Set/check response_tracking param"
1296 reinit_dlc || return $?
1297 add_net "${NETTYPE}" "${INTERFACES[0]}"
1299 local gwnid=$(generate_gw_nid ${NETTYPE})
1301 do_lnetctl route add --net ${NETTYPE}105 --gateway ${gwnid} ||
1302 error "route add failed $?"
1303 do_lnetctl peer add --prim ${gwnid} &&
1304 error "peer add should fail"
1308 run_test 105 "Adding duplicate GW peer should fail"
1311 reinit_dlc || return $?
1312 add_net "${NETTYPE}" "${INTERFACES[0]}"
1314 local gwnid=$(generate_gw_nid ${NETTYPE})
1316 do_lnetctl route add --net ${NETTYPE}106 --gateway ${gwnid} ||
1317 error "route add failed $?"
1318 do_lnetctl peer del --prim ${gwnid} &&
1319 error "peer del should fail"
1323 run_test 106 "Deleting GW peer should fail"
1326 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
1328 cleanup_netns || error "Failed to cleanup netns before test execution"
1329 cleanup_lnet || error "Failed to unload modules before test execution"
1331 setup_fakeif || error "Failed to add fake IF"
1332 have_interface "$FAKE_IF" ||
1333 error "Expect $FAKE_IF configured but not found"
1335 reinit_dlc || return $?
1337 add_net "tcp" "${INTERFACES[0]}" || return $?
1338 add_net "tcp" "$FAKE_IF" || return $?
1340 del_net "tcp" "$FAKE_IF" || return $?
1346 run_test 107 "Deleting extra interface doesn't crash node"
1349 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
1351 cleanup_netns || error "Failed to cleanup netns before test execution"
1352 cleanup_lnet || error "Failed to unload modules before test execution"
1354 setup_fakeif || error "Failed to add fake IF"
1355 have_interface "$FAKE_IF" ||
1356 error "Expect $FAKE_IF configured but not found"
1358 reinit_dlc || return $?
1360 add_net "tcp" "${INTERFACES[0]}" || return $?
1361 $LNETCTL net show > $TMP/sanity-lnet-$testnum-expected.yaml
1362 add_net "tcp" "$FAKE_IF" || return $?
1364 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
1365 - nid: ${FAKE_IP}@tcp
1370 $LNETCTL net show > $TMP/sanity-lnet-$testnum-actual.yaml
1371 compare_yaml_files || error "not all interfaces were setup"
1379 run_test 108 "Check Multi-Rail setup"
1382 [[ ${NETTYPE} == tcp* ]] ||
1383 skip "Need tcp NETTYPE"
1384 cleanup_lnet || exit 1
1385 load_lnet "networks=\"\""
1386 do_ns $LNETCTL lnet configure --all || exit 1
1387 $LNETCTL net show --net tcp | grep -q "nid: ${FAKE_IP}@tcp$"
1389 run_test 200 "load lnet w/o module option, configure in a non-default namespace"
1392 [[ ${NETTYPE} == tcp* ]] ||
1393 skip "Need tcp NETTYPE"
1394 cleanup_lnet || exit 1
1395 load_lnet "networks=tcp($FAKE_IF)"
1396 do_ns $LNETCTL lnet configure --all || exit 1
1397 $LNETCTL net show --net tcp | grep -q "nid: ${FAKE_IP}@tcp$"
1399 run_test 201 "load lnet using networks module options in a non-default namespace"
1402 [[ ${NETTYPE} == tcp* ]] ||
1403 skip "Need tcp NETTYPE"
1404 cleanup_lnet || exit 1
1405 load_lnet "networks=\"\" ip2nets=\"tcp0($FAKE_IF) ${FAKE_IP}\""
1406 do_ns $LNETCTL lnet configure --all || exit 1
1407 $LNETCTL net show | grep -q "nid: ${FAKE_IP}@tcp$"
1409 run_test 202 "load lnet using ip2nets in a non-default namespace"
1412 ### Add the interfaces in the target namespace
1415 [[ ${NETTYPE} == tcp* ]] ||
1416 skip "Need tcp NETTYPE"
1417 cleanup_lnet || exit 1
1419 do_lnetctl lnet configure || exit 1
1420 do_ns $LNETCTL net add --net tcp0 --if $FAKE_IF
1422 run_test 203 "add a network using an interface in the non-default namespace"
1424 LNET_PARAMS_FILE="$TMP/$TESTSUITE.parameters"
1425 function save_lnet_params() {
1426 $LNETCTL global show | egrep -v '^global:$' |
1427 sed 's/://' > $LNET_PARAMS_FILE
1430 function restore_lnet_params() {
1432 while read param value; do
1433 [[ $param == max_intf ]] && continue
1434 [[ $param == lnd_timeout ]] && continue
1435 $LNETCTL set ${param} ${value} ||
1436 error "Failed to restore ${param} to ${value}"
1437 done < $LNET_PARAMS_FILE
1440 function lnet_health_pre() {
1443 # Lower transaction timeout to speed up test execution
1444 $LNETCTL set transaction_timeout 10 ||
1445 error "Failed to set transaction_timeout $?"
1447 RETRY_PARAM=$($LNETCTL global show | awk '/retry_count/{print $NF}')
1448 RSND_PRE=$($LNETCTL stats show | awk '/resend_count/{print $NF}')
1449 LO_HVAL_PRE=$($LNETCTL net show -v 2 | awk '/health value/{print $NF}' |
1450 xargs echo | sed 's/ /+/g' | bc -l)
1452 RMT_HVAL_PRE=$($LNETCTL peer show --nid ${RNIDS[0]} -v 2 2>/dev/null |
1453 awk '/health value/{print $NF}' | xargs echo |
1454 sed 's/ /+/g' | bc -l)
1456 # Might not have any peers so initialize to zero.
1457 RMT_HVAL_PRE=${RMT_HVAL_PRE:-0}
1462 function lnet_health_post() {
1463 RSND_POST=$($LNETCTL stats show | awk '/resend_count/{print $NF}')
1464 LO_HVAL_POST=$($LNETCTL net show -v 2 |
1465 awk '/health value/{print $NF}' |
1466 xargs echo | sed 's/ /+/g' | bc -l)
1468 RMT_HVAL_POST=$($LNETCTL peer show --nid ${RNIDS[0]} -v 2 2>/dev/null |
1469 awk '/health value/{print $NF}' | xargs echo |
1470 sed 's/ /+/g' | bc -l)
1472 # Might not have any peers so initialize to zero.
1473 RMT_HVAL_POST=${RMT_HVAL_POST:-0}
1476 echo "Pre resends: $RSND_PRE" &&
1477 echo "Post resends: $RSND_POST" &&
1478 echo "Resends delta: $((RSND_POST - RSND_PRE))" &&
1479 echo "Pre local health: $LO_HVAL_PRE" &&
1480 echo "Post local health: $LO_HVAL_POST" &&
1481 echo "Pre remote health: $RMT_HVAL_PRE" &&
1482 echo "Post remote health: $RMT_HVAL_POST"
1486 do_lnetctl peer set --health 1000 --all
1487 do_lnetctl net set --health 1000 --all
1492 function check_no_resends() {
1493 echo "Check that no resends took place"
1494 [[ $RSND_POST -ne $RSND_PRE ]] &&
1495 error "Found resends: $RSND_POST != $RSND_PRE"
1500 function check_resends() {
1501 local delta=$((RSND_POST - RSND_PRE))
1503 echo "Check that $RETRY_PARAM resends took place"
1504 [[ $delta -ne $RETRY_PARAM ]] &&
1505 error "Expected $RETRY_PARAM resends found $delta"
1510 function check_no_local_health() {
1511 echo "Check that local NI health is unchanged"
1512 [[ $LO_HVAL_POST -ne $LO_HVAL_PRE ]] &&
1513 error "Local health changed: $LO_HVAL_POST != $LO_HVAL_PRE"
1518 function check_local_health() {
1519 echo "Check that local NI health has been changed"
1520 [[ $LO_HVAL_POST -eq $LO_HVAL_PRE ]] &&
1521 error "Local health unchanged: $LO_HVAL_POST == $LO_HVAL_PRE"
1526 function check_no_remote_health() {
1527 echo "Check that remote NI health is unchanged"
1528 [[ $RMT_HVAL_POST -ne $RMT_HVAL_PRE ]] &&
1529 error "Remote health changed: $RMT_HVAL_POST != $RMT_HVAL_PRE"
1534 function check_remote_health() {
1535 echo "Check that remote NI health has been changed"
1536 [[ $RMT_HVAL_POST -eq $RMT_HVAL_PRE ]] &&
1537 error "Remote health unchanged: $RMT_HVAL_POST == $RMT_HVAL_PRE"
1547 setup_health_test() {
1551 [[ ${NETTYPE} == kfi* ]] && skip "kfi doesn't support drop rules"
1553 local rnodes=$(remote_nodes_list)
1554 [[ -z $rnodes ]] && skip "Need at least 1 remote node"
1556 cleanup_lnet || error "Failed to cleanup before test execution"
1558 # Loading modules should configure LNet with the appropriate
1559 # test-framework configuration
1560 load_lnet "config_on_load=1" || error "Failed to load modules"
1562 LNIDS=( $($LCTL list_nids | xargs echo) )
1564 RNODE=$(awk '{print $1}' <<<$rnodes)
1565 RNIDS=( $(do_node $RNODE $LCTL list_nids | xargs echo) )
1567 if [[ -z ${RNIDS[@]} ]]; then
1568 do_rpc_nodes $RNODE load_lnet "config_on_load=1"
1570 RNIDS=( $(do_node $RNODE $LCTL list_nids | xargs echo) )
1573 [[ ${#LNIDS[@]} -lt 1 ]] &&
1574 error "No NIDs configured for local host $HOSTNAME"
1575 [[ ${#RNIDS[@]} -lt 1 ]] &&
1576 error "No NIDs configured for remote host $RNODE"
1578 # Ensure all peer NIs are local (i.e. non-routed config)
1579 local rnid rnet lnid lnet
1581 for rnid in ${RNIDS[@]}; do
1583 for lnid in ${LNIDS[@]}; do
1585 [[ ${lnet} == ${rnet} ]] &&
1588 [[ ${lnet} != ${rnet} ]] &&
1589 skip "Need non-routed configuration"
1592 do_lnetctl discover ${RNIDS[0]} ||
1593 error "Unable to discover ${RNIDS[0]}"
1595 local mr=$($LNETCTL peer show --nid ${RNIDS[0]} |
1596 awk '/Multi-Rail/{print $NF}')
1598 if ${need_mr} && [[ $mr == False ]]; then
1599 cleanup_health_test || return $?
1603 if ( ! ${need_mr} && [[ ${#RNIDS[@]} -gt 1 ]] ) ||
1604 ( ! ${need_mr} && [[ ${#LNIDS[@]} -gt 1 ]] ); then
1605 cleanup_health_test || return $?
1609 if ${need_mr} && [[ ${#RNIDS[@]} -lt 2 ]]; then
1610 # Add a second, reachable NID to rnode.
1611 local net=${RNIDS[0]}
1615 local if=$(do_rpc_nodes --quiet $RNODE lnet_if_list)
1617 error "Failed to determine interface for $RNODE"
1619 do_rpc_nodes $RNODE "$LNETCTL lnet configure"
1620 do_rpc_nodes $RNODE "$LNETCTL net add --net $net --if $if" ||
1622 if [[ $rc -ne 0 ]]; then
1623 error "Failed to add interface to $RNODE rc=$?"
1625 RNIDS[1]="${RNIDS[0]}1"
1626 NET_DEL_ARGS="--net $net --if $if"
1630 if ${need_mr} && [[ ${#LNIDS[@]} -lt 2 ]]; then
1631 local net=${LNIDS[0]}
1634 do_lnetctl lnet configure &&
1635 do_lnetctl net add --net $net --if ${INTERFACES[0]} ||
1637 if [[ $rc -ne 0 ]]; then
1638 error "Failed to add interface rc=$?"
1640 LNIDS[1]="${LNIDS[0]}1"
1646 $LNETCTL peer show -v 2 | egrep -e nid -e health
1648 $LCTL set_param debug=+net
1654 cleanup_health_test() {
1657 if [[ -n $NET_DEL_ARGS ]]; then
1658 do_rpc_nodes $RNODE \
1659 "$LNETCTL net del $NET_DEL_ARGS" ||
1664 unload_modules || rc=$?
1667 do_rpc_nodes $RNODE unload_modules_local ||
1673 error "Failed cleanup"
1678 add_health_test_drop_rules() {
1679 local args="-m GET -r 1 -e ${1}"
1682 for src in "${LNIDS[@]}"; do
1683 for dst in "${RNIDS[@]}" "${LNIDS[@]}"; do
1684 $LCTL net_drop_add -s $src -d $dst ${args} ||
1685 error "Failed to add drop rule $src $dst $args"
1690 do_lnet_health_ping_test() {
1693 echo "Simulate $hstatus"
1695 lnet_health_pre || return $?
1697 add_health_test_drop_rules ${hstatus}
1698 do_lnetctl ping ${RNIDS[0]} &&
1699 error "Should have failed"
1703 $LCTL net_drop_del -a
1708 # See lnet/lnet/lib-msg.c:lnet_health_check()
1709 LNET_LOCAL_RESEND_STATUSES="local_interrupt local_dropped local_aborted"
1710 LNET_LOCAL_RESEND_STATUSES+=" local_no_route local_timeout"
1711 LNET_LOCAL_NO_RESEND_STATUSES="local_error"
1713 setup_health_test false || return $?
1716 for hstatus in ${LNET_LOCAL_RESEND_STATUSES} \
1717 ${LNET_LOCAL_NO_RESEND_STATUSES}; do
1718 do_lnet_health_ping_test "${hstatus}" || return $?
1719 check_no_resends || return $?
1720 check_no_local_health || return $?
1723 cleanup_health_test || return $?
1727 run_test 204 "Check no health or resends for single-rail local failures"
1730 (( $MDS1_VERSION >= $(version_code 2.14.58) )) ||
1731 skip "need at least 2.14.58"
1733 setup_health_test true || return $?
1736 for hstatus in ${LNET_LOCAL_RESEND_STATUSES}; do
1737 do_lnet_health_ping_test "${hstatus}" || return $?
1738 check_resends || return $?
1739 check_local_health || return $?
1742 for hstatus in ${LNET_LOCAL_NO_RESEND_STATUSES}; do
1743 do_lnet_health_ping_test "${hstatus}" || return $?
1744 check_no_resends || return $?
1745 check_local_health || return $?
1748 cleanup_health_test || return $?
1752 run_test 205 "Check health and resends for multi-rail local failures"
1754 # See lnet/lnet/lib-msg.c:lnet_health_check()
1755 LNET_REMOTE_RESEND_STATUSES="remote_dropped"
1756 LNET_REMOTE_NO_RESEND_STATUSES="remote_error remote_timeout"
1758 setup_health_test false || return $?
1761 for hstatus in ${LNET_REMOTE_RESEND_STATUSES} \
1762 ${LNET_REMOTE_NO_RESEND_STATUSES}; do
1763 do_lnet_health_ping_test "${hstatus}" || return $?
1764 check_no_resends || return $?
1765 check_no_local_health || return $?
1766 check_no_remote_health || return $?
1769 cleanup_health_test || return $?
1773 run_test 206 "Check no health or resends for single-rail remote failures"
1776 (( $MDS1_VERSION >= $(version_code 2.14.58) )) ||
1777 skip "need at least 2.14.58"
1779 setup_health_test true || return $?
1782 for hstatus in ${LNET_REMOTE_RESEND_STATUSES}; do
1783 do_lnet_health_ping_test "${hstatus}" || return $?
1784 check_resends || return $?
1785 check_no_local_health || return $?
1786 check_remote_health || return $?
1787 do_lnetctl peer set --health 1000 --all ||
1788 error "Unable to reset health rc=$?"
1790 for hstatus in ${LNET_REMOTE_NO_RESEND_STATUSES}; do
1791 do_lnet_health_ping_test "${hstatus}" || return $?
1792 check_no_resends || return $?
1793 check_no_local_health || return $?
1794 check_remote_health || return $?
1795 do_lnetctl peer set --health 1000 --all ||
1796 error "Unable to reset health rc=$?"
1799 cleanup_health_test || return $?
1803 run_test 207 "Check health and resends for multi-rail remote errors"
1805 test_208_load_and_check_lnet() {
1809 local num_expected=1
1811 load_lnet "networks=\"\" ip2nets=\"${ip2nets_str}\""
1814 error "Failed to load LNet with ip2nets \"${ip2nets_str}\""
1820 nids=( $($LCTL list_nids) )
1822 [[ ${#nids[@]} -ne ${num_expected} ]] &&
1823 error "Expect ${num_expected} NIDs found ${#nids[@]}"
1825 [[ ${nids[0]} == ${p_nid} ]] ||
1826 error "Expect NID \"${p_nid}\" found \"${nids[0]}\""
1828 [[ -n $s_nid ]] && [[ ${nids[1]} != ${s_nid} ]] &&
1829 error "Expect second NID \"${s_nid}\" found \"${nids[1]}\""
1831 $LCTL net down &>/dev/null
1836 [[ ${NETTYPE} == tcp* ]] ||
1837 skip "Need tcp NETTYPE"
1839 cleanup_netns || error "Failed to cleanup netns before test execution"
1840 cleanup_lnet || error "Failed to unload modules before test execution"
1841 setup_fakeif || error "Failed to add fake IF"
1843 have_interface "$FAKE_IF" ||
1844 error "Expect $FAKE_IF configured but not found"
1846 local if0_ip=$(ip --oneline addr show dev ${INTERFACES[0]} |
1847 awk '/inet /{print $4}' |
1849 if0_ip=($(echo "${if0_ip[@]}" | tr ' ' '\n' | uniq | tr '\n' ' '))
1850 local ip2nets_str="tcp(${INTERFACES[0]}) $if0_ip"
1852 echo "Configure single NID \"$ip2nets_str\""
1853 test_208_load_and_check_lnet "${ip2nets_str}" "${if0_ip}@tcp"
1855 ip2nets_str="tcp(${INTERFACES[0]}) $if0_ip; tcp1($FAKE_IF) $FAKE_IP"
1856 echo "Configure two NIDs; two NETs \"$ip2nets_str\""
1857 test_208_load_and_check_lnet "${ip2nets_str}" "${if0_ip}@tcp" \
1860 ip2nets_str="tcp(${INTERFACES[0]}) $if0_ip; tcp($FAKE_IF) $FAKE_IP"
1861 echo "Configure two NIDs; one NET \"$ip2nets_str\""
1862 test_208_load_and_check_lnet "${ip2nets_str}" "${if0_ip}@tcp" \
1864 local addr1=( ${if0_ip//./ } )
1865 local addr2=( ${FAKE_IP//./ } )
1866 local range="[${addr1[0]},${addr2[0]}]"
1869 for i in $(seq 1 3); do
1870 range+=".[${addr1[$i]},${addr2[$i]}]"
1872 ip2nets_str="tcp(${INTERFACES[0]},${FAKE_IF}) ${range}"
1874 echo "Configured two NIDs; one NET alt syntax \"$ip2nets_str\""
1875 test_208_load_and_check_lnet "${ip2nets_str}" "${if0_ip}@tcp" \
1880 echo "alt syntax with missing IF \"$ip2nets_str\""
1881 load_lnet "networks=\"\" ip2nets=\"${ip2nets_str}\""
1883 echo "$LCTL net up should fail"
1885 error "LNet bring up should have failed"
1889 run_test 208 "Test various kernel ip2nets configurations"
1892 (( $MDS1_VERSION >= $(version_code 2.14.58) )) ||
1893 skip "need at least 2.14.58"
1895 setup_health_test false || return $?
1897 echo "Simulate network_timeout w/SR config"
1900 add_health_test_drop_rules network_timeout
1902 do_lnetctl discover ${RNIDS[0]} &&
1903 error "Should have failed"
1907 check_no_resends || return $?
1908 check_no_local_health || return $?
1909 check_no_remote_health || return $?
1911 cleanup_health_test || return $?
1913 setup_health_test true || return $?
1915 echo "Simulate network_timeout w/MR config"
1919 add_health_test_drop_rules network_timeout
1921 do_lnetctl discover ${RNIDS[0]} &&
1922 error "Should have failed"
1926 check_no_resends || return $?
1927 check_local_health || return $?
1928 check_remote_health || return $?
1930 cleanup_health_test || return $?
1934 run_test 209 "Check health, but not resends, for network timeout"
1936 check_nid_in_recovq() {
1940 local max_wait="${4:-10}"
1944 echo "$queue recovery queue should be empty" ||
1945 echo "$queue recovery queue should have $nid"
1947 wait_update $HOSTNAME \
1948 "$LNETCTL debug recovery $queue | \
1949 grep -wc \"nid-0: $nid\"" \
1950 "$expect" "$max_wait"
1952 do_lnetctl debug recovery $queue
1954 error "Expect $expect NIDs in recovery."
1959 # First ping is sent at time 0.
1960 # 2nd at 0 + 2^1 = 2
1961 # 3rd at 2 + 2^2 = 6
1962 # 4th at 6 + 2^3 = 14
1963 # 5th at 14 + 2^4 = 30
1964 # e.g. after 10 seconds we would expect 3 pings to have been sent, and the
1965 # NI will have been enqueued for the 4th ping.
1967 # If the recovery limit is 10 seconds, then after the 4th ping is sent
1968 # we expect the peer NI to have aged out, so it will not actually be
1969 # queued for a 5th ping.
1970 # If max_recovery_ping_interval is set to 4 then:
1971 # First ping is sent at time 0
1972 # 2nd at 0 + min(2^1, 4) = 2
1973 # 3rd at 2 + min(2^2, 4) = 6
1974 # 4th at 6 + min(2^3, 4) = 10
1975 # 5th at 10 + min(2^4, 4) = 14
1976 # 6th at 14 + min(2^5, 4) = 18
1977 # 7th at 18 + min(2^6, 4) = 22
1978 # e.g. after 4 seconds we would expect 2 pings to have been sent, and
1979 # after 13 seconds we would expect 4 pings to have been sent
1980 check_ping_count() {
1986 echo "Check ping counts:"
1989 if [[ $queue == "ni" ]]; then
1990 wait_update $HOSTNAME \
1991 "$LNETCTL net show -v 2 | \
1992 grep -e $nid -e ping_count | grep -wA1 $nid | \
1993 awk '/ping_count/{print \\\$NF}'" "$expect" "$max_wait"
1995 $LNETCTL net show -v 2 | grep -e $nid -e ping_count
1996 elif [[ $queue == peer_ni ]]; then
1997 wait_update $HOSTNAME \
1998 "$LNETCTL peer show -v 2 --nid $nid | \
2000 grep -e $nid -e ping_count | grep -wA1 $nid | \
2001 awk '/ping_count/{print \\\$NF}'" "$expect" "$max_wait"
2003 $LNETCTL peer show -v 2 --nid $nid | grep -v primary |
2004 grep -e $nid -e ping_count
2006 error "Unrecognized queue \"$queue\""
2010 ((rc == 0)) || error "Unexpected ping count"
2016 [[ ${NETTYPE} == kfi* ]] && skip "kfi doesn't support drop rules"
2018 reinit_dlc || return $?
2019 add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
2020 add_net "${NETTYPE}1" "${INTERFACES[0]}" || return $?
2022 local prim_nid=$($LCTL list_nids | head -n 1)
2024 do_lnetctl discover $prim_nid ||
2025 error "failed to discover myself"
2027 local default=$($LNETCTL global show |
2028 awk '/recovery_limit/{print $NF}')
2029 # Set recovery limit to 10 seconds.
2030 do_lnetctl set recovery_limit 10 ||
2031 error "failed to set recovery_limit"
2033 $LCTL set_param debug=+net
2034 $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -m GET -r 1 -e local_error
2035 $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -m GET -r 1 -e local_error
2036 $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -r 1
2037 $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -r 1
2038 do_lnetctl net set --health 0 --nid $prim_nid
2040 check_ping_count "ni" "$prim_nid" "2" "10"
2041 check_nid_in_recovq "-l" "$prim_nid" "1"
2043 check_ping_count "ni" "$prim_nid" "3" "10"
2044 check_nid_in_recovq "-l" "$prim_nid" "1"
2046 $LCTL net_drop_del -a
2048 reinit_dlc || return $?
2049 add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
2050 add_net "${NETTYPE}1" "${INTERFACES[0]}" || return $?
2052 local prim_nid=$($LCTL list_nids | head -n 1)
2054 do_lnetctl discover $prim_nid ||
2055 error "failed to discover myself"
2057 do_lnetctl set recovery_limit $default ||
2058 error "failed to set recovery_limit"
2060 default=$($LNETCTL global show |
2061 awk '/max_recovery_ping_interval/{print $NF}')
2062 do_lnetctl set max_recovery_ping_interval 4 ||
2063 error "failed to set max_recovery_ping_interval"
2065 $LCTL set_param debug=+net
2066 $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -m GET -r 1 -e local_error
2067 $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -m GET -r 1 -e local_error
2068 $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -r 1
2069 $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -r 1
2070 do_lnetctl net set --health 0 --nid $prim_nid
2072 check_ping_count "ni" "$prim_nid" "2" "10"
2073 check_nid_in_recovq "-l" "$prim_nid" "1"
2075 check_ping_count "ni" "$prim_nid" "4" "10"
2076 check_nid_in_recovq "-l" "$prim_nid" "1"
2078 $LCTL net_drop_del -a
2080 do_lnetctl set max_recovery_ping_interval $default ||
2081 error "failed to set max_recovery_ping_interval"
2085 run_test 210 "Local NI recovery checks"
2088 [[ ${NETTYPE} == kfi* ]] && skip "kfi doesn't support drop rules"
2090 reinit_dlc || return $?
2091 add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
2092 add_net "${NETTYPE}1" "${INTERFACES[0]}" || return $?
2094 local prim_nid=$($LCTL list_nids | head -n 1)
2096 do_lnetctl discover $prim_nid ||
2097 error "failed to discover myself"
2099 local default=$($LNETCTL global show |
2100 awk '/recovery_limit/{print $NF}')
2101 # Set recovery limit to 10 seconds.
2102 do_lnetctl set recovery_limit 10 ||
2103 error "failed to set recovery_limit"
2105 $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -m GET -r 1 -e remote_error
2106 $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -m GET -r 1 -e remote_error
2107 $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -r 1
2108 $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -r 1
2110 # Set health to 0 on one interface. This forces it onto the recovery
2112 do_lnetctl peer set --nid $prim_nid --health 0
2114 check_nid_in_recovq "-p" "$prim_nid" "1"
2116 # The peer should age out in 10-20 seconds
2117 check_nid_in_recovq "-p" "$prim_nid" "0" "20"
2118 # Ping count should reset to 0 when peer ages out
2119 check_ping_count "peer_ni" "$prim_nid" "0"
2121 $LCTL net_drop_del -a
2123 # Set health to force it back onto the recovery queue. Set to 500 means
2124 # in ~5 seconds it should be back at maximum value.
2125 # NB: we reset the recovery limit to 0 (indefinite) so the peer NI is
2127 do_lnetctl set recovery_limit 0 ||
2128 error "failed to set recovery_limit"
2130 do_lnetctl peer set --nid $prim_nid --health 500
2132 check_nid_in_recovq "-p" "$prim_nid" "1"
2133 check_nid_in_recovq "-p" "$prim_nid" "0" "20"
2135 reinit_dlc || return $?
2136 add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
2137 add_net "${NETTYPE}1" "${INTERFACES[0]}" || return $?
2139 local prim_nid=$($LCTL list_nids | head -n 1)
2141 do_lnetctl discover $prim_nid ||
2142 error "failed to discover myself"
2144 do_lnetctl set recovery_limit $default ||
2145 error "failed to set recovery_limit"
2147 default=$($LNETCTL global show |
2148 awk '/max_recovery_ping_interval/{print $NF}')
2149 do_lnetctl set max_recovery_ping_interval 4 ||
2150 error "failed to set max_recovery_ping_interval"
2152 $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -m GET -r 1 -e remote_error
2153 $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -m GET -r 1 -e remote_error
2154 $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -r 1
2155 $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -r 1
2157 # Set health to 0 on one interface. This forces it onto the recovery
2159 do_lnetctl peer set --nid $prim_nid --health 0
2161 check_ping_count "peer_ni" "$prim_nid" "1" "4"
2162 check_nid_in_recovq "-p" "$prim_nid" "1"
2164 # After we detect the 1st ping above, the 4th ping should be sent after
2166 check_ping_count "peer_ni" "$prim_nid" "4" "14"
2167 check_nid_in_recovq "-p" "$prim_nid" "1"
2169 $LCTL net_drop_del -a
2171 do_lnetctl set max_recovery_ping_interval $default ||
2172 error "failed to set max_recovery_ping_interval"
2176 run_test 211 "Remote NI recovery checks"
2179 [[ ${NETTYPE} == kfi* ]] && skip "kfi doesn't support drop rules"
2181 local rnodes=$(remote_nodes_list)
2182 [[ -z $rnodes ]] && skip "Need at least 1 remote node"
2184 cleanup_lnet || error "Failed to cleanup before test execution"
2186 # Loading modules should configure LNet with the appropriate
2187 # test-framework configuration
2188 load_lnet "config_on_load=1" || error "Failed to load modules"
2190 local my_nid=$($LCTL list_nids | head -n 1)
2192 error "Failed to get primary NID for local host $HOSTNAME"
2194 local rnode=$(awk '{print $1}' <<<$rnodes)
2195 local rnodenids=$(do_node $rnode $LCTL list_nids | xargs echo)
2198 if [[ -z $rnodenids ]]; then
2199 do_rpc_nodes $rnode load_lnet "config_on_load=1"
2201 rnodenids=$(do_node $rnode $LCTL list_nids | xargs echo)
2204 local rnodepnid=$(awk '{print $1}' <<< $rnodenids)
2206 [[ -z $rnodepnid ]] &&
2207 error "Failed to get primary NID for remote host $rnode"
2209 log "Initial discovery"
2210 do_lnetctl discover --force $rnodepnid ||
2211 error "Failed to discover $rnodepnid"
2213 do_node $rnode "$LNETCTL discover --force $my_nid" ||
2214 error "$rnode failed to discover $my_nid"
2216 log "Fail local discover ping to set LNET_PEER_REDISCOVER flag"
2217 $LCTL net_drop_add -s "*@$NETTYPE" -d "*@$NETTYPE" -r 1 -e local_error
2218 do_lnetctl discover --force $rnodepnid &&
2219 error "Discovery should have failed"
2220 $LCTL net_drop_del -a
2223 for nid in $rnodenids; do
2224 # We need GET (PING) delay just long enough so we can trigger
2225 # discovery on the remote peer
2226 $LCTL net_delay_add -s "*@$NETTYPE" -d $nid -r 1 -m GET -l 3
2227 $LCTL net_drop_add -s "*@$NETTYPE" -d $nid -r 1 -m GET -e local_error
2228 # We need PUT (PUSH) delay just long enough so we can process
2230 $LCTL net_delay_add -s "*@$NETTYPE" -d $nid -r 1 -m PUT -l 6
2233 log "Force $HOSTNAME to discover $rnodepnid (in background)"
2234 # We want to get a PING sent that we know will eventually fail.
2235 # The delay rules we added will ensure the ping is not sent until
2236 # the PUSH is also in flight (see below), and the drop rule ensures that
2237 # when the PING is eventually sent it will error out
2238 do_lnetctl discover --force $rnodepnid &
2241 # We want a discovery PUSH from rnode to put rnode back on our
2242 # discovery queue. This should cause us to try and send a PUSH to rnode
2243 # while the PING is still outstanding.
2244 log "Force $rnode to discover $my_nid"
2245 do_node $rnode $LNETCTL discover --force $my_nid
2247 # At this point we'll have both PING_SENT and PUSH_SENT set for the
2248 # rnode peer. Wait for the PING to error out which should terminate the
2249 # discovery process that we backgrounded.
2250 log "Wait for $pid1"
2252 log "Finished wait on $pid1"
2254 # The PING send failure clears the PING_SENT flag and puts the peer back
2255 # on the discovery queue. When discovery thread processes the peer it
2256 # will mistakenly clear the PUSH_SENT flag (and set PUSH_FAILED).
2257 # Discovery will then complete for this peer even though we have an
2259 # When PUSH is actually unlinked it will be forced back onto the
2260 # discovery queue, but we no longer have a ref on the peer. When
2261 # discovery completes again, we'll trip the ASSERT in
2262 # lnet_destroy_peer_locked()
2264 # Delete the delay rules to send the PUSH
2265 $LCTL net_delay_del -a
2266 # Delete the drop rules
2267 $LCTL net_drop_del -a
2270 error "Failed to unload modules"
2272 do_rpc_nodes $rnode unload_modules_local ||
2273 error "Failed to unload modules on $rnode"
2278 run_test 212 "Check discovery refcount loss bug (LU-14627)"
2281 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
2283 cleanup_netns || error "Failed to cleanup netns before test execution"
2284 cleanup_lnet || error "Failed to unload modules before test execution"
2286 setup_fakeif || error "Failed to add fake IF"
2287 have_interface "$FAKE_IF" ||
2288 error "Expect $FAKE_IF configured but not found"
2290 reinit_dlc || return $?
2292 add_net "tcp" "${INTERFACES[0]}" || return $?
2293 add_net "tcp" "$FAKE_IF" || return $?
2295 local nid1=$(lctl list_nids | head -n 1)
2296 local nid2=$(lctl list_nids | tail --lines 1)
2298 [[ $(lctl which_nid $nid1 $nid2) == $nid1 ]] ||
2299 error "Expect nid1 \"$nid1\" to be preferred"
2301 [[ $(lctl which_nid $nid2 $nid1) == $nid2 ]] ||
2302 error "Expect nid2 \"$nid2\" to be preferred"
2306 run_test 213 "Check LNetDist calculation for multiple local NIDs"
2308 function check_ni_status() {
2312 local status=$($LNETCTL net show |
2314 awk '/status/{print $NF}')
2316 echo "NI ${nid} expect status \"${expect}\" found \"${status}\""
2317 if [[ $status != $expect ]]; then
2318 error "Error: Expect NI status \"$expect\" for NID \"$nid\" but found \"$status\""
2325 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
2327 cleanup_netns || error "Failed to cleanup netns before test execution"
2328 cleanup_lnet || error "Failed to unload modules before test execution"
2330 setup_fakeif || error "Failed to add fake IF"
2331 have_interface "$FAKE_IF" ||
2332 error "Expect $FAKE_IF configured but not found"
2334 reinit_dlc || return $?
2336 add_net "tcp" "${INTERFACES[0]}" || return $?
2337 add_net "tcp" "$FAKE_IF" || return $?
2339 local nid1=$(lctl list_nids | head -n 1)
2340 local nid2=$(lctl list_nids | tail --lines 1)
2342 check_ni_status "0@lo" up
2343 check_ni_status "$nid1" up
2344 check_ni_status "$nid2" up
2346 do_lnetctl ping --source $nid2 $nid1 ||
2347 error "$LNETCTL ping --source $nid2 $nid1 failed"
2349 echo "Set $FAKE_IF down"
2350 echo "ip link set dev $FAKE_IF down"
2351 ip link set dev $FAKE_IF down
2352 check_ni_status "0@lo" up
2353 check_ni_status "$nid1" up
2354 check_ni_status "$nid2" down
2356 run_test 214 "Check local NI status when link is downed"
2362 $LNETCTL net show -v 2 |
2363 egrep -e nid -e $stat |
2365 awk '/'$stat':/{print $NF}'
2370 for nidvar in nid1 nid2; do
2371 for stat in send_count recv_count; do
2372 s=$(get_ni_stat ${!nidvar} $stat)
2373 eval ${nidvar}_pre_${stat}=$s
2380 for nidvar in nid1 nid2; do
2381 for stat in send_count recv_count; do
2382 s=$(get_ni_stat ${!nidvar} $stat)
2383 eval ${nidvar}_post_${stat}=$s
2393 eval pre=\${${nidvar}_pre_${stat}}
2394 eval post=\${${nidvar}_post_${stat}}
2396 echo "${!nidvar} pre ${stat} $pre post ${stat} $post"
2398 [[ $pre -ne $post ]]
2402 cleanup_netns || error "Failed to cleanup netns before test execution"
2403 cleanup_lnet || error "Failed to unload modules before test execution"
2405 reinit_dlc || return $?
2407 add_net "${NETTYPE}1" "${INTERFACES[0]}" || return $?
2408 add_net "${NETTYPE}2" "${INTERFACES[0]}" || return $?
2410 local nid1=$($LCTL list_nids | head -n 1)
2411 local nid2=$($LCTL list_nids | tail --lines 1)
2413 do_lnetctl peer add --prim $nid1 --nid $nid2 ||
2414 error "Failed to add peer"
2418 for nidvarA in nid1 nid2; do
2421 for nidvarB in nid1 nid2; do
2422 [[ $nidvarA == $nidvarB ]] && continue
2426 echo "$LNETCTL ping $dst x $npings"
2427 for i in $(seq 1 $npings); do
2428 $LNETCTL ping $dst &>/dev/null ||
2429 error "$LNETCTL ping $dst failed"
2434 # No source specified, sends to either NID should cause
2435 # counts to increase across both NIs
2436 for nidvar in nid1 nid2; do
2437 for stat in send_count recv_count; do
2438 ni_stat_changed $nidvar $stat ||
2439 error "$stat unchanged for ${!nidvar}"
2445 echo "$LNETCTL ping --source $src $dst x $npings"
2446 for i in $(seq 1 $npings); do
2447 $LNETCTL ping --source $src $dst &>/dev/null ||
2448 error "$LNETCTL ping --source $src $dst failed"
2453 # src nid == dest nid means stats for the _other_ NI
2454 # should be unchanged
2455 for nidvar in nid1 nid2; do
2456 for stat in send_count recv_count; do
2457 if [[ ${!nidvar} == $src ]]; then
2458 ni_stat_changed $nidvar $stat ||
2459 error "$stat unchanged for ${!nidvar}"
2461 ni_stat_changed $nidvar $stat &&
2462 error "$stat changed for ${!nidvar}"
2467 # Double number of pings for next iteration because the net
2468 # sequence numbers will have diverged
2469 npings=$(($npings * 2))
2472 # Ping from nid1 to nid2 should fail
2473 do_lnetctl ping --source $nid1 $nid2 &&
2474 error "ping from $nid1 to $nid2 should fail"
2476 # Ping from nid2 to nid1 should fail
2477 do_lnetctl ping --source $nid2 $nid1 &&
2478 error "ping from $nid2 to $nid1 should fail"
2482 run_test 215 "Test lnetctl ping --source option"
2485 [[ ${NETTYPE} == kfi* ]] && skip "kfi doesn't support drop rules"
2489 reinit_dlc || return $?
2491 add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
2492 add_net "${NETTYPE}1" "${INTERFACES[0]}" || return $?
2494 local nids=( $($LCTL list_nids | xargs echo) )
2496 do_lnetctl discover ${nids[0]} ||
2497 error "Initial discovery failed"
2499 do_lnetctl ping --source ${nids[0]} ${nids[0]} ||
2500 error "Initial ping failed $?"
2502 do_lnetctl ping --source ${nids[1]} ${nids[1]} ||
2503 error "Initial ping failed $?"
2506 for src in "${nids[@]}"; do
2507 for dst in "${nids[@]}"; do
2508 $LCTL net_drop_add -r 1 -s $src -d $dst -e network_timeout
2512 do_lnetctl ping ${nids[0]} || rc=$?
2514 $LCTL net_drop_del -a
2517 error "expected ping to fail"
2519 check_nid_in_recovq "-p" "${nids[0]}" "0"
2520 check_nid_in_recovq "-l" "${nids[0]}" "1"
2524 run_test 216 "Failed send to peer NI owned by local host should not trigger peer NI recovery"
2527 reinit_dlc || return $?
2529 [[ $($LNETCTL net show | grep -c nid) -ne 1 ]] &&
2530 error "Unexpected number of NIs after initalizing DLC"
2532 do_lnetctl discover 0@lo ||
2533 error "Failed to discover 0@lo"
2537 run_test 217 "Don't leak memory when discovering peer with nnis <= 1"
2540 [[ ${NETTYPE} == kfi* ]] && skip "kfi doesn't support drop rules"
2542 reinit_dlc || return $?
2544 [[ ${#INTERFACES[@]} -lt 2 ]] &&
2545 skip "Need two LNet interfaces"
2547 add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
2549 local nid1=$($LCTL list_nids | head -n 1)
2551 do_lnetctl ping $nid1 ||
2554 add_net "${NETTYPE}" "${INTERFACES[1]}" || return $?
2556 local nid2=$($LCTL list_nids | tail --lines 1)
2558 do_lnetctl ping $nid2 ||
2561 $LCTL net_drop_add -s $nid1 -d $nid1 -e local_error -r 1
2563 do_lnetctl ping --source $nid1 $nid1 &&
2564 error "ping should have failed"
2566 local health_recovered
2569 for i in $(seq 1 5); do
2570 health_recovered=$($LNETCTL net show -v 2 |
2571 grep -c 'health value: 1000')
2573 if [[ $health_recovered -ne 2 ]]; then
2574 echo "Wait 1 second for health to recover"
2581 health_recovered=$($LNETCTL net show -v 2 |
2582 grep -c 'health value: 1000')
2584 $LCTL net_drop_del -a
2586 [[ $health_recovered -ne 2 ]] &&
2587 do_lnetctl net show -v 2 | egrep -e nid -e health &&
2588 error "Health hasn't recovered"
2592 run_test 218 "Local recovery pings should exercise all available paths"
2595 reinit_dlc || return $?
2596 add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
2597 add_net "${NETTYPE}1" "${INTERFACES[0]}" || return $?
2599 local nid1=$(lctl list_nids | head -n 1)
2600 local nid2=$(lctl list_nids | tail --lines 1)
2602 do_lnetctl ping $nid1 ||
2603 error "Ping failed $?"
2604 do_lnetctl ping $nid2 ||
2605 error "Ping failed $?"
2607 do_lnetctl discover $nid2 ||
2608 error "Discovery failed"
2610 $LNETCTL peer show --nid $nid1 | grep -q $nid2 ||
2611 error "$nid2 is not listed under $nid1"
2613 run_test 219 "Consolidate peer entries"
2620 do_rpc_nodes $node "$LNETCTL net add --net $net --if $if" ||
2621 error "add $net on interface $if on node $node failed rc=$?"
2629 do_node $node "$LNETCTL route add --net $net --gateway $gw" ||
2630 error "route add to $net via $gw failed rc=$?"
2634 ROUTER_INTERFACES=()
2637 init_router_test_vars() {
2638 local rnodes=$(remote_nodes_list)
2639 [[ -z $rnodes || $(wc -w <<<$rnodes) -lt 2 ]] &&
2640 skip "Need at least 2 remote nodes found \"$rnodes\""
2642 ROUTER=$(awk '{print $1}' <<<$rnodes)
2643 RPEER=$(awk '{print $2}' <<<$rnodes)
2645 rnodes=$(comma_list $ROUTER $RPEER)
2646 local all_nodes=$(comma_list $rnodes $HOSTNAME)
2648 do_nodes $rnodes $LUSTRE_RMMOD ||
2649 error "failed to unload modules"
2651 do_rpc_nodes $rnodes "load_lnet config_on_load=1" ||
2652 error "Failed to load and configure LNet"
2654 ROUTER_INTERFACES=( $(do_rpc_nodes --quiet $ROUTER lnet_if_list) )
2656 RPEER_INTERFACES=( $(do_rpc_nodes --quiet $RPEER lnet_if_list) )
2658 do_nodes $all_nodes $LUSTRE_RMMOD ||
2659 error "Failed to unload modules"
2661 [[ ${#INTERFACES[@]} -eq 0 ]] &&
2662 error "No interfaces configured for local host $HOSTNAME"
2663 [[ ${#ROUTER_INTERFACES[@]} -eq 0 ]] &&
2664 error "No interfaces configured for router $ROUTER"
2665 [[ ${#RPEER_INTERFACES[@]} -eq 0 ]] &&
2666 error "No interfaces configured for remote peer $RPEER"
2674 LOCAL_NET=${NETTYPE}1
2675 REMOTE_NET=${NETTYPE}2
2676 setup_router_test() {
2679 (( $MDS1_VERSION >= $(version_code 2.15.0) )) ||
2680 skip "need at least 2.15.0 for load_lnet"
2682 if [[ ${#RPEER_INTERFACES[@]} -eq 0 ]]; then
2683 init_router_test_vars ||
2687 local all_nodes=$(comma_list $ROUTER $RPEER $HOSTNAME)
2689 do_nodes $all_nodes $LUSTRE_RMMOD ||
2690 error "failed to unload modules"
2692 mod_opts+=" alive_router_check_interval=5"
2693 mod_opts+=" router_ping_timeout=5"
2694 mod_opts+=" large_router_buffers=4"
2695 mod_opts+=" small_router_buffers=8"
2696 mod_opts+=" tiny_router_buffers=16"
2697 do_rpc_nodes $all_nodes load_lnet "${mod_opts}" ||
2698 error "Failed to load lnet"
2700 do_nodes $all_nodes "$LNETCTL lnet configure" ||
2701 error "Failed to initialize DLC"
2703 do_net_add $ROUTER $LOCAL_NET ${ROUTER_INTERFACES[0]} ||
2706 do_net_add $ROUTER $REMOTE_NET ${ROUTER_INTERFACES[0]} ||
2709 do_net_add $RPEER $REMOTE_NET ${RPEER_INTERFACES[0]} ||
2712 add_net $LOCAL_NET ${INTERFACES[0]} ||
2715 ROUTER_NIDS=( $(do_node $ROUTER $LCTL list_nids 2>/dev/null |
2717 RPEER_NIDS=( $(do_node $RPEER $LCTL list_nids 2>/dev/null |
2719 LNIDS=( $($LCTL list_nids 2>/dev/null | xargs echo) )
2727 do_nodesv $node "if $LNETCTL route show --net $net --gateway $gw; then \
2728 $LNETCTL route del --net $net --gateway $gw; \
2734 cleanup_router_test() {
2735 local all_nodes=$(comma_list $HOSTNAME $ROUTER $RPEER)
2737 do_route_del $HOSTNAME $REMOTE_NET ${ROUTER_NIDS[0]} ||
2738 error "Failed to delete $REMOTE_NET route"
2740 do_route_del $RPEER $LOCAL_NET ${ROUTER_NIDS[1]} ||
2741 error "Failed to delete $LOCAL_NET route"
2743 do_nodes $all_nodes $LUSTRE_RMMOD ||
2744 error "failed to unload modules"
2749 check_route_aliveness() {
2754 local lnetctl_actual
2758 chk_intvl=$(cat /sys/module/lnet/parameters/alive_router_check_interval)
2760 lctl_actual=$(do_node $node $LCTL show_route | awk '{print $7}')
2761 lnetctl_actual=$(do_node $node $LNETCTL route show -v |
2762 awk '/state/{print $NF}')
2764 for ((i = 0; i < $chk_intvl; i++)); do
2765 if [[ $lctl_actual == $expected ]] &&
2766 [[ $lnetctl_actual == $expected ]]; then
2770 echo "wait 1s for route state change"
2773 lctl_actual=$(do_node $node $LCTL show_route | awk '{print $7}')
2774 lnetctl_actual=$(do_node $node $LNETCTL route show -v |
2775 awk '/state/{print $NF}')
2778 [[ $lctl_actual != $expected ]] &&
2779 error "Wanted \"$expected\" lctl found \"$lctl_actual\""
2781 [[ $lnetctl_actual != $expected ]] &&
2782 error "Wanted \"$expected\" lnetctl found \"$lnetctl_actual\""
2787 check_router_ni_status() {
2788 local expected_local="$1"
2789 local expected_remote="$2"
2797 chk_intvl=$(cat /sys/module/lnet/parameters/alive_router_check_interval)
2798 timeout=$(cat /sys/module/lnet/parameters/router_ping_timeout)
2800 actual_local=$(do_node $ROUTER "$LNETCTL net show --net $LOCAL_NET" |
2801 awk '/status/{print $NF}')
2802 actual_remote=$(do_node $ROUTER "$LNETCTL net show --net $REMOTE_NET" |
2803 awk '/status/{print $NF}')
2805 for ((i = 0; i < $((chk_intvl + timeout)); i++)); do
2806 if [[ $actual_local == $expected_local ]] &&
2807 [[ $actual_remote == $expected_remote ]]; then
2811 echo "wait 1s for NI state change"
2814 actual_local=$(do_node $ROUTER \
2815 "$LNETCTL net show --net $LOCAL_NET" |
2816 awk '/status/{print $NF}')
2817 actual_remote=$(do_node $ROUTER \
2818 "$LNETCTL net show --net $REMOTE_NET" |
2819 awk '/status/{print $NF}')
2822 [[ $actual_local == $expected_local ]] ||
2823 error "$LOCAL_NET should be $expected_local"
2825 [[ $actual_remote == $expected_remote ]] ||
2826 error "$REMOTE_NET should be $expected_remote"
2831 do_basic_rtr_test() {
2832 do_node $ROUTER "$LNETCTL set routing 1" ||
2833 error "Unable to enable routing on $ROUTER"
2835 do_route_add $HOSTNAME $REMOTE_NET ${ROUTER_NIDS[0]} ||
2838 do_route_add $RPEER $LOCAL_NET ${ROUTER_NIDS[1]} ||
2841 check_route_aliveness "$HOSTNAME" "up" ||
2844 check_route_aliveness "$RPEER" "up" ||
2847 do_lnetctl ping ${RPEER_NIDS[0]} ||
2848 error "Failed to ping ${RPEER_NIDS[0]}"
2850 do_node $RPEER "$LNETCTL ping ${LNIDS[0]}" ||
2851 error "$RPEER failed to ping ${LNIDS[0]}"
2857 setup_router_test || return $?
2859 do_basic_rtr_test || return $?
2861 do_rpc_nodes $HOSTNAME,$RPEER load_module ../lnet/selftest/lnet_selftest ||
2862 error "Failed to load lnet-selftest module"
2864 $LSTSH -H -t $HOSTNAME -f $RPEER -m rw -s 4k ||
2867 $LSTSH -H -t $HOSTNAME -f $RPEER -m rw ||
2870 cleanup_router_test || return $?
2872 run_test 220 "Add routes w/default options - check aliveness"
2875 setup_router_test lnet_peer_discovery_disabled=1 || return $?
2877 do_basic_rtr_test || return $?
2879 cleanup_router_test || return $?
2881 run_test 221 "Add routes w/DD disabled - check aliveness"
2883 do_aarf_enabled_test() {
2884 do_node $ROUTER "$LNETCTL set routing 1" ||
2885 error "Unable to enable routing on $ROUTER"
2887 check_router_ni_status "down" "down"
2889 do_lnetctl ping ${RPEER_NIDS[0]} &&
2890 error "Ping should fail"
2892 do_node $RPEER "$LNETCTL ping ${LNIDS[0]}" &&
2893 error "$RPEER ping should fail"
2895 # Adding a route should cause the router's NI on LOCAL_NET to get up
2896 do_route_add $HOSTNAME $REMOTE_NET ${ROUTER_NIDS[0]} ||
2899 check_router_ni_status "up" "down" ||
2902 # But route should still be down because of avoid_asym_router_failure
2903 check_route_aliveness "$HOSTNAME" "down" ||
2906 do_lnetctl ping ${RPEER_NIDS[0]} &&
2907 error "Ping should fail"
2909 do_node $RPEER "$LNETCTL ping ${LNIDS[0]}" &&
2910 error "$RPEER ping should fail"
2912 # Adding the symmetric route should cause the remote NI to go up and
2914 do_route_add $RPEER $LOCAL_NET ${ROUTER_NIDS[1]} ||
2917 check_router_ni_status "up" "up" ||
2920 check_route_aliveness "$HOSTNAME" "up" ||
2923 check_route_aliveness "$RPEER" "up" ||
2926 do_lnetctl ping ${RPEER_NIDS[0]} ||
2927 error "Failed to ping ${RPEER_NIDS[0]}"
2929 do_node $RPEER "$LNETCTL ping ${LNIDS[0]}" ||
2930 error "$RPEER failed to ping ${LNIDS[0]}"
2932 # Stop LNet on local host
2933 do_lnetctl lnet unconfigure ||
2934 error "Failed to stop LNet rc=$?"
2936 check_router_ni_status "down" "up" ||
2939 check_route_aliveness "$RPEER" "down" ||
2942 do_lnetctl ping ${RPEER_NIDS[0]} &&
2943 error "Ping should fail"
2945 do_node $RPEER "$LNETCTL ping ${LNIDS[0]}" &&
2946 error "$RPEER ping should fail"
2952 setup_router_test avoid_asym_router_failure=1 || return $?
2954 do_aarf_enabled_test || return $?
2956 cleanup_router_test || return $?
2958 run_test 222 "Check avoid_asym_router_failure=1"
2961 local opts="avoid_asym_router_failure=1 lnet_peer_discovery_disabled=1"
2963 setup_router_test $opts || return $?
2965 do_aarf_enabled_test || return $?
2967 cleanup_router_test || return $?
2969 run_test 223 "Check avoid_asym_router_failure=1 w/DD disabled"
2971 do_aarf_disabled_test() {
2972 do_node $ROUTER "$LNETCTL set routing 1" ||
2973 error "Unable to enable routing on $ROUTER"
2975 check_router_ni_status "down" "down"
2977 do_route_add $HOSTNAME $REMOTE_NET ${ROUTER_NIDS[0]} ||
2980 check_router_ni_status "up" "down" ||
2983 check_route_aliveness "$HOSTNAME" "up" ||
2986 do_route_add $RPEER $LOCAL_NET ${ROUTER_NIDS[1]} ||
2989 check_router_ni_status "up" "up" ||
2992 check_route_aliveness "$HOSTNAME" "up" ||
2995 check_route_aliveness "$RPEER" "up" ||
2998 do_lnetctl ping ${RPEER_NIDS[0]} ||
2999 error "Failed to ping ${RPEER_NIDS[0]}"
3001 do_node $RPEER "$LNETCTL ping ${LNIDS[0]}" ||
3002 error "$RPEER failed to ping ${LNIDS[0]}"
3004 # Stop LNet on local host
3005 do_lnetctl lnet unconfigure ||
3006 error "Failed to stop LNet rc=$?"
3008 check_router_ni_status "down" "up" ||
3011 check_route_aliveness "$RPEER" "up" ||
3018 setup_router_test avoid_asym_router_failure=0 ||
3021 do_aarf_disabled_test ||
3024 cleanup_router_test ||
3027 run_test 224 "Check avoid_asym_router_failure=0"
3030 local opts="avoid_asym_router_failure=0 lnet_peer_discovery_disabled=1"
3032 setup_router_test $opts || return $?
3034 do_aarf_disabled_test || return $?
3036 cleanup_router_test ||
3039 run_test 225 "Check avoid_asym_router_failure=0 w/DD disabled"
3042 [[ ${NETTYPE} == tcp* ]] ||
3043 skip "Need tcp NETTYPE"
3045 echo "Check valid values; Should succeed"
3049 for ((i = 4; i < 16; i+=1)); do
3050 reinit_dlc || return $?
3051 add_net "tcp" "${INTERFACES[0]}" || return $?
3052 do_lnetctl net set --all --conns-per-peer $i ||
3053 error "should have succeeded $?"
3054 $LNETCTL net show -v 1 | grep -q "conns_per_peer: $i" ||
3055 error "failed to set conns-per-peer to $i"
3056 lnid="$(lctl list_nids | head -n 1)"
3057 do_lnetctl ping "$lnid" ||
3058 error "failed to ping myself"
3060 # "lctl --net tcp conn_list" prints the list of active
3061 # connections. Since we're pinging ourselves, there should be
3062 # 2 Control connections plus 2*conns_per_peer connections
3063 # created (one Bulk Input, one Bulk Output in each pair).
3064 # Here's the sample output for conns_per_peer set to 1:
3065 # 12345-1.1.1.1@tcp I[0]host01->host01:988 2626560/1061296 nonagle
3066 # 12345-1.1.1.1@tcp O[0]host01->host01:1022 2626560/1061488 nonagle
3067 # 12345-1.1.1.1@tcp C[0]host01->host01:988 2626560/1061296 nonagle
3068 # 12345-1.1.1.1@tcp C[0]host01->host01:1023 2626560/1061488 nonagle
3069 cmd="printf 'network tcp\nconn_list\n' | lctl | grep -c '$lnid'"
3071 # Expect 2+conns_per_peer*2 connections. Wait no longer
3073 wait_update $HOSTNAME "$cmd" "$((2+i*2))" 2 ||
3074 error "expected number of tcp connections $((2+i*2))"
3077 reinit_dlc || return $?
3078 add_net "tcp" "${INTERFACES[0]}" || return $?
3079 echo "Set > 127; Should fail"
3080 do_lnetctl net set --all --conns-per-peer 128 &&
3081 error "should have failed $?"
3083 reinit_dlc || return $?
3084 add_net "tcp" "${INTERFACES[0]}" || return $?
3086 local default=$($LNETCTL net show -v 1 |
3087 awk '/conns_per_peer/{print $NF}')
3089 echo "Set < 0; Should be ignored"
3090 do_lnetctl net set --all --conns-per-peer -1 ||
3091 error "should have succeeded $?"
3092 $LNETCTL net show -v 1 | grep -q "conns_per_peer: ${default}" ||
3093 error "Did not stay at default"
3095 run_test 230 "Test setting conns-per-peer"
3098 reinit_dlc || return $?
3100 local net=${NETTYPE}231
3102 do_lnetctl net add --net $net --if ${INTERFACES[0]} ||
3103 error "Failed to add net"
3105 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
3106 sed -i 's/peer_timeout: .*$/peer_timeout: 0/' \
3107 $TMP/sanity-lnet-$testnum-expected.yaml
3109 reinit_dlc || return $?
3111 do_lnetctl import $TMP/sanity-lnet-$testnum-expected.yaml ||
3112 error "Failed to import configuration"
3114 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
3116 compare_yaml_files || error "Wrong config after import"
3118 do_lnetctl net del --net $net --if ${INTERFACES[0]} ||
3119 error "Failed to delete net $net"
3121 do_lnetctl net add --net $net --if ${INTERFACES[0]} --peer-timeout=0 ||
3122 error "Failed to add net with peer-timeout=0"
3124 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
3126 compare_yaml_files || error "Wrong config after lnetctl net add"
3128 reinit_dlc || return $?
3130 # lnet/include/lnet/lib-lnet.h defines DEFAULT_PEER_TIMEOUT 180
3131 sed -i 's/peer_timeout: .*$/peer_timeout: 180/' \
3132 $TMP/sanity-lnet-$testnum-expected.yaml
3134 sed -i '/^.*peer_timeout:.*$/d' $TMP/sanity-lnet-$testnum-actual.yaml
3136 do_lnetctl import $TMP/sanity-lnet-$testnum-actual.yaml ||
3137 error "Failed to import config without peer_timeout"
3139 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
3143 run_test 231 "Check DLC handling of peer_timeout parameter"
3145 ### Test that linux route is added for each ni
3149 [[ ${NETTYPE} == tcp* ]] ||
3150 skip "Need tcp NETTYPE"
3151 reinit_dlc || return $?
3152 add_net "tcp" "${INTERFACES[0]}" || return $?
3154 skip_param=$(cat /sys/module/ksocklnd/parameters/skip_mr_route_setup)
3155 [[ ${skip_param:-0} -ne 0 ]] &&
3156 skip "Need skip_mr_route_setup=0 found $skip_param"
3158 ip route show table ${INTERFACES[0]} | grep -q "${INTERFACES[0]}"
3160 run_test 250 "test that linux routes are added"
3163 [[ ${NETTYPE} =~ kfi* ]] ||
3164 skip "Need kfi NETTYPE"
3166 reinit_dlc || return $?
3167 add_net "kfi" "${INTERFACES[0]}" || return $?
3168 add_net "kfi1" "${INTERFACES[0]}" || return $?
3169 add_net "kfi10" "${INTERFACES[0]}" || return $?
3172 run_test 251 "Define multiple kfi networks on single interface"
3175 setup_health_test false || return $?
3179 do_rpc_nodes $RNODE unload_modules_local || rc=$?
3181 if [[ $rc -ne 0 ]]; then
3182 cleanup_health_test || return $?
3184 error "Failed to unload modules on $RNODE rc=$rc"
3189 local ts1=$(date +%s)
3191 do_lnetctl ping --timeout 15 ${RNIDS[0]} &&
3192 error "Expected ping ${RNIDS[0]} to fail"
3194 local ts2=$(date +%s)
3196 local delta=$(echo "$ts2 - $ts1" | bc)
3198 [[ $delta -lt 15 ]] ||
3199 error "Ping took longer than expected to fail: $delta"
3203 run_test 252 "Ping to down peer should unlink quickly"
3205 do_expired_message_drop_test() {
3206 local rnid lnid old_tto
3208 old_tto=$($LNETCTL global show |
3209 awk '/transaction_timeout:/{print $NF}')
3211 [[ -z $old_tto ]] &&
3212 error "Cannot determine LNet transaction timeout"
3216 do_lnetctl set transaction_timeout "${tto}" ||
3217 error "Failed to set transaction_timeout"
3219 # We want to consume all peer credits for at least transaction_timeout
3225 for lnid in "${LNIDS[@]}"; do
3226 for rnid in "${RNIDS[@]}"; do
3227 $LCTL net_delay_add -s "${lnid}" -d "${rnid}" \
3228 -l "${delay}" -r 1 -m GET
3234 pcs=( $($LNETCTL peer show -v --nid "${RNIDS[0]}" |
3235 awk '/max_ni_tx_credits:/{print $NF}' |
3238 [[ ${#RNIDS[@]} -ne ${#pcs[@]} ]] &&
3239 error "Expect ${#RNIDS[@]} peer credit values found ${#pcs[@]}"
3241 local rnet lnid lnet i j
3243 # Need to use --source for multi-rail configs to ensure we consume
3244 # all available peer credits
3245 for ((i = 0; i < ${#RNIDS[@]}; i++)); do
3246 local ping_args="--timeout $((delay+2))"
3248 rnet=${RNIDS[i]##*@}
3249 for lnid in ${LNIDS[@]}; do
3251 [[ $rnet == $lnet ]] && break
3254 ping_args+=" --source ${lnid} ${RNIDS[i]}"
3255 for j in $(seq 1 "${pcs[i]}"); do
3256 $LNETCTL ping ${ping_args} 1>/dev/null &
3259 echo "Issued ${pcs[i]} pings to ${RNIDS[i]} from $lnid"
3262 # This ping should be queued on peer NI tx credit
3263 $LNETCTL ping --timeout $((delay+2)) "${RNIDS[0]}" &
3267 $LCTL net_delay_del -a
3271 # Messages sent from the delay list do not go through
3272 # lnet_post_send_locked(), thus we should only have a single drop
3275 dropped=$($LNETCTL peer show -v 2 --nid "${RNIDS[0]}" |
3276 grep -A 2 dropped_stats |
3277 awk '/get:/{print $2}' |
3279 sed 's/ /\+/g' | bc)
3281 [[ $dropped -ne 1 ]] &&
3282 error "Expect 1 dropped GET but found $dropped"
3284 do_lnetctl set transaction_timeout "${old_tto}"
3290 setup_health_test false || return $?
3292 do_expired_message_drop_test || return $?
3296 run_test 253 "Message delayed beyond deadline should be dropped (single-rail)"
3299 setup_health_test true || return $?
3301 do_expired_message_drop_test || return $?
3305 run_test 254 "Message delayed beyond deadline should be dropped (multi-rail)"
3308 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
3310 reinit_dlc || return $?
3312 cleanup_lnet || return $?
3314 local routes_str="o2ib ${IF0_NET}.[$GW_HOSTNUM-$((GW_HOSTNUM+4))]"
3315 local network_str="${NETTYPE}(${INTERFACES[0]})"
3317 load_lnet "networks=\"${network_str}\" routes=\"${routes_str}\"" ||
3318 error "Failed to load LNet"
3321 error "Failed to load LNet with networks=\"${network_str}\" routes=\"${routes_str}\""
3323 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
3325 - net type: ${NETTYPE}
3330 append_net_tunables tcp
3332 echo "route:" >> $TMP/sanity-lnet-$testnum-expected.yaml
3333 for i in $(seq $GW_HOSTNUM $((GW_HOSTNUM + 4))); do
3334 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
3336 gateway: ${IF0_NET}.${i}@${NETTYPE}
3339 health_sensitivity: 1
3343 echo "peer:" >> $TMP/sanity-lnet-$testnum-expected.yaml
3344 for i in $(seq $GW_HOSTNUM $((GW_HOSTNUM + 4))); do
3345 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
3346 - primary nid: ${IF0_NET}.${i}@${NETTYPE}
3349 - nid: ${IF0_NET}.${i}@${NETTYPE}
3355 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml ||
3356 error "export failed $?"
3358 validate_gateway_nids
3360 run_test 255 "Use lnet routes param with pdsh syntax"
3365 local out=$TMP/$tfile
3366 local prefix=/usr/include/linux/lnet
3368 # We use a hard coded prefix so that this test will not fail
3371 if ! which $CC > /dev/null 2>&1; then
3372 skip_env "$CC is not installed"
3375 cleanup_lnet || exit 1
3378 local cc_args="-Wall -Werror -std=c99 -c -x c /dev/null -o $out"
3379 if ! [[ -d $prefix ]]; then
3380 # Assume we're running in tree and fixup the include path.
3381 prefix=$LUSTRE/../lnet/include/uapi/linux/lnet
3382 cc_args+=" -I $LUSTRE/../lnet/include/uapi"
3385 for header in $prefix/*.h; do
3386 if ! [[ -f "$header" ]]; then
3390 echo "$CC $cc_args -include $header"
3391 $CC $cc_args -include $header ||
3392 error "cannot compile '$header'"
3396 run_test 300 "packaged LNet UAPI headers can be compiled"
3398 # LU-16081 lnet: Memory leak on adding existing interface
3401 reinit_dlc || return $?
3402 do_lnetctl net add --net ${NETTYPE} --if ${INTERFACES[0]} ||
3403 error "Failed to add net"
3404 do_lnetctl net add --net ${NETTYPE} --if ${INTERFACES[0]} &&
3405 error "add net should have failed"
3406 do_lnetctl net del --net ${NETTYPE} --if ${INTERFACES[0]} ||
3407 error "Failed to del net"
3410 run_test 301 "Check for dynamic adds of same/wrong interface (memory leak)"
3413 ! [[ $NETTYPE =~ (tcp|o2ib) ]] && skip "Need tcp or o2ib NETTYPE"
3414 reinit_dlc || return $?
3416 add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
3418 local nid=$($LCTL list_nids)
3420 do_lnetctl ping ${nid} ||
3421 error "pinging self failed $?"
3422 do_lnetctl debug peer --nid ${nid} ||
3423 error "failed to dump peer debug info $?"
3425 run_test 302 "Check that peer debug info can be dumped"
3428 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
3430 setup_health_test true || return $?
3432 cleanup_netns || error "Failed to cleanup netns before test execution"
3433 setup_fakeif || error "Failed to add fake IF"
3434 have_interface "$FAKE_IF" ||
3435 error "Expect $FAKE_IF configured but not found"
3437 add_net "${NETTYPE}99" "$FAKE_IF" || return $?
3439 local nid=$($LCTL list_nids | tail --lines 1)
3441 # Our updated config should be pushed to RNODE
3442 local found=$(do_node $RNODE "$LNETCTL peer show --nid $nid")
3444 [[ -z $found ]] && error "Peer not updated on $RNODE"
3446 local prim=$($LCTL list_nids | head -n 1)
3448 if ! grep -q -- "- primary nid: $prim"<<<"${found}"; then
3450 error "Wrong primary nid"
3453 echo "Set $FAKE_IF down"
3454 echo "ip link set dev $FAKE_IF down"
3455 ip link set dev $FAKE_IF down
3456 check_ni_status "$nid" down
3458 local hval=$(do_node $RNODE "$LNETCTL peer show --nid $nid -v 2 | \
3459 grep -e '- nid:' -e 'health value:'")
3461 hval=$(grep -A 1 $nid<<<"$hval" | tail -n 1 | awk '{print $NF}')
3462 (( hval < 1000 )) ||
3463 error "Expect $hval < 1000"
3467 run_test 303 "Check peer NI health after link down"
3470 [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
3472 cleanup_netns || error "Failed to cleanup netns before test execution"
3473 cleanup_lnet || error "Failed to unload modules before test execution"
3475 setup_fakeif || error "Failed to add fake IF"
3476 have_interface "$FAKE_IF" ||
3477 error "Expect $FAKE_IF configured but not found"
3479 reinit_dlc || return $?
3481 add_net "tcp" "${INTERFACES[0]}" || return $?
3482 add_net "tcp" "$FAKE_IF" || return $?
3484 local nid1=$(lctl list_nids | head -n 1)
3485 local nid2=$(lctl list_nids | tail --lines 1)
3487 check_ni_status "$nid1" up
3488 check_ni_status "$nid2" up
3490 do_lnetctl peer add --prim_nid ${nid2} --lock_prim ||
3491 error "peer add failed $?"
3492 local locked_peer_state=($(do_lnetctl peer show -v 4 --nid ${nid2} |
3493 awk '/peer state/{print $NF}'))
3495 # Expect peer state bits:
3496 # LNET_PEER_MULTI_RAIL(0) | LNET_PEER_CONFIGURED(3) |
3497 # LNET_PEER_LOCK_PRIMARY(20)
3498 (( $locked_peer_state != "1048585")) &&
3499 error "Wrong peer state \"$locked_peer_state\" expected 1048585"
3501 # Clear LNET_PEER_CONFIGURED bit and verify
3502 do_lnetctl peer set --nid ${nid2} --state 1048577 ||
3503 error "peer add failed $?"
3504 locked_peer_state=($(do_lnetctl peer show -v 4 --nid ${nid2} |
3505 awk '/peer state/{print $NF}'))
3506 (( $locked_peer_state != "1048577")) &&
3507 error "Wrong peer state \"$locked_peer_state\" expected 1048577"
3508 do_lnetctl discover ${nid1} ||
3509 error "Failed to discover peer"
3511 # Expect nid2 and nid1 peer entries to be consolidated,
3512 # nid2 to stay primary
3513 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
3515 - primary nid: ${nid2}
3523 $LNETCTL peer show > $TMP/sanity-lnet-$testnum-actual.yaml
3524 compare_yaml_files ||
3525 error "Unexpected peer configuration"
3527 locked_peer_state=($(do_lnetctl peer show -v 4 --nid ${nid2} |
3528 awk '/peer state/{print $NF}'))
3529 # Expect peer state bits to be added:
3530 # LNET_PEER_DISCOVERED(4) | LNET_PEER_NIDS_UPTODATE(8)
3531 (( $locked_peer_state != "1048849")) &&
3532 error "Wrong peer state \"$locked_peer_state\" expected 1048849"
3535 run_test 304 "Check locked primary peer nid consolidation"
3541 echo "check parameter ${para} value ${value}"
3543 return $(( $(do_lnetctl net show -v | \
3545 grep -c "^ \+${para}: ${value}$") != 1 ))
3552 cleanup_lnet || error "Failed to cleanup LNet"
3554 load_module ../libcfs/libcfs/libcfs ||
3555 error "Failed to load module libcfs rc = $?"
3557 load_module ../lnet/lnet/lnet ||
3558 error "Failed to load module lnet rc = $?"
3560 echo "loading ${module} ${setting} type ${NETTYPE}"
3561 load_module "${module}" "${setting}" ||
3562 error "Failed to load module ${module} rc = $?"
3564 do_lnetctl lnet configure --all || error "lnet configure failed rc = $?"
3572 if [[ ${NETTYPE} == tcp* ]];then
3573 static_config "../lnet/klnds/socklnd/ksocklnd" \
3574 "sock_timeout=${value}"
3575 elif [[ ${NETTYPE} == o2ib* ]]; then
3576 static_config "../lnet/klnds/o2iblnd/ko2iblnd" \
3578 elif [[ ${NETTYPE} == gni* ]]; then
3579 static_config "../lnet/klnds/gnilnd/kgnilnd" \
3582 skip "NETTYPE ${NETTYPE} not supported"
3585 check_parameter "timeout" $value
3589 run_test 310 "Set timeout and verify"
3592 [[ $NETTYPE == kfi* ]] ||
3593 skip "Need kfi network type"
3595 setupall || error "setupall failed"
3597 mkdir -p $DIR/$tdir || error "mkdir failed"
3598 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 oflag=direct ||
3599 error "dd write failed"
3601 local list=$(comma_list $(osts_nodes))
3603 #define CFS_KFI_FAIL_WAIT_SEND_COMP1 0xF115
3604 do_nodes $list $LCTL set_param fail_loc=0x8000F115
3605 dd if=$DIR/$tdir/$tfile of=/dev/null bs=1M count=1 ||
3606 error "dd read failed"
3608 rm -f $DIR/$tdir/$tfile
3611 cleanupall || error "Failed cleanup"
3613 run_test 311 "Fail bulk put in send wait completion"
3616 [[ $NETTYPE == kfi* ]] ||
3617 skip "Need kfi network type"
3619 setupall || error "setupall failed"
3621 mkdir -p $DIR/$tdir || error "mkdir failed"
3623 local list=$(comma_list $(osts_nodes))
3625 #define CFS_KFI_FAIL_WAIT_SEND_COMP3 0xF117
3626 do_nodes $list $LCTL set_param fail_loc=0x8000F117
3627 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 oflag=direct ||
3628 error "dd write failed"
3630 local tfile2="$DIR/$tdir/testfile2"
3632 do_nodes $list $LCTL set_param fail_loc=0x8000F117
3633 dd if=$DIR/$tdir/$tfile of=$tfile2 bs=1M count=1 oflag=direct ||
3634 error "dd read failed"
3636 rm -f $DIR/$tdir/$tfile
3640 cleanupall || error "Failed cleanup"
3642 run_test 312 "TAG_RX_OK is possible after TX_FAIL"
3645 local target_net="${1}"
3646 local target_nid="${2}"
3647 local expect_net="${3}"
3648 local expect_nid="${4}"
3652 declare -a net_prios
3653 declare -a nid_prios
3655 nids=( $($LNETCTL ${type} show -v 5 | awk '/- nid:/{print $NF}' |
3658 net_prios=( $($LNETCTL ${type} show -v 5 |
3659 awk '/net priority:/{print $NF}' | xargs echo) )
3661 nid_prios=( $($LNETCTL ${type} show -v 5 |
3662 awk '/nid priority:/{print $NF}' | xargs echo) )
3664 (( ${#nids[@]} != ${#net_prios[@]} )) &&
3665 error "Wrong # net prios ${#nids[@]} != ${#net_prios[@]}"
3667 (( ${#nids[@]} != ${#nid_prios[@]} )) &&
3668 error "Wrong # nid prios ${#nids[@]} != ${#nid_prios[@]}"
3672 for ((i = 0; i < ${#nids[@]}; i++)); do
3673 [[ -n ${target_net} ]] &&
3674 [[ ${nids[i]##*@} != "${target_net}" ]] &&
3676 [[ -n ${target_nid} ]] &&
3677 [[ ${nids[i]} != "${target_nid}" ]] &&
3680 echo "${nids[i]}: net_prio ${net_prios[i]} expect ${expect_net}"
3681 (( net_prios[i] != expect_net )) &&
3682 error "Wrong net priority \"${net_prios[i]}\" expect ${expect_net}"
3684 echo "${nids[i]}: nid_prio ${nid_prios[i]} expect ${expect_nid}"
3685 (( nid_prios[i] != expect_nid )) &&
3686 error "Wrong nid priority \"${nid_prios[i]}\" expect ${expect_nid}"
3692 check_peer_udsp_prio() {
3693 check_udsp_prio "${1}" "${2}" "${3}" "${4}" "peer"
3696 check_net_udsp_prio() {
3697 check_udsp_prio "${1}" "${2}" "${3}" "${4}" "net"
3701 reinit_dlc || return $?
3703 do_lnetctl udsp add --src tcp --priority 0 ||
3704 error "Failed to add udsp rule"
3705 do_lnetctl udsp del --idx 0 ||
3706 error "Failed to del udsp rule"
3709 run_test 400 "Check for udsp add/delete net rule without net num"
3712 reinit_dlc || return $?
3714 do_lnetctl net add --net ${NETTYPE} --if ${INTERFACES[0]} ||
3715 error "Failed to add net"
3717 do_lnetctl udsp add --dst ${NETTYPE} --prio 1 ||
3718 error "Failed to add peer net priority rule"
3720 do_lnetctl discover $($LCTL list_nids | head -n 1) ||
3721 error "Failed to discover peer"
3723 check_peer_udsp_prio "${NETTYPE}" "" "1" "-1"
3727 run_test 401 "Discover peer after adding peer net UDSP rule"
3730 reinit_dlc || return $?
3732 do_lnetctl udsp add --dst kfi --priority 0 ||
3733 error "Failed to add UDSP rule"
3735 do_lnetctl peer add --prim 402@kfi ||
3736 error "Failed to add peer"
3740 run_test 402 "Destination net rule should not panic"
3742 complete_test $SECONDS