Commit be587adb authored by David S. Miller's avatar David S. Miller

Merge branch 'mptcp-selftest-improvements-and-header-tweak'

Mat Martineau says:

====================
mptcp: Self test improvements and a header tweak

Patch 1 moves a definition to a header so it can be used in a struct
declaration.

Patch 2 adjusts a time threshold for a selftest that runs much slower on
debug kernels (and even more on slow CI infrastructure), to reduce
spurious failures.

Patches 3 & 4 improve userspace PM test coverage.

Patches 5 & 6 clean up output from a test script and selftest helper
tool.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 9f7cb73e 65ebc667
...@@ -39,6 +39,7 @@ struct mptcp_ext { ...@@ -39,6 +39,7 @@ struct mptcp_ext {
infinite_map:1; infinite_map:1;
}; };
#define MPTCPOPT_HMAC_LEN 20
#define MPTCP_RM_IDS_MAX 8 #define MPTCP_RM_IDS_MAX 8
struct mptcp_rm_list { struct mptcp_rm_list {
...@@ -89,7 +90,7 @@ struct mptcp_out_options { ...@@ -89,7 +90,7 @@ struct mptcp_out_options {
u32 nonce; u32 nonce;
u32 token; u32 token;
u64 thmac; u64 thmac;
u8 hmac[20]; u8 hmac[MPTCPOPT_HMAC_LEN];
}; };
}; };
#endif #endif
......
...@@ -83,7 +83,6 @@ ...@@ -83,7 +83,6 @@
/* MPTCP MP_JOIN flags */ /* MPTCP MP_JOIN flags */
#define MPTCPOPT_BACKUP BIT(0) #define MPTCPOPT_BACKUP BIT(0)
#define MPTCPOPT_HMAC_LEN 20
#define MPTCPOPT_THMAC_LEN 8 #define MPTCPOPT_THMAC_LEN 8
/* MPTCP MP_CAPABLE flags */ /* MPTCP MP_CAPABLE flags */
......
...@@ -455,6 +455,12 @@ wait_mpj() ...@@ -455,6 +455,12 @@ wait_mpj()
done done
} }
kill_wait()
{
kill $1 > /dev/null 2>&1
wait $1 2>/dev/null
}
pm_nl_set_limits() pm_nl_set_limits()
{ {
local ns=$1 local ns=$1
...@@ -654,6 +660,11 @@ do_transfer() ...@@ -654,6 +660,11 @@ do_transfer()
local port=$((10000 + TEST_COUNT - 1)) local port=$((10000 + TEST_COUNT - 1))
local cappid local cappid
local userspace_pm=0
local evts_ns1
local evts_ns1_pid
local evts_ns2
local evts_ns2_pid
:> "$cout" :> "$cout"
:> "$sout" :> "$sout"
...@@ -690,10 +701,29 @@ do_transfer() ...@@ -690,10 +701,29 @@ do_transfer()
extra_args="-r ${speed:6}" extra_args="-r ${speed:6}"
fi fi
if [[ "${addr_nr_ns1}" = "userspace_"* ]]; then
userspace_pm=1
addr_nr_ns1=${addr_nr_ns1:10}
fi
if [[ "${addr_nr_ns2}" = "fastclose_"* ]]; then if [[ "${addr_nr_ns2}" = "fastclose_"* ]]; then
# disconnect # disconnect
extra_args="$extra_args -I ${addr_nr_ns2:10}" extra_args="$extra_args -I ${addr_nr_ns2:10}"
addr_nr_ns2=0 addr_nr_ns2=0
elif [[ "${addr_nr_ns2}" = "userspace_"* ]]; then
userspace_pm=1
addr_nr_ns2=${addr_nr_ns2:10}
fi
if [ $userspace_pm -eq 1 ]; then
evts_ns1=$(mktemp)
evts_ns2=$(mktemp)
:> "$evts_ns1"
:> "$evts_ns2"
ip netns exec ${listener_ns} ./pm_nl_ctl events >> "$evts_ns1" 2>&1 &
evts_ns1_pid=$!
ip netns exec ${connector_ns} ./pm_nl_ctl events >> "$evts_ns2" 2>&1 &
evts_ns2_pid=$!
fi fi
local local_addr local local_addr
...@@ -748,6 +778,8 @@ do_transfer() ...@@ -748,6 +778,8 @@ do_transfer()
if [ $addr_nr_ns1 -gt 0 ]; then if [ $addr_nr_ns1 -gt 0 ]; then
local counter=2 local counter=2
local add_nr_ns1=${addr_nr_ns1} local add_nr_ns1=${addr_nr_ns1}
local id=10
local tk
while [ $add_nr_ns1 -gt 0 ]; do while [ $add_nr_ns1 -gt 0 ]; do
local addr local addr
if is_v6 "${connect_addr}"; then if is_v6 "${connect_addr}"; then
...@@ -755,9 +787,18 @@ do_transfer() ...@@ -755,9 +787,18 @@ do_transfer()
else else
addr="10.0.$counter.1" addr="10.0.$counter.1"
fi fi
pm_nl_add_endpoint $ns1 $addr flags signal if [ $userspace_pm -eq 0 ]; then
pm_nl_add_endpoint $ns1 $addr flags signal
else
tk=$(sed -n 's/.*\(token:\)\([[:digit:]]*\).*$/\2/p;q' "$evts_ns1")
ip netns exec ${listener_ns} ./pm_nl_ctl ann $addr token $tk id $id
sleep 1
ip netns exec ${listener_ns} ./pm_nl_ctl rem token $tk id $id
fi
counter=$((counter + 1)) counter=$((counter + 1))
add_nr_ns1=$((add_nr_ns1 - 1)) add_nr_ns1=$((add_nr_ns1 - 1))
id=$((id + 1))
done done
elif [ $addr_nr_ns1 -lt 0 ]; then elif [ $addr_nr_ns1 -lt 0 ]; then
local rm_nr_ns1=$((-addr_nr_ns1)) local rm_nr_ns1=$((-addr_nr_ns1))
...@@ -804,6 +845,8 @@ do_transfer() ...@@ -804,6 +845,8 @@ do_transfer()
if [ $addr_nr_ns2 -gt 0 ]; then if [ $addr_nr_ns2 -gt 0 ]; then
local add_nr_ns2=${addr_nr_ns2} local add_nr_ns2=${addr_nr_ns2}
local counter=3 local counter=3
local id=20
local tk da dp sp
while [ $add_nr_ns2 -gt 0 ]; do while [ $add_nr_ns2 -gt 0 ]; do
local addr local addr
if is_v6 "${connect_addr}"; then if is_v6 "${connect_addr}"; then
...@@ -811,9 +854,23 @@ do_transfer() ...@@ -811,9 +854,23 @@ do_transfer()
else else
addr="10.0.$counter.2" addr="10.0.$counter.2"
fi fi
pm_nl_add_endpoint $ns2 $addr flags $flags if [ $userspace_pm -eq 0 ]; then
pm_nl_add_endpoint $ns2 $addr flags $flags
else
tk=$(sed -n 's/.*\(token:\)\([[:digit:]]*\).*$/\2/p;q' "$evts_ns2")
da=$(sed -n 's/.*\(daddr4:\)\([0-9.]*\).*$/\2/p;q' "$evts_ns2")
dp=$(sed -n 's/.*\(dport:\)\([[:digit:]]*\).*$/\2/p;q' "$evts_ns2")
ip netns exec ${connector_ns} ./pm_nl_ctl csf lip $addr lid $id \
rip $da rport $dp token $tk
sleep 1
sp=$(grep "type:10" "$evts_ns2" |
sed -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q')
ip netns exec ${connector_ns} ./pm_nl_ctl dsf lip $addr lport $sp \
rip $da rport $dp token $tk
fi
counter=$((counter + 1)) counter=$((counter + 1))
add_nr_ns2=$((add_nr_ns2 - 1)) add_nr_ns2=$((add_nr_ns2 - 1))
id=$((id + 1))
done done
elif [ $addr_nr_ns2 -lt 0 ]; then elif [ $addr_nr_ns2 -lt 0 ]; then
local rm_nr_ns2=$((-addr_nr_ns2)) local rm_nr_ns2=$((-addr_nr_ns2))
...@@ -890,6 +947,12 @@ do_transfer() ...@@ -890,6 +947,12 @@ do_transfer()
kill $cappid kill $cappid
fi fi
if [ $userspace_pm -eq 1 ]; then
kill_wait $evts_ns1_pid
kill_wait $evts_ns2_pid
rm -rf $evts_ns1 $evts_ns2
fi
NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \ NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \
nstat | grep Tcp > /tmp/${listener_ns}.out nstat | grep Tcp > /tmp/${listener_ns}.out
NSTAT_HISTORY=/tmp/${connector_ns}.nstat ip netns exec ${connector_ns} \ NSTAT_HISTORY=/tmp/${connector_ns}.nstat ip netns exec ${connector_ns} \
...@@ -2810,6 +2873,25 @@ userspace_tests() ...@@ -2810,6 +2873,25 @@ userspace_tests()
chk_join_nr 0 0 0 chk_join_nr 0 0 0
chk_rm_nr 0 0 chk_rm_nr 0 0
fi fi
# userspace pm add & remove address
if reset "userspace pm add & remove address"; then
set_userspace_pm $ns1
pm_nl_set_limits $ns2 1 1
run_tests $ns1 $ns2 10.0.1.1 0 userspace_1 0 slow
chk_join_nr 1 1 1
chk_add_nr 1 1
chk_rm_nr 1 1 invert
fi
# userspace pm create destroy subflow
if reset "userspace pm create destroy subflow"; then
set_userspace_pm $ns2
pm_nl_set_limits $ns1 0 1
run_tests $ns1 $ns2 10.0.1.1 0 0 userspace_1 slow
chk_join_nr 1 1 1
chk_rm_nr 0 1
fi
} }
endpoint_tests() endpoint_tests()
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
static void syntax(char *argv[]) static void syntax(char *argv[])
{ {
fprintf(stderr, "%s add|get|set|del|flush|dump|accept [<args>]\n", argv[0]); fprintf(stderr, "%s add|ann|rem|csf|dsf|get|set|del|flush|dump|events|listen|accept [<args>]\n", argv[0]);
fprintf(stderr, "\tadd [flags signal|subflow|backup|fullmesh] [id <nr>] [dev <name>] <ip>\n"); fprintf(stderr, "\tadd [flags signal|subflow|backup|fullmesh] [id <nr>] [dev <name>] <ip>\n");
fprintf(stderr, "\tann <local-ip> id <local-id> token <token> [port <local-port>] [dev <name>]\n"); fprintf(stderr, "\tann <local-ip> id <local-id> token <token> [port <local-port>] [dev <name>]\n");
fprintf(stderr, "\trem id <local-id> token <token>\n"); fprintf(stderr, "\trem id <local-id> token <token>\n");
......
...@@ -12,6 +12,7 @@ timeout_test=$((timeout_poll * 2 + 1)) ...@@ -12,6 +12,7 @@ timeout_test=$((timeout_poll * 2 + 1))
test_cnt=1 test_cnt=1
ret=0 ret=0
bail=0 bail=0
slack=50
usage() { usage() {
echo "Usage: $0 [ -b ] [ -c ] [ -d ]" echo "Usage: $0 [ -b ] [ -c ] [ -d ]"
...@@ -52,6 +53,7 @@ setup() ...@@ -52,6 +53,7 @@ setup()
cout=$(mktemp) cout=$(mktemp)
capout=$(mktemp) capout=$(mktemp)
size=$((2 * 2048 * 4096)) size=$((2 * 2048 * 4096))
dd if=/dev/zero of=$small bs=4096 count=20 >/dev/null 2>&1 dd if=/dev/zero of=$small bs=4096 count=20 >/dev/null 2>&1
dd if=/dev/zero of=$large bs=4096 count=$((size / 4096)) >/dev/null 2>&1 dd if=/dev/zero of=$large bs=4096 count=$((size / 4096)) >/dev/null 2>&1
...@@ -104,6 +106,16 @@ setup() ...@@ -104,6 +106,16 @@ setup()
ip -net "$ns3" route add default via dead:beef:3::2 ip -net "$ns3" route add default via dead:beef:3::2
ip netns exec "$ns3" ./pm_nl_ctl limits 1 1 ip netns exec "$ns3" ./pm_nl_ctl limits 1 1
# debug build can slow down measurably the test program
# we use quite tight time limit on the run-time, to ensure
# maximum B/W usage.
# Use kmemleak/lockdep/kasan/prove_locking presence as a rough
# estimate for this being a debug kernel and increase the
# maximum run-time accordingly. Observed run times for CI builds
# running selftests, including kbuild, were used to determine the
# amount of time to add.
grep -q ' kmemleak_init$\| lockdep_init$\| kasan_init$\| prove_locking$' /proc/kallsyms && slack=$((slack+550))
} }
# $1: ns, $2: port # $1: ns, $2: port
...@@ -241,7 +253,7 @@ run_test() ...@@ -241,7 +253,7 @@ run_test()
# mptcp_connect will do some sleeps to allow the mp_join handshake # mptcp_connect will do some sleeps to allow the mp_join handshake
# completion (see mptcp_connect): 200ms on each side, add some slack # completion (see mptcp_connect): 200ms on each side, add some slack
time=$((time + 450)) time=$((time + 400 + slack))
printf "%-60s" "$msg" printf "%-60s" "$msg"
do_transfer $small $large $time do_transfer $small $large $time
......
...@@ -37,6 +37,12 @@ rndh=$(stdbuf -o0 -e0 printf %x "$sec")-$(mktemp -u XXXXXX) ...@@ -37,6 +37,12 @@ rndh=$(stdbuf -o0 -e0 printf %x "$sec")-$(mktemp -u XXXXXX)
ns1="ns1-$rndh" ns1="ns1-$rndh"
ns2="ns2-$rndh" ns2="ns2-$rndh"
kill_wait()
{
kill $1 > /dev/null 2>&1
wait $1 2>/dev/null
}
cleanup() cleanup()
{ {
echo "cleanup" echo "cleanup"
...@@ -48,16 +54,16 @@ cleanup() ...@@ -48,16 +54,16 @@ cleanup()
kill -SIGUSR1 $client4_pid > /dev/null 2>&1 kill -SIGUSR1 $client4_pid > /dev/null 2>&1
fi fi
if [ $server4_pid -ne 0 ]; then if [ $server4_pid -ne 0 ]; then
kill $server4_pid > /dev/null 2>&1 kill_wait $server4_pid
fi fi
if [ $client6_pid -ne 0 ]; then if [ $client6_pid -ne 0 ]; then
kill -SIGUSR1 $client6_pid > /dev/null 2>&1 kill -SIGUSR1 $client6_pid > /dev/null 2>&1
fi fi
if [ $server6_pid -ne 0 ]; then if [ $server6_pid -ne 0 ]; then
kill $server6_pid > /dev/null 2>&1 kill_wait $server6_pid
fi fi
if [ $evts_pid -ne 0 ]; then if [ $evts_pid -ne 0 ]; then
kill $evts_pid > /dev/null 2>&1 kill_wait $evts_pid
fi fi
local netns local netns
for netns in "$ns1" "$ns2" ;do for netns in "$ns1" "$ns2" ;do
...@@ -153,7 +159,7 @@ make_connection() ...@@ -153,7 +159,7 @@ make_connection()
sleep 1 sleep 1
# Capture client/server attributes from MPTCP connection netlink events # Capture client/server attributes from MPTCP connection netlink events
kill $client_evts_pid kill_wait $client_evts_pid
local client_token local client_token
local client_port local client_port
...@@ -165,7 +171,7 @@ make_connection() ...@@ -165,7 +171,7 @@ make_connection()
client_port=$(sed --unbuffered -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q' "$client_evts") client_port=$(sed --unbuffered -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q' "$client_evts")
client_serverside=$(sed --unbuffered -n 's/.*\(server_side:\)\([[:digit:]]*\).*$/\2/p;q'\ client_serverside=$(sed --unbuffered -n 's/.*\(server_side:\)\([[:digit:]]*\).*$/\2/p;q'\
"$client_evts") "$client_evts")
kill $server_evts_pid kill_wait $server_evts_pid
server_token=$(sed --unbuffered -n 's/.*\(token:\)\([[:digit:]]*\).*$/\2/p;q' "$server_evts") server_token=$(sed --unbuffered -n 's/.*\(token:\)\([[:digit:]]*\).*$/\2/p;q' "$server_evts")
server_serverside=$(sed --unbuffered -n 's/.*\(server_side:\)\([[:digit:]]*\).*$/\2/p;q'\ server_serverside=$(sed --unbuffered -n 's/.*\(server_side:\)\([[:digit:]]*\).*$/\2/p;q'\
"$server_evts") "$server_evts")
...@@ -286,7 +292,7 @@ test_announce() ...@@ -286,7 +292,7 @@ test_announce()
verify_announce_event "$evts" "$ANNOUNCED" "$server4_token" "10.0.2.2"\ verify_announce_event "$evts" "$ANNOUNCED" "$server4_token" "10.0.2.2"\
"$client_addr_id" "$new4_port" "$client_addr_id" "$new4_port"
kill $evts_pid kill_wait $evts_pid
# Capture events on the network namespace running the client # Capture events on the network namespace running the client
:>"$evts" :>"$evts"
...@@ -321,7 +327,7 @@ test_announce() ...@@ -321,7 +327,7 @@ test_announce()
verify_announce_event "$evts" "$ANNOUNCED" "$client4_token" "10.0.2.1"\ verify_announce_event "$evts" "$ANNOUNCED" "$client4_token" "10.0.2.1"\
"$server_addr_id" "$new4_port" "$server_addr_id" "$new4_port"
kill $evts_pid kill_wait $evts_pid
rm -f "$evts" rm -f "$evts"
} }
...@@ -416,7 +422,7 @@ test_remove() ...@@ -416,7 +422,7 @@ test_remove()
sleep 0.5 sleep 0.5
verify_remove_event "$evts" "$REMOVED" "$server6_token" "$client_addr_id" verify_remove_event "$evts" "$REMOVED" "$server6_token" "$client_addr_id"
kill $evts_pid kill_wait $evts_pid
# Capture events on the network namespace running the client # Capture events on the network namespace running the client
:>"$evts" :>"$evts"
...@@ -449,7 +455,7 @@ test_remove() ...@@ -449,7 +455,7 @@ test_remove()
sleep 0.5 sleep 0.5
verify_remove_event "$evts" "$REMOVED" "$client6_token" "$server_addr_id" verify_remove_event "$evts" "$REMOVED" "$client6_token" "$server_addr_id"
kill $evts_pid kill_wait $evts_pid
rm -f "$evts" rm -f "$evts"
} }
...@@ -553,7 +559,7 @@ test_subflows() ...@@ -553,7 +559,7 @@ test_subflows()
"10.0.2.2" "$client4_port" "23" "$client_addr_id" "ns1" "ns2" "10.0.2.2" "$client4_port" "23" "$client_addr_id" "ns1" "ns2"
# Delete the listener from the client ns, if one was created # Delete the listener from the client ns, if one was created
kill $listener_pid > /dev/null 2>&1 kill_wait $listener_pid
local sport local sport
sport=$(sed --unbuffered -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q' "$evts") sport=$(sed --unbuffered -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q' "$evts")
...@@ -592,7 +598,7 @@ test_subflows() ...@@ -592,7 +598,7 @@ test_subflows()
"$client_addr_id" "ns1" "ns2" "$client_addr_id" "ns1" "ns2"
# Delete the listener from the client ns, if one was created # Delete the listener from the client ns, if one was created
kill $listener_pid > /dev/null 2>&1 kill_wait $listener_pid
sport=$(sed --unbuffered -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q' "$evts") sport=$(sed --unbuffered -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q' "$evts")
...@@ -631,7 +637,7 @@ test_subflows() ...@@ -631,7 +637,7 @@ test_subflows()
"$client_addr_id" "ns1" "ns2" "$client_addr_id" "ns1" "ns2"
# Delete the listener from the client ns, if one was created # Delete the listener from the client ns, if one was created
kill $listener_pid > /dev/null 2>&1 kill_wait $listener_pid
sport=$(sed --unbuffered -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q' "$evts") sport=$(sed --unbuffered -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q' "$evts")
...@@ -647,7 +653,7 @@ test_subflows() ...@@ -647,7 +653,7 @@ test_subflows()
ip netns exec "$ns2" ./pm_nl_ctl rem id $client_addr_id token\ ip netns exec "$ns2" ./pm_nl_ctl rem id $client_addr_id token\
"$client4_token" > /dev/null 2>&1 "$client4_token" > /dev/null 2>&1
kill $evts_pid kill_wait $evts_pid
# Capture events on the network namespace running the client # Capture events on the network namespace running the client
:>"$evts" :>"$evts"
...@@ -674,7 +680,7 @@ test_subflows() ...@@ -674,7 +680,7 @@ test_subflows()
"10.0.2.1" "$app4_port" "23" "$server_addr_id" "ns2" "ns1" "10.0.2.1" "$app4_port" "23" "$server_addr_id" "ns2" "ns1"
# Delete the listener from the server ns, if one was created # Delete the listener from the server ns, if one was created
kill $listener_pid> /dev/null 2>&1 kill_wait $listener_pid
sport=$(sed --unbuffered -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q' "$evts") sport=$(sed --unbuffered -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q' "$evts")
...@@ -713,7 +719,7 @@ test_subflows() ...@@ -713,7 +719,7 @@ test_subflows()
"$server_addr_id" "ns2" "ns1" "$server_addr_id" "ns2" "ns1"
# Delete the listener from the server ns, if one was created # Delete the listener from the server ns, if one was created
kill $listener_pid > /dev/null 2>&1 kill_wait $listener_pid
sport=$(sed --unbuffered -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q' "$evts") sport=$(sed --unbuffered -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q' "$evts")
...@@ -750,7 +756,7 @@ test_subflows() ...@@ -750,7 +756,7 @@ test_subflows()
"10.0.2.2" "10.0.2.1" "$new4_port" "23" "$server_addr_id" "ns2" "ns1" "10.0.2.2" "10.0.2.1" "$new4_port" "23" "$server_addr_id" "ns2" "ns1"
# Delete the listener from the server ns, if one was created # Delete the listener from the server ns, if one was created
kill $listener_pid > /dev/null 2>&1 kill_wait $listener_pid
sport=$(sed --unbuffered -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q' "$evts") sport=$(sed --unbuffered -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q' "$evts")
...@@ -766,7 +772,7 @@ test_subflows() ...@@ -766,7 +772,7 @@ test_subflows()
ip netns exec "$ns1" ./pm_nl_ctl rem id $server_addr_id token\ ip netns exec "$ns1" ./pm_nl_ctl rem id $server_addr_id token\
"$server4_token" > /dev/null 2>&1 "$server4_token" > /dev/null 2>&1
kill $evts_pid kill_wait $evts_pid
rm -f "$evts" rm -f "$evts"
} }
......
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