Skip to content

Commit

Permalink
selftests: mptcp: add ADD_ADDR timeout test case
Browse files Browse the repository at this point in the history
This patch added the test case for retransmitting ADD_ADDR when timeout
occurs. It set NS1's add_addr_timeout to 1 second, and drop NS2's ADD_ADDR
echo packets.

Here we need to slow down the transfer process of all data to let the
ADD_ADDR suboptions can be retransmitted three times. So we added a new
parameter "speed" for do_transfer, it can be set with fast or slow.

We also added three new optional parameters for run_tests, and dropped
run_remove_tests function.

Since we added the netfilter rules in this test case, we need to update
the "config" file.

Suggested-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Suggested-by: Paolo Abeni <pabeni@redhat.com>
Acked-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: Geliang Tang <geliangtang@gmail.com>
  • Loading branch information
geliangtang authored and jenkins-tessares committed Oct 15, 2020
1 parent 4e829f2 commit f584bdd
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 24 deletions.
6 changes: 6 additions & 0 deletions tools/testing/selftests/net/mptcp/config
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ CONFIG_INET_DIAG=m
CONFIG_INET_MPTCP_DIAG=m
CONFIG_VETH=y
CONFIG_NET_SCH_NETEM=m
CONFIG_NETFILTER=y
CONFIG_NETFILTER_ADVANCED=y
CONFIG_NETFILTER_XTABLES=m
CONFIG_NETFILTER_XT_MATCH_BPF=m
CONFIG_IP_NF_IPTABLES=m
CONFIG_IP_NF_FILTER=m
73 changes: 49 additions & 24 deletions tools/testing/selftests/net/mptcp/mptcp_join.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@ capture=0

TEST_COUNT=0

# generated using "nfbpf_compile '(tcp[34] & 0xf0) == 0x30'"
CBPF_MPTCP_SUBOPTION_ADD_ADDR="13,
48 0 0 0,
84 0 0 240,
21 0 9 64,
48 0 0 9,
21 0 7 6,
40 0 0 6,
69 5 0 8191,
177 0 0 0,
80 0 0 34,
84 0 0 240,
21 0 1 48,
6 0 0 65535,
6 0 0 0"

init()
{
capout=$(mktemp)
Expand Down Expand Up @@ -82,6 +98,18 @@ reset_with_cookies()
done
}

reset_with_add_addr_timeout()
{
reset

ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1
ip netns exec $ns2 iptables -A OUTPUT -p tcp \
-m tcp --tcp-option 30 \
-m bpf --bytecode \
"$CBPF_MPTCP_SUBOPTION_ADD_ADDR" \
-j DROP
}

for arg in "$@"; do
if [ "$arg" = "-c" ]; then
capture=1
Expand Down Expand Up @@ -135,6 +163,7 @@ do_transfer()
connect_addr="$5"
rm_nr_ns1="$6"
rm_nr_ns2="$7"
speed="$8"

port=$((10000+$TEST_COUNT))
TEST_COUNT=$((TEST_COUNT+1))
Expand All @@ -159,7 +188,7 @@ do_transfer()
sleep 1
fi

if [[ $rm_nr_ns1 -eq 0 && $rm_nr_ns2 -eq 0 ]]; then
if [ $speed = "fast" ]; then
mptcp_connect="./mptcp_connect -j"
else
mptcp_connect="./mptcp_connect -r"
Expand Down Expand Up @@ -250,26 +279,13 @@ run_tests()
listener_ns="$1"
connector_ns="$2"
connect_addr="$3"
rm_nr_ns1="${4:-0}"
rm_nr_ns2="${5:-0}"
speed="${6:-fast}"
lret=0

do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} 0 0
lret=$?
if [ $lret -ne 0 ]; then
ret=$lret
return
fi
}

run_remove_tests()
{
listener_ns="$1"
connector_ns="$2"
connect_addr="$3"
rm_nr_ns1="$4"
rm_nr_ns2="$5"
lret=0

do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} ${rm_nr_ns1} ${rm_nr_ns2}
do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} \
${rm_nr_ns1} ${rm_nr_ns2} ${speed}
lret=$?
if [ $lret -ne 0 ]; then
ret=$lret
Expand Down Expand Up @@ -491,12 +507,21 @@ run_tests $ns1 $ns2 10.0.1.1
chk_join_nr "multiple subflows and signal" 3 3 3
chk_add_nr 1 1

# add_addr timeout
reset_with_add_addr_timeout
ip netns exec $ns1 ./pm_nl_ctl limits 0 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
run_tests $ns1 $ns2 10.0.1.1 0 0 slow
chk_join_nr "signal address, ADD_ADDR timeout" 1 1 1
chk_add_nr 4 0

# single subflow, remove
reset
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 add 10.0.3.2 flags subflow
run_remove_tests $ns1 $ns2 10.0.1.1 0 1
run_tests $ns1 $ns2 10.0.1.1 0 1 slow
chk_join_nr "remove single subflow" 1 1 1
chk_rm_nr 1 1

Expand All @@ -506,7 +531,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 add 10.0.2.2 flags subflow
ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
run_remove_tests $ns1 $ns2 10.0.1.1 0 2
run_tests $ns1 $ns2 10.0.1.1 0 2 slow
chk_join_nr "remove multiple subflows" 2 2 2
chk_rm_nr 2 2

Expand All @@ -515,7 +540,7 @@ reset
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 $ns2 ./pm_nl_ctl limits 1 1
run_remove_tests $ns1 $ns2 10.0.1.1 1 0
run_tests $ns1 $ns2 10.0.1.1 1 0 slow
chk_join_nr "remove single address" 1 1 1
chk_add_nr 1 1
chk_rm_nr 0 0
Expand All @@ -526,7 +551,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 $ns2 ./pm_nl_ctl limits 1 2
ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
run_remove_tests $ns1 $ns2 10.0.1.1 1 1
run_tests $ns1 $ns2 10.0.1.1 1 1 slow
chk_join_nr "remove subflow and signal" 2 2 2
chk_add_nr 1 1
chk_rm_nr 1 1
Expand All @@ -538,7 +563,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 add 10.0.3.2 flags subflow
ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow
run_remove_tests $ns1 $ns2 10.0.1.1 1 2
run_tests $ns1 $ns2 10.0.1.1 1 2 slow
chk_join_nr "remove subflows and signal" 3 3 3
chk_add_nr 1 1
chk_rm_nr 2 2
Expand Down

0 comments on commit f584bdd

Please sign in to comment.