Commit 8b819a84 authored by Florian Westphal's avatar Florian Westphal Committed by Jakub Kicinski

selftests: mptcp: add link failure test case

Add a test case where a link fails with multiple subflows.
The expectation is that MPTCP will transmit any data that
could not be delivered via the failed link on another subflow.
Co-developed-by: default avatarGeliang Tang <geliangtang@gmail.com>
Signed-off-by: default avatarGeliang Tang <geliangtang@gmail.com>
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Signed-off-by: default avatarMat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 860975c6
...@@ -5,6 +5,7 @@ ret=0 ...@@ -5,6 +5,7 @@ ret=0
sin="" sin=""
sout="" sout=""
cin="" cin=""
cinsent=""
cout="" cout=""
ksft_skip=4 ksft_skip=4
timeout=30 timeout=30
...@@ -81,7 +82,7 @@ cleanup_partial() ...@@ -81,7 +82,7 @@ cleanup_partial()
cleanup() cleanup()
{ {
rm -f "$cin" "$cout" rm -f "$cin" "$cout"
rm -f "$sin" "$sout" rm -f "$sin" "$sout" "$cinsent"
cleanup_partial cleanup_partial
} }
...@@ -144,6 +145,13 @@ if [ $? -ne 0 ];then ...@@ -144,6 +145,13 @@ if [ $? -ne 0 ];then
exit $ksft_skip exit $ksft_skip
fi fi
print_file_err()
{
ls -l "$1" 1>&2
echo "Trailing bytes are: "
tail -c 27 "$1"
}
check_transfer() check_transfer()
{ {
in=$1 in=$1
...@@ -155,6 +163,7 @@ check_transfer() ...@@ -155,6 +163,7 @@ check_transfer()
echo "[ FAIL ] $what does not match (in, out):" echo "[ FAIL ] $what does not match (in, out):"
print_file_err "$in" print_file_err "$in"
print_file_err "$out" print_file_err "$out"
ret=1
return 1 return 1
fi fi
...@@ -175,6 +184,17 @@ do_ping() ...@@ -175,6 +184,17 @@ do_ping()
fi fi
} }
link_failure()
{
ns="$1"
l=$((RANDOM%4))
l=$((l+1))
veth="ns1eth$l"
ip -net "$ns" link set "$veth" down
}
do_transfer() do_transfer()
{ {
listener_ns="$1" listener_ns="$1"
...@@ -182,9 +202,10 @@ do_transfer() ...@@ -182,9 +202,10 @@ do_transfer()
cl_proto="$3" cl_proto="$3"
srv_proto="$4" srv_proto="$4"
connect_addr="$5" connect_addr="$5"
rm_nr_ns1="$6" test_link_fail="$6"
rm_nr_ns2="$7" rm_nr_ns1="$7"
speed="$8" rm_nr_ns2="$8"
speed="$9"
port=$((10000+$TEST_COUNT)) port=$((10000+$TEST_COUNT))
TEST_COUNT=$((TEST_COUNT+1)) TEST_COUNT=$((TEST_COUNT+1))
...@@ -220,7 +241,12 @@ do_transfer() ...@@ -220,7 +241,12 @@ do_transfer()
sleep 1 sleep 1
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" & ip netns exec ${connector_ns} $mptcp_connect -t $timeout -p $port -s ${cl_proto} $connect_addr < "$cin" > "$cout" &
else
( cat "$cin" ; sleep 2; link_failure $listener_ns ; cat "$cin" ) | tee "$cinsent" | \
ip netns exec ${connector_ns} $mptcp_connect -t $timeout -p $port -s ${cl_proto} $connect_addr > "$cout" &
fi
cpid=$! cpid=$!
if [ $rm_nr_ns1 -gt 0 ]; then if [ $rm_nr_ns1 -gt 0 ]; then
...@@ -265,12 +291,17 @@ do_transfer() ...@@ -265,12 +291,17 @@ do_transfer()
ip netns exec ${connector_ns} ss -nita 1>&2 -o "dport = :$port" ip netns exec ${connector_ns} ss -nita 1>&2 -o "dport = :$port"
cat "$capout" cat "$capout"
ret=1
return 1 return 1
fi fi
check_transfer $sin $cout "file received by client" check_transfer $sin $cout "file received by client"
retc=$? retc=$?
if [ "$test_link_fail" -eq 0 ];then
check_transfer $cin $sout "file received by server" check_transfer $cin $sout "file received by server"
else
check_transfer $cinsent $sout "file received by server"
fi
rets=$? rets=$?
if [ $retc -eq 0 ] && [ $rets -eq 0 ];then if [ $retc -eq 0 ] && [ $rets -eq 0 ];then
...@@ -286,13 +317,12 @@ make_file() ...@@ -286,13 +317,12 @@ make_file()
{ {
name=$1 name=$1
who=$2 who=$2
size=$3
SIZE=1 dd if=/dev/urandom of="$name" bs=1024 count=$size 2> /dev/null
dd if=/dev/urandom of="$name" bs=1024 count=$SIZE 2> /dev/null
echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name" echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name"
echo "Created $name (size $SIZE KB) containing data sent by $who" echo "Created $name (size $size KB) containing data sent by $who"
} }
run_tests() run_tests()
...@@ -300,14 +330,32 @@ run_tests() ...@@ -300,14 +330,32 @@ run_tests()
listener_ns="$1" listener_ns="$1"
connector_ns="$2" connector_ns="$2"
connect_addr="$3" connect_addr="$3"
rm_nr_ns1="${4:-0}" test_linkfail="${4:-0}"
rm_nr_ns2="${5:-0}" rm_nr_ns1="${5:-0}"
speed="${6:-fast}" rm_nr_ns2="${6:-0}"
speed="${7:-fast}"
lret=0 lret=0
oldin=""
if [ "$test_linkfail" -eq 1 ];then
size=$((RANDOM%1024))
size=$((size+1))
size=$((size*128))
oldin=$(mktemp)
cp "$cin" "$oldin"
make_file "$cin" "client" $size
fi
do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} \ do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} \
${rm_nr_ns1} ${rm_nr_ns2} ${speed} ${test_linkfail} ${rm_nr_ns1} ${rm_nr_ns2} ${speed}
lret=$? lret=$?
if [ "$test_linkfail" -eq 1 ];then
cp "$oldin" "$cin"
rm -f "$oldin"
fi
if [ $lret -ne 0 ]; then if [ $lret -ne 0 ]; then
ret=$lret ret=$lret
return return
...@@ -440,10 +488,11 @@ chk_rm_nr() ...@@ -440,10 +488,11 @@ chk_rm_nr()
sin=$(mktemp) sin=$(mktemp)
sout=$(mktemp) sout=$(mktemp)
cin=$(mktemp) cin=$(mktemp)
cinsent=$(mktemp)
cout=$(mktemp) cout=$(mktemp)
init init
make_file "$cin" "client" make_file "$cin" "client" 1
make_file "$sin" "server" make_file "$sin" "server" 1
trap cleanup EXIT trap cleanup EXIT
run_tests $ns1 $ns2 10.0.1.1 run_tests $ns1 $ns2 10.0.1.1
...@@ -528,12 +577,23 @@ run_tests $ns1 $ns2 10.0.1.1 ...@@ -528,12 +577,23 @@ run_tests $ns1 $ns2 10.0.1.1
chk_join_nr "multiple subflows and signal" 3 3 3 chk_join_nr "multiple subflows and signal" 3 3 3
chk_add_nr 1 1 chk_add_nr 1 1
# accept and use add_addr with additional subflows and link loss
reset
ip netns exec $ns1 ./pm_nl_ctl limits 0 3
ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal
ip netns exec $ns2 ./pm_nl_ctl limits 1 3
ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow
run_tests $ns1 $ns2 10.0.1.1 1
chk_join_nr "multiple flows, signal, link failure" 3 3 3
chk_add_nr 1 1
# add_addr timeout # add_addr timeout
reset_with_add_addr_timeout reset_with_add_addr_timeout
ip netns exec $ns1 ./pm_nl_ctl limits 0 1 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
ip netns exec $ns2 ./pm_nl_ctl limits 1 1 ip netns exec $ns2 ./pm_nl_ctl limits 1 1
ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal
run_tests $ns1 $ns2 10.0.1.1 0 0 slow run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow
chk_join_nr "signal address, ADD_ADDR timeout" 1 1 1 chk_join_nr "signal address, ADD_ADDR timeout" 1 1 1
chk_add_nr 4 0 chk_add_nr 4 0
...@@ -542,7 +602,7 @@ reset ...@@ -542,7 +602,7 @@ reset
ip netns exec $ns1 ./pm_nl_ctl limits 0 1 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
ip netns exec $ns2 ./pm_nl_ctl limits 0 1 ip netns exec $ns2 ./pm_nl_ctl limits 0 1
ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
run_tests $ns1 $ns2 10.0.1.1 0 1 slow run_tests $ns1 $ns2 10.0.1.1 0 0 1 slow
chk_join_nr "remove single subflow" 1 1 1 chk_join_nr "remove single subflow" 1 1 1
chk_rm_nr 1 1 chk_rm_nr 1 1
...@@ -552,7 +612,7 @@ ip netns exec $ns1 ./pm_nl_ctl limits 0 2 ...@@ -552,7 +612,7 @@ ip netns exec $ns1 ./pm_nl_ctl limits 0 2
ip netns exec $ns2 ./pm_nl_ctl limits 0 2 ip netns exec $ns2 ./pm_nl_ctl limits 0 2
ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow
ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
run_tests $ns1 $ns2 10.0.1.1 0 2 slow run_tests $ns1 $ns2 10.0.1.1 0 0 2 slow
chk_join_nr "remove multiple subflows" 2 2 2 chk_join_nr "remove multiple subflows" 2 2 2
chk_rm_nr 2 2 chk_rm_nr 2 2
...@@ -561,7 +621,7 @@ reset ...@@ -561,7 +621,7 @@ reset
ip netns exec $ns1 ./pm_nl_ctl limits 0 1 ip netns exec $ns1 ./pm_nl_ctl limits 0 1
ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal
ip netns exec $ns2 ./pm_nl_ctl limits 1 1 ip netns exec $ns2 ./pm_nl_ctl limits 1 1
run_tests $ns1 $ns2 10.0.1.1 1 0 slow run_tests $ns1 $ns2 10.0.1.1 0 1 0 slow
chk_join_nr "remove single address" 1 1 1 chk_join_nr "remove single address" 1 1 1
chk_add_nr 1 1 chk_add_nr 1 1
chk_rm_nr 0 0 chk_rm_nr 0 0
...@@ -572,7 +632,7 @@ ip netns exec $ns1 ./pm_nl_ctl limits 0 2 ...@@ -572,7 +632,7 @@ ip netns exec $ns1 ./pm_nl_ctl limits 0 2
ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal
ip netns exec $ns2 ./pm_nl_ctl limits 1 2 ip netns exec $ns2 ./pm_nl_ctl limits 1 2
ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
run_tests $ns1 $ns2 10.0.1.1 1 1 slow run_tests $ns1 $ns2 10.0.1.1 0 1 1 slow
chk_join_nr "remove subflow and signal" 2 2 2 chk_join_nr "remove subflow and signal" 2 2 2
chk_add_nr 1 1 chk_add_nr 1 1
chk_rm_nr 1 1 chk_rm_nr 1 1
...@@ -584,7 +644,7 @@ ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal ...@@ -584,7 +644,7 @@ ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal
ip netns exec $ns2 ./pm_nl_ctl limits 1 3 ip netns exec $ns2 ./pm_nl_ctl limits 1 3
ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow
run_tests $ns1 $ns2 10.0.1.1 1 2 slow run_tests $ns1 $ns2 10.0.1.1 0 1 2 slow
chk_join_nr "remove subflows and signal" 3 3 3 chk_join_nr "remove subflows and signal" 3 3 3
chk_add_nr 1 1 chk_add_nr 1 1
chk_rm_nr 2 2 chk_rm_nr 2 2
......
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