cleanup_testsuite() {
trap "" EXIT
# Cleanup any tmp files created by the sub tests
- rm -f $TMP/sanity-lnet*
+ rm -f $TMP/sanity-lnet-*.yaml $LNET_PARAMS_FILE
cleanup_netns
cleanup_lnet
if $restore_mounts; then
error "No NID configured after module load"
fi
+do_lnetctl net show
+ip a
+
declare -a INTERFACES
for ((i = 0; i < ${#NIDS[@]}; i++)); do
ip=$(sed 's/^\(.*\)@.*$/\1/'<<<${NIDS[i]})
INTERFACES[i]=$(ip -o a s |
awk '$4 ~ /^'$ip'\//{print $2}')
+ INTERFACES=($(echo "${INTERFACES[@]}" | tr ' ' '\n' | uniq | tr '\n' ' '))
if [[ -z ${INTERFACES[i]} ]]; then
error "Can't determine interface name for NID ${NIDS[i]}"
elif [[ 1 -ne $(wc -w <<<${INTERFACES[i]}) ]]; then
local if0_ip=$(ip --oneline addr show dev ${INTERFACES[0]} |
awk '/inet /{print $4}' |
sed 's:/.*::')
+ if0_ip=($(echo "${if0_ip[@]}" | tr ' ' '\n' | uniq | tr '\n' ' '))
local ip2nets_str="tcp(${INTERFACES[0]}) $if0_ip"
echo "Configure single NID \"$ip2nets_str\""
}
run_test 213 "Check LNetDist calculation for multiple local NIDs"
+function check_ni_status() {
+ local nid="$1"
+ local expect="$2"
+
+ local status=$($LNETCTL net show |
+ grep -A 1 ${nid} |
+ awk '/status/{print $NF}')
+
+ echo "NI ${nid} expect status \"${expect}\" found \"${status}\""
+ if [[ $status != $expect ]]; then
+ error "Error: Expect NI status \"$expect\" for NID \"$nid\" but found \"$status\""
+ fi
+
+ return 0
+}
+
+test_214() {
+ have_interface "eth0" || skip "Need eth0 interface with ipv4 configured"
+
+ cleanup_netns || error "Failed to cleanup netns before test execution"
+ cleanup_lnet || error "Failed to unload modules before test execution"
+
+ setup_fakeif || error "Failed to add fake IF"
+ have_interface "$FAKE_IF" ||
+ error "Expect $FAKE_IF configured but not found"
+
+ reinit_dlc || return $?
+
+ add_net "tcp" "eth0" || return $?
+ add_net "tcp" "$FAKE_IF" || return $?
+
+ local nid1=$(lctl list_nids | head -n 1)
+ local nid2=$(lctl list_nids | tail --lines 1)
+
+ check_ni_status "0@lo" up
+ check_ni_status "$nid1" up
+ check_ni_status "$nid2" up
+
+ echo "Set $FAKE_IF down"
+ echo "ip link set dev $FAKE_IF down"
+ ip link set dev $FAKE_IF down
+ check_ni_status "0@lo" up
+ check_ni_status "$nid1" up
+ check_ni_status "$nid2" down
+}
+run_test 214 "Check local NI status when link is downed"
+
test_230() {
# LU-12815
echo "Check valid values; Should succeed"
local i
local lnid
- for ((i = 4; i < 16; i+=4)); do
+ local cmd
+ for ((i = 4; i < 16; i+=1)); do
reinit_dlc || return $?
add_net "tcp" "${INTERFACES[0]}" || return $?
do_lnetctl net set --all --conns-per-peer $i ||
lnid="$(lctl list_nids | head -n 1)"
do_lnetctl ping "$lnid" ||
error "failed to ping myself"
- printf 'network tcp\nconn_list\n' | lctl | grep -c "$lnid" | grep -q $((2+i*2)) ||
+ # "lctl --net tcp conn_list" prints the list of active
+ # connections. Since we're pinging ourselves, there should be
+ # 2 Control connections plus 2*conns_per_peer connections
+ # created (one Bulk Input, one Bulk Output in each pair).
+ # Here's the sample output for conns_per_peer set to 1:
+ # 12345-1.1.1.1@tcp I[0]host01->host01:988 2626560/1061296 nonagle
+ # 12345-1.1.1.1@tcp O[0]host01->host01:1022 2626560/1061488 nonagle
+ # 12345-1.1.1.1@tcp C[0]host01->host01:988 2626560/1061296 nonagle
+ # 12345-1.1.1.1@tcp C[0]host01->host01:1023 2626560/1061488 nonagle
+ cmd="printf 'network tcp\nconn_list\n' | lctl | grep -c '$lnid'"
+
+ # Expect 2+conns_per_peer*2 connections. Wait no longer
+ # than 2 seconds.
+ wait_update $HOSTNAME "$cmd" "$((2+i*2))" 2 ||
error "expected number of tcp connections $((2+i*2))"
done