Commit 3ad8ba6a authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'mptcp-selftest-fine-tuning-and-cleanup'

Mat Martineau says:

====================
mptcp: Selftest fine-tuning and cleanup

Patch 1 adjusts the mptcp selftest timeout to account for slow machines
running debug builds.

Patch 2 simplifies one test function.

Patches 3-6 do some cleanup, like deleting unused variables and avoiding
extra work when only printing usage information.

Patch 7 improves the checksum tests by utilizing existing checksum MIBs.
====================

Link: https://lore.kernel.org/r/20220218030311.367536-1-mathew.j.martineau@linux.intel.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents a3fc4b1d 24720d74
......@@ -432,6 +432,8 @@ do_transfer()
local stat_ackrx_last_l=$(get_mib_counter "${listener_ns}" "MPTcpExtMPCapableACKRX")
local stat_cookietx_last=$(get_mib_counter "${listener_ns}" "TcpExtSyncookiesSent")
local stat_cookierx_last=$(get_mib_counter "${listener_ns}" "TcpExtSyncookiesRecv")
local stat_csum_err_s=$(get_mib_counter "${listener_ns}" "MPTcpExtDataCsumErr")
local stat_csum_err_c=$(get_mib_counter "${connector_ns}" "MPTcpExtDataCsumErr")
timeout ${timeout_test} \
ip netns exec ${listener_ns} \
......@@ -524,6 +526,23 @@ do_transfer()
fi
fi
if $checksum; then
local csum_err_s=$(get_mib_counter "${listener_ns}" "MPTcpExtDataCsumErr")
local csum_err_c=$(get_mib_counter "${connector_ns}" "MPTcpExtDataCsumErr")
local csum_err_s_nr=$((csum_err_s - stat_csum_err_s))
if [ $csum_err_s_nr -gt 0 ]; then
printf "[ FAIL ]\nserver got $csum_err_s_nr data checksum error[s]"
rets=1
fi
local csum_err_c_nr=$((csum_err_c - stat_csum_err_c))
if [ $csum_err_c_nr -gt 0 ]; then
printf "[ FAIL ]\nclient got $csum_err_c_nr data checksum error[s]"
retc=1
fi
fi
if [ $retc -eq 0 ] && [ $rets -eq 0 ]; then
printf "[ OK ]"
fi
......
......@@ -17,6 +17,7 @@ capture=0
checksum=0
ip_mptcp=0
do_all_tests=1
init=0
TEST_COUNT=0
......@@ -38,11 +39,11 @@ CBPF_MPTCP_SUBOPTION_ADD_ADDR="14,
6 0 0 65535,
6 0 0 0"
init()
init_partial()
{
capout=$(mktemp)
rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
rndh=$(mktemp -u XXXXXX)
ns1="ns1-$rndh"
ns2="ns2-$rndh"
......@@ -98,6 +99,41 @@ cleanup_partial()
done
}
check_tools()
{
if ! ip -Version &> /dev/null; then
echo "SKIP: Could not run test without ip tool"
exit $ksft_skip
fi
if ! iptables -V &> /dev/null; then
echo "SKIP: Could not run all tests without iptables tool"
exit $ksft_skip
fi
if ! ip6tables -V &> /dev/null; then
echo "SKIP: Could not run all tests without ip6tables tool"
exit $ksft_skip
fi
}
init() {
init=1
check_tools
sin=$(mktemp)
sout=$(mktemp)
cin=$(mktemp)
cinsent=$(mktemp)
cout=$(mktemp)
trap cleanup EXIT
make_file "$cin" "client" 1
make_file "$sin" "server" 1
}
cleanup()
{
rm -f "$cin" "$cout" "$sinfail"
......@@ -107,8 +143,13 @@ cleanup()
reset()
{
cleanup_partial
if [ "${init}" != "1" ]; then
init
else
cleanup_partial
fi
init_partial
}
reset_with_cookies()
......@@ -162,24 +203,6 @@ reset_with_allow_join_id0()
ip netns exec $ns2 sysctl -q net.mptcp.allow_join_initial_addr_port=$ns2_enable
}
ip -Version > /dev/null 2>&1
if [ $? -ne 0 ];then
echo "SKIP: Could not run test without ip tool"
exit $ksft_skip
fi
iptables -V > /dev/null 2>&1
if [ $? -ne 0 ];then
echo "SKIP: Could not run all tests without iptables tool"
exit $ksft_skip
fi
ip6tables -V > /dev/null 2>&1
if [ $? -ne 0 ];then
echo "SKIP: Could not run all tests without ip6tables tool"
exit $ksft_skip
fi
print_file_err()
{
ls -l "$1" 1>&2
......@@ -240,16 +263,6 @@ is_v6()
[ -z "${1##*:*}" ]
}
is_addr()
{
[ -z "${1##*[.:]*}" ]
}
is_number()
{
[[ $1 == ?(-)+([0-9]) ]]
}
# $1: ns, $2: port
wait_local_port_listen()
{
......@@ -379,16 +392,13 @@ pm_nl_show_endpoints()
pm_nl_change_endpoint()
{
local ns=$1
local flags=$2
local id=$3
local addr=$4
local port=""
local id=$2
local flags=$3
if [ $ip_mptcp -eq 1 ]; then
ip -n $ns mptcp endpoint change id $id ${flags//","/" "}
else
if [ $5 -ne 0 ]; then port="port $5"; fi
ip netns exec $ns ./pm_nl_ctl set $addr flags $flags $port
ip netns exec $ns ./pm_nl_ctl set id $id flags $flags
fi
}
......@@ -591,24 +601,16 @@ do_transfer()
for netns in "$ns1" "$ns2"; do
pm_nl_show_endpoints $netns | while read line; do
local arr=($line)
local addr
local port=0
local nr=0
local id
for i in ${arr[@]}; do
if is_addr $i; then
addr=$i
elif is_number $i; then
# The minimum expected port number is 10000
if [ $i -gt 10000 ]; then
port=$i
# The maximum id number is 255
elif [ $i -lt 255 ]; then
id=$i
fi
if [ $i = "id" ]; then
id=${arr[$nr+1]}
fi
let nr+=1
done
pm_nl_change_endpoint $netns $sflags $id $addr $port
pm_nl_change_endpoint $netns $id $sflags
done
done
fi
......@@ -686,8 +688,6 @@ run_tests()
addr_nr_ns2="${6:-0}"
speed="${7:-fast}"
sflags="${8:-""}"
lret=0
oldin=""
# create the input file for the failure test when
# the first failure test run
......@@ -715,7 +715,6 @@ run_tests()
do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} \
${test_linkfail} ${addr_nr_ns1} ${addr_nr_ns2} ${speed} ${sflags}
lret=$?
}
dump_stats()
......@@ -2098,8 +2097,14 @@ all_tests()
fullmesh_tests
}
# [$1: error message]
usage()
{
if [ -n "${1}" ]; then
echo "${1}"
ret=1
fi
echo "mptcp_join usage:"
echo " -f subflows_tests"
echo " -e subflows_error_tests"
......@@ -2120,17 +2125,9 @@ usage()
echo " -C enable data checksum"
echo " -i use ip mptcp"
echo " -h help"
}
sin=$(mktemp)
sout=$(mktemp)
cin=$(mktemp)
cinsent=$(mktemp)
cout=$(mktemp)
init
make_file "$cin" "client" 1
make_file "$sin" "server" 1
trap cleanup EXIT
exit ${ret}
}
for arg in "$@"; do
# check for "capture/checksum" args before launching tests
......@@ -2208,9 +2205,12 @@ while getopts 'fesltra64bpkdmchCSi' opt; do
;;
i)
;;
h | *)
h)
usage
;;
*)
usage "Unknown option: -${opt}"
;;
esac
done
......
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