Commit 5888a61c authored by Matthieu Baerts's avatar Matthieu Baerts Committed by David S. Miller

selftests: mptcp: launch mptcp_connect with timeout

'mptcp_connect' already has a timeout for poll() but in some cases, it
is not enough.

With "timeout" tool, we will force the command to fail if it doesn't
finish on time. Thanks to that, the script will continue and display
details about the current state before marking the test as failed.
Displaying this state is very important to be able to understand the
issue. Best to have our CI reporting the issue than just "the test
hanged".

Note that in mptcp_connect.sh, we were using a long timeout to validate
the fact we cannot create a socket if a sysctl is set. We don't need
this timeout.

In diag.sh, we want to send signals to mptcp_connect instances that have
been started in the netns. But we cannot send this signal to 'timeout'
otherwise that will stop the timeout and messages telling us SIGUSR1 has
been received will be printed. Instead of trying to find the right PID
and storing them in an array, we can simply use the output of
'ip netns pids' which is all the PIDs we want to send signal to.

Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/160Signed-off-by: default avatarMatthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: default avatarMat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent dc87efdb
...@@ -5,8 +5,9 @@ rndh=$(printf %x $sec)-$(mktemp -u XXXXXX) ...@@ -5,8 +5,9 @@ rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
ns="ns1-$rndh" ns="ns1-$rndh"
ksft_skip=4 ksft_skip=4
test_cnt=1 test_cnt=1
timeout_poll=100
timeout_test=$((timeout_poll * 2 + 1))
ret=0 ret=0
pids=()
flush_pids() flush_pids()
{ {
...@@ -14,18 +15,14 @@ flush_pids() ...@@ -14,18 +15,14 @@ flush_pids()
# give it some time # give it some time
sleep 1.1 sleep 1.1
for pid in ${pids[@]}; do ip netns pids "${ns}" | xargs --no-run-if-empty kill -SIGUSR1 &>/dev/null
[ -d /proc/$pid ] && kill -SIGUSR1 $pid >/dev/null 2>&1
done
pids=()
} }
cleanup() cleanup()
{ {
ip netns pids "${ns}" | xargs --no-run-if-empty kill -SIGKILL &>/dev/null
ip netns del $ns ip netns del $ns
for pid in ${pids[@]}; do
[ -d /proc/$pid ] && kill -9 $pid >/dev/null 2>&1
done
} }
ip -Version > /dev/null 2>&1 ip -Version > /dev/null 2>&1
...@@ -79,39 +76,57 @@ trap cleanup EXIT ...@@ -79,39 +76,57 @@ trap cleanup EXIT
ip netns add $ns ip netns add $ns
ip -n $ns link set dev lo up ip -n $ns link set dev lo up
echo "a" | ip netns exec $ns ./mptcp_connect -p 10000 -l 0.0.0.0 -t 100 >/dev/null & echo "a" | \
timeout ${timeout_test} \
ip netns exec $ns \
./mptcp_connect -p 10000 -l -t ${timeout_poll} \
0.0.0.0 >/dev/null &
sleep 0.1 sleep 0.1
pids[0]=$!
chk_msk_nr 0 "no msk on netns creation" chk_msk_nr 0 "no msk on netns creation"
echo "b" | ip netns exec $ns ./mptcp_connect -p 10000 127.0.0.1 -j -t 100 >/dev/null & echo "b" | \
timeout ${timeout_test} \
ip netns exec $ns \
./mptcp_connect -p 10000 -j -t ${timeout_poll} \
127.0.0.1 >/dev/null &
sleep 0.1 sleep 0.1
pids[1]=$!
chk_msk_nr 2 "after MPC handshake " chk_msk_nr 2 "after MPC handshake "
chk_msk_remote_key_nr 2 "....chk remote_key" chk_msk_remote_key_nr 2 "....chk remote_key"
chk_msk_fallback_nr 0 "....chk no fallback" chk_msk_fallback_nr 0 "....chk no fallback"
flush_pids flush_pids
echo "a" | ip netns exec $ns ./mptcp_connect -p 10001 -s TCP -l 0.0.0.0 -t 100 >/dev/null & echo "a" | \
pids[0]=$! timeout ${timeout_test} \
ip netns exec $ns \
./mptcp_connect -p 10001 -l -s TCP -t ${timeout_poll} \
0.0.0.0 >/dev/null &
sleep 0.1 sleep 0.1
echo "b" | ip netns exec $ns ./mptcp_connect -p 10001 127.0.0.1 -j -t 100 >/dev/null & echo "b" | \
pids[1]=$! timeout ${timeout_test} \
ip netns exec $ns \
./mptcp_connect -p 10001 -j -t ${timeout_poll} \
127.0.0.1 >/dev/null &
sleep 0.1 sleep 0.1
chk_msk_fallback_nr 1 "check fallback" chk_msk_fallback_nr 1 "check fallback"
flush_pids flush_pids
NR_CLIENTS=100 NR_CLIENTS=100
for I in `seq 1 $NR_CLIENTS`; do for I in `seq 1 $NR_CLIENTS`; do
echo "a" | ip netns exec $ns ./mptcp_connect -p $((I+10001)) -l 0.0.0.0 -t 100 -w 10 >/dev/null & echo "a" | \
pids[$((I*2))]=$! timeout ${timeout_test} \
ip netns exec $ns \
./mptcp_connect -p $((I+10001)) -l -w 10 \
-t ${timeout_poll} 0.0.0.0 >/dev/null &
done done
sleep 0.1 sleep 0.1
for I in `seq 1 $NR_CLIENTS`; do for I in `seq 1 $NR_CLIENTS`; do
echo "b" | ip netns exec $ns ./mptcp_connect -p $((I+10001)) 127.0.0.1 -t 100 -w 10 >/dev/null & echo "b" | \
pids[$((I*2 + 1))]=$! timeout ${timeout_test} \
ip netns exec $ns \
./mptcp_connect -p $((I+10001)) -w 10 \
-t ${timeout_poll} 127.0.0.1 >/dev/null &
done done
sleep 1.5 sleep 1.5
......
...@@ -11,7 +11,8 @@ cin="" ...@@ -11,7 +11,8 @@ cin=""
cout="" cout=""
ksft_skip=4 ksft_skip=4
capture=false capture=false
timeout=30 timeout_poll=30
timeout_test=$((timeout_poll * 2 + 1))
ipv6=true ipv6=true
ethtool_random_on=true ethtool_random_on=true
tc_delay="$((RANDOM%50))" tc_delay="$((RANDOM%50))"
...@@ -273,7 +274,7 @@ check_mptcp_disabled() ...@@ -273,7 +274,7 @@ check_mptcp_disabled()
ip netns exec ${disabled_ns} sysctl -q net.mptcp.enabled=0 ip netns exec ${disabled_ns} sysctl -q net.mptcp.enabled=0
local err=0 local err=0
LANG=C ip netns exec ${disabled_ns} ./mptcp_connect -t $timeout -p 10000 -s MPTCP 127.0.0.1 < "$cin" 2>&1 | \ LANG=C ip netns exec ${disabled_ns} ./mptcp_connect -p 10000 -s MPTCP 127.0.0.1 < "$cin" 2>&1 | \
grep -q "^socket: Protocol not available$" && err=1 grep -q "^socket: Protocol not available$" && err=1
ip netns delete ${disabled_ns} ip netns delete ${disabled_ns}
...@@ -430,14 +431,20 @@ do_transfer() ...@@ -430,14 +431,20 @@ do_transfer()
local stat_cookietx_last=$(get_mib_counter "${listener_ns}" "TcpExtSyncookiesSent") local stat_cookietx_last=$(get_mib_counter "${listener_ns}" "TcpExtSyncookiesSent")
local stat_cookierx_last=$(get_mib_counter "${listener_ns}" "TcpExtSyncookiesRecv") local stat_cookierx_last=$(get_mib_counter "${listener_ns}" "TcpExtSyncookiesRecv")
ip netns exec ${listener_ns} ./mptcp_connect -t $timeout -l -p $port -s ${srv_proto} $extra_args $local_addr < "$sin" > "$sout" & timeout ${timeout_test} \
ip netns exec ${listener_ns} \
./mptcp_connect -t ${timeout_poll} -l -p $port -s ${srv_proto} \
$extra_args $local_addr < "$sin" > "$sout" &
local spid=$! local spid=$!
wait_local_port_listen "${listener_ns}" "${port}" wait_local_port_listen "${listener_ns}" "${port}"
local start local start
start=$(date +%s%3N) start=$(date +%s%3N)
ip netns exec ${connector_ns} ./mptcp_connect -t $timeout -p $port -s ${cl_proto} $extra_args $connect_addr < "$cin" > "$cout" & timeout ${timeout_test} \
ip netns exec ${connector_ns} \
./mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \
$extra_args $connect_addr < "$cin" > "$cout" &
local cpid=$! local cpid=$!
wait $cpid wait $cpid
......
...@@ -8,7 +8,8 @@ cin="" ...@@ -8,7 +8,8 @@ cin=""
cinsent="" cinsent=""
cout="" cout=""
ksft_skip=4 ksft_skip=4
timeout=30 timeout_poll=30
timeout_test=$((timeout_poll * 2 + 1))
mptcp_connect="" mptcp_connect=""
capture=0 capture=0
do_all_tests=1 do_all_tests=1
...@@ -247,17 +248,26 @@ do_transfer() ...@@ -247,17 +248,26 @@ do_transfer()
local_addr="0.0.0.0" local_addr="0.0.0.0"
fi fi
ip netns exec ${listener_ns} $mptcp_connect -t $timeout -l -p $port \ timeout ${timeout_test} \
-s ${srv_proto} ${local_addr} < "$sin" > "$sout" & ip netns exec ${listener_ns} \
$mptcp_connect -t ${timeout_poll} -l -p $port -s ${srv_proto} \
${local_addr} < "$sin" > "$sout" &
spid=$! spid=$!
sleep 1 sleep 1
if [ "$test_link_fail" -eq 0 ];then if [ "$test_link_fail" -eq 0 ];then
ip netns exec ${connector_ns} $mptcp_connect -t $timeout -p $port -s ${cl_proto} $connect_addr < "$cin" > "$cout" & timeout ${timeout_test} \
ip netns exec ${connector_ns} \
$mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \
$connect_addr < "$cin" > "$cout" &
else else
( cat "$cin" ; sleep 2; link_failure $listener_ns ; cat "$cin" ) | tee "$cinsent" | \ ( cat "$cin" ; sleep 2; link_failure $listener_ns ; cat "$cin" ) | \
ip netns exec ${connector_ns} $mptcp_connect -t $timeout -p $port -s ${cl_proto} $connect_addr > "$cout" & tee "$cinsent" | \
timeout ${timeout_test} \
ip netns exec ${connector_ns} \
$mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \
$connect_addr > "$cout" &
fi fi
cpid=$! cpid=$!
......
...@@ -7,7 +7,8 @@ ns2="ns2-$rndh" ...@@ -7,7 +7,8 @@ ns2="ns2-$rndh"
ns3="ns3-$rndh" ns3="ns3-$rndh"
capture=false capture=false
ksft_skip=4 ksft_skip=4
timeout=30 timeout_poll=30
timeout_test=$((timeout_poll * 2 + 1))
test_cnt=1 test_cnt=1
ret=0 ret=0
bail=0 bail=0
...@@ -157,14 +158,20 @@ do_transfer() ...@@ -157,14 +158,20 @@ do_transfer()
sleep 1 sleep 1
fi fi
ip netns exec ${ns3} ./mptcp_connect -jt $timeout -l -p $port 0.0.0.0 < "$sin" > "$sout" & timeout ${timeout_test} \
ip netns exec ${ns3} \
./mptcp_connect -jt ${timeout_poll} -l -p $port \
0.0.0.0 < "$sin" > "$sout" &
local spid=$! local spid=$!
wait_local_port_listen "${ns3}" "${port}" wait_local_port_listen "${ns3}" "${port}"
local start local start
start=$(date +%s%3N) start=$(date +%s%3N)
ip netns exec ${ns1} ./mptcp_connect -jt $timeout -p $port 10.0.3.3 < "$cin" > "$cout" & timeout ${timeout_test} \
ip netns exec ${ns1} \
./mptcp_connect -jt ${timeout_poll} -p $port \
10.0.3.3 < "$cin" > "$cout" &
local cpid=$! local cpid=$!
wait $cpid wait $cpid
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment