+ echo "Delete peer that has multiple nids (tcp)"
+ do_lnetctl peer add --prim_nid 7.7.7.7@tcp --nid 7.7.7.[8-12]@tcp ||
+ error "Peer add failed $?"
+ compare_peer_del "7.7.7.7@tcp"
+
+ echo "Delete peer that has multiple nids (o2ib)"
+ do_lnetctl peer add --prim_nid 7.7.7.7@o2ib --nid 7.7.7.[8-12]@o2ib ||
+ error "Peer add failed $?"
+ compare_peer_del "7.7.7.7@o2ib"
+
+ echo "Delete peer that has both tcp and o2ib nids"
+ do_lnetctl peer add --prim_nid 7.7.7.7@tcp \
+ --nid 7.7.7.[9-12]@tcp,7.7.7.[13-15]@o2ib ||
+ error "Peer add failed $?"
+ compare_peer_del "7.7.7.7@tcp"
+
+ echo "Delete peer with single nid (gni)"
+ do_lnetctl peer add --prim_nid 7@gni || error "Peer add failed $?"
+ compare_peer_del "7@gni"
+
+ echo "Delete peer that has multiple nids (gni)"
+ do_lnetctl peer add --prim_nid 7@gni --nid [8-12]@gni ||
+ error "Peer add failed $?"
+ compare_peer_del "7@gni"
+
+ echo "Delete peer that has tcp, o2ib and gni nids"
+ do_lnetctl peer add --prim_nid 7@gni \
+ --nid [8-12]@gni,7.7.7.[9-12]@tcp,7.7.7.[13-15]@o2ib ||
+ error "Peer add failed $?"
+ compare_peer_del "7@gni"
+}
+run_test 7 "Various peer delete tests"
+
+test_8() {
+ reinit_dlc || return $?
+
+ cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
+peer:
+ - primary nid: 8.8.8.8@tcp
+ Multi-Rail: True
+ peer ni:
+ - nid: 8.8.8.8@tcp
+ - nid: 8.8.8.10@tcp
+ - nid: 8.8.8.11@tcp
+ - nid: 8.8.8.12@tcp
+ - nid: 8.8.8.14@tcp
+ - nid: 8.8.8.15@tcp
+EOF
+ append_global_yaml
+
+ do_lnetctl peer add --prim_nid 8.8.8.8@tcp --nid 8.8.8.[10-15]@tcp ||
+ error "Peer add failed $?"
+ compare_peer_del "8.8.8.8@tcp" "8.8.8.13@tcp"
+}
+run_test 8 "Delete single secondary nid from peer (tcp)"
+
+test_9() {
+ reinit_dlc || return $?
+
+ cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
+peer:
+ - primary nid: 9.9.9.9@tcp
+ Multi-Rail: True
+ peer ni:
+ - nid: 9.9.9.9@tcp
+EOF
+ append_global_yaml
+
+ do_lnetctl peer add --prim_nid 9.9.9.9@tcp \
+ --nid 9.9.9.[11-16]@tcp || error "Peer add failed $?"
+ compare_peer_del "9.9.9.9@tcp" "9.9.9.[11-16]@tcp"
+}
+run_test 9 "Delete all secondary nids from peer (tcp)"
+
+test_10() {
+ reinit_dlc || return $?
+
+ cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
+peer:
+ - primary nid: 10.10.10.10@tcp
+ Multi-Rail: True
+ peer ni:
+ - nid: 10.10.10.10@tcp
+ - nid: 10.10.10.12@tcp
+ - nid: 10.10.10.13@tcp
+ - nid: 10.10.10.15@tcp
+ - nid: 10.10.10.16@tcp
+EOF
+ append_global_yaml
+ do_lnetctl peer add --prim_nid 10.10.10.10@tcp \
+ --nid 10.10.10.[12-16]@tcp || error "Peer add failed $?"
+ compare_peer_del "10.10.10.10@tcp" "10.10.10.14@tcp"
+}
+run_test 10 "Delete single secondary nid from peer (o2ib)"
+
+test_11() {
+ reinit_dlc || return $?
+
+ cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
+peer:
+ - primary nid: 11.11.11.11@tcp
+ Multi-Rail: True
+ peer ni:
+ - nid: 11.11.11.11@tcp
+EOF
+ append_global_yaml
+ do_lnetctl peer add --prim_nid 11.11.11.11@tcp \
+ --nid 11.11.11.[13-17]@tcp || error "Peer add failed $?"
+ compare_peer_del "11.11.11.11@tcp" "11.11.11.[13-17]@tcp"
+}
+run_test 11 "Delete all secondary nids from peer (o2ib)"
+
+test_12() {
+ reinit_dlc || return $?
+
+ cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
+peer:
+ - primary nid: 12.12.12.12@o2ib
+ Multi-Rail: True
+ peer ni:
+ - nid: 12.12.12.12@o2ib
+ - nid: 13.13.13.13@o2ib
+ - nid: 14.13.13.13@o2ib
+ - nid: 14.15.13.13@o2ib
+ - nid: 15.17.1.5@tcp
+ - nid: 15.17.1.10@tcp
+ - nid: 15.17.1.20@tcp
+EOF
+ append_global_yaml
+ do_lnetctl peer add --prim_nid 12.12.12.12@o2ib \
+ --nid [13-14/1].[13-15/2].13.13@o2ib,[15-16/3].[17-19/4].[1].[5-20/5]@tcp ||
+ error "Peer add failed $?"
+ compare_peer_del "12.12.12.12@o2ib" "13.15.13.13@o2ib,15.17.1.15@tcp"
+}
+run_test 12 "Delete a secondary nid from peer (tcp and o2ib)"
+
+test_13() {
+ reinit_dlc || return $?
+
+ cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
+peer:
+ - primary nid: 13.13.13.13@o2ib
+ Multi-Rail: True
+ peer ni:
+ - nid: 13.13.13.13@o2ib
+EOF
+ append_global_yaml
+ do_lnetctl peer add --prim_nid 13.13.13.13@o2ib \
+ --nid [14-15].[1-2/1].[1].[100-254/10]@tcp,14.14.[254].14@o2ib ||
+ error "Peer add failed $?"
+ compare_peer_del "13.13.13.13@o2ib" \
+ "[14-15].[1-2/1].[1].[100-254/10]@tcp,14.14.[254].14@o2ib"
+}
+run_test 13 "Delete all secondary nids from peer (tcp and o2ib)"
+
+create_nid() {
+ local num="$1"
+ local net="$2"
+
+ if [[ $net =~ gni* ]]; then
+ echo "${num}@${net}"
+ else
+ echo "${num}.${num}.${num}.${num}@${net}"
+ fi
+}
+
+create_mr_peer_yaml() {
+ local num_peers="$1"
+ local secondary_nids="$2"
+ local net="$3"
+
+ echo "Generating peer yaml for $num_peers peers with $secondary_nids secondary nids"
+ echo "peer:" >> $TMP/sanity-lnet-$testnum-expected.yaml
+ local i
+ local total_nids=$((num_peers + $((num_peers * secondary_nids))))
+ local created=0
+ local nidnum=1
+ while [[ $created -lt $num_peers ]]; do
+ local primary=$(create_nid ${nidnum} ${net})
+ cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
+ - primary nid: $primary
+ Multi-Rail: True
+ peer ni:
+ - nid: $primary
+EOF
+ local j
+ local start=$((nidnum + 1))
+ local end=$((nidnum + $secondary_nids))
+ for j in $(seq ${start} ${end}); do
+ local nid=$(create_nid $j ${net})
+ echo " - nid: $nid" >> $TMP/sanity-lnet-$testnum-expected.yaml
+ done
+ nidnum=$((end + 1))
+ ((created++))
+ done
+}
+
+test_14() {
+ reinit_dlc || return $?
+
+ echo "Create single peer, single nid, using import"
+ create_mr_peer_yaml 1 0 tcp
+ do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
+ error "Import failed $?"
+ append_global_yaml
+ $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
+ compare_yaml_files
+
+ echo "Delete single peer using import --del"
+ do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
+ error "Import failed $?"
+ rm -f $TMP/sanity-lnet-$testnum-expected.yaml
+ create_base_yaml_file
+ $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
+ compare_yaml_files
+}
+run_test 14 "import peer create/delete with single nid"
+
+test_15() {
+ reinit_dlc || return $?
+
+ echo "Create multiple peers, single nid per peer, using import"
+ create_mr_peer_yaml 5 0 o2ib
+ # The ordering of nids for this use-case is non-deterministic, so we
+ # we can't just diff the expected/actual output.
+ do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
+ error "Import failed $?"
+ $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
+ validate_peer_nids 5 0
+
+ echo "Delete multiple peers, single nid per peer, using import --del"
+ do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
+ error "Import failed $?"
+ rm -f $TMP/sanity-lnet-$testnum-expected.yaml
+ create_base_yaml_file
+ $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
+ compare_yaml_files
+}
+run_test 15 "import multi peer create/delete with single nid per peer"
+
+test_16() {
+ reinit_dlc || return $?
+
+ echo "Create single peer, multiple nids, using import"
+ create_mr_peer_yaml 1 5 tcp
+ do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
+ error "Import failed $?"
+ $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
+ validate_peer_nids 1 5
+
+ echo "Delete single peer, multiple nids, using import --del"
+ do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
+ error "Import failed $?"
+ rm -f $TMP/sanity-lnet-$testnum-expected.yaml
+ create_base_yaml_file
+ $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
+ compare_yaml_files
+}
+run_test 16 "import peer create/delete with multiple nids"
+
+test_17() {
+ reinit_dlc || return $?
+
+ echo "Create multiple peers, multiple nids per peer, using import"
+ create_mr_peer_yaml 5 7 o2ib
+ do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
+ error "Import failed $?"
+ $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
+ validate_peer_nids 5 7
+
+ echo "Delete multiple peers, multiple nids per peer, using import --del"
+ do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
+ error "Import failed $?"
+ rm -f $TMP/sanity-lnet-$testnum-expected.yaml
+ create_base_yaml_file
+ $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
+ compare_yaml_files
+}
+run_test 17 "import multi peer create/delete with multiple nids"
+
+test_18a() {
+ reinit_dlc || return $?
+
+ cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
+peer:
+ - primary nid: 1.1.1.1@tcp
+ Multi-Rail: True
+ peer ni:
+ - nid: 1.1.1.1@tcp
+ - nid: 2.2.2.2@tcp
+ - nid: 4.4.4.4@tcp
+ - nid: 3.3.3.3@o2ib
+ - nid: 5@gni
+EOF
+ echo "Import peer with 5 nids"
+ cat $TMP/sanity-lnet-$testnum-expected.yaml
+ do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
+ error "Import failed $?"
+ cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
+peer:
+ - primary nid: 1.1.1.1@tcp
+ Multi-Rail: True
+ peer ni:
+ - nid: 2.2.2.2@tcp
+ - nid: 3.3.3.3@o2ib
+ - nid: 5@gni
+EOF
+ echo "Delete three of the nids"
+ cat $TMP/sanity-lnet-$testnum-expected.yaml
+ do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml
+ cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
+peer:
+ - primary nid: 1.1.1.1@tcp
+ Multi-Rail: True
+ peer ni:
+ - nid: 1.1.1.1@tcp
+ - nid: 4.4.4.4@tcp
+EOF
+ echo "Check peer has expected nids remaining"
+ $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
+ append_global_yaml
+ compare_yaml_files
+}
+run_test 18a "Delete a subset of nids from a single peer using import --del"
+
+test_18b() {
+ reinit_dlc || return $?
+
+ cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
+peer:
+ - primary nid: 1.1.1.1@tcp
+ Multi-Rail: True
+ peer ni:
+ - nid: 1.1.1.1@tcp
+ - nid: 2.2.2.2@tcp
+ - nid: 4.4.4.4@tcp
+ - nid: 3.3.3.3@o2ib
+ - nid: 5@gni
+ - primary nid: 6.6.6.6@o2ib
+ Multi-Rail: True
+ peer ni:
+ - nid: 6.6.6.6@o2ib
+ - nid: 7.7.7.7@tcp
+ - nid: 8.8.8.8@tcp
+ - nid: 9.9.9.9@tcp
+ - nid: 10@gni
+EOF
+ echo "Import two peers with 5 nids each"
+ cat $TMP/sanity-lnet-$testnum-expected.yaml
+ do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
+ error "Import failed $?"
+ cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
+peer:
+ - primary nid: 1.1.1.1@tcp
+ Multi-Rail: True
+ peer ni:
+ - nid: 2.2.2.2@tcp
+ - nid: 3.3.3.3@o2ib
+ - nid: 5@gni
+ - primary nid: 6.6.6.6@o2ib
+ Multi-Rail: True
+ peer ni:
+ - nid: 7.7.7.7@tcp
+ - nid: 8.8.8.8@tcp
+ - nid: 10@gni
+EOF
+ echo "Delete three of the nids from each peer"
+ cat $TMP/sanity-lnet-$testnum-expected.yaml
+ do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml
+ cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
+peer:
+ - primary nid: 6.6.6.6@o2ib
+ Multi-Rail: True
+ peer ni:
+ - nid: 6.6.6.6@o2ib
+ - nid: 7.7.7.7@tcp
+ - primary nid: 1.1.1.1@tcp
+ Multi-Rail: True
+ peer ni:
+ - nid: 1.1.1.1@tcp
+ - nid: 4.4.4.4@tcp
+EOF
+ append_global_yaml
+ echo "Check peers have expected nids remaining"
+ $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
+ compare_yaml_files
+ validate_peer_nids 2 1
+}
+run_test 18b "Delete multiple nids from multiple peers using import --del"
+
+test_19() {
+ reinit_dlc || return $?
+ cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
+peer:
+ - primary nid: 19@gni
+ Multi-Rail: True
+ peer ni:
+ - nid: 19@gni
+EOF
+ append_global_yaml
+ compare_peer_add "19@gni"
+}
+run_test 19 "Add peer with single nid (gni)"
+
+test_20() {
+ reinit_dlc || return $?
+ cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
+peer:
+ - primary nid: 20@gni
+ Multi-Rail: True
+ peer ni:
+ - nid: 20@gni
+ - nid: 20.20.20.20@tcp
+ - nid: 20.20.20.20@o2ib
+EOF
+ append_global_yaml
+ compare_peer_add "20@gni" "20.20.20.20@tcp,20.20.20.20@o2ib"
+}
+run_test 20 "Add peer with gni primary and tcp, o2ib secondary"
+
+test_21() {
+ reinit_dlc || return $?
+ cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
+peer:
+ - primary nid: 21@gni
+ Multi-Rail: True
+ peer ni:
+ - nid: 21@gni
+ - nid: 22@gni
+ - nid: 23@gni
+ - nid: 24@gni
+ - nid: 25@gni
+EOF
+ append_global_yaml
+ echo"Add peer with nidrange (gni)"
+ compare_peer_add "21@gni" "[22-25]@gni" || error
+ echo "Add peer with nidrange that overlaps primary nid (gni)"
+ compare_peer_add "21@gni" "[21-25]@gni"
+}
+run_test 21 "Add peer with nidrange (gni)"
+
+test_22() {
+ reinit_dlc || return $?
+ cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
+peer:
+ - primary nid: 22@gni
+ Multi-Rail: True
+ peer ni:
+ - nid: 22@gni
+ - nid: 24@gni
+ - nid: 25@gni
+ - nid: 27@gni
+ - nid: 28@gni
+ - nid: 29@gni
+EOF
+ append_global_yaml
+ do_lnetctl peer add --prim_nid 22@gni --nid [24-29]@gni ||
+ error "Peer add failed $?"
+ compare_peer_del "22@gni" "26@gni"
+}
+run_test 22 "Delete single secondary nid from peer (gni)"
+
+test_23() {
+ reinit_dlc || return $?
+ cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
+peer:
+ - primary nid: 23@gni
+ Multi-Rail: True
+ peer ni:
+ - nid: 23@gni
+EOF
+ append_global_yaml
+
+ do_lnetctl peer add --prim_nid 23@gni --nid [25-29]@gni ||
+ error "Peer add failed $?"
+ compare_peer_del "23@gni" "[25-29]@gni"
+}
+run_test 23 "Delete all secondary nids from peer (gni)"
+
+test_24() {
+ reinit_dlc || return $?
+ cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
+peer:
+ - primary nid: 24@gni
+ Multi-Rail: True
+ peer ni:
+ - nid: 24@gni
+ - nid: 11@gni
+ - nid: 13.13.13.13@o2ib
+ - nid: 14.13.13.13@o2ib
+ - nid: 14.15.13.13@o2ib
+ - nid: 15.17.1.5@tcp
+ - nid: 15.17.1.10@tcp
+ - nid: 15.17.1.20@tcp
+EOF
+ append_global_yaml
+ do_lnetctl peer add --prim_nid 24@gni \
+ --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 ||
+ error "Peer add failed $?"
+ compare_peer_del "24@gni" "5@gni,13.15.13.13@o2ib,15.17.1.15@tcp"
+}
+run_test 24 "Delete a secondary nid from peer (tcp, o2ib and gni)"
+
+test_25() {
+ reinit_dlc || return $?
+ cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
+peer:
+ - primary nid: 25@gni
+ Multi-Rail: True
+ peer ni:
+ - nid: 25@gni
+EOF
+ append_global_yaml
+ do_lnetctl peer add --prim_nid 25@gni \
+ --nid [26-27].[4-10/3].26.26@tcp,26.26.26.26@o2ib,[30-35]@gni ||
+ error "Peer add failed $?"
+ compare_peer_del "25@gni" \
+ "[26-27].[4-10/3].26.26@tcp,26.26.26.26@o2ib,[30-35]@gni"
+}
+run_test 25 "Delete all secondary nids from peer (tcp, gni and o2ib)"
+
+test_99a() {
+ reinit_dlc || return $?
+
+ echo "Invalid prim_nid - peer add"
+ do_lnetctl peer add --prim_nid foobar &&
+ error "Command should have failed"
+
+ echo "Invalid prim_nid - peer del"
+ do_lnetctl peer del --prim_nid foobar &&
+ error "Command should have failed"
+
+ echo "Delete non-existing peer"
+ do_lnetctl peer del --prim_nid 1.1.1.1@o2ib &&
+ error "Command should have failed"
+
+ echo "Don't provide mandatory arguments peer del"
+ do_lnetctl peer del --nid 1.1.1.1@tcp &&
+ error "Command should have failed"
+
+ echo "Don't provide mandatory arguments peer add"
+ do_lnetctl peer add &&
+ error "Command should have failed"
+
+ echo "Invalid secondary nids"
+ do_lnetctl peer add --prim_nid 1.1.1.1@tcp --nid foobar &&
+ error "Command should have failed"
+
+ echo "Exceed max nids per peer"
+ do_lnetctl peer add --prim_nid 1.1.1.1@tcp --nid 1.1.1.[2-255]@tcp &&
+ error "Command should have failed"
+
+ echo "Invalid net type"
+ do_lnetctl peer add --prim_nid 1@foo &&
+ error "Command should have failed"
+
+ echo "Invalid nid format"
+ local invalid_nids="1@tcp 1@o2ib 1.1.1.1@gni"
+
+ local nid
+ for nid in ${invalid_nids}; do
+ echo "Check invalid primary nid - '$nid'"
+ do_lnetctl peer add --prim_nid $nid &&
+ error "Command should have failed"
+ done
+
+ local invalid_strs="[2-1]@gni [a-f/x]@gni 256.256.256.256@tcp"
+ invalid_strs+=" 1.1.1.1.[2-5/f]@tcp 1.]2[.3.4@o2ib"
+ invalid_strs+="1.[2-4,[5-6],7-8].1.1@tcp foobar"
+
+ local nidstr
+ for nidstr in ${invalid_strs}; do
+ echo "Check invalid nidstring - '$nidstr'"
+ do_lnetctl peer add --nid $nidstr &&
+ error "Command should have failed"
+ done
+
+ echo "Add non-local gateway"
+ do_lnetctl route add --net tcp --gateway 1@gni &&
+ error "Command should have failed"
+
+ return 0
+}
+run_test 99a "Check various invalid inputs to lnetctl peer"
+
+test_99b() {
+ reinit_dlc || return $?
+
+ create_base_yaml_file
+
+ cat <<EOF > $TMP/sanity-lnet-$testnum-invalid.yaml
+peer:
+ - primary nid: 99.99.99.99@tcp
+ Multi-Rail: Foobar
+ peer ni:
+ - nid: 99.99.99.99@tcp
+EOF
+ do_lnetctl import < $TMP/sanity-lnet-$testnum-invalid.yaml &&
+ error "import should have failed"
+ $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
+ compare_yaml_files
+}
+run_test 99b "Invalid value for Multi-Rail in yaml import"
+
+have_interface() {
+ local if="$1"
+ local ip=$(ip addr show dev $if | awk '/ inet /{print $2}')
+ [[ -n $ip ]]
+}
+
+add_net() {
+ local net="$1"
+ local if="$2"
+
+ reinit_dlc || return $?
+ load_module ../lnet/klnds/socklnd/ksocklnd ||
+ error "Can't load ksocklnd.ko"
+ do_lnetctl net add --net ${net} --if ${if} ||
+ error "Failed to add net ${net} on if ${if}"
+}
+
+compare_route_add() {
+ local rnet="$1"
+ local gw="$2"
+
+ local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
+
+ do_lnetctl route add --net ${rnet} --gateway ${gw} ||
+ error "route add failed $?"
+ # CPT configuration is pruned from the exported yaml, since the default
+ # can vary across test systems (unlike default values for things like
+ # peer_credits, peer_timeout, etc.)
+ $LNETCTL export --backup | grep -v CPT > $actual ||
+ error "export failed $?"
+ validate_gateway_nids
+ return $?
+}
+
+test_100() {
+ have_interface "eth0" || skip "Need eth0 interface with ipv4 configured"
+ add_net "tcp" "eth0"
+ cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
+net:
+ - net type: tcp
+ local NI(s):
+ - interfaces:
+ 0: eth0
+ tunables:
+ peer_timeout: 180
+ peer_credits: 8
+ peer_buffer_credits: 0
+ credits: 256
+route:
+ - net: tcp7
+ gateway: 7.7.7.7@tcp
+ hop: -1
+ priority: 0
+ health_sensitivity: 1
+peer:
+ - primary nid: 7.7.7.7@tcp
+ Multi-Rail: False
+ peer ni:
+ - nid: 7.7.7.7@tcp
+EOF
+ append_global_yaml
+ compare_route_add "tcp7" "7.7.7.7@tcp" || return $?
+ compare_yaml_files
+}
+run_test 100 "Add route with single gw (tcp)"
+
+test_101() {
+ have_interface "eth0" || skip "Need eth0 interface with ipv4 configured"
+ add_net "tcp" "eth0"
+ cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
+net:
+ - net type: tcp
+ local NI(s):
+ - interfaces:
+ 0: eth0
+ tunables:
+ peer_timeout: 180
+ peer_credits: 8
+ peer_buffer_credits: 0
+ credits: 256
+route:
+ - net: tcp8
+ gateway: 8.8.8.10@tcp
+ hop: -1
+ priority: 0
+ health_sensitivity: 1
+ - net: tcp8
+ gateway: 8.8.8.9@tcp
+ hop: -1
+ priority: 0
+ health_sensitivity: 1
+ - net: tcp8
+ gateway: 8.8.8.8@tcp
+ hop: -1
+ priority: 0
+ health_sensitivity: 1
+peer:
+ - primary nid: 8.8.8.9@tcp
+ Multi-Rail: False
+ peer ni:
+ - nid: 8.8.8.9@tcp
+ - primary nid: 8.8.8.10@tcp
+ Multi-Rail: False
+ peer ni:
+ - nid: 8.8.8.10@tcp
+ - primary nid: 8.8.8.8@tcp
+ Multi-Rail: False
+ peer ni:
+ - nid: 8.8.8.8@tcp
+EOF
+ append_global_yaml
+ compare_route_add "tcp8" "8.8.8.[8-10]@tcp"
+}
+run_test 101 "Add route with multiple gw (tcp)"
+
+compare_route_del() {
+ local rnet="$1"
+ local gw="$2"
+
+ local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
+
+ do_lnetctl route del --net ${rnet} --gateway ${gw} ||
+ error "route del failed $?"
+ $LNETCTL export --backup > $actual ||
+ error "export failed $?"
+ validate_gateway_nids
+}
+
+test_102() {
+ have_interface "eth0" || skip "Need eth0 interface with ipv4 configured"
+ add_net "tcp" "eth0"
+ $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
+ do_lnetctl route add --net tcp102 --gateway 102.102.102.102@tcp ||
+ error "route add failed $?"
+ compare_route_del "tcp102" "102.102.102.102@tcp"
+}
+run_test 102 "Delete route with single gw (tcp)"
+
+test_103() {
+ have_interface "eth0" || skip "Need eth0 interface with ipv4 configured"
+ add_net "tcp" "eth0"
+ $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
+ do_lnetctl route add --net tcp103 \
+ --gateway 103.103.103.[103-120/4]@tcp ||
+ error "route add failed $?"
+ compare_route_del "tcp103" "103.103.103.[103-120/4]@tcp"
+}
+run_test 103 "Delete route with multiple gw (tcp)"