3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
10 # bug number for skipped test:
11 ALWAYS_EXCEPT="$SANITY_LNET_EXCEPT "
12 [ "$SLOW" = "no" ] && EXCEPT_SLOW=""
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
17 . $LUSTRE/tests/test-framework.sh
21 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
26 export LNETCTL=${LNETCTL:-"$LUSTRE/../lnet/utils/lnetctl"}
27 [ ! -f "$LNETCTL" ] &&
28 export LNETCTL=$(which lnetctl 2> /dev/null)
29 [[ -z $LNETCTL ]] && skip "Need lnetctl"
33 if is_mounted $MOUNT || is_mounted $MOUNT2; then
34 cleanupall || error "Failed cleanup prior to test execution"
39 echo "Cleaning up 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 rm -f $TMP/sanity-dlc*
55 if $restore_mounts; then
56 setupall || error "Failed to setup Lustre after test execution"
57 elif $restore_modules; then
59 error "Couldn't load modules after test execution"
65 load_module ../libcfs/libcfs/libcfs
66 # Prevent local MODOPTS_LIBCFS being passed as part of environment
67 # variable to remote nodes
71 load_module ../lnet/lnet/lnet "$@"
73 LNDPATH=${LNDPATH:-"../lnet/klnds"}
74 if [ -z "$LNETLND" ]; then
76 o2ib*) LNETLND="o2iblnd/ko2iblnd" ;;
77 tcp*) LNETLND="socklnd/ksocklnd" ;;
78 *) local lnd="${NETTYPE%%[0-9]}lnd"
79 [ -f "$LNDPATH/$lnd/k$lnd.ko" ] &&
80 LNETLND="$lnd/k$lnd" ||
81 LNETLND="socklnd/ksocklnd"
84 load_module ../lnet/klnds/$LNETLND
96 echo "ip netns exec $TESTNS $@"
97 ip netns exec $TESTNS "$@"
104 ip link add 'test1pl' type veth peer name $FAKE_IF netns $TESTNS
105 ip link set 'test1pl' up
106 do_ns ip addr add "${FAKE_IP}/31" dev $FAKE_IF
107 do_ns ip link set $FAKE_IF up
111 (ip netns list | grep -q $TESTNS) && ip netns del $TESTNS
112 ip link show test1pl >& /dev/null && ip link del test1pl || return 0
116 echo "Loading LNet and configuring DLC"
118 do_lnetctl lnet configure
121 GLOBAL_YAML_FILE=$TMP/sanity-lnet-global.yaml
122 define_global_yaml() {
123 $LNETCTL export --backup >${GLOBAL_YAML_FILE} ||
124 error "Failed to export global yaml $?"
128 if lsmod | grep -q lnet; then
129 do_lnetctl lnet unconfigure ||
130 error "lnetctl lnet unconfigure failed $?"
131 do_lnetctl lnet configure ||
132 error "lnetctl lnet configure failed $?"
134 configure_dlc || error "configure_dlc failed $?"
139 append_global_yaml() {
140 [[ ! -e ${GLOBAL_YAML_FILE} ]] &&
141 error "Missing global yaml at ${GLOBAL_YAML_FILE}"
143 cat ${GLOBAL_YAML_FILE} >> $TMP/sanity-lnet-$testnum-expected.yaml
146 create_base_yaml_file() {
150 compare_yaml_files() {
151 local expected="$TMP/sanity-lnet-$testnum-expected.yaml"
152 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
154 ! [[ -e $expected ]] && echo "$expected not found" && return 1
155 ! [[ -e $actual ]] && echo "$actual not found" && return 1
156 diff -upN ${actual} ${expected} || rc=$?
166 local net="${nid//*@/}"
167 local addr="${nid//@*/}"
169 local num_re='[0-9]\+'
170 local ip_re="[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"
172 if [[ $net =~ gni[0-9]* ]]; then
173 [[ $addr =~ ${num_re} ]] && return 0
175 [[ $addr =~ ${ip_re} ]] && return 0
180 local yfile=$TMP/sanity-lnet-$testnum-actual.yaml
181 local primary_nids=$(awk '/- primary nid:/{print $NF}' $yfile | xargs echo)
182 local secondary_nids=$(awk '/- nid:/{print $NF}' $yfile | xargs echo)
183 local gateway_nids=$(awk '/gateway:/{print $NF}' $yfile | xargs echo)
186 for nid in $primary_nids $secondary_nids; do
187 validate_nid "$nid" || error "Bad NID \"${nid}\""
192 validate_peer_nids() {
194 local nids_per_peer="$2"
196 local expect_p="$num_peers"
197 # The primary nid also shows up in the list of secondary nids
198 local expect_s="$(($num_peers + $(($nids_per_peer*$num_peers))))"
200 local actual_p=$(grep -c -- '- primary nid:' $TMP/sanity-lnet-$testnum-actual.yaml)
201 local actual_s=$(grep -c -- '- nid:' $TMP/sanity-lnet-$testnum-actual.yaml)
202 if [[ $expect_p -ne $actual_p ]]; then
204 error "Expected $expect_p but found $actual_p primary nids"
205 elif [[ $expect_s -ne $actual_s ]]; then
207 error "Expected $expect_s but found $actual_s secondary nids"
212 validate_gateway_nids() {
213 local expect_gw=$(grep -c -- 'gateway:' $TMP/sanity-lnet-$testnum-expected.yaml)
214 local actual_gw=$(grep -c -- 'gateway:' $TMP/sanity-lnet-$testnum-actual.yaml)
215 if [[ $expect_gw -ne $actual_gw ]]; then
217 error "Expected $expect_gw gateways but found $actual_gw gateways"
223 setup_netns || error "setup_netns failed with $?"
225 stack_trap 'cleanup_testsuite' EXIT
228 load_module ../lnet/lnet/lnet || error "Failed to load module rc = $?"
229 do_lnetctl lnet configure || error "lnet configure failed rc = $?"
231 reinit_dlc || return $?
232 do_lnetctl import < ${GLOBAL_YAML_FILE} || error "Import failed $?"
233 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
234 create_base_yaml_file
235 compare_yaml_files || error "Configuration changed after import"
237 run_test 0 "Export empty config, import the config, compare"
240 local prim_nid="${1:+--prim_nid $1}"
241 local nid="${2:+--nid $2}"
243 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
245 do_lnetctl peer add ${prim_nid} ${nid} || error "peer add failed $?"
246 $LNETCTL export --backup > $actual || error "export failed $?"
252 reinit_dlc || return $?
253 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
255 - primary nid: 1.1.1.1@tcp
261 compare_peer_add "1.1.1.1@tcp"
263 run_test 1 "Add peer with single nid (tcp)"
266 reinit_dlc || return $?
267 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
269 - primary nid: 2.2.2.2@o2ib
275 compare_peer_add "2.2.2.2@o2ib"
277 run_test 2 "Add peer with single nid (o2ib)"
280 reinit_dlc || return $?
281 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
283 - primary nid: 3.3.3.3@tcp
290 compare_peer_add "3.3.3.3@tcp" "3.3.3.3@o2ib"
292 run_test 3 "Add peer with tcp primary o2ib secondary"
295 reinit_dlc || return $?
296 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
298 - primary nid: 4.4.4.4@tcp
307 echo "Add peer with nidrange (tcp)"
308 compare_peer_add "4.4.4.4@tcp" "4.4.4.[1-3]@tcp"
310 echo "Add peer with nidrange that overlaps primary nid (tcp)"
311 compare_peer_add "4.4.4.4@tcp" "4.4.4.[1-4]@tcp"
313 run_test 4 "Add peer with nidrange (tcp)"
316 reinit_dlc || return $?
317 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
319 - primary nid: 5.5.5.5@o2ib
329 echo "Add peer with nidrange (o2ib)"
330 compare_peer_add "5.5.5.5@o2ib" "5.5.5.[1-4]@o2ib"
332 echo "Add peer with nidranage that overlaps primary nid (o2ib)"
333 compare_peer_add "5.5.5.5@o2ib" "5.5.5.[1-4]@o2ib"
335 run_test 5 "Add peer with nidrange (o2ib)"
338 reinit_dlc || return $?
339 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
341 - primary nid: 6.6.6.6@tcp
361 compare_peer_add "6.6.6.6@tcp" \
362 "6.6.[6-7].[0-4/2]@tcp,6.6.[1-4/2].[0-6/3]@o2ib,[6-12/4]@gni"
364 run_test 6 "Add peer with multiple nidranges"
367 local prim_nid="${1:+--prim_nid $1}"
368 local nid="${2:+--nid $2}"
370 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
372 do_lnetctl peer del ${prim_nid} ${nid} || error "peer del failed $?"
373 $LNETCTL export --backup > $actual || error "export failed $?"
379 reinit_dlc || return $?
380 create_base_yaml_file
382 echo "Delete peer with single nid (tcp)"
383 do_lnetctl peer add --prim_nid 7.7.7.7@tcp || error "Peer add failed $?"
384 compare_peer_del "7.7.7.7@tcp"
386 echo "Delete peer with single nid (o2ib)"
387 do_lnetctl peer add --prim_nid 7.7.7.7@o2ib || error "Peer add failed $?"
388 compare_peer_del "7.7.7.7@o2ib"
390 echo "Delete peer that has multiple nids (tcp)"
391 do_lnetctl peer add --prim_nid 7.7.7.7@tcp --nid 7.7.7.[8-12]@tcp ||
392 error "Peer add failed $?"
393 compare_peer_del "7.7.7.7@tcp"
395 echo "Delete peer that has multiple nids (o2ib)"
396 do_lnetctl peer add --prim_nid 7.7.7.7@o2ib --nid 7.7.7.[8-12]@o2ib ||
397 error "Peer add failed $?"
398 compare_peer_del "7.7.7.7@o2ib"
400 echo "Delete peer that has both tcp and o2ib nids"
401 do_lnetctl peer add --prim_nid 7.7.7.7@tcp \
402 --nid 7.7.7.[9-12]@tcp,7.7.7.[13-15]@o2ib ||
403 error "Peer add failed $?"
404 compare_peer_del "7.7.7.7@tcp"
406 echo "Delete peer with single nid (gni)"
407 do_lnetctl peer add --prim_nid 7@gni || error "Peer add failed $?"
408 compare_peer_del "7@gni"
410 echo "Delete peer that has multiple nids (gni)"
411 do_lnetctl peer add --prim_nid 7@gni --nid [8-12]@gni ||
412 error "Peer add failed $?"
413 compare_peer_del "7@gni"
415 echo "Delete peer that has tcp, o2ib and gni nids"
416 do_lnetctl peer add --prim_nid 7@gni \
417 --nid [8-12]@gni,7.7.7.[9-12]@tcp,7.7.7.[13-15]@o2ib ||
418 error "Peer add failed $?"
419 compare_peer_del "7@gni"
421 run_test 7 "Various peer delete tests"
424 reinit_dlc || return $?
426 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
428 - primary nid: 8.8.8.8@tcp
440 do_lnetctl peer add --prim_nid 8.8.8.8@tcp --nid 8.8.8.[10-15]@tcp ||
441 error "Peer add failed $?"
442 compare_peer_del "8.8.8.8@tcp" "8.8.8.13@tcp"
444 run_test 8 "Delete single secondary nid from peer (tcp)"
447 reinit_dlc || return $?
449 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
451 - primary nid: 9.9.9.9@tcp
458 do_lnetctl peer add --prim_nid 9.9.9.9@tcp \
459 --nid 9.9.9.[11-16]@tcp || error "Peer add failed $?"
460 compare_peer_del "9.9.9.9@tcp" "9.9.9.[11-16]@tcp"
462 run_test 9 "Delete all secondary nids from peer (tcp)"
465 reinit_dlc || return $?
467 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
469 - primary nid: 10.10.10.10@tcp
472 - nid: 10.10.10.10@tcp
473 - nid: 10.10.10.12@tcp
474 - nid: 10.10.10.13@tcp
475 - nid: 10.10.10.15@tcp
476 - nid: 10.10.10.16@tcp
479 do_lnetctl peer add --prim_nid 10.10.10.10@tcp \
480 --nid 10.10.10.[12-16]@tcp || error "Peer add failed $?"
481 compare_peer_del "10.10.10.10@tcp" "10.10.10.14@tcp"
483 run_test 10 "Delete single secondary nid from peer (o2ib)"
486 reinit_dlc || return $?
488 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
490 - primary nid: 11.11.11.11@tcp
493 - nid: 11.11.11.11@tcp
496 do_lnetctl peer add --prim_nid 11.11.11.11@tcp \
497 --nid 11.11.11.[13-17]@tcp || error "Peer add failed $?"
498 compare_peer_del "11.11.11.11@tcp" "11.11.11.[13-17]@tcp"
500 run_test 11 "Delete all secondary nids from peer (o2ib)"
503 reinit_dlc || return $?
505 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
507 - primary nid: 12.12.12.12@o2ib
510 - nid: 12.12.12.12@o2ib
511 - nid: 13.13.13.13@o2ib
512 - nid: 14.13.13.13@o2ib
513 - nid: 14.15.13.13@o2ib
515 - nid: 15.17.1.10@tcp
516 - nid: 15.17.1.20@tcp
519 do_lnetctl peer add --prim_nid 12.12.12.12@o2ib \
520 --nid [13-14/1].[13-15/2].13.13@o2ib,[15-16/3].[17-19/4].[1].[5-20/5]@tcp ||
521 error "Peer add failed $?"
522 compare_peer_del "12.12.12.12@o2ib" "13.15.13.13@o2ib,15.17.1.15@tcp"
524 run_test 12 "Delete a secondary nid from peer (tcp and o2ib)"
527 reinit_dlc || return $?
529 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
531 - primary nid: 13.13.13.13@o2ib
534 - nid: 13.13.13.13@o2ib
537 do_lnetctl peer add --prim_nid 13.13.13.13@o2ib \
538 --nid [14-15].[1-2/1].[1].[100-254/10]@tcp,14.14.[254].14@o2ib ||
539 error "Peer add failed $?"
540 compare_peer_del "13.13.13.13@o2ib" \
541 "[14-15].[1-2/1].[1].[100-254/10]@tcp,14.14.[254].14@o2ib"
543 run_test 13 "Delete all secondary nids from peer (tcp and o2ib)"
549 if [[ $net =~ gni* ]]; then
552 echo "${num}.${num}.${num}.${num}@${net}"
556 create_mr_peer_yaml() {
558 local secondary_nids="$2"
561 echo "Generating peer yaml for $num_peers peers with $secondary_nids secondary nids"
562 echo "peer:" >> $TMP/sanity-lnet-$testnum-expected.yaml
564 local total_nids=$((num_peers + $((num_peers * secondary_nids))))
567 while [[ $created -lt $num_peers ]]; do
568 local primary=$(create_nid ${nidnum} ${net})
569 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
570 - primary nid: $primary
576 local start=$((nidnum + 1))
577 local end=$((nidnum + $secondary_nids))
578 for j in $(seq ${start} ${end}); do
579 local nid=$(create_nid $j ${net})
580 echo " - nid: $nid" >> $TMP/sanity-lnet-$testnum-expected.yaml
588 reinit_dlc || return $?
590 echo "Create single peer, single nid, using import"
591 create_mr_peer_yaml 1 0 tcp
592 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
593 error "Import failed $?"
595 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
598 echo "Delete single peer using import --del"
599 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
600 error "Import failed $?"
601 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
602 create_base_yaml_file
603 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
606 run_test 14 "import peer create/delete with single nid"
609 reinit_dlc || return $?
611 echo "Create multiple peers, single nid per peer, using import"
612 create_mr_peer_yaml 5 0 o2ib
613 # The ordering of nids for this use-case is non-deterministic, so we
614 # we can't just diff the expected/actual output.
615 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
616 error "Import failed $?"
617 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
618 validate_peer_nids 5 0
620 echo "Delete multiple peers, single nid per peer, using import --del"
621 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
622 error "Import failed $?"
623 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
624 create_base_yaml_file
625 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
628 run_test 15 "import multi peer create/delete with single nid per peer"
631 reinit_dlc || return $?
633 echo "Create single peer, multiple nids, using import"
634 create_mr_peer_yaml 1 5 tcp
635 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
636 error "Import failed $?"
637 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
638 validate_peer_nids 1 5
640 echo "Delete single peer, multiple nids, using import --del"
641 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
642 error "Import failed $?"
643 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
644 create_base_yaml_file
645 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
648 run_test 16 "import peer create/delete with multiple nids"
651 reinit_dlc || return $?
653 echo "Create multiple peers, multiple nids per peer, using import"
654 create_mr_peer_yaml 5 7 o2ib
655 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
656 error "Import failed $?"
657 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
658 validate_peer_nids 5 7
660 echo "Delete multiple peers, multiple nids per peer, using import --del"
661 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
662 error "Import failed $?"
663 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
664 create_base_yaml_file
665 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
668 run_test 17 "import multi peer create/delete with multiple nids"
671 reinit_dlc || return $?
673 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
675 - primary nid: 1.1.1.1@tcp
684 echo "Import peer with 5 nids"
685 cat $TMP/sanity-lnet-$testnum-expected.yaml
686 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
687 error "Import failed $?"
688 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
690 - primary nid: 1.1.1.1@tcp
697 echo "Delete three of the nids"
698 cat $TMP/sanity-lnet-$testnum-expected.yaml
699 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml
700 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
702 - primary nid: 1.1.1.1@tcp
708 echo "Check peer has expected nids remaining"
709 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
713 run_test 18a "Delete a subset of nids from a single peer using import --del"
716 reinit_dlc || return $?
718 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
720 - primary nid: 1.1.1.1@tcp
728 - primary nid: 6.6.6.6@o2ib
737 echo "Import two peers with 5 nids each"
738 cat $TMP/sanity-lnet-$testnum-expected.yaml
739 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
740 error "Import failed $?"
741 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
743 - primary nid: 1.1.1.1@tcp
749 - primary nid: 6.6.6.6@o2ib
756 echo "Delete three of the nids from each peer"
757 cat $TMP/sanity-lnet-$testnum-expected.yaml
758 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml
759 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
761 - primary nid: 6.6.6.6@o2ib
766 - primary nid: 1.1.1.1@tcp
773 echo "Check peers have expected nids remaining"
774 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
776 validate_peer_nids 2 1
778 run_test 18b "Delete multiple nids from multiple peers using import --del"
781 reinit_dlc || return $?
782 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
784 - primary nid: 19@gni
790 compare_peer_add "19@gni"
792 run_test 19 "Add peer with single nid (gni)"
795 reinit_dlc || return $?
796 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
798 - primary nid: 20@gni
802 - nid: 20.20.20.20@tcp
803 - nid: 20.20.20.20@o2ib
806 compare_peer_add "20@gni" "20.20.20.20@tcp,20.20.20.20@o2ib"
808 run_test 20 "Add peer with gni primary and tcp, o2ib secondary"
811 reinit_dlc || return $?
812 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
814 - primary nid: 21@gni
824 echo"Add peer with nidrange (gni)"
825 compare_peer_add "21@gni" "[22-25]@gni" || error
826 echo "Add peer with nidrange that overlaps primary nid (gni)"
827 compare_peer_add "21@gni" "[21-25]@gni"
829 run_test 21 "Add peer with nidrange (gni)"
832 reinit_dlc || return $?
833 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
835 - primary nid: 22@gni
846 do_lnetctl peer add --prim_nid 22@gni --nid [24-29]@gni ||
847 error "Peer add failed $?"
848 compare_peer_del "22@gni" "26@gni"
850 run_test 22 "Delete single secondary nid from peer (gni)"
853 reinit_dlc || return $?
854 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
856 - primary nid: 23@gni
863 do_lnetctl peer add --prim_nid 23@gni --nid [25-29]@gni ||
864 error "Peer add failed $?"
865 compare_peer_del "23@gni" "[25-29]@gni"
867 run_test 23 "Delete all secondary nids from peer (gni)"
870 reinit_dlc || return $?
871 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
873 - primary nid: 24@gni
878 - nid: 13.13.13.13@o2ib
879 - nid: 14.13.13.13@o2ib
880 - nid: 14.15.13.13@o2ib
882 - nid: 15.17.1.10@tcp
883 - nid: 15.17.1.20@tcp
886 do_lnetctl peer add --prim_nid 24@gni \
887 --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 ||
888 error "Peer add failed $?"
889 compare_peer_del "24@gni" "5@gni,13.15.13.13@o2ib,15.17.1.15@tcp"
891 run_test 24 "Delete a secondary nid from peer (tcp, o2ib and gni)"
894 reinit_dlc || return $?
895 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
897 - primary nid: 25@gni
903 do_lnetctl peer add --prim_nid 25@gni \
904 --nid [26-27].[4-10/3].26.26@tcp,26.26.26.26@o2ib,[30-35]@gni ||
905 error "Peer add failed $?"
906 compare_peer_del "25@gni" \
907 "[26-27].[4-10/3].26.26@tcp,26.26.26.26@o2ib,[30-35]@gni"
909 run_test 25 "Delete all secondary nids from peer (tcp, gni and o2ib)"
912 reinit_dlc || return $?
914 echo "Invalid prim_nid - peer add"
915 do_lnetctl peer add --prim_nid foobar &&
916 error "Command should have failed"
918 echo "Invalid prim_nid - peer del"
919 do_lnetctl peer del --prim_nid foobar &&
920 error "Command should have failed"
922 echo "Delete non-existing peer"
923 do_lnetctl peer del --prim_nid 1.1.1.1@o2ib &&
924 error "Command should have failed"
926 echo "Don't provide mandatory arguments peer del"
927 do_lnetctl peer del --nid 1.1.1.1@tcp &&
928 error "Command should have failed"
930 echo "Don't provide mandatory arguments peer add"
931 do_lnetctl peer add &&
932 error "Command should have failed"
934 echo "Invalid secondary nids"
935 do_lnetctl peer add --prim_nid 1.1.1.1@tcp --nid foobar &&
936 error "Command should have failed"
938 echo "Exceed max nids per peer"
939 do_lnetctl peer add --prim_nid 1.1.1.1@tcp --nid 1.1.1.[2-255]@tcp &&
940 error "Command should have failed"
942 echo "Invalid net type"
943 do_lnetctl peer add --prim_nid 1@foo &&
944 error "Command should have failed"
946 echo "Invalid nid format"
947 local invalid_nids="1@tcp 1@o2ib 1.1.1.1@gni"
950 for nid in ${invalid_nids}; do
951 echo "Check invalid primary nid - '$nid'"
952 do_lnetctl peer add --prim_nid $nid &&
953 error "Command should have failed"
956 local invalid_strs="[2-1]@gni [a-f/x]@gni 256.256.256.256@tcp"
957 invalid_strs+=" 1.1.1.1.[2-5/f]@tcp 1.]2[.3.4@o2ib"
958 invalid_strs+="1.[2-4,[5-6],7-8].1.1@tcp foobar"
961 for nidstr in ${invalid_strs}; do
962 echo "Check invalid nidstring - '$nidstr'"
963 do_lnetctl peer add --nid $nidstr &&
964 error "Command should have failed"
967 echo "Add non-local gateway"
968 do_lnetctl route add --net tcp --gateway 1@gni &&
969 error "Command should have failed"
973 run_test 99a "Check various invalid inputs to lnetctl peer"
976 reinit_dlc || return $?
978 create_base_yaml_file
980 cat <<EOF > $TMP/sanity-lnet-$testnum-invalid.yaml
982 - primary nid: 99.99.99.99@tcp
985 - nid: 99.99.99.99@tcp
987 do_lnetctl import < $TMP/sanity-lnet-$testnum-invalid.yaml &&
988 error "import should have failed"
989 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
992 run_test 99b "Invalid value for Multi-Rail in yaml import"
996 local ip=$(ip addr show dev $if | awk '/ inet /{print $2}')
1004 reinit_dlc || return $?
1005 load_module ../lnet/klnds/socklnd/ksocklnd ||
1006 error "Can't load ksocklnd.ko"
1007 do_lnetctl net add --net ${net} --if ${if} ||
1008 error "Failed to add net ${net} on if ${if}"
1011 compare_route_add() {
1015 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
1017 do_lnetctl route add --net ${rnet} --gateway ${gw} ||
1018 error "route add failed $?"
1019 # CPT configuration is pruned from the exported yaml, since the default
1020 # can vary across test systems (unlike default values for things like
1021 # peer_credits, peer_timeout, etc.)
1022 $LNETCTL export --backup | grep -v CPT > $actual ||
1023 error "export failed $?"
1024 validate_gateway_nids
1029 have_interface "eth0" || skip "Need eth0 interface with ipv4 configured"
1030 add_net "tcp" "eth0"
1031 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
1040 peer_buffer_credits: 0
1044 gateway: 7.7.7.7@tcp
1047 health_sensitivity: 1
1049 - primary nid: 7.7.7.7@tcp
1055 compare_route_add "tcp7" "7.7.7.7@tcp" || return $?
1058 run_test 100 "Add route with single gw (tcp)"
1061 have_interface "eth0" || skip "Need eth0 interface with ipv4 configured"
1062 add_net "tcp" "eth0"
1063 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
1072 peer_buffer_credits: 0
1076 gateway: 8.8.8.10@tcp
1079 health_sensitivity: 1
1081 gateway: 8.8.8.9@tcp
1084 health_sensitivity: 1
1086 gateway: 8.8.8.8@tcp
1089 health_sensitivity: 1
1091 - primary nid: 8.8.8.9@tcp
1095 - primary nid: 8.8.8.10@tcp
1099 - primary nid: 8.8.8.8@tcp
1105 compare_route_add "tcp8" "8.8.8.[8-10]@tcp"
1107 run_test 101 "Add route with multiple gw (tcp)"
1109 compare_route_del() {
1113 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
1115 do_lnetctl route del --net ${rnet} --gateway ${gw} ||
1116 error "route del failed $?"
1117 $LNETCTL export --backup > $actual ||
1118 error "export failed $?"
1119 validate_gateway_nids
1123 have_interface "eth0" || skip "Need eth0 interface with ipv4 configured"
1124 add_net "tcp" "eth0"
1125 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
1126 do_lnetctl route add --net tcp102 --gateway 102.102.102.102@tcp ||
1127 error "route add failed $?"
1128 compare_route_del "tcp102" "102.102.102.102@tcp"
1130 run_test 102 "Delete route with single gw (tcp)"
1133 have_interface "eth0" || skip "Need eth0 interface with ipv4 configured"
1134 add_net "tcp" "eth0"
1135 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
1136 do_lnetctl route add --net tcp103 \
1137 --gateway 103.103.103.[103-120/4]@tcp ||
1138 error "route add failed $?"
1139 compare_route_del "tcp103" "103.103.103.[103-120/4]@tcp"
1141 run_test 103 "Delete route with multiple gw (tcp)"
1143 ### load lnet in default namespace, configure in target namespace
1146 cleanup_lnet || exit 1
1147 load_lnet "networks=\"\""
1148 do_ns $LNETCTL lnet configure --all || exit 1
1149 $LNETCTL net show --net tcp | grep -q "nid: ${FAKE_IP}@tcp$"
1151 run_test 200 "load lnet w/o module option, configure in a non-default namespace"
1154 cleanup_lnet || exit 1
1155 load_lnet "networks=tcp($FAKE_IF)"
1156 do_ns $LNETCTL lnet configure --all || exit 1
1157 $LNETCTL net show --net tcp | grep -q "nid: ${FAKE_IP}@tcp$"
1159 run_test 201 "load lnet using networks module options in a non-default namespace"
1162 cleanup_lnet || exit 1
1163 load_lnet "networks=\"\" ip2nets=\"tcp0($FAKE_IF) ${FAKE_IP}\""
1164 do_ns $LNETCTL lnet configure --all || exit 1
1165 $LNETCTL net show | grep -q "nid: ${FAKE_IP}@tcp$"
1167 run_test 202 "load lnet using ip2nets in a non-default namespace"
1170 ### Add the interfaces in the target namespace
1173 cleanup_lnet || exit 1
1175 do_lnetctl lnet configure || exit 1
1176 do_ns $LNETCTL net add --net tcp0 --if $FAKE_IF
1178 run_test 203 "add a network using an interface in the non-default namespace"
1183 local out=$TMP/$tfile
1184 local prefix=/usr/include/linux/lnet
1186 # We use a hard coded prefix so that this test will not fail
1189 if ! which $CC > /dev/null 2>&1; then
1190 skip_env "$CC is not installed"
1193 cleanup_lnet || exit 1
1196 if ! [[ -d $prefix ]]; then
1197 # Assume we're running in tree and fixup the include path.
1198 prefix=$LUSTRE/../lnet/include/uapi/linux/lnet
1201 for header in $prefix/*.h; do
1202 if ! [[ -f "$header" ]]; then
1206 $CC -Wall -Werror -std=c99 -include $header -c -x c /dev/null -o $out ||
1207 error "cannot compile '$header'"
1211 run_test 300 "packaged LNet UAPI headers can be compiled"