found = true;
}
- if (pto >= 0 || pc > 0 || pbc > 0 || cre > 0 || cpp > -1) {
- tunables.lt_cmn.lct_peer_timeout = pto;
- tunables.lt_cmn.lct_peer_tx_credits = pc;
- tunables.lt_cmn.lct_peer_rtr_credits = pbc;
- tunables.lt_cmn.lct_max_tx_credits = cre;
+ tunables.lt_cmn.lct_peer_timeout = pto;
+ tunables.lt_cmn.lct_peer_tx_credits = pc;
+ tunables.lt_cmn.lct_peer_rtr_credits = pbc;
+ tunables.lt_cmn.lct_max_tx_credits = cre;
+ if (pto >= 0 || pc > 0 || pbc > 0 || cre > 0)
found = true;
- }
if (found && LNET_NETTYP(nw_descr.nw_id) == O2IBLND)
tunables.lt_tun.lnd_tun_u.lnd_o2ib.lnd_map_on_demand = UINT_MAX;
reinit_dlc || return $?
local net=${NETTYPE}231
+ local opts="--net $net --if ${INTERFACES[0]}"
- do_lnetctl net add --net $net --if ${INTERFACES[0]} ||
- error "Failed to add net"
+ do_lnetctl net add $opts || error "Failed to add net"
+
+ local lnd=$(basename $LNETLND)
+ local param_path="/sys/module/$lnd/parameters"
+
+ [[ -d $param_path ]] ||
+ error "Cannot find kernel params for $lnd at $param_path"
+
+ local lnd_pto=$(cat $param_path/peer_timeout)
+
+ # A value of -1 means we use the default peer timeout
+ #lnet/include/lnet/lib-lnet.h:#define DEFAULT_PEER_TIMEOUT 180
+ ((lnd_pto != -1)) || lnd_pto=180
$LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
- sed -i 's/peer_timeout: .*$/peer_timeout: 0/' \
- $TMP/sanity-lnet-$testnum-expected.yaml
- reinit_dlc || return $?
+ local pto=$(awk '/^\s+peer_timeout:/{print $NF}' \
+ $TMP/sanity-lnet-$testnum-expected.yaml)
- do_lnetctl import $TMP/sanity-lnet-$testnum-expected.yaml ||
- error "Failed to import configuration"
+ ((pto == lnd_pto)) ||
+ error "Expect peer_timeout $lnd_pto but found $pto"
$LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
+ compare_yaml_files ||
+ error "Unexpected config after net add without options"
- compare_yaml_files || error "Wrong config after import"
+ for pto in -1 0 60 180; do
+ reinit_dlc || return $?
- do_lnetctl net del --net $net --if ${INTERFACES[0]} ||
- error "Failed to delete net $net"
+ sed -i 's/peer_timeout: .*/peer_timeout: '$pto'/' \
+ $TMP/sanity-lnet-$testnum-expected.yaml
- do_lnetctl net add --net $net --if ${INTERFACES[0]} --peer-timeout=0 ||
- error "Failed to add net with peer-timeout=0"
+ do_lnetctl import $TMP/sanity-lnet-$testnum-expected.yaml ||
+ error "Failed to import configuration"
- $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
+ $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
- compare_yaml_files || error "Wrong config after lnetctl net add"
+ # Swap lnd_to for -1 in the expected output
+ ((pto != -1)) ||
+ sed -i 's/peer_timeout: '$pto'/peer_timeout: '$lnd_pto'/' \
+ $TMP/sanity-lnet-$testnum-expected.yaml
- reinit_dlc || return $?
+ compare_yaml_files || error "Wrong config after import"
- # lnet/include/lnet/lib-lnet.h defines DEFAULT_PEER_TIMEOUT 180
- sed -i 's/peer_timeout: .*$/peer_timeout: 180/' \
- $TMP/sanity-lnet-$testnum-expected.yaml
+ do_lnetctl net del $opts || error "Failed to delete net $net"
- sed -i '/^.*peer_timeout:.*$/d' $TMP/sanity-lnet-$testnum-actual.yaml
+ do_lnetctl net add $opts --peer-timeout=$pto ||
+ error "Failed to add net with peer-timeout=$pto"
- do_lnetctl import $TMP/sanity-lnet-$testnum-actual.yaml ||
- error "Failed to import config without peer_timeout"
+ $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
- $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
+ compare_yaml_files || error "Wrong config after lnetctl net add"
+ done
- compare_yaml_files
+ return 0
}
run_test 231 "Check DLC handling of peer_timeout parameter"