Whamcloud - gitweb
9aaed97196d55cf76834c2153bc9af4ecd3a9fd1
[fs/lustre-release.git] / lustre / tests / sanity-lnet.sh
1 #!/bin/bash
2 #
3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
5 #
6
7 set -e
8
9 ONLY=${ONLY:-"$*"}
10
11 # bug number for skipped test:
12 ALWAYS_EXCEPT="$SANITY_LNET_EXCEPT "
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
14
15 [ "$SLOW" = "no" ] && EXCEPT_SLOW=""
16
17 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
18
19 . $LUSTRE/tests/test-framework.sh
20 CLEANUP=${CLEANUP:-:}
21 SETUP=${SETUP:-:}
22 init_test_env "$@"
23 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
24 init_logging
25
26 build_test_filter
27
28 [[ -z $LNETCTL ]] && skip "Need lnetctl"
29
30 restore_mounts=false
31
32 if is_mounted $MOUNT || is_mounted $MOUNT2; then
33         cleanupall || error "Failed cleanup prior to test execution"
34         restore_mounts=true
35 fi
36
37 cleanup_lnet() {
38         echo "Cleaning up LNet"
39         lsmod | grep -q lnet &&
40                 $LNETCTL lnet unconfigure 2>/dev/null
41         unload_modules
42 }
43
44 restore_modules=false
45 if module_loaded lnet ; then
46         cleanup_lnet || error "Failed to unload modules before test execution"
47         restore_modules=true
48 fi
49
50 cleanup_testsuite() {
51         trap "" EXIT
52         # Cleanup any tmp files created by the sub tests
53         rm -f $TMP/sanity-lnet-*.yaml $LNET_PARAMS_FILE
54         cleanup_netns
55         cleanup_lnet
56         if $restore_mounts; then
57                 setupall || error "Failed to setup Lustre after test execution"
58         elif $restore_modules; then
59                 load_modules ||
60                         error "Couldn't load modules after test execution"
61         fi
62         return 0
63 }
64
65 TESTNS='test_ns'
66 FAKE_IF="test1pg"
67 FAKE_IP="10.1.2.3"
68 do_ns() {
69         echo "ip netns exec $TESTNS $*"
70         ip netns exec $TESTNS "$@"
71 }
72
73 setup_fakeif() {
74         local netns="$1"
75
76         local netns_arg=""
77         [[ -n $netns ]] &&
78                 netns_arg="netns $netns"
79
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
85         else
86                 ip addr add "${FAKE_IP}/31" dev $FAKE_IF
87                 ip link set $FAKE_IF up
88         fi
89 }
90
91 cleanup_fakeif() {
92         ip link show test1pl >& /dev/null && ip link del test1pl || return 0
93 }
94
95 setup_netns() {
96         cleanup_netns
97
98         ip netns add $TESTNS
99         setup_fakeif $TESTNS
100 }
101
102 cleanup_netns() {
103         (ip netns list | grep -q $TESTNS) && ip netns del $TESTNS
104         cleanup_fakeif
105 }
106
107 configure_dlc() {
108         echo "Loading LNet and configuring DLC"
109         load_lnet || return $?
110         do_lnetctl lnet configure
111 }
112
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 $?"
117 }
118
119 reinit_dlc() {
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 $?"
125         else
126                 configure_dlc || error "configure_dlc failed $?"
127         fi
128         define_global_yaml
129 }
130
131 append_global_yaml() {
132         [[ ! -e ${GLOBAL_YAML_FILE} ]] &&
133                 error "Missing global yaml at ${GLOBAL_YAML_FILE}"
134
135         cat ${GLOBAL_YAML_FILE} >> $TMP/sanity-lnet-$testnum-expected.yaml
136 }
137
138 create_base_yaml_file() {
139         append_global_yaml
140 }
141
142 compare_yaml_files() {
143         local expected="$TMP/sanity-lnet-$testnum-expected.yaml"
144         local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
145         local rc=0
146         ! [[ -e $expected ]] && echo "$expected not found" && return 1
147         ! [[ -e $actual ]] && echo "$actual not found" && return 1
148         if [ verify_yaml_available ]; then
149                 verify_compare_yaml $actual $expected || rc=$?
150         else
151                 diff -upN ${actual} ${expected} || rc=$?
152         fi
153         echo "Expected:"
154         cat $expected
155         echo "Actual:"
156         cat $actual
157         return $rc
158 }
159
160 validate_nid() {
161         local nid="$1"
162         local net="${nid//*@/}"
163         local addr="${nid//@*/}"
164
165         local num_re='[0-9]+'
166         local ip_re="[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"
167
168         if [[ $net =~ (gni|kfi)[0-9]* ]]; then
169                 [[ $addr =~ ${num_re} ]] && return 0
170         else
171                 [[ $addr =~ ${ip_re} ]] && return 0
172         fi
173 }
174
175 validate_nids() {
176         local yfile=$TMP/sanity-lnet-$testnum-actual.yaml
177         local primary_nids=$(awk '/- primary nid:/{print $NF}' $yfile | xargs echo)
178         local secondary_nids=$(awk '/- nid:/{print $NF}' $yfile | xargs echo)
179         local gateway_nids=$(awk '/gateway:/{print $NF}' $yfile | xargs echo)
180
181         local nid
182         for nid in $primary_nids $secondary_nids; do
183                 validate_nid "$nid" || error "Bad NID \"${nid}\""
184         done
185         return 0
186 }
187
188 validate_peer_nids() {
189         local num_peers="$1"
190         local nids_per_peer="$2"
191
192         local expect_p="$num_peers"
193         # The primary nid also shows up in the list of secondary nids
194         local expect_s="$(($num_peers + $(($nids_per_peer*$num_peers))))"
195
196         local actual_p=$(grep -c -- '- primary nid:' $TMP/sanity-lnet-$testnum-actual.yaml)
197         local actual_s=$(grep -c -- '- nid:' $TMP/sanity-lnet-$testnum-actual.yaml)
198         if [[ $expect_p -ne $actual_p ]]; then
199                 compare_yaml_files
200                 error "Expected $expect_p but found $actual_p primary nids"
201         elif [[ $expect_s -ne $actual_s ]]; then
202                 compare_yaml_files
203                 error "Expected $expect_s but found $actual_s secondary nids"
204         fi
205         validate_nids
206 }
207
208 validate_gateway_nids() {
209         local expect_gw=$(grep -c -- 'gateway:' $TMP/sanity-lnet-$testnum-expected.yaml)
210         local actual_gw=$(grep -c -- 'gateway:' $TMP/sanity-lnet-$testnum-actual.yaml)
211         if [[ $expect_gw -ne $actual_gw ]]; then
212                 compare_yaml_files
213                 error "Expected $expect_gw gateways but found $actual_gw gateways"
214         fi
215
216         local expect_gwnids=$(awk '/gateway:/{print $NF}' $TMP/sanity-lnet-$testnum-expected.yaml |
217                               xargs echo)
218         local nid
219         for nid in ${expect_gwnids}; do
220                 if ! grep -q "gateway: ${nid}" $TMP/sanity-lnet-$testnum-actual.yaml; then
221                         error "${nid} not configured as gateway"
222                 fi
223         done
224
225         validate_nids
226 }
227
228 cleanupall -f
229 setup_netns || error "setup_netns failed with $?"
230
231 # Determine the local interface(s) used for LNet
232 load_lnet "config_on_load=1" || error "Failed to load modules"
233
234 do_lnetctl net show
235 ip a
236
237 INTERFACES=( $(lnet_if_list) )
238
239 cleanup_lnet || error "Failed to cleanup LNet"
240
241 stack_trap 'cleanup_testsuite' EXIT
242
243 test_0() {
244         configure_dlc || error "Failed to configure DLC rc = $?"
245         define_global_yaml
246         reinit_dlc || return $?
247         do_lnetctl import <  ${GLOBAL_YAML_FILE} || error "Import failed $?"
248         $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
249         create_base_yaml_file
250         compare_yaml_files || error "Configuration changed after import"
251 }
252 run_test 0 "Export empty config, import the config, compare"
253
254 compare_peer_add() {
255         local prim_nid="${1:+--prim_nid $1}"
256         local nid="${2:+--nid $2}"
257
258         local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
259
260         do_lnetctl peer add ${prim_nid} ${nid} || error "peer add failed $?"
261         $LNETCTL export --backup > $actual || error "export failed $?"
262         compare_yaml_files
263         return $?
264 }
265
266 test_1() {
267         reinit_dlc || return $?
268         cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
269 peer:
270     - primary nid: 1.1.1.1@tcp
271       Multi-Rail: True
272       peer ni:
273         - nid: 1.1.1.1@tcp
274 EOF
275         append_global_yaml
276         compare_peer_add "1.1.1.1@tcp"
277 }
278 run_test 1 "Add peer with single nid (tcp)"
279
280 test_2() {
281         reinit_dlc || return $?
282         cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
283 peer:
284     - primary nid: 2.2.2.2@o2ib
285       Multi-Rail: True
286       peer ni:
287         - nid: 2.2.2.2@o2ib
288 EOF
289         append_global_yaml
290         compare_peer_add "2.2.2.2@o2ib"
291 }
292 run_test 2 "Add peer with single nid (o2ib)"
293
294 test_3() {
295         reinit_dlc || return $?
296         cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
297 peer:
298     - primary nid: 3.3.3.3@tcp
299       Multi-Rail: True
300       peer ni:
301         - nid: 3.3.3.3@tcp
302         - nid: 3.3.3.3@o2ib
303 EOF
304         append_global_yaml
305         compare_peer_add "3.3.3.3@tcp" "3.3.3.3@o2ib"
306 }
307 run_test 3 "Add peer with tcp primary o2ib secondary"
308
309 test_4() {
310         reinit_dlc || return $?
311         cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
312 peer:
313     - primary nid: 4.4.4.4@tcp
314       Multi-Rail: True
315       peer ni:
316         - nid: 4.4.4.4@tcp
317         - nid: 4.4.4.1@tcp
318         - nid: 4.4.4.2@tcp
319         - nid: 4.4.4.3@tcp
320 EOF
321         append_global_yaml
322         echo "Add peer with nidrange (tcp)"
323         compare_peer_add "4.4.4.4@tcp" "4.4.4.[1-3]@tcp"
324
325         echo "Add peer with nidrange that overlaps primary nid (tcp)"
326         compare_peer_add "4.4.4.4@tcp" "4.4.4.[1-4]@tcp"
327 }
328 run_test 4 "Add peer with nidrange (tcp)"
329
330 test_5() {
331         reinit_dlc || return $?
332         cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
333 peer:
334     - primary nid: 5.5.5.5@o2ib
335       Multi-Rail: True
336       peer ni:
337         - nid: 5.5.5.5@o2ib
338         - nid: 5.5.5.1@o2ib
339         - nid: 5.5.5.2@o2ib
340         - nid: 5.5.5.3@o2ib
341         - nid: 5.5.5.4@o2ib
342 EOF
343         append_global_yaml
344         echo "Add peer with nidrange (o2ib)"
345         compare_peer_add "5.5.5.5@o2ib" "5.5.5.[1-4]@o2ib"
346
347         echo "Add peer with nidranage that overlaps primary nid (o2ib)"
348         compare_peer_add "5.5.5.5@o2ib" "5.5.5.[1-4]@o2ib"
349 }
350 run_test 5 "Add peer with nidrange (o2ib)"
351
352 test_6() {
353         reinit_dlc || return $?
354         cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
355 peer:
356     - primary nid: 6.6.6.6@tcp
357       Multi-Rail: True
358       peer ni:
359         - nid: 6.6.6.6@tcp
360         - nid: 6.6.6.0@tcp
361         - nid: 6.6.6.2@tcp
362         - nid: 6.6.6.4@tcp
363         - nid: 6.6.7.0@tcp
364         - nid: 6.6.7.2@tcp
365         - nid: 6.6.7.4@tcp
366         - nid: 6.6.1.0@o2ib
367         - nid: 6.6.1.3@o2ib
368         - nid: 6.6.1.6@o2ib
369         - nid: 6.6.3.0@o2ib
370         - nid: 6.6.3.3@o2ib
371         - nid: 6.6.3.6@o2ib
372         - nid: 6@gni
373         - nid: 10@gni
374         - nid: 6@kfi
375         - nid: 10@kfi
376 EOF
377         append_global_yaml
378
379         local nid_expr="6.6.[6-7].[0-4/2]@tcp"
380         nid_expr+=",6.6.[1-4/2].[0-6/3]@o2ib"
381         nid_expr+=",[6-12/4]@gni"
382         nid_expr+=",[6-12/4]@kfi"
383
384         compare_peer_add "6.6.6.6@tcp" "${nid_expr}"
385 }
386 run_test 6 "Add peer with multiple nidranges"
387
388 compare_peer_del() {
389         local prim_nid="${1:+--prim_nid $1}"
390         local nid="${2:+--nid $2}"
391
392         local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
393
394         do_lnetctl peer del ${prim_nid} ${nid} || error "peer del failed $?"
395         $LNETCTL export --backup > $actual || error "export failed $?"
396         compare_yaml_files
397         return $?
398 }
399
400 test_7() {
401         reinit_dlc || return $?
402         create_base_yaml_file
403
404         echo "Delete peer with single nid (tcp)"
405         do_lnetctl peer add --prim_nid 7.7.7.7@tcp || error "Peer add failed $?"
406         compare_peer_del "7.7.7.7@tcp"
407
408         echo "Delete peer with single nid (o2ib)"
409         do_lnetctl peer add --prim_nid 7.7.7.7@o2ib || error "Peer add failed $?"
410         compare_peer_del "7.7.7.7@o2ib"
411
412         echo "Delete peer that has multiple nids (tcp)"
413         do_lnetctl peer add --prim_nid 7.7.7.7@tcp --nid 7.7.7.[8-12]@tcp ||
414                 error "Peer add failed $?"
415         compare_peer_del "7.7.7.7@tcp"
416
417         echo "Delete peer that has multiple nids (o2ib)"
418         do_lnetctl peer add --prim_nid 7.7.7.7@o2ib --nid 7.7.7.[8-12]@o2ib ||
419                 error "Peer add failed $?"
420         compare_peer_del "7.7.7.7@o2ib"
421
422         echo "Delete peer that has both tcp and o2ib nids"
423         do_lnetctl peer add --prim_nid 7.7.7.7@tcp \
424                 --nid 7.7.7.[9-12]@tcp,7.7.7.[13-15]@o2ib ||
425                 error "Peer add failed $?"
426         compare_peer_del "7.7.7.7@tcp"
427
428         echo "Delete peer with single nid (gni)"
429         do_lnetctl peer add --prim_nid 7@gni || error "Peer add failed $?"
430         compare_peer_del "7@gni"
431
432         echo "Delete peer that has multiple nids (gni)"
433         do_lnetctl peer add --prim_nid 7@gni --nid [8-12]@gni ||
434                 error "Peer add failed $?"
435         compare_peer_del "7@gni"
436
437         echo "Delete peer with single nid (kfi)"
438         do_lnetctl peer add --prim_nid 7@kfi || error "Peer add failed $?"
439         compare_peer_del "7@kfi"
440
441         echo "Delete peer that has multiple nids (kfi)"
442         do_lnetctl peer add --prim_nid 7@kfi --nid [8-12]@kfi ||
443                 error "Peer add failed $?"
444         compare_peer_del "7@kfi"
445
446         echo "Delete peer that has tcp, o2ib, gni and kfi nids"
447         do_lnetctl peer add --prim_nid 7@gni \
448                 --nid [8-12]@gni,7.7.7.[1-4]@tcp,7.7.7.[5-9]@o2ib,[1-5]@kfi ||
449                 error "Peer add failed $?"
450         compare_peer_del "7@gni"
451 }
452 run_test 7 "Various peer delete tests"
453
454 test_8() {
455         reinit_dlc || return $?
456
457         cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
458 peer:
459     - primary nid: 8.8.8.8@tcp
460       Multi-Rail: True
461       peer ni:
462         - nid: 8.8.8.8@tcp
463         - nid: 8.8.8.10@tcp
464         - nid: 8.8.8.11@tcp
465         - nid: 8.8.8.12@tcp
466         - nid: 8.8.8.14@tcp
467         - nid: 8.8.8.15@tcp
468 EOF
469         append_global_yaml
470
471         do_lnetctl peer add --prim_nid 8.8.8.8@tcp --nid 8.8.8.[10-15]@tcp ||
472                 error "Peer add failed $?"
473         compare_peer_del "8.8.8.8@tcp" "8.8.8.13@tcp"
474 }
475 run_test 8 "Delete single secondary nid from peer (tcp)"
476
477 test_9() {
478         reinit_dlc || return $?
479
480         cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
481 peer:
482     - primary nid: 9.9.9.9@tcp
483       Multi-Rail: True
484       peer ni:
485         - nid: 9.9.9.9@tcp
486 EOF
487         append_global_yaml
488
489         do_lnetctl peer add --prim_nid 9.9.9.9@tcp \
490                 --nid 9.9.9.[11-16]@tcp || error "Peer add failed $?"
491         compare_peer_del "9.9.9.9@tcp" "9.9.9.[11-16]@tcp"
492 }
493 run_test 9 "Delete all secondary nids from peer (tcp)"
494
495 test_10() {
496         reinit_dlc || return $?
497
498         cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
499 peer:
500     - primary nid: 10.10.10.10@tcp
501       Multi-Rail: True
502       peer ni:
503         - nid: 10.10.10.10@tcp
504         - nid: 10.10.10.12@tcp
505         - nid: 10.10.10.13@tcp
506         - nid: 10.10.10.15@tcp
507         - nid: 10.10.10.16@tcp
508 EOF
509         append_global_yaml
510         do_lnetctl peer add --prim_nid 10.10.10.10@tcp \
511                 --nid 10.10.10.[12-16]@tcp || error "Peer add failed $?"
512         compare_peer_del "10.10.10.10@tcp" "10.10.10.14@tcp"
513 }
514 run_test 10 "Delete single secondary nid from peer (o2ib)"
515
516 test_11() {
517         reinit_dlc || return $?
518
519         cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
520 peer:
521     - primary nid: 11.11.11.11@tcp
522       Multi-Rail: True
523       peer ni:
524         - nid: 11.11.11.11@tcp
525 EOF
526         append_global_yaml
527         do_lnetctl peer add --prim_nid 11.11.11.11@tcp \
528                 --nid 11.11.11.[13-17]@tcp || error "Peer add failed $?"
529         compare_peer_del "11.11.11.11@tcp" "11.11.11.[13-17]@tcp"
530 }
531 run_test 11 "Delete all secondary nids from peer (o2ib)"
532
533 test_12() {
534         reinit_dlc || return $?
535
536         cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
537 peer:
538     - primary nid: 12.12.12.12@o2ib
539       Multi-Rail: True
540       peer ni:
541         - nid: 12.12.12.12@o2ib
542         - nid: 13.13.13.13@o2ib
543         - nid: 14.13.13.13@o2ib
544         - nid: 14.15.13.13@o2ib
545         - nid: 15.17.1.5@tcp
546         - nid: 15.17.1.10@tcp
547         - nid: 15.17.1.20@tcp
548 EOF
549         append_global_yaml
550         do_lnetctl peer add --prim_nid 12.12.12.12@o2ib \
551                 --nid [13-14/1].[13-15/2].13.13@o2ib,[15-16/3].[17-19/4].[1].[5-20/5]@tcp ||
552                 error "Peer add failed $?"
553         compare_peer_del "12.12.12.12@o2ib" "13.15.13.13@o2ib,15.17.1.15@tcp"
554 }
555 run_test 12 "Delete a secondary nid from peer (tcp and o2ib)"
556
557 test_13() {
558         reinit_dlc || return $?
559
560         cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
561 peer:
562     - primary nid: 13.13.13.13@o2ib
563       Multi-Rail: True
564       peer ni:
565         - nid: 13.13.13.13@o2ib
566 EOF
567         append_global_yaml
568         do_lnetctl peer add --prim_nid 13.13.13.13@o2ib \
569                 --nid [14-15].[1-2/1].[1].[100-254/10]@tcp,14.14.[254].14@o2ib ||
570                 error "Peer add failed $?"
571         compare_peer_del "13.13.13.13@o2ib" \
572                 "[14-15].[1-2/1].[1].[100-254/10]@tcp,14.14.[254].14@o2ib"
573 }
574 run_test 13 "Delete all secondary nids from peer (tcp and o2ib)"
575
576 create_nid() {
577         local num="$1"
578         local net="$2"
579
580         if [[ $net =~ gni* ]] || [[ $net =~ kfi* ]]; then
581                 echo "${num}@${net}"
582         else
583                 echo "${num}.${num}.${num}.${num}@${net}"
584         fi
585 }
586
587 create_mr_peer_yaml() {
588         local num_peers="$1"
589         local secondary_nids="$2"
590         local net="$3"
591
592         echo "Generating peer yaml for $num_peers peers with $secondary_nids secondary nids"
593         echo "peer:" >> $TMP/sanity-lnet-$testnum-expected.yaml
594         local i
595         local total_nids=$((num_peers + $((num_peers * secondary_nids))))
596         local created=0
597         local nidnum=1
598         while [[ $created -lt $num_peers ]]; do
599                 local primary=$(create_nid ${nidnum} ${net})
600         cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
601     - primary nid: $primary
602       Multi-Rail: True
603       peer ni:
604         - nid: $primary
605 EOF
606                 local j
607                 local start=$((nidnum + 1))
608                 local end=$((nidnum + $secondary_nids))
609                 for j in $(seq ${start} ${end}); do
610                         local nid=$(create_nid $j ${net})
611                         echo "        - nid: $nid" >> $TMP/sanity-lnet-$testnum-expected.yaml
612                 done
613                 nidnum=$((end + 1))
614                 ((created++))
615         done
616 }
617
618 test_14() {
619         reinit_dlc || return $?
620
621         echo "Create single peer, single nid, using import"
622         create_mr_peer_yaml 1 0 tcp
623         do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
624                 error "Import failed $?"
625         append_global_yaml
626         $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
627         compare_yaml_files
628
629         echo "Delete single peer using import --del"
630         do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
631                 error "Import failed $?"
632         rm -f $TMP/sanity-lnet-$testnum-expected.yaml
633         create_base_yaml_file
634         $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
635         compare_yaml_files
636 }
637 run_test 14 "import peer create/delete with single nid"
638
639 test_15() {
640         reinit_dlc || return $?
641
642         echo "Create multiple peers, single nid per peer, using import"
643         create_mr_peer_yaml 5 0 o2ib
644         # The ordering of nids for this use-case is non-deterministic, so we
645         # we can't just diff the expected/actual output.
646         do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
647                 error "Import failed $?"
648         $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
649         validate_peer_nids 5 0
650
651         echo "Delete multiple peers, single nid per peer, using import --del"
652         do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
653                 error "Import failed $?"
654         rm -f $TMP/sanity-lnet-$testnum-expected.yaml
655         create_base_yaml_file
656         $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
657         compare_yaml_files
658 }
659 run_test 15 "import multi peer create/delete with single nid per peer"
660
661 test_16() {
662         reinit_dlc || return $?
663
664         echo "Create single peer, multiple nids, using import"
665         create_mr_peer_yaml 1 5 tcp
666         do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
667                 error "Import failed $?"
668         $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
669         validate_peer_nids 1 5
670
671         echo "Delete single peer, multiple nids, using import --del"
672         do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
673                 error "Import failed $?"
674         rm -f $TMP/sanity-lnet-$testnum-expected.yaml
675         create_base_yaml_file
676         $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
677         compare_yaml_files
678 }
679 run_test 16 "import peer create/delete with multiple nids"
680
681 test_17() {
682         reinit_dlc || return $?
683
684         echo "Create multiple peers, multiple nids per peer, using import"
685         create_mr_peer_yaml 5 7 o2ib
686         do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
687                 error "Import failed $?"
688         $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
689         validate_peer_nids 5 7
690
691         echo "Delete multiple peers, multiple nids per peer, using import --del"
692         do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
693                 error "Import failed $?"
694         rm -f $TMP/sanity-lnet-$testnum-expected.yaml
695         create_base_yaml_file
696         $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
697         compare_yaml_files
698 }
699 run_test 17 "import multi peer create/delete with multiple nids"
700
701 test_18a() {
702         reinit_dlc || return $?
703
704         cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
705 peer:
706     - primary nid: 1.1.1.1@tcp
707       Multi-Rail: True
708       peer ni:
709         - nid: 1.1.1.1@tcp
710         - nid: 2.2.2.2@tcp
711         - nid: 4.4.4.4@tcp
712         - nid: 3.3.3.3@o2ib
713         - nid: 5@gni
714 EOF
715         echo "Import peer with 5 nids"
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
720 peer:
721     - primary nid: 1.1.1.1@tcp
722       Multi-Rail: True
723       peer ni:
724         - nid: 2.2.2.2@tcp
725         - nid: 3.3.3.3@o2ib
726         - nid: 5@gni
727 EOF
728         echo "Delete three of the nids"
729         cat $TMP/sanity-lnet-$testnum-expected.yaml
730         do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml
731         cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
732 peer:
733     - primary nid: 1.1.1.1@tcp
734       Multi-Rail: True
735       peer ni:
736         - nid: 1.1.1.1@tcp
737         - nid: 4.4.4.4@tcp
738 EOF
739         echo "Check peer has expected nids remaining"
740         $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
741         append_global_yaml
742         compare_yaml_files
743 }
744 run_test 18a "Delete a subset of nids from a single peer using import --del"
745
746 test_18b() {
747         reinit_dlc || return $?
748
749         cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
750 peer:
751     - primary nid: 1.1.1.1@tcp
752       Multi-Rail: True
753       peer ni:
754         - nid: 1.1.1.1@tcp
755         - nid: 2.2.2.2@tcp
756         - nid: 4.4.4.4@tcp
757         - nid: 3.3.3.3@o2ib
758         - nid: 5@gni
759     - primary nid: 6.6.6.6@o2ib
760       Multi-Rail: True
761       peer ni:
762         - nid: 6.6.6.6@o2ib
763         - nid: 7.7.7.7@tcp
764         - nid: 8.8.8.8@tcp
765         - nid: 9.9.9.9@tcp
766         - nid: 10@gni
767 EOF
768         echo "Import two peers with 5 nids each"
769         cat $TMP/sanity-lnet-$testnum-expected.yaml
770         do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
771                 error "Import failed $?"
772         cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
773 peer:
774     - primary nid: 1.1.1.1@tcp
775       Multi-Rail: True
776       peer ni:
777         - nid: 2.2.2.2@tcp
778         - nid: 3.3.3.3@o2ib
779         - nid: 5@gni
780     - primary nid: 6.6.6.6@o2ib
781       Multi-Rail: True
782       peer ni:
783         - nid: 7.7.7.7@tcp
784         - nid: 8.8.8.8@tcp
785         - nid: 10@gni
786 EOF
787         echo "Delete three of the nids from each peer"
788         cat $TMP/sanity-lnet-$testnum-expected.yaml
789         do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml
790         cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
791 peer:
792     - primary nid: 6.6.6.6@o2ib
793       Multi-Rail: True
794       peer ni:
795         - nid: 6.6.6.6@o2ib
796         - nid: 7.7.7.7@tcp
797     - primary nid: 1.1.1.1@tcp
798       Multi-Rail: True
799       peer ni:
800         - nid: 1.1.1.1@tcp
801         - nid: 4.4.4.4@tcp
802 EOF
803         append_global_yaml
804         echo "Check peers have expected nids remaining"
805         $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
806         compare_yaml_files
807         validate_peer_nids 2 1
808 }
809 run_test 18b "Delete multiple nids from multiple peers using import --del"
810
811 test_19() {
812         reinit_dlc || return $?
813         cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
814 peer:
815     - primary nid: 19@gni
816       Multi-Rail: True
817       peer ni:
818         - nid: 19@gni
819 EOF
820         append_global_yaml
821         compare_peer_add "19@gni"
822 }
823 run_test 19 "Add peer with single nid (gni)"
824
825 test_20() {
826         reinit_dlc || return $?
827         cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
828 peer:
829     - primary nid: 20@gni
830       Multi-Rail: True
831       peer ni:
832         - nid: 20@gni
833         - nid: 20.20.20.20@tcp
834         - nid: 20.20.20.20@o2ib
835 EOF
836         append_global_yaml
837         compare_peer_add "20@gni" "20.20.20.20@tcp,20.20.20.20@o2ib"
838 }
839 run_test 20 "Add peer with gni primary and tcp, o2ib secondary"
840
841 test_21() {
842         reinit_dlc || return $?
843         cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
844 peer:
845     - primary nid: 21@gni
846       Multi-Rail: True
847       peer ni:
848         - nid: 21@gni
849         - nid: 22@gni
850         - nid: 23@gni
851         - nid: 24@gni
852         - nid: 25@gni
853 EOF
854         append_global_yaml
855         echo "Add peer with nidrange (gni)"
856         compare_peer_add "21@gni" "[22-25]@gni" || error
857         echo "Add peer with nidrange that overlaps primary nid (gni)"
858         compare_peer_add "21@gni" "[21-25]@gni"
859 }
860 run_test 21 "Add peer with nidrange (gni)"
861
862 test_22() {
863         reinit_dlc || return $?
864         cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
865 peer:
866     - primary nid: 22@gni
867       Multi-Rail: True
868       peer ni:
869         - nid: 22@gni
870         - nid: 24@gni
871         - nid: 25@gni
872         - nid: 27@gni
873         - nid: 28@gni
874         - nid: 29@gni
875 EOF
876         append_global_yaml
877         do_lnetctl peer add --prim_nid 22@gni --nid [24-29]@gni ||
878                 error "Peer add failed $?"
879         compare_peer_del "22@gni" "26@gni"
880 }
881 run_test 22 "Delete single secondary nid from peer (gni)"
882
883 test_23() {
884         reinit_dlc || return $?
885         cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
886 peer:
887     - primary nid: 23@gni
888       Multi-Rail: True
889       peer ni:
890         - nid: 23@gni
891 EOF
892         append_global_yaml
893
894         do_lnetctl peer add --prim_nid 23@gni --nid [25-29]@gni ||
895                 error "Peer add failed $?"
896         compare_peer_del "23@gni" "[25-29]@gni"
897 }
898 run_test 23 "Delete all secondary nids from peer (gni)"
899
900 test_24() {
901         reinit_dlc || return $?
902         cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
903 peer:
904     - primary nid: 24@gni
905       Multi-Rail: True
906       peer ni:
907         - nid: 24@gni
908         - nid: 11@gni
909         - nid: 13.13.13.13@o2ib
910         - nid: 14.13.13.13@o2ib
911         - nid: 14.15.13.13@o2ib
912         - nid: 15.17.1.5@tcp
913         - nid: 15.17.1.10@tcp
914         - nid: 15.17.1.20@tcp
915 EOF
916         append_global_yaml
917         do_lnetctl peer add --prim_nid 24@gni \
918                 --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 ||
919                 error "Peer add failed $?"
920         compare_peer_del "24@gni" "5@gni,13.15.13.13@o2ib,15.17.1.15@tcp"
921 }
922 run_test 24 "Delete a secondary nid from peer (tcp, o2ib and gni)"
923
924 test_25() {
925         reinit_dlc || return $?
926         cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
927 peer:
928     - primary nid: 25@gni
929       Multi-Rail: True
930       peer ni:
931         - nid: 25@gni
932 EOF
933         append_global_yaml
934         do_lnetctl peer add --prim_nid 25@gni \
935                 --nid [26-27].[4-10/3].26.26@tcp,26.26.26.26@o2ib,[30-35]@gni ||
936                 error "Peer add failed $?"
937         compare_peer_del "25@gni" \
938                 "[26-27].[4-10/3].26.26@tcp,26.26.26.26@o2ib,[30-35]@gni"
939 }
940 run_test 25 "Delete all secondary nids from peer (tcp, gni and o2ib)"
941
942 test_26() {
943         reinit_dlc || return $?
944
945         do_lnetctl peer add --prim_nid 1.1.1.1@tcp --lock_prim ||
946                 error "Peer add with --lock_prim option failed $?"
947         local peer_state=$($LNETCTL peer show -v 4 --nid 1.1.1.1@tcp |
948                 awk '/peer state/ {print $NF}')
949         # This relies on the following peer state definition:
950         # #define LNET_PEER_LOCK_PRIMARY          BIT(20)
951         if ((!("$peer_state" & (1 << 20)))); then
952                 error "Peer state does not have 'locked' bit set: $peer_state"
953         fi
954         do_lnetctl peer del --prim_nid 1.1.1.1@tcp ||
955                 error "Peer del failed $?"
956         $LNETCTL peer show --nid 1.1.1.1@tcp | grep -q 1.1.1.1@tcp ||
957                 error "1.1.1.1@tcp is not listed"
958         do_lnetctl peer del --prim_nid 1.1.1.1@tcp --force ||
959                 error "Peer del --force failed $?"
960         do_lnetctl peer show --nid 1.1.1.1@tcp &&
961                 error "failed to delete 1.1.1.1@tcp"
962
963         return 0
964 }
965 run_test 26 "Delete peer with primary nid locked"
966
967 test_99a() {
968         reinit_dlc || return $?
969
970         echo "Invalid prim_nid - peer add"
971         do_lnetctl peer add --prim_nid foobar &&
972                 error "Command should have failed"
973
974         echo "Invalid prim_nid - peer del"
975         do_lnetctl peer del --prim_nid foobar &&
976                 error "Command should have failed"
977
978         echo "Delete non-existing peer"
979         do_lnetctl peer del --prim_nid 1.1.1.1@o2ib &&
980                 error "Command should have failed"
981
982         echo "Don't provide mandatory argument for peer del"
983         do_lnetctl peer del --nid 1.1.1.1@tcp &&
984                 error "Command should have failed"
985
986         echo "Don't provide mandatory argument for peer add"
987         do_lnetctl peer add --nid 1.1.1.1@tcp &&
988                 error "Command should have failed"
989
990         echo "Don't provide mandatory arguments peer add"
991         do_lnetctl peer add &&
992                 error "Command should have failed"
993
994         echo "Invalid secondary nids"
995         do_lnetctl peer add --prim_nid 1.1.1.1@tcp --nid foobar &&
996                 error "Command should have failed"
997
998         echo "Exceed max nids per peer"
999         do_lnetctl peer add --prim_nid 1.1.1.1@tcp --nid 1.1.1.[2-255]@tcp &&
1000                 error "Command should have failed"
1001
1002         echo "Invalid net type"
1003         do_lnetctl peer add --prim_nid 1@foo &&
1004                 error "Command should have failed"
1005
1006         echo "Invalid nid format"
1007         local invalid_nids="1@tcp 1@o2ib 1.1.1.1@gni"
1008
1009         local nid
1010         for nid in ${invalid_nids}; do
1011                 echo "Check invalid primary nid - '$nid'"
1012                 do_lnetctl peer add --prim_nid $nid &&
1013                         error "Command should have failed"
1014         done
1015
1016         local invalid_strs="[2-1]@gni [a-f/x]@gni 256.256.256.256@tcp"
1017         invalid_strs+=" 1.1.1.1.[2-5/f]@tcp 1.]2[.3.4@o2ib"
1018         invalid_strs+="1.[2-4,[5-6],7-8].1.1@tcp foobar"
1019
1020         local nidstr
1021         for nidstr in ${invalid_strs}; do
1022                 echo "Check invalid nidstring - '$nidstr'"
1023                 do_lnetctl peer add --prim_nid 1.1.1.1@tcp --nid $nidstr &&
1024                         error "Command should have failed"
1025         done
1026
1027         echo "Add non-local gateway"
1028         do_lnetctl route add --net tcp --gateway 1@gni &&
1029                 error "Command should have failed"
1030
1031         return 0
1032 }
1033 run_test 99a "Check various invalid inputs to lnetctl peer"
1034
1035 test_99b() {
1036         reinit_dlc || return $?
1037
1038         create_base_yaml_file
1039
1040         cat <<EOF > $TMP/sanity-lnet-$testnum-invalid.yaml
1041 peer:
1042     - primary nid: 99.99.99.99@tcp
1043       Multi-Rail: Foobar
1044       peer ni:
1045         - nid: 99.99.99.99@tcp
1046 EOF
1047         do_lnetctl import < $TMP/sanity-lnet-$testnum-invalid.yaml &&
1048                 error "import should have failed"
1049         $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
1050         compare_yaml_files
1051 }
1052 run_test 99b "Invalid value for Multi-Rail in yaml import"
1053
1054 have_interface() {
1055         local if="$1"
1056         local ip=$(ip addr show dev $if | awk '/ inet /{print $2}')
1057         [[ -n $ip ]]
1058 }
1059
1060 add_net() {
1061         local net="$1"
1062         local if="$2"
1063
1064         do_lnetctl net add --net ${net} --if ${if} ||
1065                 error "Failed to add net ${net} on if ${if}"
1066 }
1067
1068 del_net() {
1069         local net="$1"
1070         local if="$2"
1071
1072         do_lnetctl net del --net ${net} --if ${if} ||
1073                 error "Failed to del net ${net} on if ${if}"
1074 }
1075
1076 compare_route_add() {
1077         local rnet="$1"
1078         local gw="$2"
1079
1080         local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
1081
1082         do_lnetctl route add --net ${rnet} --gateway ${gw} ||
1083                 error "route add failed $?"
1084         $LNETCTL export --backup > $actual ||
1085                 error "export failed $?"
1086         validate_gateway_nids
1087         return $?
1088 }
1089
1090 append_net_tunables() {
1091         local net=${1:-tcp}
1092
1093         $LNETCTL net show -v --net ${net} | grep -v 'dev cpt' |
1094                 awk '/^\s+tunables:$/,/^\s+CPT:/' >> $TMP/sanity-lnet-$testnum-expected.yaml
1095 }
1096
1097 IF0_IP=$(ip -o -4 a s ${INTERFACES[0]} |
1098          awk '{print $4}' | sed 's/\/.*//')
1099 IF0_NET=$(awk -F. '{print $1"."$2"."$3}'<<<"${IF0_IP}")
1100 IF0_HOSTNUM=$(awk -F. '{print $4}'<<<"${IF0_IP}")
1101 if (((IF0_HOSTNUM + 5) > 254)); then
1102         GW_HOSTNUM=1
1103 else
1104         GW_HOSTNUM=$((IF0_HOSTNUM + 1))
1105 fi
1106 GW_NID="${IF0_NET}.${GW_HOSTNUM}@${NETTYPE}"
1107 test_100() {
1108         [[ ${NETTYPE} == tcp* ]] ||
1109                 skip "Need tcp NETTYPE"
1110         reinit_dlc || return $?
1111         add_net "${NETTYPE}" "${INTERFACES[0]}"
1112         cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
1113 net:
1114     - net type: ${NETTYPE}
1115       local NI(s):
1116         - interfaces:
1117               0: ${INTERFACES[0]}
1118 EOF
1119         append_net_tunables tcp
1120         cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
1121 route:
1122     - net: tcp7
1123       gateway: ${GW_NID}
1124       hop: -1
1125       priority: 0
1126       health_sensitivity: 1
1127 peer:
1128     - primary nid: ${GW_NID}
1129       Multi-Rail: False
1130       peer ni:
1131         - nid: ${GW_NID}
1132 EOF
1133         append_global_yaml
1134         compare_route_add "tcp7" "${GW_NID}"
1135 }
1136 run_test 100 "Add route with single gw (tcp)"
1137
1138 test_101() {
1139         [[ ${NETTYPE} == tcp* ]] ||
1140                 skip "Need tcp NETTYPE"
1141         reinit_dlc || return $?
1142         add_net "${NETTYPE}" "${INTERFACES[0]}"
1143         cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
1144 net:
1145     - net type: ${NETTYPE}
1146       local NI(s):
1147         - interfaces:
1148               0: ${INTERFACES[0]}
1149 EOF
1150         append_net_tunables tcp
1151
1152         echo "route:" >> $TMP/sanity-lnet-$testnum-expected.yaml
1153         for i in $(seq $GW_HOSTNUM $((GW_HOSTNUM + 4))); do
1154                 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
1155     - net: tcp8
1156       gateway: ${IF0_NET}.${i}@tcp
1157       hop: -1
1158       priority: 0
1159       health_sensitivity: 1
1160 EOF
1161         done
1162
1163         echo "peer:" >> $TMP/sanity-lnet-$testnum-expected.yaml
1164         for i in $(seq $GW_HOSTNUM $((GW_HOSTNUM + 4))); do
1165                 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
1166     - primary nid: ${IF0_NET}.${i}@tcp
1167       Multi-Rail: False
1168       peer ni:
1169         - nid: ${IF0_NET}.${i}@tcp
1170 EOF
1171         done
1172         append_global_yaml
1173
1174         local gw="${IF0_NET}.[$GW_HOSTNUM-$((GW_HOSTNUM + 4))]@tcp"
1175
1176         compare_route_add "tcp8" "${gw}"
1177 }
1178 run_test 101 "Add route with multiple gw (tcp)"
1179
1180 compare_route_del() {
1181         local rnet="$1"
1182         local gw="$2"
1183
1184         local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
1185
1186         do_lnetctl route del --net ${rnet} --gateway ${gw} ||
1187                 error "route del failed $?"
1188         $LNETCTL export --backup > $actual ||
1189                 error "export failed $?"
1190         validate_gateway_nids
1191 }
1192
1193 generate_gw_nid() {
1194         local net=${1}
1195
1196         if [[ ${net} =~ (tcp|o2ib)[0-9]* ]]; then
1197                 echo "${GW_NID}"
1198         else
1199                 echo "$((${testnum} % 255))@${net}"
1200         fi
1201 }
1202
1203 test_102() {
1204         reinit_dlc || return $?
1205         add_net "${NETTYPE}" "${INTERFACES[0]}"
1206         $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
1207
1208         local gwnid=$(generate_gw_nid ${NETTYPE})
1209
1210         do_lnetctl route add --net ${NETTYPE}2 --gateway ${gwnid} ||
1211                 error "route add failed $?"
1212         compare_route_del "${NETTYPE}2" "${gwnid}"
1213 }
1214 run_test 102 "Delete route with single gw"
1215
1216 IP_NID_EXPR='103.103.103.[103-120/4]'
1217 NUM_NID_EXPR='[103-120/4]'
1218 test_103() {
1219         reinit_dlc || return $?
1220         add_net "${NETTYPE}" "${INTERFACES[0]}"
1221         $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
1222
1223         local nid_expr
1224
1225         if [[ $NETTYPE =~ (tcp|o2ib)[0-9]* ]]; then
1226                 nid_expr="${IF0_NET}.[$GW_HOSTNUM-$((GW_HOSTNUM+5))/2]"
1227         else
1228                 nid_expr="${NUM_NID_EXPR}"
1229         fi
1230
1231         do_lnetctl route add --net ${NETTYPE}103 \
1232                 --gateway ${nid_expr}@${NETTYPE} ||
1233                 error "route add failed $?"
1234         compare_route_del "${NETTYPE}103" "${nid_expr}@${NETTYPE}"
1235 }
1236 run_test 103 "Delete route with multiple gw"
1237
1238 test_104() {
1239         local tyaml="$TMP/sanity-lnet-$testnum-expected.yaml"
1240
1241         reinit_dlc || return $?
1242
1243         # Default value is '3'
1244         local val=$($LNETCTL global show | awk '/response_tracking/{print $NF}')
1245         [[ $val -ne 3 ]] &&
1246                 error "Expect 3 found $val"
1247
1248         echo "Set < 0;  Should fail"
1249         do_lnetctl set response_tracking -1 &&
1250                 error "should have failed $?"
1251
1252         reinit_dlc || return $?
1253         cat <<EOF > $tyaml
1254 global:
1255     response_tracking: -10
1256 EOF
1257         do_lnetctl import < $tyaml &&
1258                 error "should have failed $?"
1259
1260         echo "Check valid values; Should succeed"
1261         local i
1262         for ((i = 0; i < 4; i++)); do
1263                 reinit_dlc || return $?
1264                 do_lnetctl set response_tracking $i ||
1265                         error "should have succeeded $?"
1266                 $LNETCTL global show | grep -q "response_tracking: $i" ||
1267                         error "Failed to set response_tracking to $i"
1268                 reinit_dlc || return $?
1269                 cat <<EOF > $tyaml
1270 global:
1271     response_tracking: $i
1272 EOF
1273                 do_lnetctl import < $tyaml ||
1274                         error "should have succeeded $?"
1275                 $LNETCTL global show | grep -q "response_tracking: $i" ||
1276                         error "Failed to set response_tracking to $i"
1277         done
1278
1279         reinit_dlc || return $?
1280         echo "Set > 3; Should fail"
1281         do_lnetctl set response_tracking 4 &&
1282                 error "should have failed $?"
1283
1284         reinit_dlc || return $?
1285         cat <<EOF > $tyaml
1286 global:
1287     response_tracking: 10
1288 EOF
1289         do_lnetctl import < $tyaml &&
1290                 error "should have failed $?"
1291         return 0
1292 }
1293 run_test 104 "Set/check response_tracking param"
1294
1295 test_105() {
1296         reinit_dlc || return $?
1297         add_net "${NETTYPE}" "${INTERFACES[0]}"
1298
1299         local gwnid=$(generate_gw_nid ${NETTYPE})
1300
1301         do_lnetctl route add --net ${NETTYPE}105 --gateway ${gwnid} ||
1302                 error "route add failed $?"
1303         do_lnetctl peer add --prim ${gwnid} &&
1304                 error "peer add should fail"
1305
1306         return 0
1307 }
1308 run_test 105 "Adding duplicate GW peer should fail"
1309
1310 test_106() {
1311         reinit_dlc || return $?
1312         add_net "${NETTYPE}" "${INTERFACES[0]}"
1313
1314         local gwnid=$(generate_gw_nid ${NETTYPE})
1315
1316         do_lnetctl route add --net ${NETTYPE}106 --gateway ${gwnid} ||
1317                 error "route add failed $?"
1318         do_lnetctl peer del --prim ${gwnid} &&
1319                 error "peer del should fail"
1320
1321         return 0
1322 }
1323 run_test 106 "Deleting GW peer should fail"
1324
1325 test_107() {
1326         [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
1327
1328         cleanup_netns || error "Failed to cleanup netns before test execution"
1329         cleanup_lnet || error "Failed to unload modules before test execution"
1330
1331         setup_fakeif || error "Failed to add fake IF"
1332         have_interface "$FAKE_IF" ||
1333                 error "Expect $FAKE_IF configured but not found"
1334
1335         reinit_dlc || return $?
1336
1337         add_net "tcp" "${INTERFACES[0]}" || return $?
1338         add_net "tcp" "$FAKE_IF" || return $?
1339
1340         del_net "tcp" "$FAKE_IF" || return $?
1341
1342         cleanup_fakeif
1343         cleanup_lnet
1344         setup_netns
1345 }
1346 run_test 107 "Deleting extra interface doesn't crash node"
1347
1348 test_108() {
1349         [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
1350
1351         cleanup_netns || error "Failed to cleanup netns before test execution"
1352         cleanup_lnet || error "Failed to unload modules before test execution"
1353
1354         setup_fakeif || error "Failed to add fake IF"
1355         have_interface "$FAKE_IF" ||
1356                 error "Expect $FAKE_IF configured but not found"
1357
1358         reinit_dlc || return $?
1359
1360         add_net "tcp" "${INTERFACES[0]}" || return $?
1361         $LNETCTL net show > $TMP/sanity-lnet-$testnum-expected.yaml
1362         add_net "tcp" "$FAKE_IF" || return $?
1363
1364         cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
1365       -     nid: ${FAKE_IP}@tcp
1366             status: up
1367             interfaces:
1368                   0: ${FAKE_IF}
1369 EOF
1370         $LNETCTL net show > $TMP/sanity-lnet-$testnum-actual.yaml
1371         compare_yaml_files || error "not all interfaces were setup"
1372
1373         cleanup_fakeif
1374         cleanup_lnet
1375         setup_netns
1376
1377         return 0
1378 }
1379 run_test 108 "Check Multi-Rail setup"
1380
1381 test_200() {
1382         [[ ${NETTYPE} == tcp* ]] ||
1383                 skip "Need tcp NETTYPE"
1384         cleanup_lnet || exit 1
1385         load_lnet "networks=\"\""
1386         do_ns $LNETCTL lnet configure --all || exit 1
1387         $LNETCTL net show --net tcp | grep -q "nid: ${FAKE_IP}@tcp$"
1388 }
1389 run_test 200 "load lnet w/o module option, configure in a non-default namespace"
1390
1391 test_201() {
1392         [[ ${NETTYPE} == tcp* ]] ||
1393                 skip "Need tcp NETTYPE"
1394         cleanup_lnet || exit 1
1395         load_lnet "networks=tcp($FAKE_IF)"
1396         do_ns $LNETCTL lnet configure --all || exit 1
1397         $LNETCTL net show --net tcp | grep -q "nid: ${FAKE_IP}@tcp$"
1398 }
1399 run_test 201 "load lnet using networks module options in a non-default namespace"
1400
1401 test_202() {
1402         [[ ${NETTYPE} == tcp* ]] ||
1403                 skip "Need tcp NETTYPE"
1404         cleanup_lnet || exit 1
1405         load_lnet "networks=\"\" ip2nets=\"tcp0($FAKE_IF) ${FAKE_IP}\""
1406         do_ns $LNETCTL lnet configure --all || exit 1
1407         $LNETCTL net show | grep -q "nid: ${FAKE_IP}@tcp$"
1408 }
1409 run_test 202 "load lnet using ip2nets in a non-default namespace"
1410
1411
1412 ### Add the interfaces in the target namespace
1413
1414 test_203() {
1415         [[ ${NETTYPE} == tcp* ]] ||
1416                 skip "Need tcp NETTYPE"
1417         cleanup_lnet || exit 1
1418         load_lnet
1419         do_lnetctl lnet configure || exit 1
1420         do_ns $LNETCTL net add --net tcp0 --if $FAKE_IF
1421 }
1422 run_test 203 "add a network using an interface in the non-default namespace"
1423
1424 LNET_PARAMS_FILE="$TMP/$TESTSUITE.parameters"
1425 function save_lnet_params() {
1426         $LNETCTL global show | egrep -v '^global:$' |
1427                                sed 's/://' > $LNET_PARAMS_FILE
1428 }
1429
1430 function restore_lnet_params() {
1431         local param value
1432         while read param value; do
1433                 [[ $param == max_intf ]] && continue
1434                 [[ $param == lnd_timeout ]] && continue
1435                 $LNETCTL set ${param} ${value} ||
1436                         error "Failed to restore ${param} to ${value}"
1437         done < $LNET_PARAMS_FILE
1438 }
1439
1440 function lnet_health_pre() {
1441         save_lnet_params
1442
1443         # Lower transaction timeout to speed up test execution
1444         $LNETCTL set transaction_timeout 10 ||
1445                 error "Failed to set transaction_timeout $?"
1446
1447         RETRY_PARAM=$($LNETCTL global show | awk '/retry_count/{print $NF}')
1448         RSND_PRE=$($LNETCTL stats show | awk '/resend_count/{print $NF}')
1449         LO_HVAL_PRE=$($LNETCTL net show -v 2 | awk '/health value/{print $NF}' |
1450                       xargs echo | sed 's/ /+/g' | bc -l)
1451
1452         RMT_HVAL_PRE=$($LNETCTL peer show --nid ${RNIDS[0]} -v 2 2>/dev/null |
1453                        awk '/health value/{print $NF}' | xargs echo |
1454                        sed 's/ /+/g' | bc -l)
1455
1456         # Might not have any peers so initialize to zero.
1457         RMT_HVAL_PRE=${RMT_HVAL_PRE:-0}
1458
1459         return 0
1460 }
1461
1462 function lnet_health_post() {
1463         RSND_POST=$($LNETCTL stats show | awk '/resend_count/{print $NF}')
1464         LO_HVAL_POST=$($LNETCTL net show -v 2 |
1465                        awk '/health value/{print $NF}' |
1466                        xargs echo | sed 's/ /+/g' | bc -l)
1467
1468         RMT_HVAL_POST=$($LNETCTL peer show --nid ${RNIDS[0]} -v 2 2>/dev/null |
1469                         awk '/health value/{print $NF}' | xargs echo |
1470                         sed 's/ /+/g' | bc -l)
1471
1472         # Might not have any peers so initialize to zero.
1473         RMT_HVAL_POST=${RMT_HVAL_POST:-0}
1474
1475         ${VERBOSE} &&
1476         echo "Pre resends: $RSND_PRE" &&
1477         echo "Post resends: $RSND_POST" &&
1478         echo "Resends delta: $((RSND_POST - RSND_PRE))" &&
1479         echo "Pre local health: $LO_HVAL_PRE" &&
1480         echo "Post local health: $LO_HVAL_POST" &&
1481         echo "Pre remote health: $RMT_HVAL_PRE" &&
1482         echo "Post remote health: $RMT_HVAL_POST"
1483
1484         restore_lnet_params
1485
1486         do_lnetctl peer set --health 1000 --all
1487         do_lnetctl net set --health 1000 --all
1488
1489         return 0
1490 }
1491
1492 function check_no_resends() {
1493         echo "Check that no resends took place"
1494         [[ $RSND_POST -ne $RSND_PRE ]] &&
1495                 error "Found resends: $RSND_POST != $RSND_PRE"
1496
1497         return 0
1498 }
1499
1500 function check_resends() {
1501         local delta=$((RSND_POST - RSND_PRE))
1502
1503         echo "Check that $RETRY_PARAM resends took place"
1504         [[ $delta -ne $RETRY_PARAM ]] &&
1505                 error "Expected $RETRY_PARAM resends found $delta"
1506
1507         return 0
1508 }
1509
1510 function check_no_local_health() {
1511         echo "Check that local NI health is unchanged"
1512         [[ $LO_HVAL_POST -ne $LO_HVAL_PRE ]] &&
1513                 error "Local health changed: $LO_HVAL_POST != $LO_HVAL_PRE"
1514
1515         return 0
1516 }
1517
1518 function check_local_health() {
1519         echo "Check that local NI health has been changed"
1520         [[ $LO_HVAL_POST -eq $LO_HVAL_PRE ]] &&
1521                 error "Local health unchanged: $LO_HVAL_POST == $LO_HVAL_PRE"
1522
1523         return 0
1524 }
1525
1526 function check_no_remote_health() {
1527         echo "Check that remote NI health is unchanged"
1528         [[ $RMT_HVAL_POST -ne $RMT_HVAL_PRE ]] &&
1529                 error "Remote health changed: $RMT_HVAL_POST != $RMT_HVAL_PRE"
1530
1531         return 0
1532 }
1533
1534 function check_remote_health() {
1535         echo "Check that remote NI health has been changed"
1536         [[ $RMT_HVAL_POST -eq $RMT_HVAL_PRE ]] &&
1537                 error "Remote health unchanged: $RMT_HVAL_POST == $RMT_HVAL_PRE"
1538
1539         return 0
1540 }
1541
1542 RNODE=""
1543 RLOADED=false
1544 NET_DEL_ARGS=""
1545 RNIDS=( )
1546 LNIDS=( )
1547 setup_health_test() {
1548         local need_mr=$1
1549         local rc=0
1550
1551         [[ ${NETTYPE} == kfi* ]] && skip "kfi doesn't support drop rules"
1552
1553         local rnodes=$(remote_nodes_list)
1554         [[ -z $rnodes ]] && skip "Need at least 1 remote node"
1555
1556         cleanup_lnet || error "Failed to cleanup before test execution"
1557
1558         # Loading modules should configure LNet with the appropriate
1559         # test-framework configuration
1560         load_lnet "config_on_load=1" || error "Failed to load modules"
1561
1562         LNIDS=( $($LCTL list_nids | xargs echo) )
1563
1564         RNODE=$(awk '{print $1}' <<<$rnodes)
1565         RNIDS=( $(do_node $RNODE $LCTL list_nids | xargs echo) )
1566
1567         if [[ -z ${RNIDS[@]} ]]; then
1568                 do_rpc_nodes $RNODE load_lnet "config_on_load=1"
1569                 RLOADED=true
1570                 RNIDS=( $(do_node $RNODE $LCTL list_nids | xargs echo) )
1571         fi
1572
1573         [[ ${#LNIDS[@]} -lt 1 ]] &&
1574                 error "No NIDs configured for local host $HOSTNAME"
1575         [[ ${#RNIDS[@]} -lt 1 ]] &&
1576                 error "No NIDs configured for remote host $RNODE"
1577
1578         # Ensure all peer NIs are local (i.e. non-routed config)
1579         local rnid rnet lnid lnet
1580
1581         for rnid in ${RNIDS[@]}; do
1582                 rnet=${rnid##*@}
1583                 for lnid in ${LNIDS[@]}; do
1584                         lnet=${lnid##*@}
1585                         [[ ${lnet} == ${rnet} ]] &&
1586                                 break
1587                 done
1588                 [[ ${lnet} != ${rnet} ]] &&
1589                         skip "Need non-routed configuration"
1590         done
1591
1592         do_lnetctl discover ${RNIDS[0]} ||
1593                 error "Unable to discover ${RNIDS[0]}"
1594
1595         local mr=$($LNETCTL peer show --nid ${RNIDS[0]} |
1596                    awk '/Multi-Rail/{print $NF}')
1597
1598         if ${need_mr} && [[ $mr == False ]]; then
1599                 cleanup_health_test || return $?
1600                 skip "Need MR peer"
1601         fi
1602
1603         if ( ! ${need_mr} && [[ ${#RNIDS[@]} -gt 1 ]] ) ||
1604            ( ! ${need_mr} && [[ ${#LNIDS[@]} -gt 1 ]] ); then
1605                 cleanup_health_test || return $?
1606                 skip "Need SR peer"
1607         fi
1608
1609         if ${need_mr} && [[ ${#RNIDS[@]} -lt 2 ]]; then
1610                 # Add a second, reachable NID to rnode.
1611                 local net=${RNIDS[0]}
1612
1613                 net="${net//*@/}1"
1614
1615                 local if=$(do_rpc_nodes --quiet $RNODE lnet_if_list)
1616                 [[ -z $if ]] &&
1617                         error "Failed to determine interface for $RNODE"
1618
1619                 do_rpc_nodes $RNODE "$LNETCTL lnet configure"
1620                 do_rpc_nodes $RNODE "$LNETCTL net add --net $net --if $if" ||
1621                         rc=$?
1622                 if [[ $rc -ne 0 ]]; then
1623                         error "Failed to add interface to $RNODE rc=$?"
1624                 else
1625                         RNIDS[1]="${RNIDS[0]}1"
1626                         NET_DEL_ARGS="--net $net --if $if"
1627                 fi
1628         fi
1629
1630         if ${need_mr} && [[ ${#LNIDS[@]} -lt 2 ]]; then
1631                 local net=${LNIDS[0]}
1632                 net="${net//*@/}1"
1633
1634                 do_lnetctl lnet configure &&
1635                         do_lnetctl net add --net $net --if ${INTERFACES[0]} ||
1636                         rc=$?
1637                 if [[ $rc -ne 0 ]]; then
1638                         error "Failed to add interface rc=$?"
1639                 else
1640                         LNIDS[1]="${LNIDS[0]}1"
1641                 fi
1642         fi
1643
1644         $LNETCTL net show
1645
1646         $LNETCTL peer show -v 2 | egrep -e nid -e health
1647
1648         $LCTL set_param debug=+net
1649
1650         return 0
1651
1652 }
1653
1654 cleanup_health_test() {
1655         local rc=0
1656
1657         if [[ -n $NET_DEL_ARGS ]]; then
1658                 do_rpc_nodes $RNODE \
1659                         "$LNETCTL net del $NET_DEL_ARGS" ||
1660                         rc=$((rc + $?))
1661                 NET_DEL_ARGS=""
1662         fi
1663
1664         unload_modules || rc=$?
1665
1666         if $RLOADED; then
1667                 do_rpc_nodes $RNODE unload_modules_local ||
1668                         rc=$((rc + $?))
1669                 RLOADED=false
1670         fi
1671
1672         [[ $rc -ne 0 ]] &&
1673                 error "Failed cleanup"
1674
1675         return $rc
1676 }
1677
1678 add_health_test_drop_rules() {
1679         local args="-m GET -r 1 -e ${1}"
1680         local src dst
1681
1682         for src in "${LNIDS[@]}"; do
1683                 for dst in "${RNIDS[@]}" "${LNIDS[@]}"; do
1684                         $LCTL net_drop_add -s $src -d $dst ${args} ||
1685                                 error "Failed to add drop rule $src $dst $args"
1686                 done
1687         done
1688 }
1689
1690 do_lnet_health_ping_test() {
1691         local hstatus="$1"
1692
1693         echo "Simulate $hstatus"
1694
1695         lnet_health_pre || return $?
1696
1697         add_health_test_drop_rules ${hstatus}
1698         do_lnetctl ping ${RNIDS[0]} &&
1699                 error "Should have failed"
1700
1701         lnet_health_post
1702
1703         $LCTL net_drop_del -a
1704
1705         return 0
1706 }
1707
1708 # See lnet/lnet/lib-msg.c:lnet_health_check()
1709 LNET_LOCAL_RESEND_STATUSES="local_interrupt local_dropped local_aborted"
1710 LNET_LOCAL_RESEND_STATUSES+=" local_no_route local_timeout"
1711 LNET_LOCAL_NO_RESEND_STATUSES="local_error"
1712 test_204() {
1713         setup_health_test false || return $?
1714
1715         local hstatus
1716         for hstatus in ${LNET_LOCAL_RESEND_STATUSES} \
1717                        ${LNET_LOCAL_NO_RESEND_STATUSES}; do
1718                 do_lnet_health_ping_test "${hstatus}" || return $?
1719                 check_no_resends || return $?
1720                 check_no_local_health || return $?
1721         done
1722
1723         cleanup_health_test || return $?
1724
1725         return 0
1726 }
1727 run_test 204 "Check no health or resends for single-rail local failures"
1728
1729 test_205() {
1730         (( $MDS1_VERSION >= $(version_code 2.14.58) )) ||
1731                 skip "need at least 2.14.58"
1732
1733         setup_health_test true || return $?
1734
1735         local hstatus
1736         for hstatus in ${LNET_LOCAL_RESEND_STATUSES}; do
1737                 do_lnet_health_ping_test "${hstatus}" || return $?
1738                 check_resends || return $?
1739                 check_local_health || return $?
1740         done
1741
1742         for hstatus in ${LNET_LOCAL_NO_RESEND_STATUSES}; do
1743                 do_lnet_health_ping_test "${hstatus}" || return $?
1744                 check_no_resends || return $?
1745                 check_local_health || return $?
1746         done
1747
1748         cleanup_health_test || return $?
1749
1750         return 0
1751 }
1752 run_test 205 "Check health and resends for multi-rail local failures"
1753
1754 # See lnet/lnet/lib-msg.c:lnet_health_check()
1755 LNET_REMOTE_RESEND_STATUSES="remote_dropped"
1756 LNET_REMOTE_NO_RESEND_STATUSES="remote_error remote_timeout"
1757 test_206() {
1758         setup_health_test false || return $?
1759
1760         local hstatus
1761         for hstatus in ${LNET_REMOTE_RESEND_STATUSES} \
1762                        ${LNET_REMOTE_NO_RESEND_STATUSES}; do
1763                 do_lnet_health_ping_test "${hstatus}" || return $?
1764                 check_no_resends || return $?
1765                 check_no_local_health || return $?
1766                 check_no_remote_health || return $?
1767         done
1768
1769         cleanup_health_test || return $?
1770
1771         return 0
1772 }
1773 run_test 206 "Check no health or resends for single-rail remote failures"
1774
1775 test_207() {
1776         (( $MDS1_VERSION >= $(version_code 2.14.58) )) ||
1777                 skip "need at least 2.14.58"
1778
1779         setup_health_test true || return $?
1780
1781         local hstatus
1782         for hstatus in ${LNET_REMOTE_RESEND_STATUSES}; do
1783                 do_lnet_health_ping_test "${hstatus}" || return $?
1784                 check_resends || return $?
1785                 check_no_local_health || return $?
1786                 check_remote_health || return $?
1787                 do_lnetctl peer set --health 1000 --all ||
1788                         error "Unable to reset health rc=$?"
1789         done
1790         for hstatus in ${LNET_REMOTE_NO_RESEND_STATUSES}; do
1791                 do_lnet_health_ping_test "${hstatus}" || return $?
1792                 check_no_resends || return $?
1793                 check_no_local_health || return $?
1794                 check_remote_health || return $?
1795                 do_lnetctl peer set --health 1000 --all ||
1796                         error "Unable to reset health rc=$?"
1797         done
1798
1799         cleanup_health_test || return $?
1800
1801         return 0
1802 }
1803 run_test 207 "Check health and resends for multi-rail remote errors"
1804
1805 test_208_load_and_check_lnet() {
1806         local ip2nets="$1"
1807         local p_nid="$2"
1808         local s_nid="$3"
1809         local num_expected=1
1810
1811         load_lnet "networks=\"\" ip2nets=\"${ip2nets_str}\""
1812
1813         $LCTL net up ||
1814                 error "Failed to load LNet with ip2nets \"${ip2nets_str}\""
1815
1816         [[ -n $s_nid ]] &&
1817                 num_expected=2
1818
1819         declare -a nids
1820         nids=( $($LCTL list_nids) )
1821
1822         [[ ${#nids[@]} -ne ${num_expected} ]] &&
1823                 error "Expect ${num_expected} NIDs found ${#nids[@]}"
1824
1825         [[ ${nids[0]} == ${p_nid} ]] ||
1826                 error "Expect NID \"${p_nid}\" found \"${nids[0]}\""
1827
1828         [[ -n $s_nid ]] && [[ ${nids[1]} != ${s_nid} ]] &&
1829                 error "Expect second NID \"${s_nid}\" found \"${nids[1]}\""
1830
1831         $LCTL net down &>/dev/null
1832         cleanup_lnet
1833 }
1834
1835 test_208() {
1836         [[ ${NETTYPE} == tcp* ]] ||
1837                 skip "Need tcp NETTYPE"
1838
1839         cleanup_netns || error "Failed to cleanup netns before test execution"
1840         cleanup_lnet || error "Failed to unload modules before test execution"
1841         setup_fakeif || error "Failed to add fake IF"
1842
1843         have_interface "$FAKE_IF" ||
1844                 error "Expect $FAKE_IF configured but not found"
1845
1846         local if0_ip=$(ip --oneline addr show dev ${INTERFACES[0]} |
1847                        awk '/inet /{print $4}' |
1848                        sed 's:/.*::')
1849         if0_ip=($(echo "${if0_ip[@]}" | tr ' ' '\n' | uniq | tr '\n' ' '))
1850         local ip2nets_str="tcp(${INTERFACES[0]}) $if0_ip"
1851
1852         echo "Configure single NID \"$ip2nets_str\""
1853         test_208_load_and_check_lnet "${ip2nets_str}" "${if0_ip}@tcp"
1854
1855         ip2nets_str="tcp(${INTERFACES[0]}) $if0_ip; tcp1($FAKE_IF) $FAKE_IP"
1856         echo "Configure two NIDs; two NETs \"$ip2nets_str\""
1857         test_208_load_and_check_lnet "${ip2nets_str}" "${if0_ip}@tcp" \
1858                                      "${FAKE_IP}@tcp1"
1859
1860         ip2nets_str="tcp(${INTERFACES[0]}) $if0_ip; tcp($FAKE_IF) $FAKE_IP"
1861         echo "Configure two NIDs; one NET \"$ip2nets_str\""
1862         test_208_load_and_check_lnet "${ip2nets_str}" "${if0_ip}@tcp" \
1863                                      "${FAKE_IP}@tcp"
1864         local addr1=( ${if0_ip//./ } )
1865         local addr2=( ${FAKE_IP//./ } )
1866         local range="[${addr1[0]},${addr2[0]}]"
1867
1868         local i
1869         for i in $(seq 1 3); do
1870                 range+=".[${addr1[$i]},${addr2[$i]}]"
1871         done
1872         ip2nets_str="tcp(${INTERFACES[0]},${FAKE_IF}) ${range}"
1873
1874         echo "Configured two NIDs; one NET alt syntax \"$ip2nets_str\""
1875         test_208_load_and_check_lnet "${ip2nets_str}" "${if0_ip}@tcp" \
1876                                      "${FAKE_IP}@tcp"
1877
1878         cleanup_fakeif
1879
1880         echo "alt syntax with missing IF \"$ip2nets_str\""
1881         load_lnet "networks=\"\" ip2nets=\"${ip2nets_str}\""
1882
1883         echo "$LCTL net up should fail"
1884         $LCTL net up &&
1885                 error "LNet bring up should have failed"
1886
1887         cleanup_lnet
1888 }
1889 run_test 208 "Test various kernel ip2nets configurations"
1890
1891 test_209() {
1892         (( $MDS1_VERSION >= $(version_code 2.14.58) )) ||
1893                 skip "need at least 2.14.58"
1894
1895         setup_health_test false || return $?
1896
1897         echo "Simulate network_timeout w/SR config"
1898         lnet_health_pre
1899
1900         add_health_test_drop_rules network_timeout
1901
1902         do_lnetctl discover ${RNIDS[0]} &&
1903                 error "Should have failed"
1904
1905         lnet_health_post
1906
1907         check_no_resends || return $?
1908         check_no_local_health || return $?
1909         check_no_remote_health || return $?
1910
1911         cleanup_health_test || return $?
1912
1913         setup_health_test true || return $?
1914
1915         echo "Simulate network_timeout w/MR config"
1916
1917         lnet_health_pre
1918
1919         add_health_test_drop_rules network_timeout
1920
1921         do_lnetctl discover ${RNIDS[0]} &&
1922                 error "Should have failed"
1923
1924         lnet_health_post
1925
1926         check_no_resends || return $?
1927         check_local_health || return $?
1928         check_remote_health || return $?
1929
1930         cleanup_health_test || return $?
1931
1932         return 0
1933 }
1934 run_test 209 "Check health, but not resends, for network timeout"
1935
1936 check_nid_in_recovq() {
1937         local queue="$1"
1938         local nid="$2"
1939         local expect="$3"
1940         local max_wait="${4:-10}"
1941         local rc=0
1942
1943         (($expect == 0)) &&
1944                 echo "$queue recovery queue should be empty" ||
1945                 echo "$queue recovery queue should have $nid"
1946
1947         wait_update $HOSTNAME \
1948                 "$LNETCTL debug recovery $queue | \
1949                  grep -wc \"nid-0: $nid\"" \
1950                 "$expect" "$max_wait"
1951         rc=$?
1952         do_lnetctl debug recovery $queue
1953         (($rc == 0)) ||
1954                 error "Expect $expect NIDs in recovery."
1955
1956         return 0
1957 }
1958
1959 # First ping is sent at time 0.
1960 # 2nd at 0 + 2^1 = 2
1961 # 3rd at 2 + 2^2 = 6
1962 # 4th at 6 + 2^3 = 14
1963 # 5th at 14 + 2^4 = 30
1964 # e.g. after 10 seconds we would expect 3 pings to have been sent, and the
1965 # NI will have been enqueued for the 4th ping.
1966
1967 # If the recovery limit is 10 seconds, then after the 4th ping is sent
1968 # we expect the peer NI to have aged out, so it will not actually be
1969 # queued for a 5th ping.
1970 # If max_recovery_ping_interval is set to 4 then:
1971 #  First ping is sent at time 0
1972 #  2nd at  0 + min(2^1, 4) = 2
1973 #  3rd at  2 + min(2^2, 4) = 6
1974 #  4th at  6 + min(2^3, 4) = 10
1975 #  5th at 10 + min(2^4, 4) = 14
1976 #  6th at 14 + min(2^5, 4) = 18
1977 #  7th at 18 + min(2^6, 4) = 22
1978 # e.g. after 4 seconds we would expect 2 pings to have been sent, and
1979 # after 13 seconds we would expect 4 pings to have been sent
1980 check_ping_count() {
1981         local queue="$1"
1982         local nid="$2"
1983         local expect="$3"
1984         local max_wait="$4"
1985
1986         echo "Check ping counts:"
1987
1988         local rc=0
1989         if [[ $queue == "ni" ]]; then
1990                 wait_update $HOSTNAME \
1991                         "$LNETCTL net show -v 2 | \
1992                          grep -e $nid -e ping_count | grep -wA1 $nid | \
1993                          awk '/ping_count/{print \\\$NF}'" "$expect" "$max_wait"
1994                 rc=$?
1995                 $LNETCTL net show -v 2 | grep -e $nid -e ping_count
1996         elif [[ $queue == peer_ni ]]; then
1997                 wait_update $HOSTNAME \
1998                         "$LNETCTL peer show -v 2 --nid $nid | \
1999                          grep -v primary | \
2000                          grep -e $nid -e ping_count | grep -wA1 $nid | \
2001                          awk '/ping_count/{print \\\$NF}'" "$expect" "$max_wait"
2002                 rc=$?
2003                 $LNETCTL peer show -v 2 --nid $nid | grep -v primary |
2004                         grep -e $nid -e ping_count
2005         else
2006                 error "Unrecognized queue \"$queue\""
2007                 return 1
2008         fi
2009
2010         ((rc == 0)) || error "Unexpected ping count"
2011
2012         return 0
2013 }
2014
2015 test_210() {
2016         [[ ${NETTYPE} == kfi* ]] && skip "kfi doesn't support drop rules"
2017
2018         reinit_dlc || return $?
2019         add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
2020         add_net "${NETTYPE}1" "${INTERFACES[0]}" || return $?
2021
2022         local prim_nid=$($LCTL list_nids | head -n 1)
2023
2024         do_lnetctl discover $prim_nid ||
2025                 error "failed to discover myself"
2026
2027         local default=$($LNETCTL global show |
2028                         awk '/recovery_limit/{print $NF}')
2029         # Set recovery limit to 10 seconds.
2030         do_lnetctl set recovery_limit 10 ||
2031                 error "failed to set recovery_limit"
2032
2033         $LCTL set_param debug=+net
2034         $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -m GET -r 1 -e local_error
2035         $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -m GET -r 1 -e local_error
2036         $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -r 1
2037         $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -r 1
2038         do_lnetctl net set --health 0 --nid $prim_nid
2039
2040         check_ping_count "ni" "$prim_nid" "2" "10"
2041         check_nid_in_recovq "-l" "$prim_nid" "1"
2042
2043         check_ping_count "ni" "$prim_nid" "3" "10"
2044         check_nid_in_recovq "-l" "$prim_nid" "1"
2045
2046         $LCTL net_drop_del -a
2047
2048         reinit_dlc || return $?
2049         add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
2050         add_net "${NETTYPE}1" "${INTERFACES[0]}" || return $?
2051
2052         local prim_nid=$($LCTL list_nids | head -n 1)
2053
2054         do_lnetctl discover $prim_nid ||
2055                 error "failed to discover myself"
2056
2057         do_lnetctl set recovery_limit $default ||
2058                 error "failed to set recovery_limit"
2059
2060         default=$($LNETCTL global show |
2061                   awk '/max_recovery_ping_interval/{print $NF}')
2062         do_lnetctl set max_recovery_ping_interval 4 ||
2063                 error "failed to set max_recovery_ping_interval"
2064
2065         $LCTL set_param debug=+net
2066         $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -m GET -r 1 -e local_error
2067         $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -m GET -r 1 -e local_error
2068         $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -r 1
2069         $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -r 1
2070         do_lnetctl net set --health 0 --nid $prim_nid
2071
2072         check_ping_count "ni" "$prim_nid" "2" "10"
2073         check_nid_in_recovq "-l" "$prim_nid" "1"
2074
2075         check_ping_count "ni" "$prim_nid" "4" "10"
2076         check_nid_in_recovq "-l" "$prim_nid" "1"
2077
2078         $LCTL net_drop_del -a
2079
2080         do_lnetctl set max_recovery_ping_interval $default ||
2081                 error "failed to set max_recovery_ping_interval"
2082
2083         return 0
2084 }
2085 run_test 210 "Local NI recovery checks"
2086
2087 test_211() {
2088         [[ ${NETTYPE} == kfi* ]] && skip "kfi doesn't support drop rules"
2089
2090         reinit_dlc || return $?
2091         add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
2092         add_net "${NETTYPE}1" "${INTERFACES[0]}" || return $?
2093
2094         local prim_nid=$($LCTL list_nids | head -n 1)
2095
2096         do_lnetctl discover $prim_nid ||
2097                 error "failed to discover myself"
2098
2099         local default=$($LNETCTL global show |
2100                         awk '/recovery_limit/{print $NF}')
2101         # Set recovery limit to 10 seconds.
2102         do_lnetctl set recovery_limit 10 ||
2103                 error "failed to set recovery_limit"
2104
2105         $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -m GET -r 1 -e remote_error
2106         $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -m GET -r 1 -e remote_error
2107         $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -r 1
2108         $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -r 1
2109
2110         # Set health to 0 on one interface. This forces it onto the recovery
2111         # queue.
2112         do_lnetctl peer set --nid $prim_nid --health 0
2113
2114         check_nid_in_recovq "-p" "$prim_nid" "1"
2115
2116         # The peer should age out in 10-20 seconds
2117         check_nid_in_recovq "-p" "$prim_nid" "0" "20"
2118         # Ping count should reset to 0 when peer ages out
2119         check_ping_count "peer_ni" "$prim_nid" "0"
2120
2121         $LCTL net_drop_del -a
2122
2123         # Set health to force it back onto the recovery queue. Set to 500 means
2124         # in ~5 seconds it should be back at maximum value.
2125         # NB: we reset the recovery limit to 0 (indefinite) so the peer NI is
2126         # eligible again
2127         do_lnetctl set recovery_limit 0 ||
2128                 error "failed to set recovery_limit"
2129
2130         do_lnetctl peer set --nid $prim_nid --health 500
2131
2132         check_nid_in_recovq "-p" "$prim_nid" "1"
2133         check_nid_in_recovq "-p" "$prim_nid" "0" "20"
2134
2135         reinit_dlc || return $?
2136         add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
2137         add_net "${NETTYPE}1" "${INTERFACES[0]}" || return $?
2138
2139         local prim_nid=$($LCTL list_nids | head -n 1)
2140
2141         do_lnetctl discover $prim_nid ||
2142                 error "failed to discover myself"
2143
2144         do_lnetctl set recovery_limit $default ||
2145                 error "failed to set recovery_limit"
2146
2147         default=$($LNETCTL global show |
2148                   awk '/max_recovery_ping_interval/{print $NF}')
2149         do_lnetctl set max_recovery_ping_interval 4 ||
2150                 error "failed to set max_recovery_ping_interval"
2151
2152         $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -m GET -r 1 -e remote_error
2153         $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -m GET -r 1 -e remote_error
2154         $LCTL net_drop_add -s *@${NETTYPE} -d *@${NETTYPE} -r 1
2155         $LCTL net_drop_add -s *@${NETTYPE}1 -d *@${NETTYPE}1 -r 1
2156
2157         # Set health to 0 on one interface. This forces it onto the recovery
2158         # queue.
2159         do_lnetctl peer set --nid $prim_nid --health 0
2160
2161         check_ping_count "peer_ni" "$prim_nid" "1" "4"
2162         check_nid_in_recovq "-p" "$prim_nid" "1"
2163
2164         # After we detect the 1st ping above, the 4th ping should be sent after
2165         # ~13 seconds
2166         check_ping_count "peer_ni" "$prim_nid" "4" "14"
2167         check_nid_in_recovq "-p" "$prim_nid" "1"
2168
2169         $LCTL net_drop_del -a
2170
2171         do_lnetctl set max_recovery_ping_interval $default ||
2172                 error "failed to set max_recovery_ping_interval"
2173
2174         return 0
2175 }
2176 run_test 211 "Remote NI recovery checks"
2177
2178 test_212() {
2179         [[ ${NETTYPE} == kfi* ]] && skip "kfi doesn't support drop rules"
2180
2181         local rnodes=$(remote_nodes_list)
2182         [[ -z $rnodes ]] && skip "Need at least 1 remote node"
2183
2184         cleanup_lnet || error "Failed to cleanup before test execution"
2185
2186         # Loading modules should configure LNet with the appropriate
2187         # test-framework configuration
2188         load_lnet "config_on_load=1" || error "Failed to load modules"
2189
2190         local my_nid=$($LCTL list_nids | head -n 1)
2191         [[ -z $my_nid ]] &&
2192                 error "Failed to get primary NID for local host $HOSTNAME"
2193
2194         local rnode=$(awk '{print $1}' <<<$rnodes)
2195         local rnodenids=$(do_node $rnode $LCTL list_nids | xargs echo)
2196         local rloaded=false
2197
2198         if [[ -z $rnodenids ]]; then
2199                 do_rpc_nodes $rnode load_lnet "config_on_load=1"
2200                 rloaded=true
2201                 rnodenids=$(do_node $rnode $LCTL list_nids | xargs echo)
2202         fi
2203
2204         local rnodepnid=$(awk '{print $1}' <<< $rnodenids)
2205
2206         [[ -z $rnodepnid ]] &&
2207                 error "Failed to get primary NID for remote host $rnode"
2208
2209         log "Initial discovery"
2210         do_lnetctl discover --force $rnodepnid ||
2211                 error "Failed to discover $rnodepnid"
2212
2213         do_node $rnode "$LNETCTL discover --force $my_nid" ||
2214                 error "$rnode failed to discover $my_nid"
2215
2216         log "Fail local discover ping to set LNET_PEER_REDISCOVER flag"
2217         $LCTL net_drop_add -s "*@$NETTYPE" -d "*@$NETTYPE" -r 1 -e local_error
2218         do_lnetctl discover --force $rnodepnid &&
2219                 error "Discovery should have failed"
2220         $LCTL net_drop_del -a
2221
2222         local nid
2223         for nid in $rnodenids; do
2224                 # We need GET (PING) delay just long enough so we can trigger
2225                 # discovery on the remote peer
2226                 $LCTL net_delay_add -s "*@$NETTYPE" -d $nid -r 1 -m GET -l 3
2227                 $LCTL net_drop_add -s "*@$NETTYPE" -d $nid -r 1 -m GET -e local_error
2228                 # We need PUT (PUSH) delay just long enough so we can process
2229                 # the PING failure
2230                 $LCTL net_delay_add -s "*@$NETTYPE" -d $nid -r 1 -m PUT -l 6
2231         done
2232
2233         log "Force $HOSTNAME to discover $rnodepnid (in background)"
2234         # We want to get a PING sent that we know will eventually fail.
2235         # The delay rules we added will ensure the ping is not sent until
2236         # the PUSH is also in flight (see below), and the drop rule ensures that
2237         # when the PING is eventually sent it will error out
2238         do_lnetctl discover --force $rnodepnid &
2239         local pid1=$!
2240
2241         # We want a discovery PUSH from rnode to put rnode back on our
2242         # discovery queue. This should cause us to try and send a PUSH to rnode
2243         # while the PING is still outstanding.
2244         log "Force $rnode to discover $my_nid"
2245         do_node $rnode $LNETCTL discover --force $my_nid
2246
2247         # At this point we'll have both PING_SENT and PUSH_SENT set for the
2248         # rnode peer. Wait for the PING to error out which should terminate the
2249         # discovery process that we backgrounded.
2250         log "Wait for $pid1"
2251         wait $pid1
2252         log "Finished wait on $pid1"
2253
2254         # The PING send failure clears the PING_SENT flag and puts the peer back
2255         # on the discovery queue. When discovery thread processes the peer it
2256         # will mistakenly clear the PUSH_SENT flag (and set PUSH_FAILED).
2257         # Discovery will then complete for this peer even though we have an
2258         # outstanding PUSH.
2259         # When PUSH is actually unlinked it will be forced back onto the
2260         # discovery queue, but we no longer have a ref on the peer. When
2261         # discovery completes again, we'll trip the ASSERT in
2262         # lnet_destroy_peer_locked()
2263
2264         # Delete the delay rules to send the PUSH
2265         $LCTL net_delay_del -a
2266         # Delete the drop rules
2267         $LCTL net_drop_del -a
2268
2269         unload_modules ||
2270                 error "Failed to unload modules"
2271         if $rloaded; then
2272                 do_rpc_nodes $rnode unload_modules_local ||
2273                         error "Failed to unload modules on $rnode"
2274         fi
2275
2276         return 0
2277 }
2278 run_test 212 "Check discovery refcount loss bug (LU-14627)"
2279
2280 test_213() {
2281         [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
2282
2283         cleanup_netns || error "Failed to cleanup netns before test execution"
2284         cleanup_lnet || error "Failed to unload modules before test execution"
2285
2286         setup_fakeif || error "Failed to add fake IF"
2287         have_interface "$FAKE_IF" ||
2288                 error "Expect $FAKE_IF configured but not found"
2289
2290         reinit_dlc || return $?
2291
2292         add_net "tcp" "${INTERFACES[0]}" || return $?
2293         add_net "tcp" "$FAKE_IF" || return $?
2294
2295         local nid1=$(lctl list_nids | head -n 1)
2296         local nid2=$(lctl list_nids | tail --lines 1)
2297
2298         [[ $(lctl which_nid $nid1 $nid2) == $nid1 ]] ||
2299                 error "Expect nid1 \"$nid1\" to be preferred"
2300
2301         [[ $(lctl which_nid $nid2 $nid1) == $nid2 ]] ||
2302                 error "Expect nid2 \"$nid2\" to be preferred"
2303
2304         return 0
2305 }
2306 run_test 213 "Check LNetDist calculation for multiple local NIDs"
2307
2308 function check_ni_status() {
2309         local nid="$1"
2310         local expect="$2"
2311
2312         local status=$($LNETCTL net show |
2313                        grep -A 1 ${nid} |
2314                        awk '/status/{print $NF}')
2315
2316         echo "NI ${nid} expect status \"${expect}\" found \"${status}\""
2317         if [[ $status != $expect ]]; then
2318                 error "Error: Expect NI status \"$expect\" for NID \"$nid\" but found \"$status\""
2319         fi
2320
2321         return 0
2322 }
2323
2324 test_214() {
2325         [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
2326
2327         cleanup_netns || error "Failed to cleanup netns before test execution"
2328         cleanup_lnet || error "Failed to unload modules before test execution"
2329
2330         setup_fakeif || error "Failed to add fake IF"
2331         have_interface "$FAKE_IF" ||
2332                 error "Expect $FAKE_IF configured but not found"
2333
2334         reinit_dlc || return $?
2335
2336         add_net "tcp" "${INTERFACES[0]}" || return $?
2337         add_net "tcp" "$FAKE_IF" || return $?
2338
2339         local nid1=$(lctl list_nids | head -n 1)
2340         local nid2=$(lctl list_nids | tail --lines 1)
2341
2342         check_ni_status "0@lo" up
2343         check_ni_status "$nid1" up
2344         check_ni_status "$nid2" up
2345
2346         do_lnetctl ping --source $nid2 $nid1 ||
2347                 error "$LNETCTL ping --source $nid2 $nid1 failed"
2348
2349         echo "Set $FAKE_IF down"
2350         echo "ip link set dev $FAKE_IF down"
2351         ip link set dev $FAKE_IF down
2352         check_ni_status "0@lo" up
2353         check_ni_status "$nid1" up
2354         check_ni_status "$nid2" down
2355 }
2356 run_test 214 "Check local NI status when link is downed"
2357
2358 get_ni_stat() {
2359         local nid=$1
2360         local stat=$2
2361
2362         $LNETCTL net show -v 2 |
2363                 egrep -e nid -e $stat |
2364                 grep -wA 1 $nid |
2365                 awk '/'$stat':/{print $NF}'
2366 }
2367
2368 ni_stats_pre() {
2369         local nidvar s
2370         for nidvar in nid1 nid2; do
2371                 for stat in send_count recv_count; do
2372                         s=$(get_ni_stat ${!nidvar} $stat)
2373                         eval ${nidvar}_pre_${stat}=$s
2374                 done
2375         done
2376 }
2377
2378 ni_stats_post() {
2379         local nidvar s
2380         for nidvar in nid1 nid2; do
2381                 for stat in send_count recv_count; do
2382                         s=$(get_ni_stat ${!nidvar} $stat)
2383                         eval ${nidvar}_post_${stat}=$s
2384                 done
2385         done
2386 }
2387
2388 ni_stat_changed() {
2389         local nidvar=$1
2390         local stat=$2
2391
2392         local pre post
2393         eval pre=\${${nidvar}_pre_${stat}}
2394         eval post=\${${nidvar}_post_${stat}}
2395
2396         echo "${!nidvar} pre ${stat} $pre post ${stat} $post"
2397
2398         [[ $pre -ne $post ]]
2399 }
2400
2401 test_215() {
2402         cleanup_netns || error "Failed to cleanup netns before test execution"
2403         cleanup_lnet || error "Failed to unload modules before test execution"
2404
2405         reinit_dlc || return $?
2406
2407         add_net "${NETTYPE}1" "${INTERFACES[0]}" || return $?
2408         add_net "${NETTYPE}2" "${INTERFACES[0]}" || return $?
2409
2410         local nid1=$($LCTL list_nids | head -n 1)
2411         local nid2=$($LCTL list_nids | tail --lines 1)
2412
2413         do_lnetctl peer add --prim $nid1 --nid $nid2 ||
2414                 error "Failed to add peer"
2415
2416         local npings=25
2417
2418         for nidvarA in nid1 nid2; do
2419                 src=${!nidvarA}
2420                 dst=${!nidvarA}
2421                 for nidvarB in nid1 nid2; do
2422                         [[ $nidvarA == $nidvarB ]] && continue
2423
2424                         ni_stats_pre
2425
2426                         echo "$LNETCTL ping $dst x $npings"
2427                         for i in $(seq 1 $npings); do
2428                                 $LNETCTL ping $dst &>/dev/null ||
2429                                         error "$LNETCTL ping $dst failed"
2430                         done
2431
2432                         ni_stats_post
2433
2434                         # No source specified, sends to either NID should cause
2435                         # counts to increase across both NIs
2436                         for nidvar in nid1 nid2; do
2437                                 for stat in send_count recv_count; do
2438                                         ni_stat_changed $nidvar $stat ||
2439                                                 error "$stat unchanged for ${!nidvar}"
2440                                 done
2441                         done
2442
2443                         ni_stats_pre
2444
2445                         echo "$LNETCTL ping --source $src $dst x $npings"
2446                         for i in $(seq 1 $npings); do
2447                                 $LNETCTL ping --source $src $dst &>/dev/null ||
2448                                         error "$LNETCTL ping --source $src $dst failed"
2449                         done
2450
2451                         ni_stats_post
2452
2453                         # src nid == dest nid means stats for the _other_ NI
2454                         # should be unchanged
2455                         for nidvar in nid1 nid2; do
2456                                 for stat in send_count recv_count; do
2457                                         if [[ ${!nidvar} == $src ]]; then
2458                                                 ni_stat_changed $nidvar $stat ||
2459                                                         error "$stat unchanged for ${!nidvar}"
2460                                         else
2461                                                 ni_stat_changed $nidvar $stat &&
2462                                                         error "$stat changed for ${!nidvar}"
2463                                         fi
2464                                 done
2465                         done
2466                 done
2467                 # Double number of pings for next iteration because the net
2468                 # sequence numbers will have diverged
2469                 npings=$(($npings * 2))
2470         done
2471
2472         # Ping from nid1 to nid2 should fail
2473         do_lnetctl ping --source $nid1 $nid2 &&
2474                 error "ping from $nid1 to $nid2 should fail"
2475
2476         # Ping from nid2 to nid1 should fail
2477         do_lnetctl ping --source $nid2 $nid1 &&
2478                 error "ping from $nid2 to $nid1 should fail"
2479
2480         return 0
2481 }
2482 run_test 215 "Test lnetctl ping --source option"
2483
2484 test_216() {
2485         [[ ${NETTYPE} == kfi* ]] && skip "kfi doesn't support drop rules"
2486
2487         local rc=0
2488
2489         reinit_dlc || return $?
2490
2491         add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
2492         add_net "${NETTYPE}1" "${INTERFACES[0]}" || return $?
2493
2494         local nids=( $($LCTL list_nids | xargs echo) )
2495
2496         do_lnetctl discover ${nids[0]} ||
2497                 error "Initial discovery failed"
2498
2499         do_lnetctl ping --source ${nids[0]} ${nids[0]} ||
2500                 error "Initial ping failed $?"
2501
2502         do_lnetctl ping --source ${nids[1]} ${nids[1]} ||
2503                 error "Initial ping failed $?"
2504
2505         local src dst
2506         for src in "${nids[@]}"; do
2507                 for dst in "${nids[@]}"; do
2508                         $LCTL net_drop_add -r 1 -s $src -d $dst -e network_timeout
2509                 done
2510         done
2511
2512         do_lnetctl ping ${nids[0]} || rc=$?
2513
2514         $LCTL net_drop_del -a
2515
2516         [[ $rc -eq 0 ]] &&
2517                 error "expected ping to fail"
2518
2519         check_nid_in_recovq "-p" "${nids[0]}" "0"
2520         check_nid_in_recovq "-l" "${nids[0]}" "1"
2521
2522         return 0
2523 }
2524 run_test 216 "Failed send to peer NI owned by local host should not trigger peer NI recovery"
2525
2526 test_217() {
2527         reinit_dlc || return $?
2528
2529         [[ $($LNETCTL net show | grep -c nid) -ne 1 ]] &&
2530                 error "Unexpected number of NIs after initalizing DLC"
2531
2532         do_lnetctl discover 0@lo ||
2533                 error "Failed to discover 0@lo"
2534
2535         unload_modules
2536 }
2537 run_test 217 "Don't leak memory when discovering peer with nnis <= 1"
2538
2539 test_218() {
2540         [[ ${NETTYPE} == kfi* ]] && skip "kfi doesn't support drop rules"
2541
2542         reinit_dlc || return $?
2543
2544         [[ ${#INTERFACES[@]} -lt 2 ]] &&
2545                 skip "Need two LNet interfaces"
2546
2547         add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
2548
2549         local nid1=$($LCTL list_nids | head -n 1)
2550
2551         do_lnetctl ping $nid1 ||
2552                 error "ping failed"
2553
2554         add_net "${NETTYPE}" "${INTERFACES[1]}" || return $?
2555
2556         local nid2=$($LCTL list_nids | tail --lines 1)
2557
2558         do_lnetctl ping $nid2 ||
2559                 error "ping failed"
2560
2561         $LCTL net_drop_add -s $nid1 -d $nid1 -e local_error -r 1
2562
2563         do_lnetctl ping --source $nid1 $nid1 &&
2564                 error "ping should have failed"
2565
2566         local health_recovered
2567         local i
2568
2569         for i in $(seq 1 5); do
2570                 health_recovered=$($LNETCTL net show -v 2 |
2571                                    grep -c 'health value: 1000')
2572
2573                 if [[ $health_recovered -ne 2 ]]; then
2574                         echo "Wait 1 second for health to recover"
2575                         sleep 1
2576                 else
2577                         break
2578                 fi
2579         done
2580
2581         health_recovered=$($LNETCTL net show -v 2 |
2582                            grep -c 'health value: 1000')
2583
2584         $LCTL net_drop_del -a
2585
2586         [[ $health_recovered -ne 2 ]] &&
2587                 do_lnetctl net show -v 2 | egrep -e nid -e health &&
2588                 error "Health hasn't recovered"
2589
2590         return 0
2591 }
2592 run_test 218 "Local recovery pings should exercise all available paths"
2593
2594 test_219() {
2595         reinit_dlc || return $?
2596         add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
2597         add_net "${NETTYPE}1" "${INTERFACES[0]}" || return $?
2598
2599         local nid1=$(lctl list_nids | head -n 1)
2600         local nid2=$(lctl list_nids | tail --lines 1)
2601
2602         do_lnetctl ping $nid1 ||
2603                 error "Ping failed $?"
2604         do_lnetctl ping $nid2 ||
2605                 error "Ping failed $?"
2606
2607         do_lnetctl discover $nid2 ||
2608                 error "Discovery failed"
2609
2610         $LNETCTL peer show --nid $nid1 | grep -q $nid2 ||
2611                 error "$nid2 is not listed under $nid1"
2612 }
2613 run_test 219 "Consolidate peer entries"
2614
2615 do_net_add() {
2616         local node=$1
2617         local net=$2
2618         local if=$3
2619
2620         do_rpc_nodes $node "$LNETCTL net add --net $net --if $if" ||
2621                 error "add $net on interface $if on node $node failed rc=$?"
2622 }
2623
2624 do_route_add() {
2625         local node=$1
2626         local net=$2
2627         local gw=$3
2628
2629         do_node $node "$LNETCTL route add --net $net --gateway $gw" ||
2630                 error "route add to $net via $gw failed rc=$?"
2631 }
2632
2633 ROUTER=""
2634 ROUTER_INTERFACES=()
2635 RPEER=""
2636 RPEER_INTERFACES=()
2637 init_router_test_vars() {
2638         local rnodes=$(remote_nodes_list)
2639         [[ -z $rnodes || $(wc -w <<<$rnodes) -lt 2 ]] &&
2640                 skip "Need at least 2 remote nodes found \"$rnodes\""
2641
2642         ROUTER=$(awk '{print $1}' <<<$rnodes)
2643         RPEER=$(awk '{print $2}' <<<$rnodes)
2644
2645         rnodes=$(comma_list $ROUTER $RPEER)
2646         local all_nodes=$(comma_list $rnodes $HOSTNAME)
2647
2648         do_nodes $rnodes $LUSTRE_RMMOD ||
2649                 error "failed to unload modules"
2650
2651         do_rpc_nodes $rnodes "load_lnet config_on_load=1" ||
2652                 error "Failed to load and configure LNet"
2653
2654         ROUTER_INTERFACES=( $(do_rpc_nodes --quiet $ROUTER lnet_if_list) )
2655
2656         RPEER_INTERFACES=( $(do_rpc_nodes --quiet $RPEER lnet_if_list) )
2657
2658         do_nodes $all_nodes $LUSTRE_RMMOD ||
2659                 error "Failed to unload modules"
2660
2661         [[ ${#INTERFACES[@]} -eq 0 ]] &&
2662                 error "No interfaces configured for local host $HOSTNAME"
2663         [[ ${#ROUTER_INTERFACES[@]} -eq 0 ]] &&
2664                 error "No interfaces configured for router $ROUTER"
2665         [[ ${#RPEER_INTERFACES[@]} -eq 0 ]] &&
2666                 error "No interfaces configured for remote peer $RPEER"
2667
2668         return 0
2669 }
2670
2671 ROUTER_NIDS=()
2672 RPEER_NIDS=()
2673 LNIDS=()
2674 LOCAL_NET=${NETTYPE}1
2675 REMOTE_NET=${NETTYPE}2
2676 setup_router_test() {
2677         local mod_opts="$@"
2678
2679         (( $MDS1_VERSION >= $(version_code 2.15.0) )) ||
2680                 skip "need at least 2.15.0 for load_lnet"
2681
2682         if [[ ${#RPEER_INTERFACES[@]} -eq 0 ]]; then
2683                 init_router_test_vars ||
2684                         return $?
2685         fi
2686
2687         local all_nodes=$(comma_list $ROUTER $RPEER $HOSTNAME)
2688
2689         do_nodes $all_nodes $LUSTRE_RMMOD ||
2690                 error "failed to unload modules"
2691
2692         mod_opts+=" alive_router_check_interval=5"
2693         mod_opts+=" router_ping_timeout=5"
2694         mod_opts+=" large_router_buffers=4"
2695         mod_opts+=" small_router_buffers=8"
2696         mod_opts+=" tiny_router_buffers=16"
2697         do_rpc_nodes $all_nodes load_lnet "${mod_opts}" ||
2698                 error "Failed to load lnet"
2699
2700         do_nodes $all_nodes "$LNETCTL lnet configure" ||
2701                 error "Failed to initialize DLC"
2702
2703         do_net_add $ROUTER $LOCAL_NET ${ROUTER_INTERFACES[0]} ||
2704                 return $?
2705
2706         do_net_add $ROUTER $REMOTE_NET ${ROUTER_INTERFACES[0]} ||
2707                 return $?
2708
2709         do_net_add $RPEER $REMOTE_NET ${RPEER_INTERFACES[0]} ||
2710                 return $?
2711
2712         add_net $LOCAL_NET ${INTERFACES[0]} ||
2713                 return $?
2714
2715         ROUTER_NIDS=( $(do_node $ROUTER $LCTL list_nids 2>/dev/null |
2716                         xargs echo) )
2717         RPEER_NIDS=( $(do_node $RPEER $LCTL list_nids 2>/dev/null |
2718                        xargs echo) )
2719         LNIDS=( $($LCTL list_nids 2>/dev/null | xargs echo) )
2720 }
2721
2722 do_route_del() {
2723         local node=$1
2724         local net=$2
2725         local gw=$3
2726
2727         do_nodesv $node "if $LNETCTL route show --net $net --gateway $gw; then \
2728                                 $LNETCTL route del --net $net --gateway $gw;   \
2729                          else                                                  \
2730                                 exit 0;                                        \
2731                          fi"
2732 }
2733
2734 cleanup_router_test() {
2735         local all_nodes=$(comma_list $HOSTNAME $ROUTER $RPEER)
2736
2737         do_route_del $HOSTNAME $REMOTE_NET ${ROUTER_NIDS[0]} ||
2738                 error "Failed to delete $REMOTE_NET route"
2739
2740         do_route_del $RPEER $LOCAL_NET ${ROUTER_NIDS[1]} ||
2741                 error "Failed to delete $LOCAL_NET route"
2742
2743         do_nodes $all_nodes $LUSTRE_RMMOD ||
2744                 error "failed to unload modules"
2745
2746         return 0
2747 }
2748
2749 check_route_aliveness() {
2750         local node="$1"
2751         local expected="$2"
2752
2753         local lctl_actual
2754         local lnetctl_actual
2755         local chk_intvl
2756         local i
2757
2758         chk_intvl=$(cat /sys/module/lnet/parameters/alive_router_check_interval)
2759
2760         lctl_actual=$(do_node $node $LCTL show_route | awk '{print $7}')
2761         lnetctl_actual=$(do_node $node $LNETCTL route show -v |
2762                          awk '/state/{print $NF}')
2763
2764         for ((i = 0; i < $chk_intvl; i++)); do
2765                 if [[ $lctl_actual == $expected ]] &&
2766                    [[ $lnetctl_actual == $expected ]]; then
2767                         break
2768                 fi
2769
2770                 echo "wait 1s for route state change"
2771                 sleep 1
2772
2773                 lctl_actual=$(do_node $node $LCTL show_route | awk '{print $7}')
2774                 lnetctl_actual=$(do_node $node $LNETCTL route show -v |
2775                                  awk '/state/{print $NF}')
2776         done
2777
2778         [[ $lctl_actual != $expected ]] &&
2779                 error "Wanted \"$expected\" lctl found \"$lctl_actual\""
2780
2781         [[ $lnetctl_actual != $expected ]] &&
2782                 error "Wanted \"$expected\" lnetctl found \"$lnetctl_actual\""
2783
2784         return 0
2785 }
2786
2787 check_router_ni_status() {
2788         local expected_local="$1"
2789         local expected_remote="$2"
2790
2791         local actual_local
2792         local actual_remote
2793         local chk_intvl
2794         local timeout
2795         local i
2796
2797         chk_intvl=$(cat /sys/module/lnet/parameters/alive_router_check_interval)
2798         timeout=$(cat /sys/module/lnet/parameters/router_ping_timeout)
2799
2800         actual_local=$(do_node $ROUTER "$LNETCTL net show --net $LOCAL_NET" |
2801                        awk '/status/{print $NF}')
2802         actual_remote=$(do_node $ROUTER "$LNETCTL net show --net $REMOTE_NET" |
2803                         awk '/status/{print $NF}')
2804
2805         for ((i = 0; i < $((chk_intvl + timeout)); i++)); do
2806                 if [[ $actual_local == $expected_local ]] &&
2807                    [[ $actual_remote == $expected_remote ]]; then
2808                         break
2809                 fi
2810
2811                 echo "wait 1s for NI state change"
2812                 sleep 1
2813
2814                 actual_local=$(do_node $ROUTER \
2815                                "$LNETCTL net show --net $LOCAL_NET" |
2816                                 awk '/status/{print $NF}')
2817                 actual_remote=$(do_node $ROUTER \
2818                                 "$LNETCTL net show --net $REMOTE_NET" |
2819                                 awk '/status/{print $NF}')
2820         done
2821
2822         [[ $actual_local == $expected_local ]] ||
2823                 error "$LOCAL_NET should be $expected_local"
2824
2825         [[ $actual_remote == $expected_remote ]] ||
2826                 error "$REMOTE_NET should be $expected_remote"
2827
2828         return 0
2829 }
2830
2831 do_basic_rtr_test() {
2832         do_node $ROUTER "$LNETCTL set routing 1" ||
2833                 error "Unable to enable routing on $ROUTER"
2834
2835         do_route_add $HOSTNAME $REMOTE_NET ${ROUTER_NIDS[0]} ||
2836                 return $?
2837
2838         do_route_add $RPEER $LOCAL_NET ${ROUTER_NIDS[1]} ||
2839                 return $?
2840
2841         check_route_aliveness "$HOSTNAME" "up" ||
2842                 return $?
2843
2844         check_route_aliveness "$RPEER" "up" ||
2845                 return $?
2846
2847         do_lnetctl ping ${RPEER_NIDS[0]} ||
2848                 error "Failed to ping ${RPEER_NIDS[0]}"
2849
2850         do_node $RPEER "$LNETCTL ping ${LNIDS[0]}" ||
2851                 error "$RPEER failed to ping ${LNIDS[0]}"
2852
2853         return 0
2854 }
2855
2856 test_220() {
2857         setup_router_test || return $?
2858
2859         do_basic_rtr_test || return $?
2860
2861         do_rpc_nodes $HOSTNAME,$RPEER load_module ../lnet/selftest/lnet_selftest ||
2862                 error "Failed to load lnet-selftest module"
2863
2864         $LSTSH -H -t $HOSTNAME -f $RPEER -m rw -s 4k ||
2865                 error "lst failed"
2866
2867         $LSTSH -H -t $HOSTNAME -f $RPEER -m rw ||
2868                 error "lst failed"
2869
2870         cleanup_router_test || return $?
2871 }
2872 run_test 220 "Add routes w/default options - check aliveness"
2873
2874 test_221() {
2875         setup_router_test lnet_peer_discovery_disabled=1 || return $?
2876
2877         do_basic_rtr_test || return $?
2878
2879         cleanup_router_test || return $?
2880 }
2881 run_test 221 "Add routes w/DD disabled - check aliveness"
2882
2883 do_aarf_enabled_test() {
2884         do_node $ROUTER "$LNETCTL set routing 1" ||
2885                 error "Unable to enable routing on $ROUTER"
2886
2887         check_router_ni_status "down" "down"
2888
2889         do_lnetctl ping ${RPEER_NIDS[0]} &&
2890                 error "Ping should fail"
2891
2892         do_node $RPEER "$LNETCTL ping ${LNIDS[0]}" &&
2893                 error "$RPEER ping should fail"
2894
2895         # Adding a route should cause the router's NI on LOCAL_NET to get up
2896         do_route_add $HOSTNAME $REMOTE_NET ${ROUTER_NIDS[0]} ||
2897                 return $?
2898
2899         check_router_ni_status "up" "down" ||
2900                 return $?
2901
2902         # But route should still be down because of avoid_asym_router_failure
2903         check_route_aliveness "$HOSTNAME" "down" ||
2904                 return $?
2905
2906         do_lnetctl ping ${RPEER_NIDS[0]} &&
2907                 error "Ping should fail"
2908
2909         do_node $RPEER "$LNETCTL ping ${LNIDS[0]}" &&
2910                 error "$RPEER ping should fail"
2911
2912         # Adding the symmetric route should cause the remote NI to go up and
2913         # routes to go up
2914         do_route_add $RPEER $LOCAL_NET ${ROUTER_NIDS[1]} ||
2915                 return $?
2916
2917         check_router_ni_status "up" "up" ||
2918                 return $?
2919
2920         check_route_aliveness "$HOSTNAME" "up" ||
2921                 return $?
2922
2923         check_route_aliveness "$RPEER" "up" ||
2924                 return $?
2925
2926         do_lnetctl ping ${RPEER_NIDS[0]} ||
2927                 error "Failed to ping ${RPEER_NIDS[0]}"
2928
2929         do_node $RPEER "$LNETCTL ping ${LNIDS[0]}" ||
2930                 error "$RPEER failed to ping ${LNIDS[0]}"
2931
2932         # Stop LNet on local host
2933         do_lnetctl lnet unconfigure ||
2934                 error "Failed to stop LNet rc=$?"
2935
2936         check_router_ni_status "down" "up" ||
2937                 return $?
2938
2939         check_route_aliveness "$RPEER" "down" ||
2940                 return $?
2941
2942         do_lnetctl ping ${RPEER_NIDS[0]} &&
2943                 error "Ping should fail"
2944
2945         do_node $RPEER "$LNETCTL ping ${LNIDS[0]}" &&
2946                 error "$RPEER ping should fail"
2947
2948         return 0
2949 }
2950
2951 test_222() {
2952         setup_router_test avoid_asym_router_failure=1 || return $?
2953
2954         do_aarf_enabled_test || return $?
2955
2956         cleanup_router_test || return $?
2957 }
2958 run_test 222 "Check avoid_asym_router_failure=1"
2959
2960 test_223() {
2961         local opts="avoid_asym_router_failure=1 lnet_peer_discovery_disabled=1"
2962
2963         setup_router_test $opts || return $?
2964
2965         do_aarf_enabled_test || return $?
2966
2967         cleanup_router_test || return $?
2968 }
2969 run_test 223 "Check avoid_asym_router_failure=1 w/DD disabled"
2970
2971 do_aarf_disabled_test() {
2972         do_node $ROUTER "$LNETCTL set routing 1" ||
2973                 error "Unable to enable routing on $ROUTER"
2974
2975         check_router_ni_status "down" "down"
2976
2977         do_route_add $HOSTNAME $REMOTE_NET ${ROUTER_NIDS[0]} ||
2978                 return $?
2979
2980         check_router_ni_status "up" "down" ||
2981                 return $?
2982
2983         check_route_aliveness "$HOSTNAME" "up" ||
2984                 return $?
2985
2986         do_route_add $RPEER $LOCAL_NET ${ROUTER_NIDS[1]} ||
2987                 return $?
2988
2989         check_router_ni_status "up" "up" ||
2990                 return $?
2991
2992         check_route_aliveness "$HOSTNAME" "up" ||
2993                 return $?
2994
2995         check_route_aliveness "$RPEER" "up" ||
2996                 return $?
2997
2998         do_lnetctl ping ${RPEER_NIDS[0]} ||
2999                 error "Failed to ping ${RPEER_NIDS[0]}"
3000
3001         do_node $RPEER "$LNETCTL ping ${LNIDS[0]}" ||
3002                 error "$RPEER failed to ping ${LNIDS[0]}"
3003
3004         # Stop LNet on local host
3005         do_lnetctl lnet unconfigure ||
3006                 error "Failed to stop LNet rc=$?"
3007
3008         check_router_ni_status "down" "up" ||
3009                 return $?
3010
3011         check_route_aliveness "$RPEER" "up" ||
3012                 return $?
3013
3014         return 0
3015 }
3016
3017 test_224() {
3018         setup_router_test avoid_asym_router_failure=0 ||
3019                 return $?
3020
3021         do_aarf_disabled_test ||
3022                 return $?
3023
3024         cleanup_router_test ||
3025                 return $?
3026 }
3027 run_test 224 "Check avoid_asym_router_failure=0"
3028
3029 test_225() {
3030         local opts="avoid_asym_router_failure=0 lnet_peer_discovery_disabled=1"
3031
3032         setup_router_test $opts || return $?
3033
3034         do_aarf_disabled_test || return $?
3035
3036         cleanup_router_test ||
3037                 return $?
3038 }
3039 run_test 225 "Check avoid_asym_router_failure=0 w/DD disabled"
3040
3041 test_230() {
3042         [[ ${NETTYPE} == tcp* ]] ||
3043                 skip "Need tcp NETTYPE"
3044         # LU-12815
3045         echo "Check valid values; Should succeed"
3046         local i
3047         local lnid
3048         local cmd
3049         for ((i = 4; i < 16; i+=1)); do
3050                 reinit_dlc || return $?
3051                 add_net "tcp" "${INTERFACES[0]}" || return $?
3052                 do_lnetctl net set --all --conns-per-peer $i ||
3053                         error "should have succeeded $?"
3054                 $LNETCTL net show -v 1 | grep -q "conns_per_peer: $i" ||
3055                         error "failed to set conns-per-peer to $i"
3056                 lnid="$(lctl list_nids | head -n 1)"
3057                 do_lnetctl ping "$lnid" ||
3058                         error "failed to ping myself"
3059
3060                 # "lctl --net tcp conn_list" prints the list of active
3061                 # connections. Since we're pinging ourselves, there should be
3062                 # 2 Control connections plus 2*conns_per_peer connections
3063                 # created (one Bulk Input, one Bulk Output in each pair).
3064                 # Here's the sample output for conns_per_peer set to 1:
3065                 # 12345-1.1.1.1@tcp I[0]host01->host01:988 2626560/1061296 nonagle
3066                 # 12345-1.1.1.1@tcp O[0]host01->host01:1022 2626560/1061488 nonagle
3067                 # 12345-1.1.1.1@tcp C[0]host01->host01:988 2626560/1061296 nonagle
3068                 # 12345-1.1.1.1@tcp C[0]host01->host01:1023 2626560/1061488 nonagle
3069                 cmd="printf 'network tcp\nconn_list\n' | lctl | grep -c '$lnid'"
3070
3071                 # Expect 2+conns_per_peer*2 connections. Wait no longer
3072                 # than 2 seconds.
3073                 wait_update $HOSTNAME "$cmd" "$((2+i*2))" 2 ||
3074                         error "expected number of tcp connections $((2+i*2))"
3075         done
3076
3077         reinit_dlc || return $?
3078         add_net "tcp" "${INTERFACES[0]}" || return $?
3079         echo "Set > 127; Should fail"
3080         do_lnetctl net set --all --conns-per-peer 128 &&
3081                 error "should have failed $?"
3082
3083         reinit_dlc || return $?
3084         add_net "tcp" "${INTERFACES[0]}" || return $?
3085
3086         local default=$($LNETCTL net show -v 1 |
3087                         awk '/conns_per_peer/{print $NF}')
3088
3089         echo "Set < 0; Should be ignored"
3090         do_lnetctl net set --all --conns-per-peer -1 ||
3091                 error "should have succeeded $?"
3092         $LNETCTL net show -v 1 | grep -q "conns_per_peer: ${default}" ||
3093                 error "Did not stay at default"
3094 }
3095 run_test 230 "Test setting conns-per-peer"
3096
3097 test_231() {
3098         reinit_dlc || return $?
3099
3100         local net=${NETTYPE}231
3101
3102         do_lnetctl net add --net $net --if ${INTERFACES[0]} ||
3103                 error "Failed to add net"
3104
3105         $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
3106         sed -i 's/peer_timeout: .*$/peer_timeout: 0/' \
3107                 $TMP/sanity-lnet-$testnum-expected.yaml
3108
3109         reinit_dlc || return $?
3110
3111         do_lnetctl import $TMP/sanity-lnet-$testnum-expected.yaml ||
3112                 error "Failed to import configuration"
3113
3114         $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
3115
3116         compare_yaml_files || error "Wrong config after import"
3117
3118         do_lnetctl net del --net $net --if ${INTERFACES[0]} ||
3119                 error "Failed to delete net $net"
3120
3121         do_lnetctl net add --net $net --if ${INTERFACES[0]} --peer-timeout=0 ||
3122                 error "Failed to add net with peer-timeout=0"
3123
3124         $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
3125
3126         compare_yaml_files || error "Wrong config after lnetctl net add"
3127
3128         reinit_dlc || return $?
3129
3130         # lnet/include/lnet/lib-lnet.h defines DEFAULT_PEER_TIMEOUT 180
3131         sed -i 's/peer_timeout: .*$/peer_timeout: 180/' \
3132                 $TMP/sanity-lnet-$testnum-expected.yaml
3133
3134         sed -i '/^.*peer_timeout:.*$/d' $TMP/sanity-lnet-$testnum-actual.yaml
3135
3136         do_lnetctl import $TMP/sanity-lnet-$testnum-actual.yaml ||
3137                 error "Failed to import config without peer_timeout"
3138
3139         $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
3140
3141         compare_yaml_files
3142 }
3143 run_test 231 "Check DLC handling of peer_timeout parameter"
3144
3145 ### Test that linux route is added for each ni
3146 test_250() {
3147         local skip_param
3148
3149         [[ ${NETTYPE} == tcp* ]] ||
3150                 skip "Need tcp NETTYPE"
3151         reinit_dlc || return $?
3152         add_net "tcp" "${INTERFACES[0]}" || return $?
3153
3154         skip_param=$(cat /sys/module/ksocklnd/parameters/skip_mr_route_setup)
3155         [[ ${skip_param:-0} -ne 0 ]] &&
3156                 skip "Need skip_mr_route_setup=0 found $skip_param"
3157
3158         ip route show table ${INTERFACES[0]} | grep -q "${INTERFACES[0]}"
3159 }
3160 run_test 250 "test that linux routes are added"
3161
3162 test_251() {
3163         [[ ${NETTYPE} =~ kfi* ]] ||
3164                 skip "Need kfi NETTYPE"
3165
3166         reinit_dlc || return $?
3167         add_net "kfi" "${INTERFACES[0]}" || return $?
3168         add_net "kfi1" "${INTERFACES[0]}" || return $?
3169         add_net "kfi10" "${INTERFACES[0]}" || return $?
3170         return 0
3171 }
3172 run_test 251 "Define multiple kfi networks on single interface"
3173
3174 test_252() {
3175         setup_health_test false || return $?
3176
3177         local rc=0
3178
3179         do_rpc_nodes $RNODE unload_modules_local || rc=$?
3180
3181         if [[ $rc -ne 0 ]]; then
3182                 cleanup_health_test || return $?
3183
3184                 error "Failed to unload modules on $RNODE rc=$rc"
3185         else
3186                 RLOADED=false
3187         fi
3188
3189         local ts1=$(date +%s)
3190
3191         do_lnetctl ping --timeout 15 ${RNIDS[0]} &&
3192                 error "Expected ping ${RNIDS[0]} to fail"
3193
3194         local ts2=$(date +%s)
3195
3196         local delta=$(echo "$ts2 - $ts1" | bc)
3197
3198         [[ $delta -lt 15 ]] ||
3199                 error "Ping took longer than expected to fail: $delta"
3200
3201         cleanup_health_test
3202 }
3203 run_test 252 "Ping to down peer should unlink quickly"
3204
3205 do_expired_message_drop_test() {
3206         local rnid lnid old_tto
3207
3208         old_tto=$($LNETCTL global show |
3209                   awk '/transaction_timeout:/{print $NF}')
3210
3211         [[ -z $old_tto ]] &&
3212                 error "Cannot determine LNet transaction timeout"
3213
3214         local tto=10
3215
3216         do_lnetctl set transaction_timeout "${tto}" ||
3217                 error "Failed to set transaction_timeout"
3218
3219         # We want to consume all peer credits for at least transaction_timeout
3220         # seconds
3221         local delay
3222
3223         delay=$((tto + 1))
3224
3225         for lnid in "${LNIDS[@]}"; do
3226                 for rnid in "${RNIDS[@]}"; do
3227                         $LCTL net_delay_add -s "${lnid}" -d "${rnid}" \
3228                                 -l "${delay}" -r 1 -m GET
3229                 done
3230         done
3231
3232         declare -a pcs
3233
3234         pcs=( $($LNETCTL peer show -v --nid "${RNIDS[0]}" |
3235                 awk '/max_ni_tx_credits:/{print $NF}' |
3236                 xargs echo) )
3237
3238         [[ ${#RNIDS[@]} -ne ${#pcs[@]} ]] &&
3239                 error "Expect ${#RNIDS[@]} peer credit values found ${#pcs[@]}"
3240
3241         local rnet lnid lnet i j
3242
3243         # Need to use --source for multi-rail configs to ensure we consume
3244         # all available peer credits
3245         for ((i = 0; i < ${#RNIDS[@]}; i++)); do
3246                 local ping_args="--timeout $((delay+2))"
3247
3248                 rnet=${RNIDS[i]##*@}
3249                 for lnid in ${LNIDS[@]}; do
3250                         lnet=${lnid##*@}
3251                         [[ $rnet == $lnet ]] && break
3252                 done
3253
3254                 ping_args+=" --source ${lnid} ${RNIDS[i]}"
3255                 for j in $(seq 1 "${pcs[i]}"); do
3256                         $LNETCTL ping ${ping_args} 1>/dev/null &
3257                 done
3258
3259                 echo "Issued ${pcs[i]} pings to ${RNIDS[i]} from $lnid"
3260         done
3261
3262         # This ping should be queued on peer NI tx credit
3263         $LNETCTL ping --timeout $((delay+2)) "${RNIDS[0]}" &
3264
3265         sleep ${delay}
3266
3267         $LCTL net_delay_del -a
3268
3269         wait
3270
3271         # Messages sent from the delay list do not go through
3272         # lnet_post_send_locked(), thus we should only have a single drop
3273         local dropped
3274
3275         dropped=$($LNETCTL peer show -v 2 --nid "${RNIDS[0]}" |
3276                         grep -A 2 dropped_stats |
3277                         awk '/get:/{print $2}' |
3278                         xargs echo |
3279                         sed 's/ /\+/g' | bc)
3280
3281         [[ $dropped -ne 1 ]] &&
3282                 error "Expect 1 dropped GET but found $dropped"
3283
3284         do_lnetctl set transaction_timeout "${old_tto}"
3285
3286         return 0
3287 }
3288
3289 test_253() {
3290         setup_health_test false || return $?
3291
3292         do_expired_message_drop_test || return $?
3293
3294         cleanup_health_test
3295 }
3296 run_test 253 "Message delayed beyond deadline should be dropped (single-rail)"
3297
3298 test_254() {
3299         setup_health_test true || return $?
3300
3301         do_expired_message_drop_test || return $?
3302
3303         cleanup_health_test
3304 }
3305 run_test 254 "Message delayed beyond deadline should be dropped (multi-rail)"
3306
3307 test_255() {
3308         [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
3309
3310         reinit_dlc || return $?
3311
3312         cleanup_lnet || return $?
3313
3314         local routes_str="o2ib ${IF0_NET}.[$GW_HOSTNUM-$((GW_HOSTNUM+4))]"
3315         local network_str="${NETTYPE}(${INTERFACES[0]})"
3316
3317         load_lnet "networks=\"${network_str}\" routes=\"${routes_str}\"" ||
3318                 error "Failed to load LNet"
3319
3320         $LCTL net up ||
3321                 error "Failed to load LNet with networks=\"${network_str}\" routes=\"${routes_str}\""
3322
3323         cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
3324 net:
3325     - net type: ${NETTYPE}
3326       local NI(s):
3327         - interfaces:
3328               0: ${INTERFACES[0]}
3329 EOF
3330         append_net_tunables tcp
3331
3332         echo "route:" >> $TMP/sanity-lnet-$testnum-expected.yaml
3333         for i in $(seq $GW_HOSTNUM $((GW_HOSTNUM + 4))); do
3334                 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
3335     - net: o2ib
3336       gateway: ${IF0_NET}.${i}@${NETTYPE}
3337       hop: -1
3338       priority: 0
3339       health_sensitivity: 1
3340 EOF
3341         done
3342
3343         echo "peer:" >> $TMP/sanity-lnet-$testnum-expected.yaml
3344         for i in $(seq $GW_HOSTNUM $((GW_HOSTNUM + 4))); do
3345                 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
3346     - primary nid: ${IF0_NET}.${i}@${NETTYPE}
3347       Multi-Rail: False
3348       peer ni:
3349         - nid: ${IF0_NET}.${i}@${NETTYPE}
3350 EOF
3351         done
3352
3353         append_global_yaml
3354
3355         $LNETCTL export --backup >  $TMP/sanity-lnet-$testnum-actual.yaml ||
3356                 error "export failed $?"
3357
3358         validate_gateway_nids
3359 }
3360 run_test 255 "Use lnet routes param with pdsh syntax"
3361
3362 test_300() {
3363         # LU-13274
3364         local header
3365         local out=$TMP/$tfile
3366         local prefix=/usr/include/linux/lnet
3367
3368         # We use a hard coded prefix so that this test will not fail
3369         # when run in tree.
3370         CC=${CC:-cc}
3371         if ! which $CC > /dev/null 2>&1; then
3372                 skip_env "$CC is not installed"
3373         fi
3374
3375         cleanup_lnet || exit 1
3376         load_lnet
3377
3378         local cc_args="-Wall -Werror -std=c99 -c -x c /dev/null -o $out"
3379         if ! [[ -d $prefix ]]; then
3380                 # Assume we're running in tree and fixup the include path.
3381                 prefix=$LUSTRE/../lnet/include/uapi/linux/lnet
3382                 cc_args+=" -I $LUSTRE/../lnet/include/uapi"
3383         fi
3384
3385         for header in $prefix/*.h; do
3386                 if ! [[ -f "$header" ]]; then
3387                         continue
3388                 fi
3389
3390                 echo "$CC $cc_args -include $header"
3391                 $CC $cc_args -include $header ||
3392                         error "cannot compile '$header'"
3393         done
3394         rm -f $out
3395 }
3396 run_test 300 "packaged LNet UAPI headers can be compiled"
3397
3398 # LU-16081 lnet: Memory leak on adding existing interface
3399
3400 test_301() {
3401         reinit_dlc || return $?
3402         do_lnetctl net add --net ${NETTYPE} --if ${INTERFACES[0]} ||
3403                 error "Failed to add net"
3404         do_lnetctl net add --net ${NETTYPE} --if ${INTERFACES[0]} &&
3405                 error "add net should have failed"
3406         do_lnetctl net del --net ${NETTYPE} --if ${INTERFACES[0]} ||
3407                 error "Failed to del net"
3408         unload_modules
3409 }
3410 run_test 301 "Check for dynamic adds of same/wrong interface (memory leak)"
3411
3412 test_302() {
3413         ! [[ $NETTYPE =~ (tcp|o2ib) ]] && skip "Need tcp or o2ib NETTYPE"
3414         reinit_dlc || return $?
3415
3416         add_net "${NETTYPE}" "${INTERFACES[0]}" || return $?
3417
3418         local nid=$($LCTL list_nids)
3419
3420         do_lnetctl ping ${nid} ||
3421                 error "pinging self failed $?"
3422         do_lnetctl debug peer --nid ${nid} ||
3423                 error "failed to dump peer debug info $?"
3424 }
3425 run_test 302 "Check that peer debug info can be dumped"
3426
3427 test_303() {
3428         [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
3429
3430         setup_health_test true || return $?
3431
3432         cleanup_netns || error "Failed to cleanup netns before test execution"
3433         setup_fakeif || error "Failed to add fake IF"
3434         have_interface "$FAKE_IF" ||
3435                 error "Expect $FAKE_IF configured but not found"
3436
3437         add_net "${NETTYPE}99" "$FAKE_IF" || return $?
3438
3439         local nid=$($LCTL list_nids | tail --lines 1)
3440
3441         # Our updated config should be pushed to RNODE
3442         local found=$(do_node $RNODE "$LNETCTL peer show --nid $nid")
3443
3444         [[ -z $found ]] && error "Peer not updated on $RNODE"
3445
3446         local prim=$($LCTL list_nids | head -n 1)
3447
3448         if ! grep -q -- "- primary nid: $prim"<<<"${found}"; then
3449                 echo "$found"
3450                 error "Wrong primary nid"
3451         fi
3452
3453         echo "Set $FAKE_IF down"
3454         echo "ip link set dev $FAKE_IF down"
3455         ip link set dev $FAKE_IF down
3456         check_ni_status "$nid" down
3457
3458         local hval=$(do_node $RNODE "$LNETCTL peer show --nid $nid -v 2 | \
3459                                      grep -e '- nid:' -e 'health value:'")
3460
3461         hval=$(grep -A 1 $nid<<<"$hval" | tail -n 1 | awk '{print $NF}')
3462         (( hval < 1000 )) ||
3463                 error "Expect $hval < 1000"
3464
3465         return 0
3466 }
3467 run_test 303 "Check peer NI health after link down"
3468
3469 test_304() {
3470         [[ ${NETTYPE} == tcp* ]] || skip "Need tcp NETTYPE"
3471
3472         cleanup_netns || error "Failed to cleanup netns before test execution"
3473         cleanup_lnet || error "Failed to unload modules before test execution"
3474
3475         setup_fakeif || error "Failed to add fake IF"
3476         have_interface "$FAKE_IF" ||
3477                 error "Expect $FAKE_IF configured but not found"
3478
3479         reinit_dlc || return $?
3480
3481         add_net "tcp" "${INTERFACES[0]}" || return $?
3482         add_net "tcp" "$FAKE_IF" || return $?
3483
3484         local nid1=$(lctl list_nids | head -n 1)
3485         local nid2=$(lctl list_nids | tail --lines 1)
3486
3487         check_ni_status "$nid1" up
3488         check_ni_status "$nid2" up
3489
3490         do_lnetctl peer add --prim_nid ${nid2} --lock_prim ||
3491                 error "peer add failed $?"
3492         local locked_peer_state=($(do_lnetctl peer show -v 4 --nid ${nid2} |
3493                 awk '/peer state/{print $NF}'))
3494
3495         # Expect peer state bits:
3496         #   LNET_PEER_MULTI_RAIL(0) | LNET_PEER_CONFIGURED(3) |
3497         #   LNET_PEER_LOCK_PRIMARY(20)
3498         (( $locked_peer_state != "1048585")) &&
3499                 error "Wrong peer state \"$locked_peer_state\" expected 1048585"
3500
3501         # Clear LNET_PEER_CONFIGURED bit and verify
3502         do_lnetctl peer set --nid ${nid2} --state 1048577 ||
3503                 error "peer add failed $?"
3504         locked_peer_state=($(do_lnetctl peer show -v 4 --nid ${nid2} |
3505                 awk '/peer state/{print $NF}'))
3506         (( $locked_peer_state != "1048577")) &&
3507                 error "Wrong peer state \"$locked_peer_state\" expected 1048577"
3508         do_lnetctl discover ${nid1} ||
3509                 error "Failed to discover peer"
3510
3511         # Expect nid2 and nid1 peer entries to be consolidated,
3512         # nid2 to stay primary
3513         cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
3514 peer:
3515     - primary nid: ${nid2}
3516       Multi-Rail: True
3517       peer ni:
3518         - nid: ${nid1}
3519           state: NA
3520         - nid: ${nid2}
3521           state: NA
3522 EOF
3523         $LNETCTL peer show > $TMP/sanity-lnet-$testnum-actual.yaml
3524         compare_yaml_files ||
3525                 error "Unexpected peer configuration"
3526
3527         locked_peer_state=($(do_lnetctl peer show -v 4 --nid ${nid2} |
3528                 awk '/peer state/{print $NF}'))
3529         # Expect peer state bits to be added:
3530         #   LNET_PEER_DISCOVERED(4) | LNET_PEER_NIDS_UPTODATE(8)
3531         (( $locked_peer_state != "1048849")) &&
3532                 error "Wrong peer state \"$locked_peer_state\" expected 1048849"
3533         return 0
3534 }
3535 run_test 304 "Check locked primary peer nid consolidation"
3536
3537 check_parameter() {
3538         local para=$1
3539         local value=$2
3540
3541         echo "check parameter ${para} value ${value}"
3542
3543         return $(( $(do_lnetctl net show -v | \
3544                      tee /dev/stderr | \
3545                      grep -c "^ \+${para}: ${value}$") != 1 ))
3546 }
3547
3548 static_config() {
3549         local module=$1
3550         local setting=$2
3551
3552         cleanup_lnet || error "Failed to cleanup LNet"
3553
3554         load_module ../libcfs/libcfs/libcfs ||
3555                 error "Failed to load module libcfs rc = $?"
3556
3557         load_module ../lnet/lnet/lnet ||
3558                 error "Failed to load module lnet rc = $?"
3559
3560         echo "loading ${module} ${setting} type ${NETTYPE}"
3561         load_module "${module}" "${setting}" ||
3562                 error "Failed to load module ${module} rc = $?"
3563
3564         do_lnetctl lnet configure --all || error "lnet configure failed rc = $?"
3565
3566         return 0
3567 }
3568
3569 test_310() {
3570         local value=65
3571
3572         if [[ ${NETTYPE} == tcp* ]];then
3573                 static_config "../lnet/klnds/socklnd/ksocklnd" \
3574                               "sock_timeout=${value}"
3575         elif [[ ${NETTYPE} == o2ib* ]]; then
3576                 static_config "../lnet/klnds/o2iblnd/ko2iblnd" \
3577                               "timeout=${value}"
3578         elif [[ ${NETTYPE} == gni* ]]; then
3579                 static_config "../lnet/klnds/gnilnd/kgnilnd" \
3580                               "timeout=${value}"
3581         else
3582                 skip "NETTYPE ${NETTYPE} not supported"
3583         fi
3584
3585         check_parameter "timeout" $value
3586
3587         return $?
3588 }
3589 run_test 310 "Set timeout and verify"
3590
3591 test_311() {
3592         [[ $NETTYPE == kfi* ]] ||
3593                 skip "Need kfi network type"
3594
3595         setupall || error "setupall failed"
3596
3597         mkdir -p $DIR/$tdir || error "mkdir failed"
3598         dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 oflag=direct ||
3599                 error "dd write failed"
3600
3601         local list=$(comma_list $(osts_nodes))
3602
3603 #define CFS_KFI_FAIL_WAIT_SEND_COMP1 0xF115
3604         do_nodes $list $LCTL set_param fail_loc=0x8000F115
3605         dd if=$DIR/$tdir/$tfile of=/dev/null bs=1M count=1 ||
3606                 error "dd read failed"
3607
3608         rm -f $DIR/$tdir/$tfile
3609         rmdir $DIR/$tdir
3610
3611         cleanupall || error "Failed cleanup"
3612 }
3613 run_test 311 "Fail bulk put in send wait completion"
3614
3615 test_312() {
3616         [[ $NETTYPE == kfi* ]] ||
3617                 skip "Need kfi network type"
3618
3619         setupall || error "setupall failed"
3620
3621         mkdir -p $DIR/$tdir || error "mkdir failed"
3622
3623         local list=$(comma_list $(osts_nodes))
3624
3625 #define CFS_KFI_FAIL_WAIT_SEND_COMP3 0xF117
3626         do_nodes $list $LCTL set_param fail_loc=0x8000F117
3627         dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 oflag=direct ||
3628                 error "dd write failed"
3629
3630         local tfile2="$DIR/$tdir/testfile2"
3631
3632         do_nodes $list $LCTL set_param fail_loc=0x8000F117
3633         dd if=$DIR/$tdir/$tfile of=$tfile2 bs=1M count=1 oflag=direct ||
3634                 error "dd read failed"
3635
3636         rm -f $DIR/$tdir/$tfile
3637         rm -f $tfile2
3638         rmdir $DIR/$tdir
3639
3640         cleanupall || error "Failed cleanup"
3641 }
3642 run_test 312 "TAG_RX_OK is possible after TX_FAIL"
3643
3644 check_udsp_prio() {
3645         local target_net="${1}"
3646         local target_nid="${2}"
3647         local expect_net="${3}"
3648         local expect_nid="${4}"
3649         local type="${5}"
3650
3651         declare -a nids
3652         declare -a net_prios
3653         declare -a nid_prios
3654
3655         nids=( $($LNETCTL ${type} show -v 5 | awk '/- nid:/{print $NF}' |
3656                  xargs echo) )
3657
3658         net_prios=( $($LNETCTL ${type} show -v 5 |
3659                       awk '/net priority:/{print $NF}' | xargs echo) )
3660
3661         nid_prios=( $($LNETCTL ${type} show -v 5 |
3662                       awk '/nid priority:/{print $NF}' | xargs echo) )
3663
3664         (( ${#nids[@]} != ${#net_prios[@]} )) &&
3665                 error "Wrong # net prios ${#nids[@]} != ${#net_prios[@]}"
3666
3667         (( ${#nids[@]} != ${#nid_prios[@]} )) &&
3668                 error "Wrong # nid prios ${#nids[@]} != ${#nid_prios[@]}"
3669
3670         local i
3671
3672         for ((i = 0; i < ${#nids[@]}; i++)); do
3673                 [[ -n ${target_net} ]] &&
3674                         [[ ${nids[i]##*@} != "${target_net}" ]] &&
3675                         continue
3676                 [[ -n ${target_nid} ]] &&
3677                         [[ ${nids[i]} != "${target_nid}" ]] &&
3678                         continue
3679
3680                 echo "${nids[i]}: net_prio ${net_prios[i]} expect ${expect_net}"
3681                 (( net_prios[i] != expect_net )) &&
3682                         error "Wrong net priority \"${net_prios[i]}\" expect ${expect_net}"
3683
3684                 echo "${nids[i]}: nid_prio ${nid_prios[i]} expect ${expect_nid}"
3685                 (( nid_prios[i] != expect_nid )) &&
3686                         error "Wrong nid priority \"${nid_prios[i]}\" expect ${expect_nid}"
3687         done
3688
3689         return 0
3690 }
3691
3692 check_peer_udsp_prio() {
3693         check_udsp_prio "${1}" "${2}" "${3}" "${4}" "peer"
3694 }
3695
3696 check_net_udsp_prio() {
3697         check_udsp_prio "${1}" "${2}" "${3}" "${4}" "net"
3698 }
3699
3700 test_400() {
3701         reinit_dlc || return $?
3702
3703         do_lnetctl udsp add --src tcp --priority 0 ||
3704                 error "Failed to add udsp rule"
3705         do_lnetctl udsp del --idx 0 ||
3706                 error "Failed to del udsp rule"
3707         unload_modules
3708 }
3709 run_test 400 "Check for udsp add/delete net rule without net num"
3710
3711 test_401() {
3712         reinit_dlc || return $?
3713
3714         do_lnetctl net add --net ${NETTYPE} --if ${INTERFACES[0]} ||
3715                 error "Failed to add net"
3716
3717         do_lnetctl udsp add --dst ${NETTYPE} --prio 1 ||
3718                 error "Failed to add peer net priority rule"
3719
3720         do_lnetctl discover $($LCTL list_nids | head -n 1) ||
3721                 error "Failed to discover peer"
3722
3723         check_peer_udsp_prio "${NETTYPE}" "" "1" "-1"
3724
3725         return 0
3726 }
3727 run_test 401 "Discover peer after adding peer net UDSP rule"
3728
3729 test_402() {
3730         reinit_dlc || return $?
3731
3732         do_lnetctl udsp add --dst kfi --priority 0 ||
3733                 error "Failed to add UDSP rule"
3734
3735         do_lnetctl peer add --prim 402@kfi ||
3736                 error "Failed to add peer"
3737
3738         return 0
3739 }
3740 run_test 402 "Destination net rule should not panic"
3741
3742 complete_test $SECONDS
3743 cleanup_testsuite
3744 exit_status