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
358 compare_peer_add "6.6.6.6@tcp" \
359 "6.6.[6-7].[0-4/2]@tcp,6.6.[1-4/2].[0-6/3]@o2ib"
361 run_test 6 "Add peer with multiple nidranges"
364 local prim_nid="${1:+--prim_nid $1}"
365 local nid="${2:+--nid $2}"
367 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
369 do_lnetctl peer del ${prim_nid} ${nid} || error "peer del failed $?"
370 $LNETCTL export --backup > $actual || error "export failed $?"
376 reinit_dlc || return $?
377 create_base_yaml_file
379 echo "Delete peer with single nid (tcp)"
380 do_lnetctl peer add --prim_nid 7.7.7.7@tcp || error "Peer add failed $?"
381 compare_peer_del "7.7.7.7@tcp"
383 echo "Delete peer with single nid (o2ib)"
384 do_lnetctl peer add --prim_nid 7.7.7.7@o2ib || error "Peer add failed $?"
385 compare_peer_del "7.7.7.7@o2ib"
387 echo "Delete peer that has multiple nids (tcp)"
388 do_lnetctl peer add --prim_nid 7.7.7.7@tcp --nid 7.7.7.[8-12]@tcp ||
389 error "Peer add failed $?"
390 compare_peer_del "7.7.7.7@tcp"
392 echo "Delete peer that has multiple nids (o2ib)"
393 do_lnetctl peer add --prim_nid 7.7.7.7@o2ib --nid 7.7.7.[8-12]@o2ib ||
394 error "Peer add failed $?"
395 compare_peer_del "7.7.7.7@o2ib"
397 echo "Delete peer that has both tcp and o2ib nids"
398 do_lnetctl peer add --prim_nid 7.7.7.7@tcp \
399 --nid 7.7.7.[9-12]@tcp,7.7.7.[13-15]@o2ib ||
400 error "Peer add failed $?"
401 compare_peer_del "7.7.7.7@tcp"
403 run_test 7 "Various peer delete tests"
406 reinit_dlc || return $?
408 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
410 - primary nid: 8.8.8.8@tcp
422 do_lnetctl peer add --prim_nid 8.8.8.8@tcp --nid 8.8.8.[10-15]@tcp ||
423 error "Peer add failed $?"
424 compare_peer_del "8.8.8.8@tcp" "8.8.8.13@tcp"
426 run_test 8 "Delete single secondary nid from peer (tcp)"
429 reinit_dlc || return $?
431 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
433 - primary nid: 9.9.9.9@tcp
440 do_lnetctl peer add --prim_nid 9.9.9.9@tcp \
441 --nid 9.9.9.[11-16]@tcp || error "Peer add failed $?"
442 compare_peer_del "9.9.9.9@tcp" "9.9.9.[11-16]@tcp"
444 run_test 9 "Delete all secondary nids from peer (tcp)"
447 reinit_dlc || return $?
449 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
451 - primary nid: 10.10.10.10@tcp
454 - nid: 10.10.10.10@tcp
455 - nid: 10.10.10.12@tcp
456 - nid: 10.10.10.13@tcp
457 - nid: 10.10.10.15@tcp
458 - nid: 10.10.10.16@tcp
461 do_lnetctl peer add --prim_nid 10.10.10.10@tcp \
462 --nid 10.10.10.[12-16]@tcp || error "Peer add failed $?"
463 compare_peer_del "10.10.10.10@tcp" "10.10.10.14@tcp"
465 run_test 10 "Delete single secondary nid from peer (o2ib)"
468 reinit_dlc || return $?
470 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
472 - primary nid: 11.11.11.11@tcp
475 - nid: 11.11.11.11@tcp
478 do_lnetctl peer add --prim_nid 11.11.11.11@tcp \
479 --nid 11.11.11.[13-17]@tcp || error "Peer add failed $?"
480 compare_peer_del "11.11.11.11@tcp" "11.11.11.[13-17]@tcp"
482 run_test 11 "Delete all secondary nids from peer (o2ib)"
485 reinit_dlc || return $?
487 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
489 - primary nid: 12.12.12.12@o2ib
492 - nid: 12.12.12.12@o2ib
493 - nid: 13.13.13.13@o2ib
494 - nid: 14.13.13.13@o2ib
495 - nid: 14.15.13.13@o2ib
497 - nid: 15.17.1.10@tcp
498 - nid: 15.17.1.20@tcp
501 do_lnetctl peer add --prim_nid 12.12.12.12@o2ib \
502 --nid [13-14/1].[13-15/2].13.13@o2ib,[15-16/3].[17-19/4].[1].[5-20/5]@tcp ||
503 error "Peer add failed $?"
504 compare_peer_del "12.12.12.12@o2ib" "13.15.13.13@o2ib,15.17.1.15@tcp"
506 run_test 12 "Delete a secondary nid from peer (tcp and o2ib)"
509 reinit_dlc || return $?
511 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
513 - primary nid: 13.13.13.13@o2ib
516 - nid: 13.13.13.13@o2ib
519 do_lnetctl peer add --prim_nid 13.13.13.13@o2ib \
520 --nid [14-15].[1-2/1].[1].[100-254/10]@tcp,14.14.[254].14@o2ib ||
521 error "Peer add failed $?"
522 compare_peer_del "13.13.13.13@o2ib" \
523 "[14-15].[1-2/1].[1].[100-254/10]@tcp,14.14.[254].14@o2ib"
525 run_test 13 "Delete all secondary nids from peer (tcp and o2ib)"
531 if [[ $net =~ gni* ]]; then
534 echo "${num}.${num}.${num}.${num}@${net}"
538 create_mr_peer_yaml() {
540 local secondary_nids="$2"
543 echo "Generating peer yaml for $num_peers peers with $secondary_nids secondary nids"
544 echo "peer:" >> $TMP/sanity-lnet-$testnum-expected.yaml
546 local total_nids=$((num_peers + $((num_peers * secondary_nids))))
549 while [[ $created -lt $num_peers ]]; do
550 local primary=$(create_nid ${nidnum} ${net})
551 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
552 - primary nid: $primary
558 local start=$((nidnum + 1))
559 local end=$((nidnum + $secondary_nids))
560 for j in $(seq ${start} ${end}); do
561 local nid=$(create_nid $j ${net})
562 echo " - nid: $nid" >> $TMP/sanity-lnet-$testnum-expected.yaml
570 reinit_dlc || return $?
572 echo "Create single peer, single nid, using import"
573 create_mr_peer_yaml 1 0 tcp
574 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
575 error "Import failed $?"
577 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
580 echo "Delete single peer using import --del"
581 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
582 error "Import failed $?"
583 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
584 create_base_yaml_file
585 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
588 run_test 14 "import peer create/delete with single nid"
591 reinit_dlc || return $?
593 echo "Create multiple peers, single nid per peer, using import"
594 create_mr_peer_yaml 5 0 o2ib
595 # The ordering of nids for this use-case is non-deterministic, so we
596 # we can't just diff the expected/actual output.
597 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
598 error "Import failed $?"
599 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
600 validate_peer_nids 5 0
602 echo "Delete multiple peers, single nid per peer, using import --del"
603 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
604 error "Import failed $?"
605 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
606 create_base_yaml_file
607 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
610 run_test 15 "import multi peer create/delete with single nid per peer"
613 reinit_dlc || return $?
615 echo "Create single peer, multiple nids, using import"
616 create_mr_peer_yaml 1 5 tcp
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 1 5
622 echo "Delete single peer, multiple nids, 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 16 "import peer create/delete with multiple nids"
633 reinit_dlc || return $?
635 echo "Create multiple peers, multiple nids per peer, using import"
636 create_mr_peer_yaml 5 7 o2ib
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 5 7
642 echo "Delete multiple peers, multiple nids per peer, 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 17 "import multi peer create/delete with multiple nids"
653 reinit_dlc || return $?
655 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
657 - primary nid: 1.1.1.1@tcp
665 echo "Import peer with 4 nids"
666 cat $TMP/sanity-lnet-$testnum-expected.yaml
667 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
668 error "Import failed $?"
669 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
671 - primary nid: 1.1.1.1@tcp
677 echo "Delete two of the nids"
678 cat $TMP/sanity-lnet-$testnum-expected.yaml
679 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml
680 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
682 - primary nid: 1.1.1.1@tcp
688 echo "Check peer has expected nids remaining"
689 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
693 run_test 18a "Delete a subset of nids from a single peer using import --del"
696 reinit_dlc || return $?
698 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
700 - primary nid: 1.1.1.1@tcp
707 - primary nid: 5.5.5.5@o2ib
715 echo "Import two peers with 4 nids each"
716 cat $TMP/sanity-lnet-$testnum-expected.yaml
717 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
718 error "Import failed $?"
719 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
721 - primary nid: 1.1.1.1@tcp
726 - primary nid: 5.5.5.5@o2ib
732 echo "Delete two of the nids from each peer"
733 cat $TMP/sanity-lnet-$testnum-expected.yaml
734 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml
735 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
737 - primary nid: 5.5.5.5@o2ib
742 - primary nid: 1.1.1.1@tcp
749 echo "Check peers have expected nids remaining"
750 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
752 validate_peer_nids 2 1
754 run_test 18b "Delete multiple nids from multiple peers using import --del"
757 reinit_dlc || return $?
758 echo "Invalid prim_nid: should fail"
759 do_lnetctl peer add --prim_nid foobar &&
760 error "Command should have failed"
762 do_lnetctl peer del --prim_nid foobar &&
763 error "Command should have failed"
765 echo "Delete non-existing peer: should fail"
766 do_lnetctl peer del --prim_nid 1.1.1.1@o2ib &&
767 error "Command should have failed"
769 echo "Don't provide mandatory arguments: should fail"
770 do_lnetctl peer del --nid 1.1.1.1@tcp &&
771 error "Command should have failed"
772 do_lnetctl peer add &&
773 error "Command should have failed"
774 # This currently causes a segfault. Uncomment when fixed.
775 #echo "Invalid secondary nids: should fail"
776 #do_lnetctl peer add --prim_nid 1.1.1.1@tcp --nid foobar && error "Command should have failed"
778 # This shouldn't work, but currently does. Uncomment when fixed.
779 #echo "Exceed max nids per peer"
780 #do_lnetctl peer add --prim_nid 1.1.1.1@tcp --nid 1.1.1.[2-255]@tcp && error "Command should have failed"
783 run_test 99a "Check various invalid inputs to lnetctl peer add"
786 reinit_dlc || return $?
788 create_base_yaml_file
790 cat <<EOF > $TMP/sanity-lnet-$testnum-invalid.yaml
792 - primary nid: 99.99.99.99@tcp
795 - nid: 99.99.99.99@tcp
797 do_lnetctl import < $TMP/sanity-lnet-$testnum-invalid.yaml &&
798 error "import should have failed"
799 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
802 run_test 99b "Invalid value for Multi-Rail in yaml import"
806 local ip=$(ip addr show dev $if | awk '/ inet /{print $2}')
814 reinit_dlc || return $?
815 load_module ../lnet/klnds/socklnd/ksocklnd ||
816 error "Can't load ksocklnd.ko"
817 do_lnetctl net add --net ${net} --if ${if} ||
818 error "Failed to add net ${net} on if ${if}"
821 compare_route_add() {
825 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
827 do_lnetctl route add --net ${rnet} --gateway ${gw} ||
828 error "route add failed $?"
829 # CPT configuration is pruned from the exported yaml, since the default
830 # can vary across test systems (unlike default values for things like
831 # peer_credits, peer_timeout, etc.)
832 $LNETCTL export --backup | grep -v CPT > $actual ||
833 error "export failed $?"
834 validate_gateway_nids
839 have_interface "eth0" || skip "Need eth0 interface with ipv4 configured"
841 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
850 peer_buffer_credits: 0
857 health_sensitivity: 1
859 - primary nid: 7.7.7.7@tcp
865 compare_route_add "tcp7" "7.7.7.7@tcp" || return $?
868 run_test 100 "Add route with single gw (tcp)"
871 have_interface "eth0" || skip "Need eth0 interface with ipv4 configured"
873 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
882 peer_buffer_credits: 0
886 gateway: 8.8.8.10@tcp
889 health_sensitivity: 1
894 health_sensitivity: 1
899 health_sensitivity: 1
901 - primary nid: 8.8.8.9@tcp
905 - primary nid: 8.8.8.10@tcp
909 - primary nid: 8.8.8.8@tcp
915 compare_route_add "tcp8" "8.8.8.[8-10]@tcp"
917 run_test 101 "Add route with multiple gw (tcp)"
919 compare_route_del() {
923 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
925 do_lnetctl route del --net ${rnet} --gateway ${gw} ||
926 error "route del failed $?"
927 $LNETCTL export --backup > $actual ||
928 error "export failed $?"
929 validate_gateway_nids
933 have_interface "eth0" || skip "Need eth0 interface with ipv4 configured"
935 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
936 do_lnetctl route add --net tcp102 --gateway 102.102.102.102@tcp ||
937 error "route add failed $?"
938 compare_route_del "tcp102" "102.102.102.102@tcp"
940 run_test 102 "Delete route with single gw (tcp)"
943 have_interface "eth0" || skip "Need eth0 interface with ipv4 configured"
945 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
946 do_lnetctl route add --net tcp103 \
947 --gateway 103.103.103.[103-120/4]@tcp ||
948 error "route add failed $?"
949 compare_route_del "tcp103" "103.103.103.[103-120/4]@tcp"
951 run_test 103 "Delete route with multiple gw (tcp)"
953 ### load lnet in default namespace, configure in target namespace
956 cleanup_lnet || exit 1
957 load_lnet "networks=\"\""
958 do_ns $LNETCTL lnet configure --all || exit 1
959 $LNETCTL net show --net tcp | grep -q "nid: ${FAKE_IP}@tcp$"
961 run_test 200 "load lnet w/o module option, configure in a non-default namespace"
964 cleanup_lnet || exit 1
965 load_lnet "networks=tcp($FAKE_IF)"
966 do_ns $LNETCTL lnet configure --all || exit 1
967 $LNETCTL net show --net tcp | grep -q "nid: ${FAKE_IP}@tcp$"
969 run_test 201 "load lnet using networks module options in a non-default namespace"
972 cleanup_lnet || exit 1
973 load_lnet "networks=\"\" ip2nets=\"tcp0($FAKE_IF) ${FAKE_IP}\""
974 do_ns $LNETCTL lnet configure --all || exit 1
975 $LNETCTL net show | grep -q "nid: ${FAKE_IP}@tcp$"
977 run_test 202 "load lnet using ip2nets in a non-default namespace"
980 ### Add the interfaces in the target namespace
983 cleanup_lnet || exit 1
985 do_lnetctl lnet configure || exit 1
986 do_ns $LNETCTL net add --net tcp0 --if $FAKE_IF
988 run_test 203 "add a network using an interface in the non-default namespace"