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]* ]]; 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
363 compare_peer_add "6.6.6.6@tcp" \
364 "6.6.[6-7].[0-4/2]@tcp,6.6.[1-4/2].[0-6/3]@o2ib,[6-12/4]@gni"
366 run_test 6 "Add peer with multiple nidranges"
369 local prim_nid="${1:+--prim_nid $1}"
370 local nid="${2:+--nid $2}"
372 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
374 do_lnetctl peer del ${prim_nid} ${nid} || error "peer del failed $?"
375 $LNETCTL export --backup > $actual || error "export failed $?"
381 reinit_dlc || return $?
382 create_base_yaml_file
384 echo "Delete peer with single nid (tcp)"
385 do_lnetctl peer add --prim_nid 7.7.7.7@tcp || error "Peer add failed $?"
386 compare_peer_del "7.7.7.7@tcp"
388 echo "Delete peer with single nid (o2ib)"
389 do_lnetctl peer add --prim_nid 7.7.7.7@o2ib || error "Peer add failed $?"
390 compare_peer_del "7.7.7.7@o2ib"
392 echo "Delete peer that has multiple nids (tcp)"
393 do_lnetctl peer add --prim_nid 7.7.7.7@tcp --nid 7.7.7.[8-12]@tcp ||
394 error "Peer add failed $?"
395 compare_peer_del "7.7.7.7@tcp"
397 echo "Delete peer that has multiple nids (o2ib)"
398 do_lnetctl peer add --prim_nid 7.7.7.7@o2ib --nid 7.7.7.[8-12]@o2ib ||
399 error "Peer add failed $?"
400 compare_peer_del "7.7.7.7@o2ib"
402 echo "Delete peer that has both tcp and o2ib nids"
403 do_lnetctl peer add --prim_nid 7.7.7.7@tcp \
404 --nid 7.7.7.[9-12]@tcp,7.7.7.[13-15]@o2ib ||
405 error "Peer add failed $?"
406 compare_peer_del "7.7.7.7@tcp"
408 echo "Delete peer with single nid (gni)"
409 do_lnetctl peer add --prim_nid 7@gni || error "Peer add failed $?"
410 compare_peer_del "7@gni"
412 echo "Delete peer that has multiple nids (gni)"
413 do_lnetctl peer add --prim_nid 7@gni --nid [8-12]@gni ||
414 error "Peer add failed $?"
415 compare_peer_del "7@gni"
417 echo "Delete peer that has tcp, o2ib and gni nids"
418 do_lnetctl peer add --prim_nid 7@gni \
419 --nid [8-12]@gni,7.7.7.[9-12]@tcp,7.7.7.[13-15]@o2ib ||
420 error "Peer add failed $?"
421 compare_peer_del "7@gni"
423 run_test 7 "Various peer delete tests"
426 reinit_dlc || return $?
428 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
430 - primary nid: 8.8.8.8@tcp
442 do_lnetctl peer add --prim_nid 8.8.8.8@tcp --nid 8.8.8.[10-15]@tcp ||
443 error "Peer add failed $?"
444 compare_peer_del "8.8.8.8@tcp" "8.8.8.13@tcp"
446 run_test 8 "Delete single secondary nid from peer (tcp)"
449 reinit_dlc || return $?
451 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
453 - primary nid: 9.9.9.9@tcp
460 do_lnetctl peer add --prim_nid 9.9.9.9@tcp \
461 --nid 9.9.9.[11-16]@tcp || error "Peer add failed $?"
462 compare_peer_del "9.9.9.9@tcp" "9.9.9.[11-16]@tcp"
464 run_test 9 "Delete all secondary nids from peer (tcp)"
467 reinit_dlc || return $?
469 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
471 - primary nid: 10.10.10.10@tcp
474 - nid: 10.10.10.10@tcp
475 - nid: 10.10.10.12@tcp
476 - nid: 10.10.10.13@tcp
477 - nid: 10.10.10.15@tcp
478 - nid: 10.10.10.16@tcp
481 do_lnetctl peer add --prim_nid 10.10.10.10@tcp \
482 --nid 10.10.10.[12-16]@tcp || error "Peer add failed $?"
483 compare_peer_del "10.10.10.10@tcp" "10.10.10.14@tcp"
485 run_test 10 "Delete single secondary nid from peer (o2ib)"
488 reinit_dlc || return $?
490 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
492 - primary nid: 11.11.11.11@tcp
495 - nid: 11.11.11.11@tcp
498 do_lnetctl peer add --prim_nid 11.11.11.11@tcp \
499 --nid 11.11.11.[13-17]@tcp || error "Peer add failed $?"
500 compare_peer_del "11.11.11.11@tcp" "11.11.11.[13-17]@tcp"
502 run_test 11 "Delete all secondary nids from peer (o2ib)"
505 reinit_dlc || return $?
507 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
509 - primary nid: 12.12.12.12@o2ib
512 - nid: 12.12.12.12@o2ib
513 - nid: 13.13.13.13@o2ib
514 - nid: 14.13.13.13@o2ib
515 - nid: 14.15.13.13@o2ib
517 - nid: 15.17.1.10@tcp
518 - nid: 15.17.1.20@tcp
521 do_lnetctl peer add --prim_nid 12.12.12.12@o2ib \
522 --nid [13-14/1].[13-15/2].13.13@o2ib,[15-16/3].[17-19/4].[1].[5-20/5]@tcp ||
523 error "Peer add failed $?"
524 compare_peer_del "12.12.12.12@o2ib" "13.15.13.13@o2ib,15.17.1.15@tcp"
526 run_test 12 "Delete a secondary nid from peer (tcp and o2ib)"
529 reinit_dlc || return $?
531 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
533 - primary nid: 13.13.13.13@o2ib
536 - nid: 13.13.13.13@o2ib
539 do_lnetctl peer add --prim_nid 13.13.13.13@o2ib \
540 --nid [14-15].[1-2/1].[1].[100-254/10]@tcp,14.14.[254].14@o2ib ||
541 error "Peer add failed $?"
542 compare_peer_del "13.13.13.13@o2ib" \
543 "[14-15].[1-2/1].[1].[100-254/10]@tcp,14.14.[254].14@o2ib"
545 run_test 13 "Delete all secondary nids from peer (tcp and o2ib)"
551 if [[ $net =~ gni* ]]; then
554 echo "${num}.${num}.${num}.${num}@${net}"
558 create_mr_peer_yaml() {
560 local secondary_nids="$2"
563 echo "Generating peer yaml for $num_peers peers with $secondary_nids secondary nids"
564 echo "peer:" >> $TMP/sanity-lnet-$testnum-expected.yaml
566 local total_nids=$((num_peers + $((num_peers * secondary_nids))))
569 while [[ $created -lt $num_peers ]]; do
570 local primary=$(create_nid ${nidnum} ${net})
571 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
572 - primary nid: $primary
578 local start=$((nidnum + 1))
579 local end=$((nidnum + $secondary_nids))
580 for j in $(seq ${start} ${end}); do
581 local nid=$(create_nid $j ${net})
582 echo " - nid: $nid" >> $TMP/sanity-lnet-$testnum-expected.yaml
590 reinit_dlc || return $?
592 echo "Create single peer, single nid, using import"
593 create_mr_peer_yaml 1 0 tcp
594 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
595 error "Import failed $?"
597 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
600 echo "Delete single peer using import --del"
601 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
602 error "Import failed $?"
603 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
604 create_base_yaml_file
605 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
608 run_test 14 "import peer create/delete with single nid"
611 reinit_dlc || return $?
613 echo "Create multiple peers, single nid per peer, using import"
614 create_mr_peer_yaml 5 0 o2ib
615 # The ordering of nids for this use-case is non-deterministic, so we
616 # we can't just diff the expected/actual output.
617 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
618 error "Import failed $?"
619 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
620 validate_peer_nids 5 0
622 echo "Delete multiple peers, single nid per peer, using import --del"
623 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
624 error "Import failed $?"
625 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
626 create_base_yaml_file
627 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
630 run_test 15 "import multi peer create/delete with single nid per peer"
633 reinit_dlc || return $?
635 echo "Create single peer, multiple nids, using import"
636 create_mr_peer_yaml 1 5 tcp
637 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
638 error "Import failed $?"
639 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
640 validate_peer_nids 1 5
642 echo "Delete single peer, multiple nids, using import --del"
643 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
644 error "Import failed $?"
645 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
646 create_base_yaml_file
647 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
650 run_test 16 "import peer create/delete with multiple nids"
653 reinit_dlc || return $?
655 echo "Create multiple peers, multiple nids per peer, using import"
656 create_mr_peer_yaml 5 7 o2ib
657 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
658 error "Import failed $?"
659 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
660 validate_peer_nids 5 7
662 echo "Delete multiple peers, multiple nids per peer, using import --del"
663 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
664 error "Import failed $?"
665 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
666 create_base_yaml_file
667 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
670 run_test 17 "import multi peer create/delete with multiple nids"
673 reinit_dlc || return $?
675 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
677 - primary nid: 1.1.1.1@tcp
686 echo "Import peer with 5 nids"
687 cat $TMP/sanity-lnet-$testnum-expected.yaml
688 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
689 error "Import failed $?"
690 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
692 - primary nid: 1.1.1.1@tcp
699 echo "Delete three of the nids"
700 cat $TMP/sanity-lnet-$testnum-expected.yaml
701 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml
702 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
704 - primary nid: 1.1.1.1@tcp
710 echo "Check peer has expected nids remaining"
711 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
715 run_test 18a "Delete a subset of nids from a single peer using import --del"
718 reinit_dlc || return $?
720 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
722 - primary nid: 1.1.1.1@tcp
730 - primary nid: 6.6.6.6@o2ib
739 echo "Import two peers with 5 nids each"
740 cat $TMP/sanity-lnet-$testnum-expected.yaml
741 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
742 error "Import failed $?"
743 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
745 - primary nid: 1.1.1.1@tcp
751 - primary nid: 6.6.6.6@o2ib
758 echo "Delete three of the nids from each peer"
759 cat $TMP/sanity-lnet-$testnum-expected.yaml
760 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml
761 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
763 - primary nid: 6.6.6.6@o2ib
768 - primary nid: 1.1.1.1@tcp
775 echo "Check peers have expected nids remaining"
776 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
778 validate_peer_nids 2 1
780 run_test 18b "Delete multiple nids from multiple peers using import --del"
783 reinit_dlc || return $?
784 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
786 - primary nid: 19@gni
792 compare_peer_add "19@gni"
794 run_test 19 "Add peer with single nid (gni)"
797 reinit_dlc || return $?
798 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
800 - primary nid: 20@gni
804 - nid: 20.20.20.20@tcp
805 - nid: 20.20.20.20@o2ib
808 compare_peer_add "20@gni" "20.20.20.20@tcp,20.20.20.20@o2ib"
810 run_test 20 "Add peer with gni primary and tcp, o2ib secondary"
813 reinit_dlc || return $?
814 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
816 - primary nid: 21@gni
826 echo "Add peer with nidrange (gni)"
827 compare_peer_add "21@gni" "[22-25]@gni" || error
828 echo "Add peer with nidrange that overlaps primary nid (gni)"
829 compare_peer_add "21@gni" "[21-25]@gni"
831 run_test 21 "Add peer with nidrange (gni)"
834 reinit_dlc || return $?
835 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
837 - primary nid: 22@gni
848 do_lnetctl peer add --prim_nid 22@gni --nid [24-29]@gni ||
849 error "Peer add failed $?"
850 compare_peer_del "22@gni" "26@gni"
852 run_test 22 "Delete single secondary nid from peer (gni)"
855 reinit_dlc || return $?
856 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
858 - primary nid: 23@gni
865 do_lnetctl peer add --prim_nid 23@gni --nid [25-29]@gni ||
866 error "Peer add failed $?"
867 compare_peer_del "23@gni" "[25-29]@gni"
869 run_test 23 "Delete all secondary nids from peer (gni)"
872 reinit_dlc || return $?
873 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
875 - primary nid: 24@gni
880 - nid: 13.13.13.13@o2ib
881 - nid: 14.13.13.13@o2ib
882 - nid: 14.15.13.13@o2ib
884 - nid: 15.17.1.10@tcp
885 - nid: 15.17.1.20@tcp
888 do_lnetctl peer add --prim_nid 24@gni \
889 --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 ||
890 error "Peer add failed $?"
891 compare_peer_del "24@gni" "5@gni,13.15.13.13@o2ib,15.17.1.15@tcp"
893 run_test 24 "Delete a secondary nid from peer (tcp, o2ib and gni)"
896 reinit_dlc || return $?
897 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
899 - primary nid: 25@gni
905 do_lnetctl peer add --prim_nid 25@gni \
906 --nid [26-27].[4-10/3].26.26@tcp,26.26.26.26@o2ib,[30-35]@gni ||
907 error "Peer add failed $?"
908 compare_peer_del "25@gni" \
909 "[26-27].[4-10/3].26.26@tcp,26.26.26.26@o2ib,[30-35]@gni"
911 run_test 25 "Delete all secondary nids from peer (tcp, gni and o2ib)"
914 reinit_dlc || return $?
916 echo "Invalid prim_nid - peer add"
917 do_lnetctl peer add --prim_nid foobar &&
918 error "Command should have failed"
920 echo "Invalid prim_nid - peer del"
921 do_lnetctl peer del --prim_nid foobar &&
922 error "Command should have failed"
924 echo "Delete non-existing peer"
925 do_lnetctl peer del --prim_nid 1.1.1.1@o2ib &&
926 error "Command should have failed"
928 echo "Don't provide mandatory argument for peer del"
929 do_lnetctl peer del --nid 1.1.1.1@tcp &&
930 error "Command should have failed"
932 echo "Don't provide mandatory argument for peer add"
933 do_lnetctl peer add --nid 1.1.1.1@tcp &&
934 error "Command should have failed"
936 echo "Don't provide mandatory arguments peer add"
937 do_lnetctl peer add &&
938 error "Command should have failed"
940 echo "Invalid secondary nids"
941 do_lnetctl peer add --prim_nid 1.1.1.1@tcp --nid foobar &&
942 error "Command should have failed"
944 echo "Exceed max nids per peer"
945 do_lnetctl peer add --prim_nid 1.1.1.1@tcp --nid 1.1.1.[2-255]@tcp &&
946 error "Command should have failed"
948 echo "Invalid net type"
949 do_lnetctl peer add --prim_nid 1@foo &&
950 error "Command should have failed"
952 echo "Invalid nid format"
953 local invalid_nids="1@tcp 1@o2ib 1.1.1.1@gni"
956 for nid in ${invalid_nids}; do
957 echo "Check invalid primary nid - '$nid'"
958 do_lnetctl peer add --prim_nid $nid &&
959 error "Command should have failed"
962 local invalid_strs="[2-1]@gni [a-f/x]@gni 256.256.256.256@tcp"
963 invalid_strs+=" 1.1.1.1.[2-5/f]@tcp 1.]2[.3.4@o2ib"
964 invalid_strs+="1.[2-4,[5-6],7-8].1.1@tcp foobar"
967 for nidstr in ${invalid_strs}; do
968 echo "Check invalid nidstring - '$nidstr'"
969 do_lnetctl peer add --prim_nid 1.1.1.1@tcp --nid $nidstr &&
970 error "Command should have failed"
973 echo "Add non-local gateway"
974 do_lnetctl route add --net tcp --gateway 1@gni &&
975 error "Command should have failed"
979 run_test 99a "Check various invalid inputs to lnetctl peer"
982 reinit_dlc || return $?
984 create_base_yaml_file
986 cat <<EOF > $TMP/sanity-lnet-$testnum-invalid.yaml
988 - primary nid: 99.99.99.99@tcp
991 - nid: 99.99.99.99@tcp
993 do_lnetctl import < $TMP/sanity-lnet-$testnum-invalid.yaml &&
994 error "import should have failed"
995 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
998 run_test 99b "Invalid value for Multi-Rail in yaml import"
1002 local ip=$(ip addr show dev $if | awk '/ inet /{print $2}')
1010 if ! lsmod | grep -q ksocklnd ; then
1011 load_module ../lnet/klnds/socklnd/ksocklnd ||
1012 error "Can't load ksocklnd.ko"
1015 do_lnetctl net add --net ${net} --if ${if} ||
1016 error "Failed to add net ${net} on if ${if}"
1019 compare_route_add() {
1023 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
1025 do_lnetctl route add --net ${rnet} --gateway ${gw} ||
1026 error "route add failed $?"
1027 # CPT configuration is pruned from the exported yaml, since the default
1028 # can vary across test systems (unlike default values for things like
1029 # peer_credits, peer_timeout, etc.)
1030 $LNETCTL export --backup | grep -v CPT > $actual ||
1031 error "export failed $?"
1032 validate_gateway_nids
1037 reinit_dlc || return $?
1038 add_net "tcp" "${INTERFACES[0]}"
1039 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
1048 peer_buffer_credits: 0
1054 gateway: 7.7.7.7@tcp
1057 health_sensitivity: 1
1059 - primary nid: 7.7.7.7@tcp
1065 compare_route_add "tcp7" "7.7.7.7@tcp" || return $?
1068 run_test 100 "Add route with single gw (tcp)"
1071 reinit_dlc || return $?
1072 add_net "tcp" "${INTERFACES[0]}"
1073 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
1082 peer_buffer_credits: 0
1088 gateway: 8.8.8.10@tcp
1091 health_sensitivity: 1
1093 gateway: 8.8.8.9@tcp
1096 health_sensitivity: 1
1098 gateway: 8.8.8.8@tcp
1101 health_sensitivity: 1
1103 - primary nid: 8.8.8.9@tcp
1107 - primary nid: 8.8.8.10@tcp
1111 - primary nid: 8.8.8.8@tcp
1117 compare_route_add "tcp8" "8.8.8.[8-10]@tcp"
1119 run_test 101 "Add route with multiple gw (tcp)"
1121 compare_route_del() {
1125 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
1127 do_lnetctl route del --net ${rnet} --gateway ${gw} ||
1128 error "route del failed $?"
1129 $LNETCTL export --backup > $actual ||
1130 error "export failed $?"
1131 validate_gateway_nids
1135 reinit_dlc || return $?
1136 add_net "tcp" "${INTERFACES[0]}"
1137 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
1138 do_lnetctl route add --net tcp102 --gateway 102.102.102.102@tcp ||
1139 error "route add failed $?"
1140 compare_route_del "tcp102" "102.102.102.102@tcp"
1142 run_test 102 "Delete route with single gw (tcp)"
1145 reinit_dlc || return $?
1146 add_net "tcp" "${INTERFACES[0]}"
1147 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
1148 do_lnetctl route add --net tcp103 \
1149 --gateway 103.103.103.[103-120/4]@tcp ||
1150 error "route add failed $?"
1151 compare_route_del "tcp103" "103.103.103.[103-120/4]@tcp"
1153 run_test 103 "Delete route with multiple gw (tcp)"
1156 local tyaml="$TMP/sanity-lnet-$testnum-expected.yaml"
1158 reinit_dlc || return $?
1160 # Default value is '3'
1161 local val=$($LNETCTL global show | awk '/response_tracking/{print $NF}')
1163 error "Expect 3 found $val"
1165 echo "Set < 0; Should fail"
1166 do_lnetctl set response_tracking -1 &&
1167 error "should have failed $?"
1169 reinit_dlc || return $?
1172 response_tracking: -10
1174 do_lnetctl import < $tyaml &&
1175 error "should have failed $?"
1177 echo "Check valid values; Should succeed"
1179 for ((i = 0; i < 4; i++)); do
1180 reinit_dlc || return $?
1181 do_lnetctl set response_tracking $i ||
1182 error "should have succeeded $?"
1183 $LNETCTL global show | grep -q "response_tracking: $i" ||
1184 error "Failed to set response_tracking to $i"
1185 reinit_dlc || return $?
1188 response_tracking: $i
1190 do_lnetctl import < $tyaml ||
1191 error "should have succeeded $?"
1192 $LNETCTL global show | grep -q "response_tracking: $i" ||
1193 error "Failed to set response_tracking to $i"
1196 reinit_dlc || return $?
1197 echo "Set > 3; Should fail"
1198 do_lnetctl set response_tracking 4 &&
1199 error "should have failed $?"
1201 reinit_dlc || return $?
1204 response_tracking: 10
1206 do_lnetctl import < $tyaml &&
1207 error "should have failed $?"
1210 run_test 104 "Set/check response_tracking param"
1213 reinit_dlc || return $?
1214 add_net "tcp" "${INTERFACES[0]}"
1215 do_lnetctl route add --net tcp105 --gateway 105.105.105.105@tcp ||
1216 error "route add failed $?"
1217 do_lnetctl peer add --prim 105.105.105.105@tcp &&
1218 error "peer add should fail"
1222 run_test 105 "Adding duplicate GW peer should fail"
1225 reinit_dlc || return $?
1226 add_net "tcp" "${INTERFACES[0]}"
1227 do_lnetctl route add --net tcp106 --gateway 106.106.106.106@tcp ||
1228 error "route add failed $?"
1229 do_lnetctl peer del --prim 106.106.106.106@tcp &&
1230 error "peer del should fail"
1234 run_test 106 "Deleting GW peer should fail"
1237 cleanup_lnet || exit 1
1238 load_lnet "networks=\"\""
1239 do_ns $LNETCTL lnet configure --all || exit 1
1240 $LNETCTL net show --net tcp | grep -q "nid: ${FAKE_IP}@tcp$"
1242 run_test 200 "load lnet w/o module option, configure in a non-default namespace"
1245 cleanup_lnet || exit 1
1246 load_lnet "networks=tcp($FAKE_IF)"
1247 do_ns $LNETCTL lnet configure --all || exit 1
1248 $LNETCTL net show --net tcp | grep -q "nid: ${FAKE_IP}@tcp$"
1250 run_test 201 "load lnet using networks module options in a non-default namespace"
1253 cleanup_lnet || exit 1
1254 load_lnet "networks=\"\" ip2nets=\"tcp0($FAKE_IF) ${FAKE_IP}\""
1255 do_ns $LNETCTL lnet configure --all || exit 1
1256 $LNETCTL net show | grep -q "nid: ${FAKE_IP}@tcp$"
1258 run_test 202 "load lnet using ip2nets in a non-default namespace"
1261 ### Add the interfaces in the target namespace
1264 cleanup_lnet || exit 1
1266 do_lnetctl lnet configure || exit 1
1267 do_ns $LNETCTL net add --net tcp0 --if $FAKE_IF
1269 run_test 203 "add a network using an interface in the non-default namespace"
1271 LNET_PARAMS_FILE="$TMP/$TESTSUITE.parameters"
1272 function save_lnet_params() {
1273 $LNETCTL global show | egrep -v '^global:$' |
1274 sed 's/://' > $LNET_PARAMS_FILE
1277 function restore_lnet_params() {
1279 while read param value; do
1280 [[ $param == max_intf ]] && continue
1281 [[ $param == lnd_timeout ]] && continue
1282 $LNETCTL set ${param} ${value} ||
1283 error "Failed to restore ${param} to ${value}"
1284 done < $LNET_PARAMS_FILE
1287 function lnet_health_pre() {
1290 # Lower transaction timeout to speed up test execution
1291 $LNETCTL set transaction_timeout 10 ||
1292 error "Failed to set transaction_timeout $?"
1294 RETRY_PARAM=$($LNETCTL global show | awk '/retry_count/{print $NF}')
1295 RSND_PRE=$($LNETCTL stats show | awk '/resend_count/{print $NF}')
1296 LO_HVAL_PRE=$($LNETCTL net show -v 2 | awk '/health value/{print $NF}' |
1297 xargs echo | sed 's/ /+/g' | bc -l)
1299 RMT_HVAL_PRE=$($LNETCTL peer show --nid ${RNIDS[0]} -v 2 2>/dev/null |
1300 awk '/health value/{print $NF}' | xargs echo |
1301 sed 's/ /+/g' | bc -l)
1303 # Might not have any peers so initialize to zero.
1304 RMT_HVAL_PRE=${RMT_HVAL_PRE:-0}
1309 function lnet_health_post() {
1310 RSND_POST=$($LNETCTL stats show | awk '/resend_count/{print $NF}')
1311 LO_HVAL_POST=$($LNETCTL net show -v 2 |
1312 awk '/health value/{print $NF}' |
1313 xargs echo | sed 's/ /+/g' | bc -l)
1315 RMT_HVAL_POST=$($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_POST=${RMT_HVAL_POST:-0}
1323 echo "Pre resends: $RSND_PRE" &&
1324 echo "Post resends: $RSND_POST" &&
1325 echo "Resends delta: $((RSND_POST - RSND_PRE))" &&
1326 echo "Pre local health: $LO_HVAL_PRE" &&
1327 echo "Post local health: $LO_HVAL_POST" &&
1328 echo "Pre remote health: $RMT_HVAL_PRE" &&
1329 echo "Post remote health: $RMT_HVAL_POST"
1333 do_lnetctl peer set --health 1000 --all
1334 do_lnetctl net set --health 1000 --all
1339 function check_no_resends() {
1340 echo "Check that no resends took place"
1341 [[ $RSND_POST -ne $RSND_PRE ]] &&
1342 error "Found resends: $RSND_POST != $RSND_PRE"
1347 function check_resends() {
1348 local delta=$((RSND_POST - RSND_PRE))
1350 echo "Check that $RETRY_PARAM resends took place"
1351 [[ $delta -ne $RETRY_PARAM ]] &&
1352 error "Expected $RETRY_PARAM resends found $delta"
1357 function check_no_local_health() {
1358 echo "Check that local NI health is unchanged"
1359 [[ $LO_HVAL_POST -ne $LO_HVAL_PRE ]] &&
1360 error "Local health changed: $LO_HVAL_POST != $LO_HVAL_PRE"
1365 function check_local_health() {
1366 echo "Check that local NI health has been changed"
1367 [[ $LO_HVAL_POST -eq $LO_HVAL_PRE ]] &&
1368 error "Local health unchanged: $LO_HVAL_POST == $LO_HVAL_PRE"
1373 function check_no_remote_health() {
1374 echo "Check that remote NI health is unchanged"
1375 [[ $RMT_HVAL_POST -ne $RMT_HVAL_PRE ]] &&
1376 error "Remote health changed: $RMT_HVAL_POST != $RMT_HVAL_PRE"
1381 function check_remote_health() {
1382 echo "Check that remote NI health has been changed"
1383 [[ $RMT_HVAL_POST -eq $RMT_HVAL_PRE ]] &&
1384 error "Remote health unchanged: $RMT_HVAL_POST == $RMT_HVAL_PRE"
1394 setup_health_test() {
1398 local rnodes=$(remote_nodes_list)
1399 [[ -z $rnodes ]] && skip "Need at least 1 remote node"
1401 cleanup_lnet || error "Failed to cleanup before test execution"
1403 # Loading modules should configure LNet with the appropriate
1404 # test-framework configuration
1405 load_lnet "config_on_load=1" || error "Failed to load modules"
1407 LNIDS=( $($LCTL list_nids | xargs echo) )
1409 RNODE=$(awk '{print $1}' <<<$rnodes)
1410 RNIDS=( $(do_node $RNODE $LCTL list_nids | xargs echo) )
1412 if [[ -z ${RNIDS[@]} ]]; then
1413 do_rpc_nodes $RNODE load_lnet "config_on_load=1"
1415 RNIDS=( $(do_node $RNODE $LCTL list_nids | xargs echo) )
1418 [[ ${#LNIDS[@]} -lt 1 ]] &&
1419 error "No NIDs configured for local host $HOSTNAME"
1420 [[ ${#RNIDS[@]} -lt 1 ]] &&
1421 error "No NIDs configured for remote host $RNODE"
1423 do_lnetctl discover ${RNIDS[0]} ||
1424 error "Unable to discover ${RNIDS[0]}"
1426 local mr=$($LNETCTL peer show --nid ${RNIDS[0]} |
1427 awk '/Multi-Rail/{print $NF}')
1429 if ${need_mr} && [[ $mr == False ]]; then
1430 cleanup_health_test || return $?
1434 if ( ! ${need_mr} && [[ ${#RNIDS[@]} -gt 1 ]] ) ||
1435 ( ! ${need_mr} && [[ ${#LNIDS[@]} -gt 1 ]] ); then
1436 cleanup_health_test || return $?
1440 if ${need_mr} && [[ ${#RNIDS[@]} -lt 2 ]]; then
1441 # Add a second, reachable NID to rnode.
1442 local net=${RNIDS[0]}
1446 local if=$(do_rpc_nodes --quiet $RNODE lnet_if_list)
1448 error "Failed to determine interface for $RNODE"
1450 do_rpc_nodes $RNODE "$LNETCTL lnet configure"
1451 do_rpc_nodes $RNODE "$LNETCTL net add --net $net --if $if" ||
1453 if [[ $rc -ne 0 ]]; then
1454 error "Failed to add interface to $RNODE rc=$?"
1456 RNIDS[1]="${RNIDS[0]}1"
1457 NET_DEL_ARGS="--net $net --if $if"
1461 if ${need_mr} && [[ ${#LNIDS[@]} -lt 2 ]]; then
1462 local net=${LNIDS[0]}
1465 do_lnetctl lnet configure &&
1466 do_lnetctl net add --net $net --if ${INTERFACES[0]} ||
1468 if [[ $rc -ne 0 ]]; then
1469 error "Failed to add interface rc=$?"
1471 LNIDS[1]="${LNIDS[0]}1"
1477 $LNETCTL peer show -v 2 | egrep -e nid -e health
1479 $LCTL set_param debug=+net
1485 cleanup_health_test() {
1488 if [[ -n $NET_DEL_ARGS ]]; then
1489 do_rpc_nodes $RNODE \
1490 "$LNETCTL net del $NET_DEL_ARGS" ||
1495 unload_modules || rc=$?
1498 do_rpc_nodes $RNODE unload_modules_local ||
1504 error "Failed cleanup"
1509 add_health_test_drop_rules() {
1513 for lnid in "${LNIDS[@]}"; do
1514 for rnid in "${RNIDS[@]}"; do
1515 $LCTL net_drop_add -s $lnid -d $rnid -m GET -r 1 -e ${hstatus}
1520 # See lnet/lnet/lib-msg.c:lnet_health_check()
1521 LNET_LOCAL_RESEND_STATUSES="local_interrupt local_dropped local_aborted"
1522 LNET_LOCAL_RESEND_STATUSES+=" local_no_route local_timeout"
1523 LNET_LOCAL_NO_RESEND_STATUSES="local_error"
1525 setup_health_test false || return $?
1528 for hstatus in ${LNET_LOCAL_RESEND_STATUSES} \
1529 ${LNET_LOCAL_NO_RESEND_STATUSES}; do
1530 echo "Simulate $hstatus"
1531 lnet_health_pre || return $?
1533 add_health_test_drop_rules ${hstatus}
1534 do_lnetctl discover ${RNIDS[0]} &&
1535 error "Should have failed"
1536 $LCTL net_drop_del -a
1540 check_no_resends || return $?
1541 check_no_local_health || return $?
1544 cleanup_health_test || return $?
1548 run_test 204 "Check no health or resends for single-rail local failures"
1551 setup_health_test true || return $?
1554 for hstatus in ${LNET_LOCAL_RESEND_STATUSES}; do
1555 echo "Simulate $hstatus"
1556 lnet_health_pre || return $?
1558 add_health_test_drop_rules ${hstatus}
1559 do_lnetctl discover ${RNIDS[0]} &&
1560 error "Should have failed"
1561 $LCTL net_drop_del -a
1565 check_resends || return $?
1566 check_local_health || return $?
1569 for hstatus in ${LNET_LOCAL_NO_RESEND_STATUSES}; do
1570 echo "Simulate $hstatus"
1571 lnet_health_pre || return $?
1573 add_health_test_drop_rules ${hstatus}
1574 do_lnetctl discover ${RNIDS[0]} &&
1575 error "Should have failed"
1576 $LCTL net_drop_del -a
1580 check_no_resends || return $?
1581 check_local_health || return $?
1584 cleanup_health_test || return $?
1588 run_test 205 "Check health and resends for multi-rail local failures"
1590 # See lnet/lnet/lib-msg.c:lnet_health_check()
1591 LNET_REMOTE_RESEND_STATUSES="remote_dropped"
1592 LNET_REMOTE_NO_RESEND_STATUSES="remote_error remote_timeout"
1594 setup_health_test false || return $?
1597 for hstatus in ${LNET_REMOTE_RESEND_STATUSES} \
1598 ${LNET_REMOTE_NO_RESEND_STATUSES}; do
1599 echo "Simulate $hstatus"
1600 lnet_health_pre || return $?
1602 add_health_test_drop_rules ${hstatus}
1603 do_lnetctl discover ${RNIDS[0]} &&
1604 error "Should have failed"
1605 $LCTL net_drop_del -a
1609 check_no_resends || return $?
1610 check_no_local_health || return $?
1611 check_no_remote_health || return $?
1614 cleanup_health_test || return $?
1618 run_test 206 "Check no health or resends for single-rail remote failures"
1621 setup_health_test true || return $?
1624 for hstatus in ${LNET_REMOTE_RESEND_STATUSES}; do
1625 echo "Simulate $hstatus"
1626 lnet_health_pre || return $?
1628 add_health_test_drop_rules ${hstatus}
1630 do_lnetctl discover ${RNIDS[0]} &&
1631 error "Should have failed"
1635 $LCTL net_drop_del -a
1637 check_resends || return $?
1638 check_no_local_health || return $?
1639 check_remote_health || return $?
1640 do_lnetctl peer set --health 1000 --all ||
1641 error "Unable to reset health rc=$?"
1643 for hstatus in ${LNET_REMOTE_NO_RESEND_STATUSES}; do
1644 echo "Simulate $hstatus"
1645 lnet_health_pre || return $?
1647 add_health_test_drop_rules ${hstatus}
1649 do_lnetctl discover ${RNIDS[0]} &&
1650 error "Should have failed"
1654 $LCTL net_drop_del -a
1656 check_no_resends || return $?
1657 check_no_local_health || return $?
1658 check_remote_health || return $?
1659 do_lnetctl peer set --health 1000 --all ||
1660 error "Unable to reset health rc=$?"
1663 cleanup_health_test || return $?
1667 run_test 207 "Check health and resends for multi-rail remote errors"
1669 test_208_load_and_check_lnet() {
1673 local num_expected=1
1675 load_lnet "networks=\"\" ip2nets=\"${ip2nets_str}\""
1678 error "Failed to load LNet with ip2nets \"${ip2nets_str}\""
1684 nids=( $($LCTL list_nids) )
1686 [[ ${#nids[@]} -ne ${num_expected} ]] &&
1687 error "Expect ${num_expected} NIDs found ${#nids[@]}"
1689 [[ ${nids[0]} == ${p_nid} ]] ||
1690 error "Expect NID \"${p_nid}\" found \"${nids[0]}\""
1692 [[ -n $s_nid ]] && [[ ${nids[1]} != ${s_nid} ]] &&
1693 error "Expect second NID \"${s_nid}\" found \"${nids[1]}\""
1695 $LCTL net down &>/dev/null
1700 cleanup_netns || error "Failed to cleanup netns before test execution"
1701 cleanup_lnet || error "Failed to unload modules before test execution"
1702 setup_fakeif || error "Failed to add fake IF"
1704 have_interface "$FAKE_IF" ||
1705 error "Expect $FAKE_IF configured but not found"
1707 local if0_ip=$(ip --oneline addr show dev ${INTERFACES[0]} |
1708 awk '/inet /{print $4}' |
1710 if0_ip=($(echo "${if0_ip[@]}" | tr ' ' '\n' | uniq | tr '\n' ' '))
1711 local ip2nets_str="tcp(${INTERFACES[0]}) $if0_ip"
1713 echo "Configure single NID \"$ip2nets_str\""
1714 test_208_load_and_check_lnet "${ip2nets_str}" "${if0_ip}@tcp"
1716 ip2nets_str="tcp(${INTERFACES[0]}) $if0_ip; tcp1($FAKE_IF) $FAKE_IP"
1717 echo "Configure two NIDs; two NETs \"$ip2nets_str\""
1718 test_208_load_and_check_lnet "${ip2nets_str}" "${if0_ip}@tcp" \
1721 ip2nets_str="tcp(${INTERFACES[0]}) $if0_ip; tcp($FAKE_IF) $FAKE_IP"
1722 echo "Configure two NIDs; one NET \"$ip2nets_str\""
1723 test_208_load_and_check_lnet "${ip2nets_str}" "${if0_ip}@tcp" \
1725 local addr1=( ${if0_ip//./ } )
1726 local addr2=( ${FAKE_IP//./ } )
1727 local range="[${addr1[0]},${addr2[0]}]"
1730 for i in $(seq 1 3); do
1731 range+=".[${addr1[$i]},${addr2[$i]}]"
1733 ip2nets_str="tcp(${INTERFACES[0]},${FAKE_IF}) ${range}"
1735 echo "Configured two NIDs; one NET alt syntax \"$ip2nets_str\""
1736 test_208_load_and_check_lnet "${ip2nets_str}" "${if0_ip}@tcp" \
1741 echo "alt syntax with missing IF \"$ip2nets_str\""
1742 load_lnet "networks=\"\" ip2nets=\"${ip2nets_str}\""
1744 echo "$LCTL net up should fail"
1746 error "LNet bringup should have failed"
1750 run_test 208 "Test various kernel ip2nets configurations"
1753 setup_health_test false || return $?
1755 echo "Simulate network_timeout w/SR config"
1758 add_health_test_drop_rules network_timeout
1760 do_lnetctl discover ${RNIDS[0]} &&
1761 error "Should have failed"
1762 $LCTL net_drop_del -a
1766 check_no_resends || return $?
1767 check_no_local_health || return $?
1768 check_no_remote_health || return $?
1770 cleanup_health_test || return $?
1772 setup_health_test true || return $?
1774 echo "Simulate network_timeout w/MR config"
1778 add_health_test_drop_rules network_timeout
1780 do_lnetctl discover ${RNIDS[0]} &&
1781 error "Should have failed"
1782 $LCTL net_drop_del -a
1786 check_no_resends || return $?
1787 check_local_health || return $?
1788 check_remote_health || return $?
1790 cleanup_health_test || return $?
1794 run_test 209 "Check health, but not resends, for network timeout"
1796 check_nid_in_recovq() {
1797 local recovq=$($LNETCTL debug recovery $1)
1799 local nids=$($LCTL list_nids | xargs echo)
1803 echo "Check \"$1\" recovery queue"
1805 if [[ $(grep -c 'nid-'<<<$recovq) -ne $expect ]]; then
1806 error "Expect $expect NIDs found: \"$recovq\""
1809 [[ $expect -eq 0 ]] && return 0
1811 for nid in ${nids}; do
1812 grep -q "nid-0: $nid"<<<$recovq &&
1817 error "Didn't find local NIDs in recovery queue: \"$recovq\""
1823 # First enqueue happens at time 0.
1824 # 2nd at 0 + 2^0 = 1
1825 # 3rd at 1 + 2^1 = 3
1826 # 4th at 3 + 2^2 = 7
1827 # 5th at 7 + 2^3 = 15
1828 # e.g. after 10 seconds we would expect to have seen the 4th enqueue,
1829 # (3 pings sent, 4th about to happen) and the 5th enqueue is yet to
1831 # If the recovery limit is 10 seconds, then when the 5th enqueue happens
1832 # we expect the peer NI to have aged out, so it will not actually be
1834 # If max_recovery_ping_interval is set to 2 then:
1835 # First enqueue happens at time 0.
1836 # 2nd at 0 + 2^0 = 1
1837 # 3rd at 1 + 2^1 = 3
1838 # 4th at 3 + 2^1 = 5
1839 # 5th at 5 + 2^1 = 7
1840 # 6th at 7 + 2^1 = 9
1841 # 7th at 9 + 2^1 = 11
1842 # e.g. after 4 seconds we would expect to have seen the 3th enqueue,
1843 # (2 pings sent, 3rd about to happen), and the 4th enqueue is yet to happen
1844 # e.g. after 10 seconds we would expect to have seen the 6th enqueue,
1845 # (5 pings sent, 6th about to happen), and the 8th enqueue is yet to happen
1846 check_ping_count() {
1850 echo "Check ping counts:"
1852 if [[ $queue == "ni" ]]; then
1853 $LNETCTL net show -v 2 | egrep 'nid|health value|ping'
1854 ping_count=( $($LNETCTL net show -v 2 |
1855 awk '/ping_count/{print $NF}') )
1856 elif [[ $queue == "peer_ni" ]]; then
1857 $LNETCTL peer show -v 2 | egrep 'nid|health value|ping'
1858 ping_count=( $($LNETCTL peer show -v 2 |
1859 awk '/ping_count/{print $NF}') )
1861 error "Unrecognized queue \"$queue\""
1867 for count in "${ping_count[@]}"; do
1868 if [[ $count -eq $expect ]]; then
1869 if [[ $expect -ne 0 ]] && $found ; then
1870 error "Found more than one interface matching \"$expect\" ping count"
1873 echo "Expect ping count \"$expect\" found \"$count\""
1876 elif [[ $count -ne 0 ]]; then
1877 error "Found interface with ping count \"$count\" but expect \"$expect\""
1886 reinit_dlc || return $?
1887 add_net "tcp" "${INTERFACES[0]}" || return $?
1888 add_net "tcp1" "${INTERFACES[0]}" || return $?
1890 local prim_nid=$($LCTL list_nids | head -n 1)
1892 do_lnetctl discover $prim_nid ||
1893 error "failed to discover myself"
1895 local default=$($LNETCTL global show |
1896 awk '/recovery_limit/{print $NF}')
1897 # Set recovery limit to 10 seconds.
1898 do_lnetctl set recovery_limit 10 ||
1899 error "failed to set recovery_limit"
1901 $LCTL set_param debug=+net
1902 # Use local_error so LNet doesn't attempt to resend the discovery ping
1903 $LCTL net_drop_add -s *@tcp -d *@tcp -m GET -r 1 -e local_error
1904 $LCTL net_drop_add -s *@tcp1 -d *@tcp1 -m GET -r 1 -e local_error
1905 do_lnetctl discover $prim_nid &&
1906 error "Expected discovery to fail"
1908 # See comment for check_ping_count()
1910 check_nid_in_recovq "-l" "1"
1911 check_ping_count "ni" "2"
1915 check_nid_in_recovq "-l" "1"
1916 check_ping_count "ni" "3"
1918 $LCTL net_drop_del -a
1920 reinit_dlc || return $?
1921 add_net "tcp" "${INTERFACES[0]}" || return $?
1922 add_net "tcp1" "${INTERFACES[0]}" || return $?
1924 local prim_nid=$($LCTL list_nids | head -n 1)
1926 do_lnetctl discover $prim_nid ||
1927 error "failed to discover myself"
1929 do_lnetctl set recovery_limit $default ||
1930 error "failed to set recovery_limit"
1932 default=$($LNETCTL global show |
1933 awk '/max_recovery_ping_interval/{print $NF}')
1934 do_lnetctl set max_recovery_ping_interval 2 ||
1935 error "failed to set max_recovery_ping_interval"
1937 $LCTL set_param debug=+net
1938 # Use local_error so LNet doesn't attempt to resend the discovery ping
1939 $LCTL net_drop_add -s *@tcp -d *@tcp -m GET -r 1 -e local_error
1940 $LCTL net_drop_add -s *@tcp1 -d *@tcp1 -m GET -r 1 -e local_error
1941 do_lnetctl discover $prim_nid &&
1942 error "Expected discovery to fail"
1944 # See comment for check_ping_count()
1946 check_nid_in_recovq "-l" "1"
1947 check_ping_count "ni" "2"
1950 check_nid_in_recovq "-l" "1"
1951 check_ping_count "ni" "5"
1953 $LCTL net_drop_del -a
1955 do_lnetctl set max_recovery_ping_interval $default ||
1956 error "failed to set max_recovery_ping_interval"
1960 run_test 210 "Local NI recovery checks"
1963 reinit_dlc || return $?
1964 add_net "tcp" "${INTERFACES[0]}" || return $?
1965 add_net "tcp1" "${INTERFACES[0]}" || return $?
1967 local prim_nid=$($LCTL list_nids | head -n 1)
1969 do_lnetctl discover $prim_nid ||
1970 error "failed to discover myself"
1972 local default=$($LNETCTL global show |
1973 awk '/recovery_limit/{print $NF}')
1974 # Set recovery limit to 10 seconds.
1975 do_lnetctl set recovery_limit 10 ||
1976 error "failed to set recovery_limit"
1978 $LCTL net_drop_add -s *@tcp -d *@tcp -m GET -r 1 -e remote_error
1979 $LCTL net_drop_add -s *@tcp1 -d *@tcp1 -m GET -r 1 -e remote_error
1981 # Set health to 0 on one interface. This forces it onto the recovery
1983 $LNETCTL peer set --nid $prim_nid --health 0
1985 # After 5 seconds, we expect the peer NI to still be in recovery
1987 check_nid_in_recovq "-p" 1
1988 check_ping_count "peer_ni" "2"
1990 # After 15 seconds, the peer NI should have been fully processed out of
1991 # the recovery queue. We'll allow a total of 17 seconds to account for
1992 # differences in sleeping for whole seconds vs. the more accurate time
1993 # keeping that is done in the recovery code.
1995 check_nid_in_recovq "-p" 0
1996 check_ping_count "peer_ni" "4"
1998 $LCTL net_drop_del -a
2000 # Set health to force it back onto the recovery queue. Set to 500 means
2001 # in 5 seconds it should be back at maximum value. We'll wait a couple
2002 # more seconds than that to be safe.
2003 # NB: we reset the recovery limit to 0 (indefinite) so the peer NI is
2005 do_lnetctl set recovery_limit 0 ||
2006 error "failed to set recovery_limit"
2008 $LNETCTL peer set --nid $prim_nid --health 500
2010 check_nid_in_recovq "-p" 1
2011 check_ping_count "peer_ni" "2"
2015 check_nid_in_recovq "-p" 0
2016 check_ping_count "peer_ni" "0"
2018 reinit_dlc || return $?
2019 add_net "tcp" "${INTERFACES[0]}" || return $?
2020 add_net "tcp1" "${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 do_lnetctl set recovery_limit $default ||
2028 error "failed to set recovery_limit"
2030 default=$($LNETCTL global show |
2031 awk '/max_recovery_ping_interval/{print $NF}')
2032 do_lnetctl set max_recovery_ping_interval 2 ||
2033 error "failed to set max_recovery_ping_interval"
2035 $LCTL net_drop_add -s *@tcp -d *@tcp -m GET -r 1 -e remote_error
2036 $LCTL net_drop_add -s *@tcp1 -d *@tcp1 -m GET -r 1 -e remote_error
2038 # Set health to 0 on one interface. This forces it onto the recovery
2040 $LNETCTL peer set --nid $prim_nid --health 0
2042 # See comment for check_ping_count()
2044 check_nid_in_recovq "-p" "1"
2045 check_ping_count "peer_ni" "2"
2048 check_nid_in_recovq "-p" "1"
2049 check_ping_count "peer_ni" "5"
2051 $LCTL net_drop_del -a
2053 do_lnetctl set max_recovery_ping_interval $default ||
2054 error "failed to set max_recovery_ping_interval"
2058 run_test 211 "Remote NI recovery checks"
2061 local rnodes=$(remote_nodes_list)
2062 [[ -z $rnodes ]] && skip "Need at least 1 remote node"
2064 cleanup_lnet || error "Failed to cleanup before test execution"
2066 # Loading modules should configure LNet with the appropriate
2067 # test-framework configuration
2068 load_lnet "config_on_load=1" || error "Failed to load modules"
2070 local my_nid=$($LCTL list_nids | head -n 1)
2072 error "Failed to get primary NID for local host $HOSTNAME"
2074 local rnode=$(awk '{print $1}' <<<$rnodes)
2075 local rnodenids=$(do_node $rnode $LCTL list_nids | xargs echo)
2078 if [[ -z $rnodenids ]]; then
2079 do_rpc_nodes $rnode load_lnet "config_on_load=1"
2081 rnodenids=$(do_node $rnode $LCTL list_nids | xargs echo)
2084 local rnodepnid=$(awk '{print $1}' <<< $rnodenids)
2086 [[ -z $rnodepnid ]] &&
2087 error "Failed to get primary NID for remote host $rnode"
2089 log "Initial discovery"
2090 do_lnetctl discover --force $rnodepnid ||
2091 error "Failed to discover $rnodepnid"
2093 do_node $rnode "$LNETCTL discover --force $my_nid" ||
2094 error "$rnode failed to discover $my_nid"
2096 log "Fail local discover ping to set LNET_PEER_REDISCOVER flag"
2097 $LCTL net_drop_add -s "*@$NETTYPE" -d "*@$NETTYPE" -r 1 -e local_error
2098 do_lnetctl discover --force $rnodepnid &&
2099 error "Discovery should have failed"
2100 $LCTL net_drop_del -a
2103 for nid in $rnodenids; do
2104 # We need GET (PING) delay just long enough so we can trigger
2105 # discovery on the remote peer
2106 $LCTL net_delay_add -s "*@$NETTYPE" -d $nid -r 1 -m GET -l 3
2107 $LCTL net_drop_add -s "*@$NETTYPE" -d $nid -r 1 -m GET -e local_error
2108 # We need PUT (PUSH) delay just long enough so we can process
2110 $LCTL net_delay_add -s "*@$NETTYPE" -d $nid -r 1 -m PUT -l 6
2113 log "Force $HOSTNAME to discover $rnodepnid (in background)"
2114 # We want to get a PING sent that we know will eventually fail.
2115 # The delay rules we added will ensure the ping is not sent until
2116 # the PUSH is also in flight (see below), and the drop rule ensures that
2117 # when the PING is eventually sent it will error out
2118 do_lnetctl discover --force $rnodepnid &
2121 # We want a discovery PUSH from rnode to put rnode back on our
2122 # discovery queue. This should cause us to try and send a PUSH to rnode
2123 # while the PING is still outstanding.
2124 log "Force $rnode to discover $my_nid"
2125 do_node $rnode $LNETCTL discover --force $my_nid
2127 # At this point we'll have both PING_SENT and PUSH_SENT set for the
2128 # rnode peer. Wait for the PING to error out which should terminate the
2129 # discovery process that we backgrounded.
2130 log "Wait for $pid1"
2132 log "Finished wait on $pid1"
2134 # The PING send failure clears the PING_SENT flag and puts the peer back
2135 # on the discovery queue. When discovery thread processes the peer it
2136 # will mistakenly clear the PUSH_SENT flag (and set PUSH_FAILED).
2137 # Discovery will then complete for this peer even though we have an
2139 # When PUSH is actually unlinked it will be forced back onto the
2140 # discovery queue, but we no longer have a ref on the peer. When
2141 # discovery completes again, we'll trip the ASSERT in
2142 # lnet_destroy_peer_locked()
2144 # Delete the delay rules to send the PUSH
2145 $LCTL net_delay_del -a
2146 # Delete the drop rules
2147 $LCTL net_drop_del -a
2150 error "Failed to unload modules"
2152 do_rpc_nodes $rnode unload_modules_local ||
2153 error "Failed to unload modules on $rnode"
2158 run_test 212 "Check discovery refcount loss bug (LU-14627)"
2161 cleanup_netns || error "Failed to cleanup netns before test execution"
2162 cleanup_lnet || error "Failed to unload modules before test execution"
2164 setup_fakeif || error "Failed to add fake IF"
2165 have_interface "$FAKE_IF" ||
2166 error "Expect $FAKE_IF configured but not found"
2168 reinit_dlc || return $?
2170 add_net "tcp" "${INTERFACES[0]}" || return $?
2171 add_net "tcp" "$FAKE_IF" || return $?
2173 local nid1=$(lctl list_nids | head -n 1)
2174 local nid2=$(lctl list_nids | tail --lines 1)
2176 [[ $(lctl which_nid $nid1 $nid2) == $nid1 ]] ||
2177 error "Expect nid1 \"$nid1\" to be preferred"
2179 [[ $(lctl which_nid $nid2 $nid1) == $nid2 ]] ||
2180 error "Expect nid2 \"$nid2\" to be preferred"
2184 run_test 213 "Check LNetDist calculation for multiple local NIDs"
2186 function check_ni_status() {
2190 local status=$($LNETCTL net show |
2192 awk '/status/{print $NF}')
2194 echo "NI ${nid} expect status \"${expect}\" found \"${status}\""
2195 if [[ $status != $expect ]]; then
2196 error "Error: Expect NI status \"$expect\" for NID \"$nid\" but found \"$status\""
2203 cleanup_netns || error "Failed to cleanup netns before test execution"
2204 cleanup_lnet || error "Failed to unload modules before test execution"
2206 setup_fakeif || error "Failed to add fake IF"
2207 have_interface "$FAKE_IF" ||
2208 error "Expect $FAKE_IF configured but not found"
2210 reinit_dlc || return $?
2212 add_net "tcp" "${INTERFACES[0]}" || return $?
2213 add_net "tcp" "$FAKE_IF" || return $?
2215 local nid1=$(lctl list_nids | head -n 1)
2216 local nid2=$(lctl list_nids | tail --lines 1)
2218 check_ni_status "0@lo" up
2219 check_ni_status "$nid1" up
2220 check_ni_status "$nid2" up
2222 echo "Set $FAKE_IF down"
2223 echo "ip link set dev $FAKE_IF down"
2224 ip link set dev $FAKE_IF down
2225 check_ni_status "0@lo" up
2226 check_ni_status "$nid1" up
2227 check_ni_status "$nid2" down
2229 run_test 214 "Check local NI status when link is downed"
2235 $LNETCTL net show -v 2 |
2236 egrep -e nid -e $stat |
2238 awk '/'$stat':/{print $NF}'
2243 for nidvar in nid1 nid2; do
2244 for stat in send_count recv_count; do
2245 s=$(get_ni_stat ${!nidvar} $stat)
2246 eval ${nidvar}_pre_${stat}=$s
2253 for nidvar in nid1 nid2; do
2254 for stat in send_count recv_count; do
2255 s=$(get_ni_stat ${!nidvar} $stat)
2256 eval ${nidvar}_post_${stat}=$s
2266 eval pre=\${${nidvar}_pre_${stat}}
2267 eval post=\${${nidvar}_post_${stat}}
2269 echo "${!nidvar} pre ${stat} $pre post ${stat} $post"
2271 [[ $pre -ne $post ]]
2275 cleanup_netns || error "Failed to cleanup netns before test execution"
2276 cleanup_lnet || error "Failed to unload modules before test execution"
2278 reinit_dlc || return $?
2280 add_net "tcp1" "${INTERFACES[0]}" || return $?
2281 add_net "tcp2" "${INTERFACES[0]}" || return $?
2283 local nid1=$($LCTL list_nids | head -n 1)
2284 local nid2=$($LCTL list_nids | tail --lines 1)
2286 do_lnetctl peer add --prim $nid1 --nid $nid2 ||
2287 error "Failed to add peer"
2291 for nidvarA in nid1 nid2; do
2294 for nidvarB in nid1 nid2; do
2295 [[ $nidvarA == $nidvarB ]] && continue
2299 echo "$LNETCTL ping $dst x $npings"
2300 for i in $(seq 1 $npings); do
2301 $LNETCTL ping $dst &>/dev/null ||
2302 error "$LNETCTL ping $dst failed"
2307 # No source specified, sends to either NID should cause
2308 # counts to increase across both NIs
2309 for nidvar in nid1 nid2; do
2310 for stat in send_count recv_count; do
2311 ni_stat_changed $nidvar $stat ||
2312 error "$stat unchanged for ${!nidvar}"
2318 echo "$LNETCTL ping --source $src $dst x $npings"
2319 for i in $(seq 1 $npings); do
2320 $LNETCTL ping --source $src $dst &>/dev/null ||
2321 error "$LNETCTL ping --source $src $dst failed"
2326 # src nid == dest nid means stats for the _other_ NI
2327 # should be unchanged
2328 for nidvar in nid1 nid2; do
2329 for stat in send_count recv_count; do
2330 if [[ ${!nidvar} == $src ]]; then
2331 ni_stat_changed $nidvar $stat ||
2332 error "$stat unchanged for ${!nidvar}"
2334 ni_stat_changed $nidvar $stat &&
2335 error "$stat changed for ${!nidvar}"
2340 # Double number of pings for next iteration because the net
2341 # sequence numbers will have diverged
2342 npings=$(($npings * 2))
2345 # Ping from nid1 to nid2 should fail
2346 do_lnetctl ping --source $nid1 $nid2 &&
2347 error "ping from $nid1 to $nid2 should fail"
2349 # Ping from nid2 to nid1 should fail
2350 do_lnetctl ping --source $nid2 $nid1 &&
2351 error "ping from $nid2 to $nid1 should fail"
2355 run_test 215 "Test lnetctl ping --source option"
2360 reinit_dlc || return $?
2362 add_net "tcp" "${INTERFACES[0]}" || return $?
2363 add_net "tcp1" "${INTERFACES[0]}" || return $?
2365 local nids=( $($LCTL list_nids | xargs echo) )
2367 do_lnetctl discover ${nids[0]} ||
2368 error "Initial discovery failed"
2370 do_lnetctl ping --source ${nids[0]} ${nids[0]} ||
2371 error "Initial ping failed $?"
2373 do_lnetctl ping --source ${nids[1]} ${nids[1]} ||
2374 error "Initial ping failed $?"
2377 for src in "${nids[@]}"; do
2378 for dst in "${nids[@]}"; do
2379 $LCTL net_drop_add -r 1 -s $src -d $dst -e network_timeout
2383 do_lnetctl ping ${nids[0]} || rc=$?
2385 $LCTL net_drop_del -a
2388 error "expected ping to fail"
2390 check_nid_in_recovq "-p" 0
2391 check_nid_in_recovq "-l" 1
2395 run_test 216 "Failed send to peer NI owned by local host should not trigger peer NI recovery"
2398 reinit_dlc || return $?
2400 [[ $($LNETCTL net show | grep -c nid) -ne 1 ]] &&
2401 error "Unexpected number of NIs after initalizing DLC"
2403 do_lnetctl discover 0@lo ||
2404 error "Failed to discover 0@lo"
2408 run_test 217 "Don't leak memory when discovering peer with nnis <= 1"
2411 reinit_dlc || return $?
2413 [[ ${#INTERFACES[@]} -lt 2 ]] &&
2414 skip "Need two LNet interfaces"
2416 add_net "tcp" "${INTERFACES[0]}" || return $?
2418 local nid1=$($LCTL list_nids | head -n 1)
2420 do_lnetctl ping $nid1 ||
2423 add_net "tcp" "${INTERFACES[1]}" || return $?
2425 local nid2=$($LCTL list_nids | tail --lines 1)
2427 do_lnetctl ping $nid2 ||
2430 $LCTL net_drop_add -s $nid1 -d $nid1 -e local_error -r 1
2432 do_lnetctl ping $nid1 &&
2433 error "ping should have failed"
2435 local health_recovered
2438 for i in $(seq 1 5); do
2439 health_recovered=$($LNETCTL net show -v 2 |
2440 grep -c 'health value: 1000')
2442 if [[ $health_recovered -ne 2 ]]; then
2443 echo "Wait 1 second for health to recover"
2450 health_recovered=$($LNETCTL net show -v 2 |
2451 grep -c 'health value: 1000')
2453 $LCTL net_drop_del -a
2455 [[ $health_recovered -ne 2 ]] &&
2456 do_lnetctl net show -v 2 | egrep -e nid -e health &&
2457 error "Health hasn't recovered"
2461 run_test 218 "Local recovery pings should exercise all available paths"
2464 reinit_dlc || return $?
2465 add_net "tcp" "${INTERFACES[0]}" || return $?
2466 add_net "tcp1" "${INTERFACES[0]}" || return $?
2468 local nid1=$(lctl list_nids | head -n 1)
2469 local nid2=$(lctl list_nids | tail --lines 1)
2471 do_lnetctl ping $nid1 ||
2472 error "Ping failed $?"
2473 do_lnetctl ping $nid2 ||
2474 error "Ping failed $?"
2476 do_lnetctl discover $nid2 ||
2477 error "Discovery failed"
2479 $LNETCTL peer show --nid $nid1 | grep -q $nid2 ||
2480 error "$nid2 is not listed under $nid1"
2482 run_test 219 "Consolidate peer entries"
2486 echo "Check valid values; Should succeed"
2490 for ((i = 4; i < 16; i+=1)); do
2491 reinit_dlc || return $?
2492 add_net "tcp" "${INTERFACES[0]}" || return $?
2493 do_lnetctl net set --all --conns-per-peer $i ||
2494 error "should have succeeded $?"
2495 $LNETCTL net show -v 1 | grep -q "conns_per_peer: $i" ||
2496 error "failed to set conns-per-peer to $i"
2497 lnid="$(lctl list_nids | head -n 1)"
2498 do_lnetctl ping "$lnid" ||
2499 error "failed to ping myself"
2501 # "lctl --net tcp conn_list" prints the list of active
2502 # connections. Since we're pinging ourselves, there should be
2503 # 2 Control connections plus 2*conns_per_peer connections
2504 # created (one Bulk Input, one Bulk Output in each pair).
2505 # Here's the sample output for conns_per_peer set to 1:
2506 # 12345-1.1.1.1@tcp I[0]host01->host01:988 2626560/1061296 nonagle
2507 # 12345-1.1.1.1@tcp O[0]host01->host01:1022 2626560/1061488 nonagle
2508 # 12345-1.1.1.1@tcp C[0]host01->host01:988 2626560/1061296 nonagle
2509 # 12345-1.1.1.1@tcp C[0]host01->host01:1023 2626560/1061488 nonagle
2510 cmd="printf 'network tcp\nconn_list\n' | lctl | grep -c '$lnid'"
2512 # Expect 2+conns_per_peer*2 connections. Wait no longer
2514 wait_update $HOSTNAME "$cmd" "$((2+i*2))" 2 ||
2515 error "expected number of tcp connections $((2+i*2))"
2518 reinit_dlc || return $?
2519 add_net "tcp" "${INTERFACES[0]}" || return $?
2520 echo "Set > 127; Should fail"
2521 do_lnetctl net set --all --conns-per-peer 128 &&
2522 error "should have failed $?"
2524 reinit_dlc || return $?
2525 add_net "tcp" "${INTERFACES[0]}" || return $?
2526 echo "Set < 0; Should be ignored"
2527 do_lnetctl net set --all --conns-per-peer -1 ||
2528 error "should have succeeded $?"
2529 $LNETCTL net show -v 1 | grep -q "conns_per_peer: 1" ||
2530 error "Did not stay at default"
2532 run_test 230 "Test setting conns-per-peer"
2534 ### Test that linux route is added for each ni
2536 reinit_dlc || return $?
2537 add_net "tcp" "${INTERFACES[0]}" || return $?
2538 ip route show table ${INTERFACES[0]} | grep -q "${INTERFACES[0]}"
2540 run_test 250 "test that linux routes are added"
2545 local out=$TMP/$tfile
2546 local prefix=/usr/include/linux/lnet
2548 # We use a hard coded prefix so that this test will not fail
2551 if ! which $CC > /dev/null 2>&1; then
2552 skip_env "$CC is not installed"
2555 cleanup_lnet || exit 1
2558 local cc_args="-Wall -Werror -std=c99 -c -x c /dev/null -o $out"
2559 if ! [[ -d $prefix ]]; then
2560 # Assume we're running in tree and fixup the include path.
2561 prefix=$LUSTRE/../lnet/include/uapi/linux/lnet
2562 cc_args+=" -I $LUSTRE/../lnet/include/uapi"
2565 for header in $prefix/*.h; do
2566 if ! [[ -f "$header" ]]; then
2570 echo "$CC $cc_args -include $header"
2571 $CC $cc_args -include $header ||
2572 error "cannot compile '$header'"
2576 run_test 300 "packaged LNet UAPI headers can be compiled"