selftests: mptcp: add remove addr and subflow test cases
This patch added the remove addr and subflow test cases and two new functions. The first function run_remove_tests calls do_transfer with two new arguments, rm_nr_ns1 and rm_nr_ns2, for the numbers of addresses should be removed during the transfer process in namespace 1 and namespace 2. If both these two arguments are 0, we do the join test cases with "mptcp_connect -j" command. Otherwise, do the remove test cases with "mptcp_connect -r" command. The second function chk_rm_nr checks the RM_ADDR related mibs's counters. The output of the test cases looks like this: 11 remove single subflow syn[ ok ] - synack[ ok ] - ack[ ok ] rm [ ok ] - sf [ ok ] 12 remove multiple subflows syn[ ok ] - synack[ ok ] - ack[ ok ] rm [ ok ] - sf [ ok ] 13 remove single address syn[ ok ] - synack[ ok ] - ack[ ok ] add[ ok ] - echo [ ok ] rm [ ok ] - sf [ ok ] 14 remove subflow and signal syn[ ok ] - synack[ ok ] - ack[ ok ] add[ ok ] - echo [ ok ] rm [ ok ] - sf [ ok ] 15 remove subflows and signal syn[ ok ] - synack[ ok ] - ack[ ok ] add[ ok ] - echo [ ok ] rm [ ok ] - sf [ ok ] Suggested-by: Matthieu Baerts <matthieu.baerts@tessares.net> Suggested-by: Paolo Abeni <pabeni@redhat.com> Suggested-by: Mat Martineau <mathew.j.martineau@linux.intel.com> Acked-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Geliang Tang <geliangtang@gmail.com> Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
1315332409
commit
dd72b0fede
@ -8,6 +8,7 @@ cin=""
|
||||
cout=""
|
||||
ksft_skip=4
|
||||
timeout=30
|
||||
mptcp_connect=""
|
||||
capture=0
|
||||
|
||||
TEST_COUNT=0
|
||||
@ -132,6 +133,8 @@ do_transfer()
|
||||
cl_proto="$3"
|
||||
srv_proto="$4"
|
||||
connect_addr="$5"
|
||||
rm_nr_ns1="$6"
|
||||
rm_nr_ns2="$7"
|
||||
|
||||
port=$((10000+$TEST_COUNT))
|
||||
TEST_COUNT=$((TEST_COUNT+1))
|
||||
@ -156,14 +159,44 @@ do_transfer()
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
ip netns exec ${listener_ns} ./mptcp_connect -j -t $timeout -l -p $port -s ${srv_proto} 0.0.0.0 < "$sin" > "$sout" &
|
||||
if [[ $rm_nr_ns1 -eq 0 && $rm_nr_ns2 -eq 0 ]]; then
|
||||
mptcp_connect="./mptcp_connect -j"
|
||||
else
|
||||
mptcp_connect="./mptcp_connect -r"
|
||||
fi
|
||||
|
||||
ip netns exec ${listener_ns} $mptcp_connect -t $timeout -l -p $port -s ${srv_proto} 0.0.0.0 < "$sin" > "$sout" &
|
||||
spid=$!
|
||||
|
||||
sleep 1
|
||||
|
||||
ip netns exec ${connector_ns} ./mptcp_connect -j -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" &
|
||||
cpid=$!
|
||||
|
||||
if [ $rm_nr_ns1 -gt 0 ]; then
|
||||
counter=1
|
||||
sleep 1
|
||||
|
||||
while [ $counter -le $rm_nr_ns1 ]
|
||||
do
|
||||
ip netns exec ${listener_ns} ./pm_nl_ctl del $counter
|
||||
sleep 1
|
||||
let counter+=1
|
||||
done
|
||||
fi
|
||||
|
||||
if [ $rm_nr_ns2 -gt 0 ]; then
|
||||
counter=1
|
||||
sleep 1
|
||||
|
||||
while [ $counter -le $rm_nr_ns2 ]
|
||||
do
|
||||
ip netns exec ${connector_ns} ./pm_nl_ctl del $counter
|
||||
sleep 1
|
||||
let counter+=1
|
||||
done
|
||||
fi
|
||||
|
||||
wait $cpid
|
||||
retc=$?
|
||||
wait $spid
|
||||
@ -219,7 +252,24 @@ run_tests()
|
||||
connect_addr="$3"
|
||||
lret=0
|
||||
|
||||
do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr}
|
||||
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}
|
||||
lret=$?
|
||||
if [ $lret -ne 0 ]; then
|
||||
ret=$lret
|
||||
@ -313,6 +363,43 @@ chk_add_nr()
|
||||
fi
|
||||
}
|
||||
|
||||
chk_rm_nr()
|
||||
{
|
||||
local rm_addr_nr=$1
|
||||
local rm_subflow_nr=$2
|
||||
local count
|
||||
local dump_stats
|
||||
|
||||
printf "%-39s %s" " " "rm "
|
||||
count=`ip netns exec $ns1 nstat -as | grep MPTcpExtRmAddr | awk '{print $2}'`
|
||||
[ -z "$count" ] && count=0
|
||||
if [ "$count" != "$rm_addr_nr" ]; then
|
||||
echo "[fail] got $count RM_ADDR[s] expected $rm_addr_nr"
|
||||
ret=1
|
||||
dump_stats=1
|
||||
else
|
||||
echo -n "[ ok ]"
|
||||
fi
|
||||
|
||||
echo -n " - sf "
|
||||
count=`ip netns exec $ns2 nstat -as | grep MPTcpExtRmSubflow | awk '{print $2}'`
|
||||
[ -z "$count" ] && count=0
|
||||
if [ "$count" != "$rm_subflow_nr" ]; then
|
||||
echo "[fail] got $count RM_SUBFLOW[s] expected $rm_subflow_nr"
|
||||
ret=1
|
||||
dump_stats=1
|
||||
else
|
||||
echo "[ ok ]"
|
||||
fi
|
||||
|
||||
if [ "${dump_stats}" = 1 ]; then
|
||||
echo Server ns stats
|
||||
ip netns exec $ns1 nstat -as | grep MPTcp
|
||||
echo Client ns stats
|
||||
ip netns exec $ns2 nstat -as | grep MPTcp
|
||||
fi
|
||||
}
|
||||
|
||||
sin=$(mktemp)
|
||||
sout=$(mktemp)
|
||||
cin=$(mktemp)
|
||||
@ -404,6 +491,58 @@ run_tests $ns1 $ns2 10.0.1.1
|
||||
chk_join_nr "multiple subflows and signal" 3 3 3
|
||||
chk_add_nr 1 1
|
||||
|
||||
# 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
|
||||
chk_join_nr "remove single subflow" 1 1 1
|
||||
chk_rm_nr 1 1
|
||||
|
||||
# multiple subflows, remove
|
||||
reset
|
||||
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
|
||||
chk_join_nr "remove multiple subflows" 2 2 2
|
||||
chk_rm_nr 2 2
|
||||
|
||||
# single address, remove
|
||||
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
|
||||
chk_join_nr "remove single address" 1 1 1
|
||||
chk_add_nr 1 1
|
||||
chk_rm_nr 0 0
|
||||
|
||||
# subflow and signal, remove
|
||||
reset
|
||||
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
|
||||
chk_join_nr "remove subflow and signal" 2 2 2
|
||||
chk_add_nr 1 1
|
||||
chk_rm_nr 1 1
|
||||
|
||||
# subflows and signal, remove
|
||||
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_remove_tests $ns1 $ns2 10.0.1.1 1 2
|
||||
chk_join_nr "remove subflows and signal" 3 3 3
|
||||
chk_add_nr 1 1
|
||||
chk_rm_nr 2 2
|
||||
|
||||
# single subflow, syncookies
|
||||
reset_with_cookies
|
||||
ip netns exec $ns1 ./pm_nl_ctl limits 0 1
|
||||
|
Loading…
Reference in New Issue
Block a user