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"
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 diff -upN ${actual} ${expected} || rc=$?
158 local net="${nid//*@/}"
159 local addr="${nid//@*/}"
161 local num_re='[0-9]\+'
162 local ip_re="[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"
164 if [[ $net =~ gni[0-9]* ]] || [[ $net =~ kfi[0-9]* ]]; then
165 [[ $addr =~ ${num_re} ]] && return 0
167 [[ $addr =~ ${ip_re} ]] && return 0
172 local yfile=$TMP/sanity-lnet-$testnum-actual.yaml
173 local primary_nids=$(awk '/- primary nid:/{print $NF}' $yfile | xargs echo)
174 local secondary_nids=$(awk '/- nid:/{print $NF}' $yfile | xargs echo)
175 local gateway_nids=$(awk '/gateway:/{print $NF}' $yfile | xargs echo)
178 for nid in $primary_nids $secondary_nids; do
179 validate_nid "$nid" || error "Bad NID \"${nid}\""
184 validate_peer_nids() {
186 local nids_per_peer="$2"
188 local expect_p="$num_peers"
189 # The primary nid also shows up in the list of secondary nids
190 local expect_s="$(($num_peers + $(($nids_per_peer*$num_peers))))"
192 local actual_p=$(grep -c -- '- primary nid:' $TMP/sanity-lnet-$testnum-actual.yaml)
193 local actual_s=$(grep -c -- '- nid:' $TMP/sanity-lnet-$testnum-actual.yaml)
194 if [[ $expect_p -ne $actual_p ]]; then
196 error "Expected $expect_p but found $actual_p primary nids"
197 elif [[ $expect_s -ne $actual_s ]]; then
199 error "Expected $expect_s but found $actual_s secondary nids"
204 validate_gateway_nids() {
205 local expect_gw=$(grep -c -- 'gateway:' $TMP/sanity-lnet-$testnum-expected.yaml)
206 local actual_gw=$(grep -c -- 'gateway:' $TMP/sanity-lnet-$testnum-actual.yaml)
207 if [[ $expect_gw -ne $actual_gw ]]; then
209 error "Expected $expect_gw gateways but found $actual_gw gateways"
215 setup_netns || error "setup_netns failed with $?"
217 # Determine the local interface(s) used for LNet
218 load_lnet "config_on_load=1" || error "Failed to load modules"
223 INTERFACES=( $(lnet_if_list) )
225 cleanup_lnet || error "Failed to cleanup LNet"
227 stack_trap 'cleanup_testsuite' EXIT
230 load_module ../lnet/lnet/lnet || error "Failed to load module rc = $?"
231 do_lnetctl lnet configure || error "lnet configure failed rc = $?"
233 reinit_dlc || return $?
234 do_lnetctl import < ${GLOBAL_YAML_FILE} || error "Import failed $?"
235 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
236 create_base_yaml_file
237 compare_yaml_files || error "Configuration changed after import"
239 run_test 0 "Export empty config, import the config, compare"
242 local prim_nid="${1:+--prim_nid $1}"
243 local nid="${2:+--nid $2}"
245 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
247 do_lnetctl peer add ${prim_nid} ${nid} || error "peer add failed $?"
248 $LNETCTL export --backup > $actual || error "export failed $?"
254 reinit_dlc || return $?
255 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
257 - primary nid: 1.1.1.1@tcp
263 compare_peer_add "1.1.1.1@tcp"
265 run_test 1 "Add peer with single nid (tcp)"
268 reinit_dlc || return $?
269 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
271 - primary nid: 2.2.2.2@o2ib
277 compare_peer_add "2.2.2.2@o2ib"
279 run_test 2 "Add peer with single nid (o2ib)"
282 reinit_dlc || return $?
283 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
285 - primary nid: 3.3.3.3@tcp
292 compare_peer_add "3.3.3.3@tcp" "3.3.3.3@o2ib"
294 run_test 3 "Add peer with tcp primary o2ib secondary"
297 reinit_dlc || return $?
298 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
300 - primary nid: 4.4.4.4@tcp
309 echo "Add peer with nidrange (tcp)"
310 compare_peer_add "4.4.4.4@tcp" "4.4.4.[1-3]@tcp"
312 echo "Add peer with nidrange that overlaps primary nid (tcp)"
313 compare_peer_add "4.4.4.4@tcp" "4.4.4.[1-4]@tcp"
315 run_test 4 "Add peer with nidrange (tcp)"
318 reinit_dlc || return $?
319 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
321 - primary nid: 5.5.5.5@o2ib
331 echo "Add peer with nidrange (o2ib)"
332 compare_peer_add "5.5.5.5@o2ib" "5.5.5.[1-4]@o2ib"
334 echo "Add peer with nidranage that overlaps primary nid (o2ib)"
335 compare_peer_add "5.5.5.5@o2ib" "5.5.5.[1-4]@o2ib"
337 run_test 5 "Add peer with nidrange (o2ib)"
340 reinit_dlc || return $?
341 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
343 - primary nid: 6.6.6.6@tcp
366 local nid_expr="6.6.[6-7].[0-4/2]@tcp"
367 nid_expr+=",6.6.[1-4/2].[0-6/3]@o2ib"
368 nid_expr+=",[6-12/4]@gni"
369 nid_expr+=",[6-12/4]@kfi"
371 compare_peer_add "6.6.6.6@tcp" "${nid_expr}"
373 run_test 6 "Add peer with multiple nidranges"
376 local prim_nid="${1:+--prim_nid $1}"
377 local nid="${2:+--nid $2}"
379 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
381 do_lnetctl peer del ${prim_nid} ${nid} || error "peer del failed $?"
382 $LNETCTL export --backup > $actual || error "export failed $?"
388 reinit_dlc || return $?
389 create_base_yaml_file
391 echo "Delete peer with single nid (tcp)"
392 do_lnetctl peer add --prim_nid 7.7.7.7@tcp || error "Peer add failed $?"
393 compare_peer_del "7.7.7.7@tcp"
395 echo "Delete peer with single nid (o2ib)"
396 do_lnetctl peer add --prim_nid 7.7.7.7@o2ib || error "Peer add failed $?"
397 compare_peer_del "7.7.7.7@o2ib"
399 echo "Delete peer that has multiple nids (tcp)"
400 do_lnetctl peer add --prim_nid 7.7.7.7@tcp --nid 7.7.7.[8-12]@tcp ||
401 error "Peer add failed $?"
402 compare_peer_del "7.7.7.7@tcp"
404 echo "Delete peer that has multiple nids (o2ib)"
405 do_lnetctl peer add --prim_nid 7.7.7.7@o2ib --nid 7.7.7.[8-12]@o2ib ||
406 error "Peer add failed $?"
407 compare_peer_del "7.7.7.7@o2ib"
409 echo "Delete peer that has both tcp and o2ib nids"
410 do_lnetctl peer add --prim_nid 7.7.7.7@tcp \
411 --nid 7.7.7.[9-12]@tcp,7.7.7.[13-15]@o2ib ||
412 error "Peer add failed $?"
413 compare_peer_del "7.7.7.7@tcp"
415 echo "Delete peer with single nid (gni)"
416 do_lnetctl peer add --prim_nid 7@gni || error "Peer add failed $?"
417 compare_peer_del "7@gni"
419 echo "Delete peer that has multiple nids (gni)"
420 do_lnetctl peer add --prim_nid 7@gni --nid [8-12]@gni ||
421 error "Peer add failed $?"
422 compare_peer_del "7@gni"
424 echo "Delete peer with single nid (kfi)"
425 do_lnetctl peer add --prim_nid 7@kfi || error "Peer add failed $?"
426 compare_peer_del "7@kfi"
428 echo "Delete peer that has multiple nids (kfi)"
429 do_lnetctl peer add --prim_nid 7@kfi --nid [8-12]@kfi ||
430 error "Peer add failed $?"
431 compare_peer_del "7@kfi"
433 echo "Delete peer that has tcp, o2ib, gni and kfi nids"
434 do_lnetctl peer add --prim_nid 7@gni \
435 --nid [8-12]@gni,7.7.7.[1-4]@tcp,7.7.7.[5-9]@o2ib,[1-5]@kfi ||
436 error "Peer add failed $?"
437 compare_peer_del "7@gni"
439 run_test 7 "Various peer delete tests"
442 reinit_dlc || return $?
444 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
446 - primary nid: 8.8.8.8@tcp
458 do_lnetctl peer add --prim_nid 8.8.8.8@tcp --nid 8.8.8.[10-15]@tcp ||
459 error "Peer add failed $?"
460 compare_peer_del "8.8.8.8@tcp" "8.8.8.13@tcp"
462 run_test 8 "Delete single secondary nid from peer (tcp)"
465 reinit_dlc || return $?
467 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
469 - primary nid: 9.9.9.9@tcp
476 do_lnetctl peer add --prim_nid 9.9.9.9@tcp \
477 --nid 9.9.9.[11-16]@tcp || error "Peer add failed $?"
478 compare_peer_del "9.9.9.9@tcp" "9.9.9.[11-16]@tcp"
480 run_test 9 "Delete all secondary nids from peer (tcp)"
483 reinit_dlc || return $?
485 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
487 - primary nid: 10.10.10.10@tcp
490 - nid: 10.10.10.10@tcp
491 - nid: 10.10.10.12@tcp
492 - nid: 10.10.10.13@tcp
493 - nid: 10.10.10.15@tcp
494 - nid: 10.10.10.16@tcp
497 do_lnetctl peer add --prim_nid 10.10.10.10@tcp \
498 --nid 10.10.10.[12-16]@tcp || error "Peer add failed $?"
499 compare_peer_del "10.10.10.10@tcp" "10.10.10.14@tcp"
501 run_test 10 "Delete single secondary nid from peer (o2ib)"
504 reinit_dlc || return $?
506 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
508 - primary nid: 11.11.11.11@tcp
511 - nid: 11.11.11.11@tcp
514 do_lnetctl peer add --prim_nid 11.11.11.11@tcp \
515 --nid 11.11.11.[13-17]@tcp || error "Peer add failed $?"
516 compare_peer_del "11.11.11.11@tcp" "11.11.11.[13-17]@tcp"
518 run_test 11 "Delete all secondary nids from peer (o2ib)"
521 reinit_dlc || return $?
523 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
525 - primary nid: 12.12.12.12@o2ib
528 - nid: 12.12.12.12@o2ib
529 - nid: 13.13.13.13@o2ib
530 - nid: 14.13.13.13@o2ib
531 - nid: 14.15.13.13@o2ib
533 - nid: 15.17.1.10@tcp
534 - nid: 15.17.1.20@tcp
537 do_lnetctl peer add --prim_nid 12.12.12.12@o2ib \
538 --nid [13-14/1].[13-15/2].13.13@o2ib,[15-16/3].[17-19/4].[1].[5-20/5]@tcp ||
539 error "Peer add failed $?"
540 compare_peer_del "12.12.12.12@o2ib" "13.15.13.13@o2ib,15.17.1.15@tcp"
542 run_test 12 "Delete a secondary nid from peer (tcp and o2ib)"
545 reinit_dlc || return $?
547 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
549 - primary nid: 13.13.13.13@o2ib
552 - nid: 13.13.13.13@o2ib
555 do_lnetctl peer add --prim_nid 13.13.13.13@o2ib \
556 --nid [14-15].[1-2/1].[1].[100-254/10]@tcp,14.14.[254].14@o2ib ||
557 error "Peer add failed $?"
558 compare_peer_del "13.13.13.13@o2ib" \
559 "[14-15].[1-2/1].[1].[100-254/10]@tcp,14.14.[254].14@o2ib"
561 run_test 13 "Delete all secondary nids from peer (tcp and o2ib)"
567 if [[ $net =~ gni* ]] || [[ $net =~ kfi* ]]; then
570 echo "${num}.${num}.${num}.${num}@${net}"
574 create_mr_peer_yaml() {
576 local secondary_nids="$2"
579 echo "Generating peer yaml for $num_peers peers with $secondary_nids secondary nids"
580 echo "peer:" >> $TMP/sanity-lnet-$testnum-expected.yaml
582 local total_nids=$((num_peers + $((num_peers * secondary_nids))))
585 while [[ $created -lt $num_peers ]]; do
586 local primary=$(create_nid ${nidnum} ${net})
587 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
588 - primary nid: $primary
594 local start=$((nidnum + 1))
595 local end=$((nidnum + $secondary_nids))
596 for j in $(seq ${start} ${end}); do
597 local nid=$(create_nid $j ${net})
598 echo " - nid: $nid" >> $TMP/sanity-lnet-$testnum-expected.yaml
606 reinit_dlc || return $?
608 echo "Create single peer, single nid, using import"
609 create_mr_peer_yaml 1 0 tcp
610 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
611 error "Import failed $?"
613 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
616 echo "Delete single peer using import --del"
617 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
618 error "Import failed $?"
619 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
620 create_base_yaml_file
621 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
624 run_test 14 "import peer create/delete with single nid"
627 reinit_dlc || return $?
629 echo "Create multiple peers, single nid per peer, using import"
630 create_mr_peer_yaml 5 0 o2ib
631 # The ordering of nids for this use-case is non-deterministic, so we
632 # we can't just diff the expected/actual output.
633 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
634 error "Import failed $?"
635 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
636 validate_peer_nids 5 0
638 echo "Delete multiple peers, single nid per peer, using import --del"
639 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
640 error "Import failed $?"
641 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
642 create_base_yaml_file
643 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
646 run_test 15 "import multi peer create/delete with single nid per peer"
649 reinit_dlc || return $?
651 echo "Create single peer, multiple nids, using import"
652 create_mr_peer_yaml 1 5 tcp
653 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
654 error "Import failed $?"
655 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
656 validate_peer_nids 1 5
658 echo "Delete single peer, multiple nids, using import --del"
659 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
660 error "Import failed $?"
661 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
662 create_base_yaml_file
663 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
666 run_test 16 "import peer create/delete with multiple nids"
669 reinit_dlc || return $?
671 echo "Create multiple peers, multiple nids per peer, using import"
672 create_mr_peer_yaml 5 7 o2ib
673 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
674 error "Import failed $?"
675 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
676 validate_peer_nids 5 7
678 echo "Delete multiple peers, multiple nids per peer, using import --del"
679 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
680 error "Import failed $?"
681 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
682 create_base_yaml_file
683 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
686 run_test 17 "import multi peer create/delete with multiple nids"
689 reinit_dlc || return $?
691 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
693 - primary nid: 1.1.1.1@tcp
702 echo "Import peer with 5 nids"
703 cat $TMP/sanity-lnet-$testnum-expected.yaml
704 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
705 error "Import failed $?"
706 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
708 - primary nid: 1.1.1.1@tcp
715 echo "Delete three of the nids"
716 cat $TMP/sanity-lnet-$testnum-expected.yaml
717 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml
718 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
720 - primary nid: 1.1.1.1@tcp
726 echo "Check peer has expected nids remaining"
727 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
731 run_test 18a "Delete a subset of nids from a single peer using import --del"
734 reinit_dlc || return $?
736 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
738 - primary nid: 1.1.1.1@tcp
746 - primary nid: 6.6.6.6@o2ib
755 echo "Import two peers with 5 nids each"
756 cat $TMP/sanity-lnet-$testnum-expected.yaml
757 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
758 error "Import failed $?"
759 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
761 - primary nid: 1.1.1.1@tcp
767 - primary nid: 6.6.6.6@o2ib
774 echo "Delete three of the nids from each peer"
775 cat $TMP/sanity-lnet-$testnum-expected.yaml
776 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml
777 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
779 - primary nid: 6.6.6.6@o2ib
784 - primary nid: 1.1.1.1@tcp
791 echo "Check peers have expected nids remaining"
792 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
794 validate_peer_nids 2 1
796 run_test 18b "Delete multiple nids from multiple peers using import --del"
799 reinit_dlc || return $?
800 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
802 - primary nid: 19@gni
808 compare_peer_add "19@gni"
810 run_test 19 "Add peer with single nid (gni)"
813 reinit_dlc || return $?
814 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
816 - primary nid: 20@gni
820 - nid: 20.20.20.20@tcp
821 - nid: 20.20.20.20@o2ib
824 compare_peer_add "20@gni" "20.20.20.20@tcp,20.20.20.20@o2ib"
826 run_test 20 "Add peer with gni primary and tcp, o2ib secondary"
829 reinit_dlc || return $?
830 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
832 - primary nid: 21@gni
842 echo "Add peer with nidrange (gni)"
843 compare_peer_add "21@gni" "[22-25]@gni" || error
844 echo "Add peer with nidrange that overlaps primary nid (gni)"
845 compare_peer_add "21@gni" "[21-25]@gni"
847 run_test 21 "Add peer with nidrange (gni)"
850 reinit_dlc || return $?
851 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
853 - primary nid: 22@gni
864 do_lnetctl peer add --prim_nid 22@gni --nid [24-29]@gni ||
865 error "Peer add failed $?"
866 compare_peer_del "22@gni" "26@gni"
868 run_test 22 "Delete single secondary nid from peer (gni)"
871 reinit_dlc || return $?
872 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
874 - primary nid: 23@gni
881 do_lnetctl peer add --prim_nid 23@gni --nid [25-29]@gni ||
882 error "Peer add failed $?"
883 compare_peer_del "23@gni" "[25-29]@gni"
885 run_test 23 "Delete all secondary nids from peer (gni)"
888 reinit_dlc || return $?
889 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
891 - primary nid: 24@gni
896 - nid: 13.13.13.13@o2ib
897 - nid: 14.13.13.13@o2ib
898 - nid: 14.15.13.13@o2ib
900 - nid: 15.17.1.10@tcp
901 - nid: 15.17.1.20@tcp
904 do_lnetctl peer add --prim_nid 24@gni \
905 --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 ||
906 error "Peer add failed $?"
907 compare_peer_del "24@gni" "5@gni,13.15.13.13@o2ib,15.17.1.15@tcp"
909 run_test 24 "Delete a secondary nid from peer (tcp, o2ib and gni)"
912 reinit_dlc || return $?
913 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
915 - primary nid: 25@gni
921 do_lnetctl peer add --prim_nid 25@gni \
922 --nid [26-27].[4-10/3].26.26@tcp,26.26.26.26@o2ib,[30-35]@gni ||
923 error "Peer add failed $?"
924 compare_peer_del "25@gni" \
925 "[26-27].[4-10/3].26.26@tcp,26.26.26.26@o2ib,[30-35]@gni"
927 run_test 25 "Delete all secondary nids from peer (tcp, gni and o2ib)"
930 reinit_dlc || return $?
932 echo "Invalid prim_nid - peer add"
933 do_lnetctl peer add --prim_nid foobar &&
934 error "Command should have failed"
936 echo "Invalid prim_nid - peer del"
937 do_lnetctl peer del --prim_nid foobar &&
938 error "Command should have failed"
940 echo "Delete non-existing peer"
941 do_lnetctl peer del --prim_nid 1.1.1.1@o2ib &&
942 error "Command should have failed"
944 echo "Don't provide mandatory argument for peer del"
945 do_lnetctl peer del --nid 1.1.1.1@tcp &&
946 error "Command should have failed"
948 echo "Don't provide mandatory argument for peer add"
949 do_lnetctl peer add --nid 1.1.1.1@tcp &&
950 error "Command should have failed"
952 echo "Don't provide mandatory arguments peer add"
953 do_lnetctl peer add &&
954 error "Command should have failed"
956 echo "Invalid secondary nids"
957 do_lnetctl peer add --prim_nid 1.1.1.1@tcp --nid foobar &&
958 error "Command should have failed"
960 echo "Exceed max nids per peer"
961 do_lnetctl peer add --prim_nid 1.1.1.1@tcp --nid 1.1.1.[2-255]@tcp &&
962 error "Command should have failed"
964 echo "Invalid net type"
965 do_lnetctl peer add --prim_nid 1@foo &&
966 error "Command should have failed"
968 echo "Invalid nid format"
969 local invalid_nids="1@tcp 1@o2ib 1.1.1.1@gni"
972 for nid in ${invalid_nids}; do
973 echo "Check invalid primary nid - '$nid'"
974 do_lnetctl peer add --prim_nid $nid &&
975 error "Command should have failed"
978 local invalid_strs="[2-1]@gni [a-f/x]@gni 256.256.256.256@tcp"
979 invalid_strs+=" 1.1.1.1.[2-5/f]@tcp 1.]2[.3.4@o2ib"
980 invalid_strs+="1.[2-4,[5-6],7-8].1.1@tcp foobar"
983 for nidstr in ${invalid_strs}; do
984 echo "Check invalid nidstring - '$nidstr'"
985 do_lnetctl peer add --prim_nid 1.1.1.1@tcp --nid $nidstr &&
986 error "Command should have failed"
989 echo "Add non-local gateway"
990 do_lnetctl route add --net tcp --gateway 1@gni &&
991 error "Command should have failed"
995 run_test 99a "Check various invalid inputs to lnetctl peer"
998 reinit_dlc || return $?
1000 create_base_yaml_file
1002 cat <<EOF > $TMP/sanity-lnet-$testnum-invalid.yaml
1004 - primary nid: 99.99.99.99@tcp
1007 - nid: 99.99.99.99@tcp
1009 do_lnetctl import < $TMP/sanity-lnet-$testnum-invalid.yaml &&
1010 error "import should have failed"
1011 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
1014 run_test 99b "Invalid value for Multi-Rail in yaml import"
1018 local ip=$(ip addr show dev $if | awk '/ inet /{print $2}')
1026 if ! lsmod | grep -q ksocklnd ; then
1027 load_module ../lnet/klnds/socklnd/ksocklnd ||
1028 error "Can't load ksocklnd.ko"
1031 do_lnetctl net add --net ${net} --if ${if} ||
1032 error "Failed to add net ${net} on if ${if}"
1035 compare_route_add() {
1039 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
1041 do_lnetctl route add --net ${rnet} --gateway ${gw} ||
1042 error "route add failed $?"
1043 # CPT configuration is pruned from the exported yaml, since the default
1044 # can vary across test systems (unlike default values for things like
1045 # peer_credits, peer_timeout, etc.)
1046 $LNETCTL export --backup | grep -v CPT > $actual ||
1047 error "export failed $?"
1048 validate_gateway_nids
1053 reinit_dlc || return $?
1054 add_net "tcp" "${INTERFACES[0]}"
1055 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
1064 peer_buffer_credits: 0
1070 gateway: 7.7.7.7@tcp
1073 health_sensitivity: 1
1075 - primary nid: 7.7.7.7@tcp
1081 compare_route_add "tcp7" "7.7.7.7@tcp" || return $?
1084 run_test 100 "Add route with single gw (tcp)"
1087 reinit_dlc || return $?
1088 add_net "tcp" "${INTERFACES[0]}"
1089 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
1098 peer_buffer_credits: 0
1104 gateway: 8.8.8.10@tcp
1107 health_sensitivity: 1
1109 gateway: 8.8.8.9@tcp
1112 health_sensitivity: 1
1114 gateway: 8.8.8.8@tcp
1117 health_sensitivity: 1
1119 - primary nid: 8.8.8.9@tcp
1123 - primary nid: 8.8.8.10@tcp
1127 - primary nid: 8.8.8.8@tcp
1133 compare_route_add "tcp8" "8.8.8.[8-10]@tcp"
1135 run_test 101 "Add route with multiple gw (tcp)"
1137 compare_route_del() {
1141 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
1143 do_lnetctl route del --net ${rnet} --gateway ${gw} ||
1144 error "route del failed $?"
1145 $LNETCTL export --backup > $actual ||
1146 error "export failed $?"
1147 validate_gateway_nids
1151 reinit_dlc || return $?
1152 add_net "tcp" "${INTERFACES[0]}"
1153 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
1154 do_lnetctl route add --net tcp102 --gateway 102.102.102.102@tcp ||
1155 error "route add failed $?"
1156 compare_route_del "tcp102" "102.102.102.102@tcp"
1158 run_test 102 "Delete route with single gw (tcp)"
1161 reinit_dlc || return $?
1162 add_net "tcp" "${INTERFACES[0]}"
1163 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
1164 do_lnetctl route add --net tcp103 \
1165 --gateway 103.103.103.[103-120/4]@tcp ||
1166 error "route add failed $?"
1167 compare_route_del "tcp103" "103.103.103.[103-120/4]@tcp"
1169 run_test 103 "Delete route with multiple gw (tcp)"
1172 local tyaml="$TMP/sanity-lnet-$testnum-expected.yaml"
1174 reinit_dlc || return $?
1176 # Default value is '3'
1177 local val=$($LNETCTL global show | awk '/response_tracking/{print $NF}')
1179 error "Expect 3 found $val"
1181 echo "Set < 0; Should fail"
1182 do_lnetctl set response_tracking -1 &&
1183 error "should have failed $?"
1185 reinit_dlc || return $?
1188 response_tracking: -10
1190 do_lnetctl import < $tyaml &&
1191 error "should have failed $?"
1193 echo "Check valid values; Should succeed"
1195 for ((i = 0; i < 4; i++)); do
1196 reinit_dlc || return $?
1197 do_lnetctl set response_tracking $i ||
1198 error "should have succeeded $?"
1199 $LNETCTL global show | grep -q "response_tracking: $i" ||
1200 error "Failed to set response_tracking to $i"
1201 reinit_dlc || return $?
1204 response_tracking: $i
1206 do_lnetctl import < $tyaml ||
1207 error "should have succeeded $?"
1208 $LNETCTL global show | grep -q "response_tracking: $i" ||
1209 error "Failed to set response_tracking to $i"
1212 reinit_dlc || return $?
1213 echo "Set > 3; Should fail"
1214 do_lnetctl set response_tracking 4 &&
1215 error "should have failed $?"
1217 reinit_dlc || return $?
1220 response_tracking: 10
1222 do_lnetctl import < $tyaml &&
1223 error "should have failed $?"
1226 run_test 104 "Set/check response_tracking param"
1229 reinit_dlc || return $?
1230 add_net "tcp" "${INTERFACES[0]}"
1231 do_lnetctl route add --net tcp105 --gateway 105.105.105.105@tcp ||
1232 error "route add failed $?"
1233 do_lnetctl peer add --prim 105.105.105.105@tcp &&
1234 error "peer add should fail"
1238 run_test 105 "Adding duplicate GW peer should fail"
1241 reinit_dlc || return $?
1242 add_net "tcp" "${INTERFACES[0]}"
1243 do_lnetctl route add --net tcp106 --gateway 106.106.106.106@tcp ||
1244 error "route add failed $?"
1245 do_lnetctl peer del --prim 106.106.106.106@tcp &&
1246 error "peer del should fail"
1250 run_test 106 "Deleting GW peer should fail"
1253 cleanup_lnet || exit 1
1254 load_lnet "networks=\"\""
1255 do_ns $LNETCTL lnet configure --all || exit 1
1256 $LNETCTL net show --net tcp | grep -q "nid: ${FAKE_IP}@tcp$"
1258 run_test 200 "load lnet w/o module option, configure in a non-default namespace"
1261 cleanup_lnet || exit 1
1262 load_lnet "networks=tcp($FAKE_IF)"
1263 do_ns $LNETCTL lnet configure --all || exit 1
1264 $LNETCTL net show --net tcp | grep -q "nid: ${FAKE_IP}@tcp$"
1266 run_test 201 "load lnet using networks module options in a non-default namespace"
1269 cleanup_lnet || exit 1
1270 load_lnet "networks=\"\" ip2nets=\"tcp0($FAKE_IF) ${FAKE_IP}\""
1271 do_ns $LNETCTL lnet configure --all || exit 1
1272 $LNETCTL net show | grep -q "nid: ${FAKE_IP}@tcp$"
1274 run_test 202 "load lnet using ip2nets in a non-default namespace"
1277 ### Add the interfaces in the target namespace
1280 cleanup_lnet || exit 1
1282 do_lnetctl lnet configure || exit 1
1283 do_ns $LNETCTL net add --net tcp0 --if $FAKE_IF
1285 run_test 203 "add a network using an interface in the non-default namespace"
1287 LNET_PARAMS_FILE="$TMP/$TESTSUITE.parameters"
1288 function save_lnet_params() {
1289 $LNETCTL global show | egrep -v '^global:$' |
1290 sed 's/://' > $LNET_PARAMS_FILE
1293 function restore_lnet_params() {
1295 while read param value; do
1296 [[ $param == max_intf ]] && continue
1297 [[ $param == lnd_timeout ]] && continue
1298 $LNETCTL set ${param} ${value} ||
1299 error "Failed to restore ${param} to ${value}"
1300 done < $LNET_PARAMS_FILE
1303 function lnet_health_pre() {
1306 # Lower transaction timeout to speed up test execution
1307 $LNETCTL set transaction_timeout 10 ||
1308 error "Failed to set transaction_timeout $?"
1310 RETRY_PARAM=$($LNETCTL global show | awk '/retry_count/{print $NF}')
1311 RSND_PRE=$($LNETCTL stats show | awk '/resend_count/{print $NF}')
1312 LO_HVAL_PRE=$($LNETCTL net show -v 2 | awk '/health value/{print $NF}' |
1313 xargs echo | sed 's/ /+/g' | bc -l)
1315 RMT_HVAL_PRE=$($LNETCTL peer show --nid ${RNIDS[0]} -v 2 2>/dev/null |
1316 awk '/health value/{print $NF}' | xargs echo |
1317 sed 's/ /+/g' | bc -l)
1319 # Might not have any peers so initialize to zero.
1320 RMT_HVAL_PRE=${RMT_HVAL_PRE:-0}
1325 function lnet_health_post() {
1326 RSND_POST=$($LNETCTL stats show | awk '/resend_count/{print $NF}')
1327 LO_HVAL_POST=$($LNETCTL net show -v 2 |
1328 awk '/health value/{print $NF}' |
1329 xargs echo | sed 's/ /+/g' | bc -l)
1331 RMT_HVAL_POST=$($LNETCTL peer show --nid ${RNIDS[0]} -v 2 2>/dev/null |
1332 awk '/health value/{print $NF}' | xargs echo |
1333 sed 's/ /+/g' | bc -l)
1335 # Might not have any peers so initialize to zero.
1336 RMT_HVAL_POST=${RMT_HVAL_POST:-0}
1339 echo "Pre resends: $RSND_PRE" &&
1340 echo "Post resends: $RSND_POST" &&
1341 echo "Resends delta: $((RSND_POST - RSND_PRE))" &&
1342 echo "Pre local health: $LO_HVAL_PRE" &&
1343 echo "Post local health: $LO_HVAL_POST" &&
1344 echo "Pre remote health: $RMT_HVAL_PRE" &&
1345 echo "Post remote health: $RMT_HVAL_POST"
1349 do_lnetctl peer set --health 1000 --all
1350 do_lnetctl net set --health 1000 --all
1355 function check_no_resends() {
1356 echo "Check that no resends took place"
1357 [[ $RSND_POST -ne $RSND_PRE ]] &&
1358 error "Found resends: $RSND_POST != $RSND_PRE"
1363 function check_resends() {
1364 local delta=$((RSND_POST - RSND_PRE))
1366 echo "Check that $RETRY_PARAM resends took place"
1367 [[ $delta -ne $RETRY_PARAM ]] &&
1368 error "Expected $RETRY_PARAM resends found $delta"
1373 function check_no_local_health() {
1374 echo "Check that local NI health is unchanged"
1375 [[ $LO_HVAL_POST -ne $LO_HVAL_PRE ]] &&
1376 error "Local health changed: $LO_HVAL_POST != $LO_HVAL_PRE"
1381 function check_local_health() {
1382 echo "Check that local NI health has been changed"
1383 [[ $LO_HVAL_POST -eq $LO_HVAL_PRE ]] &&
1384 error "Local health unchanged: $LO_HVAL_POST == $LO_HVAL_PRE"
1389 function check_no_remote_health() {
1390 echo "Check that remote NI health is unchanged"
1391 [[ $RMT_HVAL_POST -ne $RMT_HVAL_PRE ]] &&
1392 error "Remote health changed: $RMT_HVAL_POST != $RMT_HVAL_PRE"
1397 function check_remote_health() {
1398 echo "Check that remote NI health has been changed"
1399 [[ $RMT_HVAL_POST -eq $RMT_HVAL_PRE ]] &&
1400 error "Remote health unchanged: $RMT_HVAL_POST == $RMT_HVAL_PRE"
1410 setup_health_test() {
1414 local rnodes=$(remote_nodes_list)
1415 [[ -z $rnodes ]] && skip "Need at least 1 remote node"
1417 cleanup_lnet || error "Failed to cleanup before test execution"
1419 # Loading modules should configure LNet with the appropriate
1420 # test-framework configuration
1421 load_lnet "config_on_load=1" || error "Failed to load modules"
1423 LNIDS=( $($LCTL list_nids | xargs echo) )
1425 RNODE=$(awk '{print $1}' <<<$rnodes)
1426 RNIDS=( $(do_node $RNODE $LCTL list_nids | xargs echo) )
1428 if [[ -z ${RNIDS[@]} ]]; then
1429 do_rpc_nodes $RNODE load_lnet "config_on_load=1"
1431 RNIDS=( $(do_node $RNODE $LCTL list_nids | xargs echo) )
1434 [[ ${#LNIDS[@]} -lt 1 ]] &&
1435 error "No NIDs configured for local host $HOSTNAME"
1436 [[ ${#RNIDS[@]} -lt 1 ]] &&
1437 error "No NIDs configured for remote host $RNODE"
1439 do_lnetctl discover ${RNIDS[0]} ||
1440 error "Unable to discover ${RNIDS[0]}"
1442 local mr=$($LNETCTL peer show --nid ${RNIDS[0]} |
1443 awk '/Multi-Rail/{print $NF}')
1445 if ${need_mr} && [[ $mr == False ]]; then
1446 cleanup_health_test || return $?
1450 if ( ! ${need_mr} && [[ ${#RNIDS[@]} -gt 1 ]] ) ||
1451 ( ! ${need_mr} && [[ ${#LNIDS[@]} -gt 1 ]] ); then
1452 cleanup_health_test || return $?
1456 if ${need_mr} && [[ ${#RNIDS[@]} -lt 2 ]]; then
1457 # Add a second, reachable NID to rnode.
1458 local net=${RNIDS[0]}
1462 local if=$(do_rpc_nodes --quiet $RNODE lnet_if_list)
1464 error "Failed to determine interface for $RNODE"
1466 do_rpc_nodes $RNODE "$LNETCTL lnet configure"
1467 do_rpc_nodes $RNODE "$LNETCTL net add --net $net --if $if" ||
1469 if [[ $rc -ne 0 ]]; then
1470 error "Failed to add interface to $RNODE rc=$?"
1472 RNIDS[1]="${RNIDS[0]}1"
1473 NET_DEL_ARGS="--net $net --if $if"
1477 if ${need_mr} && [[ ${#LNIDS[@]} -lt 2 ]]; then
1478 local net=${LNIDS[0]}
1481 do_lnetctl lnet configure &&
1482 do_lnetctl net add --net $net --if ${INTERFACES[0]} ||
1484 if [[ $rc -ne 0 ]]; then
1485 error "Failed to add interface rc=$?"
1487 LNIDS[1]="${LNIDS[0]}1"
1493 $LNETCTL peer show -v 2 | egrep -e nid -e health
1495 $LCTL set_param debug=+net
1501 cleanup_health_test() {
1504 if [[ -n $NET_DEL_ARGS ]]; then
1505 do_rpc_nodes $RNODE \
1506 "$LNETCTL net del $NET_DEL_ARGS" ||
1511 unload_modules || rc=$?
1514 do_rpc_nodes $RNODE unload_modules_local ||
1520 error "Failed cleanup"
1525 add_health_test_drop_rules() {
1529 for lnid in "${LNIDS[@]}"; do
1530 for rnid in "${RNIDS[@]}"; do
1531 $LCTL net_drop_add -s $lnid -d $rnid -m GET -r 1 -e ${hstatus}
1536 # See lnet/lnet/lib-msg.c:lnet_health_check()
1537 LNET_LOCAL_RESEND_STATUSES="local_interrupt local_dropped local_aborted"
1538 LNET_LOCAL_RESEND_STATUSES+=" local_no_route local_timeout"
1539 LNET_LOCAL_NO_RESEND_STATUSES="local_error"
1541 setup_health_test false || return $?
1544 for hstatus in ${LNET_LOCAL_RESEND_STATUSES} \
1545 ${LNET_LOCAL_NO_RESEND_STATUSES}; do
1546 echo "Simulate $hstatus"
1547 lnet_health_pre || return $?
1549 add_health_test_drop_rules ${hstatus}
1550 do_lnetctl discover ${RNIDS[0]} &&
1551 error "Should have failed"
1552 $LCTL net_drop_del -a
1556 check_no_resends || return $?
1557 check_no_local_health || return $?
1560 cleanup_health_test || return $?
1564 run_test 204 "Check no health or resends for single-rail local failures"
1567 setup_health_test true || return $?
1570 for hstatus in ${LNET_LOCAL_RESEND_STATUSES}; do
1571 echo "Simulate $hstatus"
1572 lnet_health_pre || return $?
1574 add_health_test_drop_rules ${hstatus}
1575 do_lnetctl discover ${RNIDS[0]} &&
1576 error "Should have failed"
1577 $LCTL net_drop_del -a
1581 check_resends || return $?
1582 check_local_health || return $?
1585 for hstatus in ${LNET_LOCAL_NO_RESEND_STATUSES}; do
1586 echo "Simulate $hstatus"
1587 lnet_health_pre || return $?
1589 add_health_test_drop_rules ${hstatus}
1590 do_lnetctl discover ${RNIDS[0]} &&
1591 error "Should have failed"
1592 $LCTL net_drop_del -a
1596 check_no_resends || return $?
1597 check_local_health || return $?
1600 cleanup_health_test || return $?
1604 run_test 205 "Check health and resends for multi-rail local failures"
1606 # See lnet/lnet/lib-msg.c:lnet_health_check()
1607 LNET_REMOTE_RESEND_STATUSES="remote_dropped"
1608 LNET_REMOTE_NO_RESEND_STATUSES="remote_error remote_timeout"
1610 setup_health_test false || return $?
1613 for hstatus in ${LNET_REMOTE_RESEND_STATUSES} \
1614 ${LNET_REMOTE_NO_RESEND_STATUSES}; do
1615 echo "Simulate $hstatus"
1616 lnet_health_pre || return $?
1618 add_health_test_drop_rules ${hstatus}
1619 do_lnetctl discover ${RNIDS[0]} &&
1620 error "Should have failed"
1621 $LCTL net_drop_del -a
1625 check_no_resends || return $?
1626 check_no_local_health || return $?
1627 check_no_remote_health || return $?
1630 cleanup_health_test || return $?
1634 run_test 206 "Check no health or resends for single-rail remote failures"
1637 setup_health_test true || return $?
1640 for hstatus in ${LNET_REMOTE_RESEND_STATUSES}; do
1641 echo "Simulate $hstatus"
1642 lnet_health_pre || return $?
1644 add_health_test_drop_rules ${hstatus}
1646 do_lnetctl discover ${RNIDS[0]} &&
1647 error "Should have failed"
1651 $LCTL net_drop_del -a
1653 check_resends || return $?
1654 check_no_local_health || return $?
1655 check_remote_health || return $?
1656 do_lnetctl peer set --health 1000 --all ||
1657 error "Unable to reset health rc=$?"
1659 for hstatus in ${LNET_REMOTE_NO_RESEND_STATUSES}; do
1660 echo "Simulate $hstatus"
1661 lnet_health_pre || return $?
1663 add_health_test_drop_rules ${hstatus}
1665 do_lnetctl discover ${RNIDS[0]} &&
1666 error "Should have failed"
1670 $LCTL net_drop_del -a
1672 check_no_resends || return $?
1673 check_no_local_health || return $?
1674 check_remote_health || return $?
1675 do_lnetctl peer set --health 1000 --all ||
1676 error "Unable to reset health rc=$?"
1679 cleanup_health_test || return $?
1683 run_test 207 "Check health and resends for multi-rail remote errors"
1685 test_208_load_and_check_lnet() {
1689 local num_expected=1
1691 load_lnet "networks=\"\" ip2nets=\"${ip2nets_str}\""
1694 error "Failed to load LNet with ip2nets \"${ip2nets_str}\""
1700 nids=( $($LCTL list_nids) )
1702 [[ ${#nids[@]} -ne ${num_expected} ]] &&
1703 error "Expect ${num_expected} NIDs found ${#nids[@]}"
1705 [[ ${nids[0]} == ${p_nid} ]] ||
1706 error "Expect NID \"${p_nid}\" found \"${nids[0]}\""
1708 [[ -n $s_nid ]] && [[ ${nids[1]} != ${s_nid} ]] &&
1709 error "Expect second NID \"${s_nid}\" found \"${nids[1]}\""
1711 $LCTL net down &>/dev/null
1716 cleanup_netns || error "Failed to cleanup netns before test execution"
1717 cleanup_lnet || error "Failed to unload modules before test execution"
1718 setup_fakeif || error "Failed to add fake IF"
1720 have_interface "$FAKE_IF" ||
1721 error "Expect $FAKE_IF configured but not found"
1723 local if0_ip=$(ip --oneline addr show dev ${INTERFACES[0]} |
1724 awk '/inet /{print $4}' |
1726 if0_ip=($(echo "${if0_ip[@]}" | tr ' ' '\n' | uniq | tr '\n' ' '))
1727 local ip2nets_str="tcp(${INTERFACES[0]}) $if0_ip"
1729 echo "Configure single NID \"$ip2nets_str\""
1730 test_208_load_and_check_lnet "${ip2nets_str}" "${if0_ip}@tcp"
1732 ip2nets_str="tcp(${INTERFACES[0]}) $if0_ip; tcp1($FAKE_IF) $FAKE_IP"
1733 echo "Configure two NIDs; two NETs \"$ip2nets_str\""
1734 test_208_load_and_check_lnet "${ip2nets_str}" "${if0_ip}@tcp" \
1737 ip2nets_str="tcp(${INTERFACES[0]}) $if0_ip; tcp($FAKE_IF) $FAKE_IP"
1738 echo "Configure two NIDs; one NET \"$ip2nets_str\""
1739 test_208_load_and_check_lnet "${ip2nets_str}" "${if0_ip}@tcp" \
1741 local addr1=( ${if0_ip//./ } )
1742 local addr2=( ${FAKE_IP//./ } )
1743 local range="[${addr1[0]},${addr2[0]}]"
1746 for i in $(seq 1 3); do
1747 range+=".[${addr1[$i]},${addr2[$i]}]"
1749 ip2nets_str="tcp(${INTERFACES[0]},${FAKE_IF}) ${range}"
1751 echo "Configured two NIDs; one NET alt syntax \"$ip2nets_str\""
1752 test_208_load_and_check_lnet "${ip2nets_str}" "${if0_ip}@tcp" \
1757 echo "alt syntax with missing IF \"$ip2nets_str\""
1758 load_lnet "networks=\"\" ip2nets=\"${ip2nets_str}\""
1760 echo "$LCTL net up should fail"
1762 error "LNet bringup should have failed"
1766 run_test 208 "Test various kernel ip2nets configurations"
1769 setup_health_test false || return $?
1771 echo "Simulate network_timeout w/SR config"
1774 add_health_test_drop_rules network_timeout
1776 do_lnetctl discover ${RNIDS[0]} &&
1777 error "Should have failed"
1778 $LCTL net_drop_del -a
1782 check_no_resends || return $?
1783 check_no_local_health || return $?
1784 check_no_remote_health || return $?
1786 cleanup_health_test || return $?
1788 setup_health_test true || return $?
1790 echo "Simulate network_timeout w/MR config"
1794 add_health_test_drop_rules network_timeout
1796 do_lnetctl discover ${RNIDS[0]} &&
1797 error "Should have failed"
1798 $LCTL net_drop_del -a
1802 check_no_resends || return $?
1803 check_local_health || return $?
1804 check_remote_health || return $?
1806 cleanup_health_test || return $?
1810 run_test 209 "Check health, but not resends, for network timeout"
1812 check_nid_in_recovq() {
1813 local recovq=$($LNETCTL debug recovery $1)
1815 local nids=$($LCTL list_nids | xargs echo)
1819 echo "Check \"$1\" recovery queue"
1821 if [[ $(grep -c 'nid-'<<<$recovq) -ne $expect ]]; then
1822 error "Expect $expect NIDs found: \"$recovq\""
1825 [[ $expect -eq 0 ]] && return 0
1827 for nid in ${nids}; do
1828 grep -q "nid-0: $nid"<<<$recovq &&
1833 error "Didn't find local NIDs in recovery queue: \"$recovq\""
1839 # First enqueue happens at time 0.
1840 # 2nd at 0 + 2^0 = 1
1841 # 3rd at 1 + 2^1 = 3
1842 # 4th at 3 + 2^2 = 7
1843 # 5th at 7 + 2^3 = 15
1844 # e.g. after 10 seconds we would expect to have seen the 4th enqueue,
1845 # (3 pings sent, 4th about to happen) and the 5th enqueue is yet to
1847 # If the recovery limit is 10 seconds, then when the 5th enqueue happens
1848 # we expect the peer NI to have aged out, so it will not actually be
1850 # If max_recovery_ping_interval is set to 2 then:
1851 # First enqueue happens at time 0.
1852 # 2nd at 0 + 2^0 = 1
1853 # 3rd at 1 + 2^1 = 3
1854 # 4th at 3 + 2^1 = 5
1855 # 5th at 5 + 2^1 = 7
1856 # 6th at 7 + 2^1 = 9
1857 # 7th at 9 + 2^1 = 11
1858 # e.g. after 4 seconds we would expect to have seen the 3th enqueue,
1859 # (2 pings sent, 3rd about to happen), and the 4th enqueue is yet to happen
1860 # e.g. after 10 seconds we would expect to have seen the 6th enqueue,
1861 # (5 pings sent, 6th about to happen), and the 8th enqueue is yet to happen
1862 check_ping_count() {
1866 echo "Check ping counts:"
1868 if [[ $queue == "ni" ]]; then
1869 $LNETCTL net show -v 2 | egrep 'nid|health value|ping'
1870 ping_count=( $($LNETCTL net show -v 2 |
1871 awk '/ping_count/{print $NF}') )
1872 elif [[ $queue == "peer_ni" ]]; then
1873 $LNETCTL peer show -v 2 | egrep 'nid|health value|ping'
1874 ping_count=( $($LNETCTL peer show -v 2 |
1875 awk '/ping_count/{print $NF}') )
1877 error "Unrecognized queue \"$queue\""
1883 for count in "${ping_count[@]}"; do
1884 if [[ $count -eq $expect ]]; then
1885 if [[ $expect -ne 0 ]] && $found ; then
1886 error "Found more than one interface matching \"$expect\" ping count"
1889 echo "Expect ping count \"$expect\" found \"$count\""
1892 elif [[ $count -ne 0 ]]; then
1893 error "Found interface with ping count \"$count\" but expect \"$expect\""
1902 reinit_dlc || return $?
1903 add_net "tcp" "${INTERFACES[0]}" || return $?
1904 add_net "tcp1" "${INTERFACES[0]}" || return $?
1906 local prim_nid=$($LCTL list_nids | head -n 1)
1908 do_lnetctl discover $prim_nid ||
1909 error "failed to discover myself"
1911 local default=$($LNETCTL global show |
1912 awk '/recovery_limit/{print $NF}')
1913 # Set recovery limit to 10 seconds.
1914 do_lnetctl set recovery_limit 10 ||
1915 error "failed to set recovery_limit"
1917 $LCTL set_param debug=+net
1918 # Use local_error so LNet doesn't attempt to resend the discovery ping
1919 $LCTL net_drop_add -s *@tcp -d *@tcp -m GET -r 1 -e local_error
1920 $LCTL net_drop_add -s *@tcp1 -d *@tcp1 -m GET -r 1 -e local_error
1921 do_lnetctl discover $prim_nid &&
1922 error "Expected discovery to fail"
1924 # See comment for check_ping_count()
1926 check_nid_in_recovq "-l" "1"
1927 check_ping_count "ni" "2"
1931 check_nid_in_recovq "-l" "1"
1932 check_ping_count "ni" "3"
1934 $LCTL net_drop_del -a
1936 reinit_dlc || return $?
1937 add_net "tcp" "${INTERFACES[0]}" || return $?
1938 add_net "tcp1" "${INTERFACES[0]}" || return $?
1940 local prim_nid=$($LCTL list_nids | head -n 1)
1942 do_lnetctl discover $prim_nid ||
1943 error "failed to discover myself"
1945 do_lnetctl set recovery_limit $default ||
1946 error "failed to set recovery_limit"
1948 default=$($LNETCTL global show |
1949 awk '/max_recovery_ping_interval/{print $NF}')
1950 do_lnetctl set max_recovery_ping_interval 2 ||
1951 error "failed to set max_recovery_ping_interval"
1953 $LCTL set_param debug=+net
1954 # Use local_error so LNet doesn't attempt to resend the discovery ping
1955 $LCTL net_drop_add -s *@tcp -d *@tcp -m GET -r 1 -e local_error
1956 $LCTL net_drop_add -s *@tcp1 -d *@tcp1 -m GET -r 1 -e local_error
1957 do_lnetctl discover $prim_nid &&
1958 error "Expected discovery to fail"
1960 # See comment for check_ping_count()
1962 check_nid_in_recovq "-l" "1"
1963 check_ping_count "ni" "2"
1966 check_nid_in_recovq "-l" "1"
1967 check_ping_count "ni" "5"
1969 $LCTL net_drop_del -a
1971 do_lnetctl set max_recovery_ping_interval $default ||
1972 error "failed to set max_recovery_ping_interval"
1976 run_test 210 "Local NI recovery checks"
1979 reinit_dlc || return $?
1980 add_net "tcp" "${INTERFACES[0]}" || return $?
1981 add_net "tcp1" "${INTERFACES[0]}" || return $?
1983 local prim_nid=$($LCTL list_nids | head -n 1)
1985 do_lnetctl discover $prim_nid ||
1986 error "failed to discover myself"
1988 local default=$($LNETCTL global show |
1989 awk '/recovery_limit/{print $NF}')
1990 # Set recovery limit to 10 seconds.
1991 do_lnetctl set recovery_limit 10 ||
1992 error "failed to set recovery_limit"
1994 $LCTL net_drop_add -s *@tcp -d *@tcp -m GET -r 1 -e remote_error
1995 $LCTL net_drop_add -s *@tcp1 -d *@tcp1 -m GET -r 1 -e remote_error
1997 # Set health to 0 on one interface. This forces it onto the recovery
1999 $LNETCTL peer set --nid $prim_nid --health 0
2001 # After 5 seconds, we expect the peer NI to still be in recovery
2003 check_nid_in_recovq "-p" 1
2004 check_ping_count "peer_ni" "2"
2006 # After 15 seconds, the peer NI should have been fully processed out of
2007 # the recovery queue. We'll allow a total of 17 seconds to account for
2008 # differences in sleeping for whole seconds vs. the more accurate time
2009 # keeping that is done in the recovery code.
2011 check_nid_in_recovq "-p" 0
2012 check_ping_count "peer_ni" "4"
2014 $LCTL net_drop_del -a
2016 # Set health to force it back onto the recovery queue. Set to 500 means
2017 # in 5 seconds it should be back at maximum value. We'll wait a couple
2018 # more seconds than that to be safe.
2019 # NB: we reset the recovery limit to 0 (indefinite) so the peer NI is
2021 do_lnetctl set recovery_limit 0 ||
2022 error "failed to set recovery_limit"
2024 $LNETCTL peer set --nid $prim_nid --health 500
2026 check_nid_in_recovq "-p" 1
2027 check_ping_count "peer_ni" "2"
2031 check_nid_in_recovq "-p" 0
2032 check_ping_count "peer_ni" "0"
2034 reinit_dlc || return $?
2035 add_net "tcp" "${INTERFACES[0]}" || return $?
2036 add_net "tcp1" "${INTERFACES[0]}" || return $?
2038 local prim_nid=$($LCTL list_nids | head -n 1)
2040 do_lnetctl discover $prim_nid ||
2041 error "failed to discover myself"
2043 do_lnetctl set recovery_limit $default ||
2044 error "failed to set recovery_limit"
2046 default=$($LNETCTL global show |
2047 awk '/max_recovery_ping_interval/{print $NF}')
2048 do_lnetctl set max_recovery_ping_interval 2 ||
2049 error "failed to set max_recovery_ping_interval"
2051 $LCTL net_drop_add -s *@tcp -d *@tcp -m GET -r 1 -e remote_error
2052 $LCTL net_drop_add -s *@tcp1 -d *@tcp1 -m GET -r 1 -e remote_error
2054 # Set health to 0 on one interface. This forces it onto the recovery
2056 $LNETCTL peer set --nid $prim_nid --health 0
2058 # See comment for check_ping_count()
2060 check_nid_in_recovq "-p" "1"
2061 check_ping_count "peer_ni" "2"
2064 check_nid_in_recovq "-p" "1"
2065 check_ping_count "peer_ni" "5"
2067 $LCTL net_drop_del -a
2069 do_lnetctl set max_recovery_ping_interval $default ||
2070 error "failed to set max_recovery_ping_interval"
2074 run_test 211 "Remote NI recovery checks"
2077 local rnodes=$(remote_nodes_list)
2078 [[ -z $rnodes ]] && skip "Need at least 1 remote node"
2080 cleanup_lnet || error "Failed to cleanup before test execution"
2082 # Loading modules should configure LNet with the appropriate
2083 # test-framework configuration
2084 load_lnet "config_on_load=1" || error "Failed to load modules"
2086 local my_nid=$($LCTL list_nids | head -n 1)
2088 error "Failed to get primary NID for local host $HOSTNAME"
2090 local rnode=$(awk '{print $1}' <<<$rnodes)
2091 local rnodenids=$(do_node $rnode $LCTL list_nids | xargs echo)
2094 if [[ -z $rnodenids ]]; then
2095 do_rpc_nodes $rnode load_lnet "config_on_load=1"
2097 rnodenids=$(do_node $rnode $LCTL list_nids | xargs echo)
2100 local rnodepnid=$(awk '{print $1}' <<< $rnodenids)
2102 [[ -z $rnodepnid ]] &&
2103 error "Failed to get primary NID for remote host $rnode"
2105 log "Initial discovery"
2106 do_lnetctl discover --force $rnodepnid ||
2107 error "Failed to discover $rnodepnid"
2109 do_node $rnode "$LNETCTL discover --force $my_nid" ||
2110 error "$rnode failed to discover $my_nid"
2112 log "Fail local discover ping to set LNET_PEER_REDISCOVER flag"
2113 $LCTL net_drop_add -s "*@$NETTYPE" -d "*@$NETTYPE" -r 1 -e local_error
2114 do_lnetctl discover --force $rnodepnid &&
2115 error "Discovery should have failed"
2116 $LCTL net_drop_del -a
2119 for nid in $rnodenids; do
2120 # We need GET (PING) delay just long enough so we can trigger
2121 # discovery on the remote peer
2122 $LCTL net_delay_add -s "*@$NETTYPE" -d $nid -r 1 -m GET -l 3
2123 $LCTL net_drop_add -s "*@$NETTYPE" -d $nid -r 1 -m GET -e local_error
2124 # We need PUT (PUSH) delay just long enough so we can process
2126 $LCTL net_delay_add -s "*@$NETTYPE" -d $nid -r 1 -m PUT -l 6
2129 log "Force $HOSTNAME to discover $rnodepnid (in background)"
2130 # We want to get a PING sent that we know will eventually fail.
2131 # The delay rules we added will ensure the ping is not sent until
2132 # the PUSH is also in flight (see below), and the drop rule ensures that
2133 # when the PING is eventually sent it will error out
2134 do_lnetctl discover --force $rnodepnid &
2137 # We want a discovery PUSH from rnode to put rnode back on our
2138 # discovery queue. This should cause us to try and send a PUSH to rnode
2139 # while the PING is still outstanding.
2140 log "Force $rnode to discover $my_nid"
2141 do_node $rnode $LNETCTL discover --force $my_nid
2143 # At this point we'll have both PING_SENT and PUSH_SENT set for the
2144 # rnode peer. Wait for the PING to error out which should terminate the
2145 # discovery process that we backgrounded.
2146 log "Wait for $pid1"
2148 log "Finished wait on $pid1"
2150 # The PING send failure clears the PING_SENT flag and puts the peer back
2151 # on the discovery queue. When discovery thread processes the peer it
2152 # will mistakenly clear the PUSH_SENT flag (and set PUSH_FAILED).
2153 # Discovery will then complete for this peer even though we have an
2155 # When PUSH is actually unlinked it will be forced back onto the
2156 # discovery queue, but we no longer have a ref on the peer. When
2157 # discovery completes again, we'll trip the ASSERT in
2158 # lnet_destroy_peer_locked()
2160 # Delete the delay rules to send the PUSH
2161 $LCTL net_delay_del -a
2162 # Delete the drop rules
2163 $LCTL net_drop_del -a
2166 error "Failed to unload modules"
2168 do_rpc_nodes $rnode unload_modules_local ||
2169 error "Failed to unload modules on $rnode"
2174 run_test 212 "Check discovery refcount loss bug (LU-14627)"
2177 cleanup_netns || error "Failed to cleanup netns before test execution"
2178 cleanup_lnet || error "Failed to unload modules before test execution"
2180 setup_fakeif || error "Failed to add fake IF"
2181 have_interface "$FAKE_IF" ||
2182 error "Expect $FAKE_IF configured but not found"
2184 reinit_dlc || return $?
2186 add_net "tcp" "${INTERFACES[0]}" || return $?
2187 add_net "tcp" "$FAKE_IF" || return $?
2189 local nid1=$(lctl list_nids | head -n 1)
2190 local nid2=$(lctl list_nids | tail --lines 1)
2192 [[ $(lctl which_nid $nid1 $nid2) == $nid1 ]] ||
2193 error "Expect nid1 \"$nid1\" to be preferred"
2195 [[ $(lctl which_nid $nid2 $nid1) == $nid2 ]] ||
2196 error "Expect nid2 \"$nid2\" to be preferred"
2200 run_test 213 "Check LNetDist calculation for multiple local NIDs"
2202 function check_ni_status() {
2206 local status=$($LNETCTL net show |
2208 awk '/status/{print $NF}')
2210 echo "NI ${nid} expect status \"${expect}\" found \"${status}\""
2211 if [[ $status != $expect ]]; then
2212 error "Error: Expect NI status \"$expect\" for NID \"$nid\" but found \"$status\""
2219 cleanup_netns || error "Failed to cleanup netns before test execution"
2220 cleanup_lnet || error "Failed to unload modules before test execution"
2222 setup_fakeif || error "Failed to add fake IF"
2223 have_interface "$FAKE_IF" ||
2224 error "Expect $FAKE_IF configured but not found"
2226 reinit_dlc || return $?
2228 add_net "tcp" "${INTERFACES[0]}" || return $?
2229 add_net "tcp" "$FAKE_IF" || return $?
2231 local nid1=$(lctl list_nids | head -n 1)
2232 local nid2=$(lctl list_nids | tail --lines 1)
2234 check_ni_status "0@lo" up
2235 check_ni_status "$nid1" up
2236 check_ni_status "$nid2" up
2238 echo "Set $FAKE_IF down"
2239 echo "ip link set dev $FAKE_IF down"
2240 ip link set dev $FAKE_IF down
2241 check_ni_status "0@lo" up
2242 check_ni_status "$nid1" up
2243 check_ni_status "$nid2" down
2245 run_test 214 "Check local NI status when link is downed"
2251 $LNETCTL net show -v 2 |
2252 egrep -e nid -e $stat |
2254 awk '/'$stat':/{print $NF}'
2259 for nidvar in nid1 nid2; do
2260 for stat in send_count recv_count; do
2261 s=$(get_ni_stat ${!nidvar} $stat)
2262 eval ${nidvar}_pre_${stat}=$s
2269 for nidvar in nid1 nid2; do
2270 for stat in send_count recv_count; do
2271 s=$(get_ni_stat ${!nidvar} $stat)
2272 eval ${nidvar}_post_${stat}=$s
2282 eval pre=\${${nidvar}_pre_${stat}}
2283 eval post=\${${nidvar}_post_${stat}}
2285 echo "${!nidvar} pre ${stat} $pre post ${stat} $post"
2287 [[ $pre -ne $post ]]
2291 cleanup_netns || error "Failed to cleanup netns before test execution"
2292 cleanup_lnet || error "Failed to unload modules before test execution"
2294 reinit_dlc || return $?
2296 add_net "tcp1" "${INTERFACES[0]}" || return $?
2297 add_net "tcp2" "${INTERFACES[0]}" || return $?
2299 local nid1=$($LCTL list_nids | head -n 1)
2300 local nid2=$($LCTL list_nids | tail --lines 1)
2302 do_lnetctl peer add --prim $nid1 --nid $nid2 ||
2303 error "Failed to add peer"
2307 for nidvarA in nid1 nid2; do
2310 for nidvarB in nid1 nid2; do
2311 [[ $nidvarA == $nidvarB ]] && continue
2315 echo "$LNETCTL ping $dst x $npings"
2316 for i in $(seq 1 $npings); do
2317 $LNETCTL ping $dst &>/dev/null ||
2318 error "$LNETCTL ping $dst failed"
2323 # No source specified, sends to either NID should cause
2324 # counts to increase across both NIs
2325 for nidvar in nid1 nid2; do
2326 for stat in send_count recv_count; do
2327 ni_stat_changed $nidvar $stat ||
2328 error "$stat unchanged for ${!nidvar}"
2334 echo "$LNETCTL ping --source $src $dst x $npings"
2335 for i in $(seq 1 $npings); do
2336 $LNETCTL ping --source $src $dst &>/dev/null ||
2337 error "$LNETCTL ping --source $src $dst failed"
2342 # src nid == dest nid means stats for the _other_ NI
2343 # should be unchanged
2344 for nidvar in nid1 nid2; do
2345 for stat in send_count recv_count; do
2346 if [[ ${!nidvar} == $src ]]; then
2347 ni_stat_changed $nidvar $stat ||
2348 error "$stat unchanged for ${!nidvar}"
2350 ni_stat_changed $nidvar $stat &&
2351 error "$stat changed for ${!nidvar}"
2356 # Double number of pings for next iteration because the net
2357 # sequence numbers will have diverged
2358 npings=$(($npings * 2))
2361 # Ping from nid1 to nid2 should fail
2362 do_lnetctl ping --source $nid1 $nid2 &&
2363 error "ping from $nid1 to $nid2 should fail"
2365 # Ping from nid2 to nid1 should fail
2366 do_lnetctl ping --source $nid2 $nid1 &&
2367 error "ping from $nid2 to $nid1 should fail"
2371 run_test 215 "Test lnetctl ping --source option"
2376 reinit_dlc || return $?
2378 add_net "tcp" "${INTERFACES[0]}" || return $?
2379 add_net "tcp1" "${INTERFACES[0]}" || return $?
2381 local nids=( $($LCTL list_nids | xargs echo) )
2383 do_lnetctl discover ${nids[0]} ||
2384 error "Initial discovery failed"
2386 do_lnetctl ping --source ${nids[0]} ${nids[0]} ||
2387 error "Initial ping failed $?"
2389 do_lnetctl ping --source ${nids[1]} ${nids[1]} ||
2390 error "Initial ping failed $?"
2393 for src in "${nids[@]}"; do
2394 for dst in "${nids[@]}"; do
2395 $LCTL net_drop_add -r 1 -s $src -d $dst -e network_timeout
2399 do_lnetctl ping ${nids[0]} || rc=$?
2401 $LCTL net_drop_del -a
2404 error "expected ping to fail"
2406 check_nid_in_recovq "-p" 0
2407 check_nid_in_recovq "-l" 1
2411 run_test 216 "Failed send to peer NI owned by local host should not trigger peer NI recovery"
2414 reinit_dlc || return $?
2416 [[ $($LNETCTL net show | grep -c nid) -ne 1 ]] &&
2417 error "Unexpected number of NIs after initalizing DLC"
2419 do_lnetctl discover 0@lo ||
2420 error "Failed to discover 0@lo"
2424 run_test 217 "Don't leak memory when discovering peer with nnis <= 1"
2427 reinit_dlc || return $?
2429 [[ ${#INTERFACES[@]} -lt 2 ]] &&
2430 skip "Need two LNet interfaces"
2432 add_net "tcp" "${INTERFACES[0]}" || return $?
2434 local nid1=$($LCTL list_nids | head -n 1)
2436 do_lnetctl ping $nid1 ||
2439 add_net "tcp" "${INTERFACES[1]}" || return $?
2441 local nid2=$($LCTL list_nids | tail --lines 1)
2443 do_lnetctl ping $nid2 ||
2446 $LCTL net_drop_add -s $nid1 -d $nid1 -e local_error -r 1
2448 do_lnetctl ping $nid1 &&
2449 error "ping should have failed"
2451 local health_recovered
2454 for i in $(seq 1 5); do
2455 health_recovered=$($LNETCTL net show -v 2 |
2456 grep -c 'health value: 1000')
2458 if [[ $health_recovered -ne 2 ]]; then
2459 echo "Wait 1 second for health to recover"
2466 health_recovered=$($LNETCTL net show -v 2 |
2467 grep -c 'health value: 1000')
2469 $LCTL net_drop_del -a
2471 [[ $health_recovered -ne 2 ]] &&
2472 do_lnetctl net show -v 2 | egrep -e nid -e health &&
2473 error "Health hasn't recovered"
2477 run_test 218 "Local recovery pings should exercise all available paths"
2480 reinit_dlc || return $?
2481 add_net "tcp" "${INTERFACES[0]}" || return $?
2482 add_net "tcp1" "${INTERFACES[0]}" || return $?
2484 local nid1=$(lctl list_nids | head -n 1)
2485 local nid2=$(lctl list_nids | tail --lines 1)
2487 do_lnetctl ping $nid1 ||
2488 error "Ping failed $?"
2489 do_lnetctl ping $nid2 ||
2490 error "Ping failed $?"
2492 do_lnetctl discover $nid2 ||
2493 error "Discovery failed"
2495 $LNETCTL peer show --nid $nid1 | grep -q $nid2 ||
2496 error "$nid2 is not listed under $nid1"
2498 run_test 219 "Consolidate peer entries"
2502 echo "Check valid values; Should succeed"
2506 for ((i = 4; i < 16; i+=1)); do
2507 reinit_dlc || return $?
2508 add_net "tcp" "${INTERFACES[0]}" || return $?
2509 do_lnetctl net set --all --conns-per-peer $i ||
2510 error "should have succeeded $?"
2511 $LNETCTL net show -v 1 | grep -q "conns_per_peer: $i" ||
2512 error "failed to set conns-per-peer to $i"
2513 lnid="$(lctl list_nids | head -n 1)"
2514 do_lnetctl ping "$lnid" ||
2515 error "failed to ping myself"
2517 # "lctl --net tcp conn_list" prints the list of active
2518 # connections. Since we're pinging ourselves, there should be
2519 # 2 Control connections plus 2*conns_per_peer connections
2520 # created (one Bulk Input, one Bulk Output in each pair).
2521 # Here's the sample output for conns_per_peer set to 1:
2522 # 12345-1.1.1.1@tcp I[0]host01->host01:988 2626560/1061296 nonagle
2523 # 12345-1.1.1.1@tcp O[0]host01->host01:1022 2626560/1061488 nonagle
2524 # 12345-1.1.1.1@tcp C[0]host01->host01:988 2626560/1061296 nonagle
2525 # 12345-1.1.1.1@tcp C[0]host01->host01:1023 2626560/1061488 nonagle
2526 cmd="printf 'network tcp\nconn_list\n' | lctl | grep -c '$lnid'"
2528 # Expect 2+conns_per_peer*2 connections. Wait no longer
2530 wait_update $HOSTNAME "$cmd" "$((2+i*2))" 2 ||
2531 error "expected number of tcp connections $((2+i*2))"
2534 reinit_dlc || return $?
2535 add_net "tcp" "${INTERFACES[0]}" || return $?
2536 echo "Set > 127; Should fail"
2537 do_lnetctl net set --all --conns-per-peer 128 &&
2538 error "should have failed $?"
2540 reinit_dlc || return $?
2541 add_net "tcp" "${INTERFACES[0]}" || return $?
2542 echo "Set < 0; Should be ignored"
2543 do_lnetctl net set --all --conns-per-peer -1 ||
2544 error "should have succeeded $?"
2545 $LNETCTL net show -v 1 | grep -q "conns_per_peer: 1" ||
2546 error "Did not stay at default"
2548 run_test 230 "Test setting conns-per-peer"
2550 ### Test that linux route is added for each ni
2552 reinit_dlc || return $?
2553 add_net "tcp" "${INTERFACES[0]}" || return $?
2554 ip route show table ${INTERFACES[0]} | grep -q "${INTERFACES[0]}"
2556 run_test 250 "test that linux routes are added"
2561 local out=$TMP/$tfile
2562 local prefix=/usr/include/linux/lnet
2564 # We use a hard coded prefix so that this test will not fail
2567 if ! which $CC > /dev/null 2>&1; then
2568 skip_env "$CC is not installed"
2571 cleanup_lnet || exit 1
2574 local cc_args="-Wall -Werror -std=c99 -c -x c /dev/null -o $out"
2575 if ! [[ -d $prefix ]]; then
2576 # Assume we're running in tree and fixup the include path.
2577 prefix=$LUSTRE/../lnet/include/uapi/linux/lnet
2578 cc_args+=" -I $LUSTRE/../lnet/include/uapi"
2581 for header in $prefix/*.h; do
2582 if ! [[ -f "$header" ]]; then
2586 echo "$CC $cc_args -include $header"
2587 $CC $cc_args -include $header ||
2588 error "cannot compile '$header'"
2592 run_test 300 "packaged LNet UAPI headers can be compiled"