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"
51 rm -f $TMP/sanity-dlc*
54 if $restore_mounts; then
55 setupall || error "Failed to setup Lustre after test execution"
56 elif $restore_modules; then
58 error "Couldn't load modules after test execution"
64 load_module ../libcfs/libcfs/libcfs
65 # Prevent local MODOPTS_LIBCFS being passed as part of environment
66 # variable to remote nodes
70 load_module ../lnet/lnet/lnet "$@"
72 LNDPATH=${LNDPATH:-"../lnet/klnds"}
73 if [ -z "$LNETLND" ]; then
75 o2ib*) LNETLND="o2iblnd/ko2iblnd" ;;
76 tcp*) LNETLND="socklnd/ksocklnd" ;;
77 *) local lnd="${NETTYPE%%[0-9]}lnd"
78 [ -f "$LNDPATH/$lnd/k$lnd.ko" ] &&
79 LNETLND="$lnd/k$lnd" ||
80 LNETLND="socklnd/ksocklnd"
83 load_module ../lnet/klnds/$LNETLND
95 echo "ip netns exec $TESTNS $@"
96 ip netns exec $TESTNS "$@"
103 ip link add 'test1pl' type veth peer name $FAKE_IF netns $TESTNS
104 ip link set 'test1pl' up
105 do_ns ip addr add "${FAKE_IP}/31" dev $FAKE_IF
106 do_ns ip link set $FAKE_IF up
110 (ip netns list | grep -q $TESTNS) && ip netns del $TESTNS
111 if ip link show test1pl >/dev/null 2>&1; then
117 echo "Loading LNet and configuring DLC"
119 do_lnetctl lnet configure
122 GLOBAL_YAML_FILE=$TMP/sanity-lnet-global.yaml
123 define_global_yaml() {
124 $LNETCTL export --backup >${GLOBAL_YAML_FILE} ||
125 error "Failed to export global yaml $?"
129 if lsmod | grep -q lnet; then
130 do_lnetctl lnet unconfigure ||
131 error "lnetctl lnet unconfigure failed $?"
132 do_lnetctl lnet configure ||
133 error "lnetctl lnet configure failed $?"
135 configure_dlc || error "configure_dlc failed $?"
140 append_global_yaml() {
141 [[ ! -e ${GLOBAL_YAML_FILE} ]] &&
142 error "Missing global yaml at ${GLOBAL_YAML_FILE}"
144 cat ${GLOBAL_YAML_FILE} >> $TMP/sanity-lnet-$testnum-expected.yaml
147 create_base_yaml_file() {
151 compare_yaml_files() {
152 local expected="$TMP/sanity-lnet-$testnum-expected.yaml"
153 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
155 ! [[ -e $expected ]] && echo "$expected not found" && return 1
156 ! [[ -e $actual ]] && echo "$actual not found" && return 1
157 diff -upN ${actual} ${expected} || rc=$?
167 local net="${nid//*@/}"
168 local addr="${nid//@*/}"
170 local num_re='[0-9]\+'
171 local ip_re="[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"
173 if [[ $net =~ gni[0-9]* ]]; then
174 [[ $addr =~ ${num_re} ]] && return 0
176 [[ $addr =~ ${ip_re} ]] && return 0
181 local yfile=$TMP/sanity-lnet-$testnum-actual.yaml
182 local primary_nids=$(awk '/- primary nid:/{print $NF}' $yfile | xargs echo)
183 local secondary_nids=$(awk '/- nid:/{print $NF}' $yfile | xargs echo)
184 local gateway_nids=$(awk '/gateway:/{print $NF}' $yfile | xargs echo)
187 for nid in $primary_nids $secondary_nids; do
188 validate_nid "$nid" || error "Bad NID \"${nid}\""
193 validate_peer_nids() {
195 local nids_per_peer="$2"
197 local expect_p="$num_peers"
198 # The primary nid also shows up in the list of secondary nids
199 local expect_s="$(($num_peers + $(($nids_per_peer*$num_peers))))"
201 local actual_p=$(grep -c -- '- primary nid:' $TMP/sanity-lnet-$testnum-actual.yaml)
202 local actual_s=$(grep -c -- '- nid:' $TMP/sanity-lnet-$testnum-actual.yaml)
203 if [[ $expect_p -ne $actual_p ]]; then
205 error "Expected $expect_p but found $actual_p primary nids"
206 elif [[ $expect_s -ne $actual_s ]]; then
208 error "Expected $expect_s but found $actual_s secondary nids"
213 validate_gateway_nids() {
214 local expect_gw=$(grep -c -- 'gateway:' $TMP/sanity-lnet-$testnum-expected.yaml)
215 local actual_gw=$(grep -c -- 'gateway:' $TMP/sanity-lnet-$testnum-actual.yaml)
216 if [[ $expect_gw -ne $actual_gw ]]; then
218 error "Expected $expect_gw gateways but found $actual_gw gateways"
224 setup_netns || error "setup_netns failed with $?"
227 load_module ../lnet/lnet/lnet || error "Failed to load module rc = $?"
228 do_lnetctl lnet configure || error "lnet configure failed rc = $?"
230 reinit_dlc || return $?
231 do_lnetctl import < ${GLOBAL_YAML_FILE} || error "Import failed $?"
232 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
233 create_base_yaml_file
234 compare_yaml_files || error "Configuration changed after import"
236 run_test 0 "Export empty config, import the config, compare"
239 local prim_nid="${1:+--prim_nid $1}"
240 local nid="${2:+--nid $2}"
242 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
244 do_lnetctl peer add ${prim_nid} ${nid} || error "peer add failed $?"
245 $LNETCTL export --backup > $actual || error "export failed $?"
251 reinit_dlc || return $?
252 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
254 - primary nid: 1.1.1.1@tcp
260 compare_peer_add "1.1.1.1@tcp"
262 run_test 1 "Add peer with single nid (tcp)"
265 reinit_dlc || return $?
266 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
268 - primary nid: 2.2.2.2@o2ib
274 compare_peer_add "2.2.2.2@o2ib"
276 run_test 2 "Add peer with single nid (o2ib)"
279 reinit_dlc || return $?
280 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
282 - primary nid: 3.3.3.3@tcp
289 compare_peer_add "3.3.3.3@tcp" "3.3.3.3@o2ib"
291 run_test 3 "Add peer with tcp primary o2ib secondary"
294 reinit_dlc || return $?
295 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
297 - primary nid: 4.4.4.4@tcp
306 echo "Add peer with nidrange (tcp)"
307 compare_peer_add "4.4.4.4@tcp" "4.4.4.[1-3]@tcp"
309 echo "Add peer with nidrange that overlaps primary nid (tcp)"
310 compare_peer_add "4.4.4.4@tcp" "4.4.4.[1-4]@tcp"
312 run_test 4 "Add peer with nidrange (tcp)"
315 reinit_dlc || return $?
316 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
318 - primary nid: 5.5.5.5@o2ib
328 echo "Add peer with nidrange (o2ib)"
329 compare_peer_add "5.5.5.5@o2ib" "5.5.5.[1-4]@o2ib"
331 echo "Add peer with nidranage that overlaps primary nid (o2ib)"
332 compare_peer_add "5.5.5.5@o2ib" "5.5.5.[1-4]@o2ib"
334 run_test 5 "Add peer with nidrange (o2ib)"
337 reinit_dlc || return $?
338 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
340 - primary nid: 6.6.6.6@tcp
360 compare_peer_add "6.6.6.6@tcp" \
361 "6.6.[6-7].[0-4/2]@tcp,6.6.[1-4/2].[0-6/3]@o2ib,[6-12/4]@gni"
363 run_test 6 "Add peer with multiple nidranges"
366 local prim_nid="${1:+--prim_nid $1}"
367 local nid="${2:+--nid $2}"
369 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
371 do_lnetctl peer del ${prim_nid} ${nid} || error "peer del failed $?"
372 $LNETCTL export --backup > $actual || error "export failed $?"
378 reinit_dlc || return $?
379 create_base_yaml_file
381 echo "Delete peer with single nid (tcp)"
382 do_lnetctl peer add --prim_nid 7.7.7.7@tcp || error "Peer add failed $?"
383 compare_peer_del "7.7.7.7@tcp"
385 echo "Delete peer with single nid (o2ib)"
386 do_lnetctl peer add --prim_nid 7.7.7.7@o2ib || error "Peer add failed $?"
387 compare_peer_del "7.7.7.7@o2ib"
389 echo "Delete peer that has multiple nids (tcp)"
390 do_lnetctl peer add --prim_nid 7.7.7.7@tcp --nid 7.7.7.[8-12]@tcp ||
391 error "Peer add failed $?"
392 compare_peer_del "7.7.7.7@tcp"
394 echo "Delete peer that has multiple nids (o2ib)"
395 do_lnetctl peer add --prim_nid 7.7.7.7@o2ib --nid 7.7.7.[8-12]@o2ib ||
396 error "Peer add failed $?"
397 compare_peer_del "7.7.7.7@o2ib"
399 echo "Delete peer that has both tcp and o2ib nids"
400 do_lnetctl peer add --prim_nid 7.7.7.7@tcp \
401 --nid 7.7.7.[9-12]@tcp,7.7.7.[13-15]@o2ib ||
402 error "Peer add failed $?"
403 compare_peer_del "7.7.7.7@tcp"
405 echo "Delete peer with single nid (gni)"
406 do_lnetctl peer add --prim_nid 7@gni || error "Peer add failed $?"
407 compare_peer_del "7@gni"
409 echo "Delete peer that has multiple nids (gni)"
410 do_lnetctl peer add --prim_nid 7@gni --nid [8-12]@gni ||
411 error "Peer add failed $?"
412 compare_peer_del "7@gni"
414 echo "Delete peer that has tcp, o2ib and gni nids"
415 do_lnetctl peer add --prim_nid 7@gni \
416 --nid [8-12]@gni,7.7.7.[9-12]@tcp,7.7.7.[13-15]@o2ib ||
417 error "Peer add failed $?"
418 compare_peer_del "7@gni"
420 run_test 7 "Various peer delete tests"
423 reinit_dlc || return $?
425 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
427 - primary nid: 8.8.8.8@tcp
439 do_lnetctl peer add --prim_nid 8.8.8.8@tcp --nid 8.8.8.[10-15]@tcp ||
440 error "Peer add failed $?"
441 compare_peer_del "8.8.8.8@tcp" "8.8.8.13@tcp"
443 run_test 8 "Delete single secondary nid from peer (tcp)"
446 reinit_dlc || return $?
448 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
450 - primary nid: 9.9.9.9@tcp
457 do_lnetctl peer add --prim_nid 9.9.9.9@tcp \
458 --nid 9.9.9.[11-16]@tcp || error "Peer add failed $?"
459 compare_peer_del "9.9.9.9@tcp" "9.9.9.[11-16]@tcp"
461 run_test 9 "Delete all secondary nids from peer (tcp)"
464 reinit_dlc || return $?
466 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
468 - primary nid: 10.10.10.10@tcp
471 - nid: 10.10.10.10@tcp
472 - nid: 10.10.10.12@tcp
473 - nid: 10.10.10.13@tcp
474 - nid: 10.10.10.15@tcp
475 - nid: 10.10.10.16@tcp
478 do_lnetctl peer add --prim_nid 10.10.10.10@tcp \
479 --nid 10.10.10.[12-16]@tcp || error "Peer add failed $?"
480 compare_peer_del "10.10.10.10@tcp" "10.10.10.14@tcp"
482 run_test 10 "Delete single secondary nid from peer (o2ib)"
485 reinit_dlc || return $?
487 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
489 - primary nid: 11.11.11.11@tcp
492 - nid: 11.11.11.11@tcp
495 do_lnetctl peer add --prim_nid 11.11.11.11@tcp \
496 --nid 11.11.11.[13-17]@tcp || error "Peer add failed $?"
497 compare_peer_del "11.11.11.11@tcp" "11.11.11.[13-17]@tcp"
499 run_test 11 "Delete all secondary nids from peer (o2ib)"
502 reinit_dlc || return $?
504 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
506 - primary nid: 12.12.12.12@o2ib
509 - nid: 12.12.12.12@o2ib
510 - nid: 13.13.13.13@o2ib
511 - nid: 14.13.13.13@o2ib
512 - nid: 14.15.13.13@o2ib
514 - nid: 15.17.1.10@tcp
515 - nid: 15.17.1.20@tcp
518 do_lnetctl peer add --prim_nid 12.12.12.12@o2ib \
519 --nid [13-14/1].[13-15/2].13.13@o2ib,[15-16/3].[17-19/4].[1].[5-20/5]@tcp ||
520 error "Peer add failed $?"
521 compare_peer_del "12.12.12.12@o2ib" "13.15.13.13@o2ib,15.17.1.15@tcp"
523 run_test 12 "Delete a secondary nid from peer (tcp and o2ib)"
526 reinit_dlc || return $?
528 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
530 - primary nid: 13.13.13.13@o2ib
533 - nid: 13.13.13.13@o2ib
536 do_lnetctl peer add --prim_nid 13.13.13.13@o2ib \
537 --nid [14-15].[1-2/1].[1].[100-254/10]@tcp,14.14.[254].14@o2ib ||
538 error "Peer add failed $?"
539 compare_peer_del "13.13.13.13@o2ib" \
540 "[14-15].[1-2/1].[1].[100-254/10]@tcp,14.14.[254].14@o2ib"
542 run_test 13 "Delete all secondary nids from peer (tcp and o2ib)"
548 if [[ $net =~ gni* ]]; then
551 echo "${num}.${num}.${num}.${num}@${net}"
555 create_mr_peer_yaml() {
557 local secondary_nids="$2"
560 echo "Generating peer yaml for $num_peers peers with $secondary_nids secondary nids"
561 echo "peer:" >> $TMP/sanity-lnet-$testnum-expected.yaml
563 local total_nids=$((num_peers + $((num_peers * secondary_nids))))
566 while [[ $created -lt $num_peers ]]; do
567 local primary=$(create_nid ${nidnum} ${net})
568 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
569 - primary nid: $primary
575 local start=$((nidnum + 1))
576 local end=$((nidnum + $secondary_nids))
577 for j in $(seq ${start} ${end}); do
578 local nid=$(create_nid $j ${net})
579 echo " - nid: $nid" >> $TMP/sanity-lnet-$testnum-expected.yaml
587 reinit_dlc || return $?
589 echo "Create single peer, single nid, using import"
590 create_mr_peer_yaml 1 0 tcp
591 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
592 error "Import failed $?"
594 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
597 echo "Delete single peer using import --del"
598 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
599 error "Import failed $?"
600 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
601 create_base_yaml_file
602 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
605 run_test 14 "import peer create/delete with single nid"
608 reinit_dlc || return $?
610 echo "Create multiple peers, single nid per peer, using import"
611 create_mr_peer_yaml 5 0 o2ib
612 # The ordering of nids for this use-case is non-deterministic, so we
613 # we can't just diff the expected/actual output.
614 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
615 error "Import failed $?"
616 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
617 validate_peer_nids 5 0
619 echo "Delete multiple peers, single nid per peer, using import --del"
620 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
621 error "Import failed $?"
622 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
623 create_base_yaml_file
624 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
627 run_test 15 "import multi peer create/delete with single nid per peer"
630 reinit_dlc || return $?
632 echo "Create single peer, multiple nids, using import"
633 create_mr_peer_yaml 1 5 tcp
634 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
635 error "Import failed $?"
636 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
637 validate_peer_nids 1 5
639 echo "Delete single peer, multiple nids, using import --del"
640 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
641 error "Import failed $?"
642 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
643 create_base_yaml_file
644 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
647 run_test 16 "import peer create/delete with multiple nids"
650 reinit_dlc || return $?
652 echo "Create multiple peers, multiple nids per peer, using import"
653 create_mr_peer_yaml 5 7 o2ib
654 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
655 error "Import failed $?"
656 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
657 validate_peer_nids 5 7
659 echo "Delete multiple peers, multiple nids per peer, using import --del"
660 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
661 error "Import failed $?"
662 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
663 create_base_yaml_file
664 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
667 run_test 17 "import multi peer create/delete with multiple nids"
670 reinit_dlc || return $?
672 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
674 - primary nid: 1.1.1.1@tcp
683 echo "Import peer with 5 nids"
684 cat $TMP/sanity-lnet-$testnum-expected.yaml
685 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
686 error "Import failed $?"
687 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
689 - primary nid: 1.1.1.1@tcp
696 echo "Delete three of the nids"
697 cat $TMP/sanity-lnet-$testnum-expected.yaml
698 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml
699 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
701 - primary nid: 1.1.1.1@tcp
707 echo "Check peer has expected nids remaining"
708 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
712 run_test 18a "Delete a subset of nids from a single peer using import --del"
715 reinit_dlc || return $?
717 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
719 - primary nid: 1.1.1.1@tcp
727 - primary nid: 6.6.6.6@o2ib
736 echo "Import two peers with 5 nids each"
737 cat $TMP/sanity-lnet-$testnum-expected.yaml
738 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
739 error "Import failed $?"
740 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
742 - primary nid: 1.1.1.1@tcp
748 - primary nid: 6.6.6.6@o2ib
755 echo "Delete three of the nids from each peer"
756 cat $TMP/sanity-lnet-$testnum-expected.yaml
757 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml
758 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
760 - primary nid: 6.6.6.6@o2ib
765 - primary nid: 1.1.1.1@tcp
772 echo "Check peers have expected nids remaining"
773 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
775 validate_peer_nids 2 1
777 run_test 18b "Delete multiple nids from multiple peers using import --del"
780 reinit_dlc || return $?
781 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
783 - primary nid: 19@gni
789 compare_peer_add "19@gni"
791 run_test 19 "Add peer with single nid (gni)"
794 reinit_dlc || return $?
795 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
797 - primary nid: 20@gni
801 - nid: 20.20.20.20@tcp
802 - nid: 20.20.20.20@o2ib
805 compare_peer_add "20@gni" "20.20.20.20@tcp,20.20.20.20@o2ib"
807 run_test 20 "Add peer with gni primary and tcp, o2ib secondary"
810 reinit_dlc || return $?
811 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
813 - primary nid: 21@gni
823 echo"Add peer with nidrange (gni)"
824 compare_peer_add "21@gni" "[22-25]@gni" || error
825 echo "Add peer with nidrange that overlaps primary nid (gni)"
826 compare_peer_add "21@gni" "[21-25]@gni"
828 run_test 21 "Add peer with nidrange (gni)"
831 reinit_dlc || return $?
832 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
834 - primary nid: 22@gni
845 do_lnetctl peer add --prim_nid 22@gni --nid [24-29]@gni ||
846 error "Peer add failed $?"
847 compare_peer_del "22@gni" "26@gni"
849 run_test 22 "Delete single secondary nid from peer (gni)"
852 reinit_dlc || return $?
853 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
855 - primary nid: 23@gni
862 do_lnetctl peer add --prim_nid 23@gni --nid [25-29]@gni ||
863 error "Peer add failed $?"
864 compare_peer_del "23@gni" "[25-29]@gni"
866 run_test 23 "Delete all secondary nids from peer (gni)"
869 reinit_dlc || return $?
870 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
872 - primary nid: 24@gni
877 - nid: 13.13.13.13@o2ib
878 - nid: 14.13.13.13@o2ib
879 - nid: 14.15.13.13@o2ib
881 - nid: 15.17.1.10@tcp
882 - nid: 15.17.1.20@tcp
885 do_lnetctl peer add --prim_nid 24@gni \
886 --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 ||
887 error "Peer add failed $?"
888 compare_peer_del "24@gni" "5@gni,13.15.13.13@o2ib,15.17.1.15@tcp"
890 run_test 24 "Delete a secondary nid from peer (tcp, o2ib and gni)"
893 reinit_dlc || return $?
894 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
896 - primary nid: 25@gni
902 do_lnetctl peer add --prim_nid 25@gni \
903 --nid [26-27].[4-10/3].26.26@tcp,26.26.26.26@o2ib,[30-35]@gni ||
904 error "Peer add failed $?"
905 compare_peer_del "25@gni" \
906 "[26-27].[4-10/3].26.26@tcp,26.26.26.26@o2ib,[30-35]@gni"
908 run_test 25 "Delete all secondary nids from peer (tcp, gni and o2ib)"
911 reinit_dlc || return $?
913 echo "Invalid prim_nid - peer add"
914 do_lnetctl peer add --prim_nid foobar &&
915 error "Command should have failed"
917 echo "Invalid prim_nid - peer del"
918 do_lnetctl peer del --prim_nid foobar &&
919 error "Command should have failed"
921 echo "Delete non-existing peer"
922 do_lnetctl peer del --prim_nid 1.1.1.1@o2ib &&
923 error "Command should have failed"
925 echo "Don't provide mandatory arguments peer del"
926 do_lnetctl peer del --nid 1.1.1.1@tcp &&
927 error "Command should have failed"
929 echo "Don't provide mandatory arguments peer add"
930 do_lnetctl peer add &&
931 error "Command should have failed"
933 echo "Invalid secondary nids"
934 do_lnetctl peer add --prim_nid 1.1.1.1@tcp --nid foobar &&
935 error "Command should have failed"
937 echo "Exceed max nids per peer"
938 do_lnetctl peer add --prim_nid 1.1.1.1@tcp --nid 1.1.1.[2-255]@tcp &&
939 error "Command should have failed"
941 echo "Invalid net type"
942 do_lnetctl peer add --prim_nid 1@foo &&
943 error "Command should have failed"
945 echo "Invalid nid format"
946 local invalid_nids="1@tcp 1@o2ib 1.1.1.1@gni"
949 for nid in ${invalid_nids}; do
950 echo "Check invalid primary nid - '$nid'"
951 do_lnetctl peer add --prim_nid $nid &&
952 error "Command should have failed"
955 local invalid_strs="[2-1]@gni [a-f/x]@gni 256.256.256.256@tcp"
956 invalid_strs+=" 1.1.1.1.[2-5/f]@tcp 1.]2[.3.4@o2ib"
957 invalid_strs+="1.[2-4,[5-6],7-8].1.1@tcp foobar"
960 for nidstr in ${invalid_strs}; do
961 echo "Check invalid nidstring - '$nidstr'"
962 do_lnetctl peer add --nid $nidstr &&
963 error "Command should have failed"
966 echo "Add non-local gateway"
967 do_lnetctl route add --net tcp --gateway 1@gni &&
968 error "Command should have failed"
972 run_test 99a "Check various invalid inputs to lnetctl peer"
975 reinit_dlc || return $?
977 create_base_yaml_file
979 cat <<EOF > $TMP/sanity-lnet-$testnum-invalid.yaml
981 - primary nid: 99.99.99.99@tcp
984 - nid: 99.99.99.99@tcp
986 do_lnetctl import < $TMP/sanity-lnet-$testnum-invalid.yaml &&
987 error "import should have failed"
988 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
991 run_test 99b "Invalid value for Multi-Rail in yaml import"
995 local ip=$(ip addr show dev $if | awk '/ inet /{print $2}')
1003 reinit_dlc || return $?
1004 load_module ../lnet/klnds/socklnd/ksocklnd ||
1005 error "Can't load ksocklnd.ko"
1006 do_lnetctl net add --net ${net} --if ${if} ||
1007 error "Failed to add net ${net} on if ${if}"
1010 compare_route_add() {
1014 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
1016 do_lnetctl route add --net ${rnet} --gateway ${gw} ||
1017 error "route add failed $?"
1018 # CPT configuration is pruned from the exported yaml, since the default
1019 # can vary across test systems (unlike default values for things like
1020 # peer_credits, peer_timeout, etc.)
1021 $LNETCTL export --backup | grep -v CPT > $actual ||
1022 error "export failed $?"
1023 validate_gateway_nids
1028 have_interface "eth0" || skip "Need eth0 interface with ipv4 configured"
1029 add_net "tcp" "eth0"
1030 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
1039 peer_buffer_credits: 0
1043 gateway: 7.7.7.7@tcp
1046 health_sensitivity: 1
1048 - primary nid: 7.7.7.7@tcp
1054 compare_route_add "tcp7" "7.7.7.7@tcp" || return $?
1057 run_test 100 "Add route with single gw (tcp)"
1060 have_interface "eth0" || skip "Need eth0 interface with ipv4 configured"
1061 add_net "tcp" "eth0"
1062 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
1071 peer_buffer_credits: 0
1075 gateway: 8.8.8.10@tcp
1078 health_sensitivity: 1
1080 gateway: 8.8.8.9@tcp
1083 health_sensitivity: 1
1085 gateway: 8.8.8.8@tcp
1088 health_sensitivity: 1
1090 - primary nid: 8.8.8.9@tcp
1094 - primary nid: 8.8.8.10@tcp
1098 - primary nid: 8.8.8.8@tcp
1104 compare_route_add "tcp8" "8.8.8.[8-10]@tcp"
1106 run_test 101 "Add route with multiple gw (tcp)"
1108 compare_route_del() {
1112 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
1114 do_lnetctl route del --net ${rnet} --gateway ${gw} ||
1115 error "route del failed $?"
1116 $LNETCTL export --backup > $actual ||
1117 error "export failed $?"
1118 validate_gateway_nids
1122 have_interface "eth0" || skip "Need eth0 interface with ipv4 configured"
1123 add_net "tcp" "eth0"
1124 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
1125 do_lnetctl route add --net tcp102 --gateway 102.102.102.102@tcp ||
1126 error "route add failed $?"
1127 compare_route_del "tcp102" "102.102.102.102@tcp"
1129 run_test 102 "Delete route with single gw (tcp)"
1132 have_interface "eth0" || skip "Need eth0 interface with ipv4 configured"
1133 add_net "tcp" "eth0"
1134 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
1135 do_lnetctl route add --net tcp103 \
1136 --gateway 103.103.103.[103-120/4]@tcp ||
1137 error "route add failed $?"
1138 compare_route_del "tcp103" "103.103.103.[103-120/4]@tcp"
1140 run_test 103 "Delete route with multiple gw (tcp)"
1142 ### load lnet in default namespace, configure in target namespace
1145 cleanup_lnet || exit 1
1146 load_lnet "networks=\"\""
1147 do_ns $LNETCTL lnet configure --all || exit 1
1148 $LNETCTL net show --net tcp | grep -q "nid: ${FAKE_IP}@tcp$"
1150 run_test 200 "load lnet w/o module option, configure in a non-default namespace"
1153 cleanup_lnet || exit 1
1154 load_lnet "networks=tcp($FAKE_IF)"
1155 do_ns $LNETCTL lnet configure --all || exit 1
1156 $LNETCTL net show --net tcp | grep -q "nid: ${FAKE_IP}@tcp$"
1158 run_test 201 "load lnet using networks module options in a non-default namespace"
1161 cleanup_lnet || exit 1
1162 load_lnet "networks=\"\" ip2nets=\"tcp0($FAKE_IF) ${FAKE_IP}\""
1163 do_ns $LNETCTL lnet configure --all || exit 1
1164 $LNETCTL net show | grep -q "nid: ${FAKE_IP}@tcp$"
1166 run_test 202 "load lnet using ip2nets in a non-default namespace"
1169 ### Add the interfaces in the target namespace
1172 cleanup_lnet || exit 1
1174 do_lnetctl lnet configure || exit 1
1175 do_ns $LNETCTL net add --net tcp0 --if $FAKE_IF
1177 run_test 203 "add a network using an interface in the non-default namespace"