selftests: add ipv6 support and reduce run time
Subsystems (3)
Florian Westphal
v4 cover selftests: add ipv6 support and reduce run time
This is the 4th iteration of the selftest patchset.
Changes since v3:
- get rid of unused variable warnings in patch 2
- get rid of bogus fallthrough in patch 4
- add patch 8: Get rid of redundant test cases, no need to test tcp fallback for all netns combinations.
- add patch 9: allow to set delay/loss/reordering etc. to use. Default is random so selftests expose wider combinations.
All changes can be squashed into "mptcp: add basic kselftest for mptcp".
The following changes since commit 117a75c747bfe24c1ba08c295a289204c291f588:
mptcp: Implement basic path manager (2019-10-25 01:30:45 +0000)
are available in the Git repository at:
git://git.breakpoint.cc/fw/mptcp-next.git mptcp_selftest_04
for you to fetch changes up to ffc4ff6abe4fcc1701afa0b924fca7ec88823e1e:
selftests: mptcp: add command line options to override netem/ethtool settings (2019-10-25 14:09:38 +0200)
----------------------------------------------------------------
Florian Westphal (9):
selftests: mptcp: make tc delays random
selftests: mptcp: add accept/getpeer checks
selftests: mptcp: extend mptcp_connect tool for ipv6 family
selftests: mptcp: random ethtool tweaking
selftests: mptcp: allow parallel execution
selftests: mptcp: fix spurious deadlock
selftests: mptcp: track duration of each test
selftests: mptcp: remove the redundant test cases
selftests: mptcp: add command line options to override netem/ethtool settings
tools/testing/selftests/net/mptcp/mptcp_connect.c | 175 +++++++++-- tools/testing/selftests/net/mptcp/mptcp_connect.sh | 326 +++++++++++++++++---- 2 files changed, 411 insertions(+), 90 deletions(-)
Florian Westphal
PATCH v4 1/9 selftests: mptcp: make tc delays random
test with less predictable setups:
tc qdisc delay is now random, same for reordering and loss. Motivation is to cover more scenarious without a increase in test-time.
--- .../selftests/net/mptcp/mptcp_connect.sh | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_connect.sh +24 -2
@@ -302,8 +302,30 @@ for sender in 1 2 3 4;do do_ping ns4 ns$sender 10.0.3.1 done -tc -net ns2 qdisc add dev ns2eth3 root netem loss random 1 -tc -net ns3 qdisc add dev ns3eth4 root netem delay 10ms reorder 25% 50% gap 5 +loss=$((RANDOM%101)) +if [ $loss -eq 100 ] ;then + loss=1% + tc -net ns2 qdisc add dev ns2eth3 root netem loss random $loss +elif [ $loss -ge 10 ]; then + loss=0.$loss% + tc -net ns2 qdisc add dev ns2eth3 root netem loss random $loss +elif [ $loss -ge 1 ]; then + loss=0.0$loss% + tc -net ns2 qdisc add dev ns2eth3 root netem loss random $loss +fi + +delay=$((RANDOM%400)) +reorder1=$((RANDOM%10)) +reorder1=$((100 - reorder1)) +reorder2=$((RANDOM%100)) + +if [ $reorder1 -lt 100 ] && [ $reorder2 -gt 0 ]; then + tc -net ns3 qdisc add dev ns3eth4 root netem delay ${delay}ms reorder ${reorder1}% ${reorder2}% + echo "INFO: Using loss of $loss, delay $delay ms, reorder: $reorder1, $reorder2 on ns3eth4" +elif [ $delay -gt 0 ]; then + tc -net ns3 qdisc add dev ns3eth4 root netem delay ${delay}ms + echo "INFO: Using loss of $loss, delay $delay ms on ns3eth4" +fi for sender in 1 2 3 4;do run_tests ns1 ns$sender 10.0.1.1
Signature · 1 line
2.23.0
Florian Westphal
PATCH v4 2/9 selftests: mptcp: add accept/getpeer checks
In reply to Florian WestphalCheck that the result coming from accept matches that of getpeername. For initiator side, check getpeername matches address passed to connect().
At this time, kernel returns the address of the first subflow in the list. Right now, we do not yet implement fate-sharing, i.e. if the original subflow goes away, the result of getpeername would change.
There are different ways to fix that. One would be to copy the quadruple from the first subflow socket to the mptcp socket.
If we do that, this test should catch a possible bug (such as accidental reversal of saddr/daddr).
--- .../selftests/net/mptcp/mptcp_connect.c | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+)
tools/testing/selftests/net/mptcp/mptcp_connect.c +107 -0
@@ -54,6 +54,21 @@ static const char *getxinfo_strerr(int err)return gai_strerror (err); } +static void xgetnameinfo (const struct sockaddr *addr,socklen_t addrlen, +char *host,socklen_t hostlen, +char *serv,socklen_t servlen) +{ +int flags =NI_NUMERICHOST |NI_NUMERICSERV ; +int err =getnameinfo (addr, addrlen, host, hostlen, serv, servlen, flags); + +if (err) { +const char *errstr =getxinfo_strerr (err); + +fprintf (stderr,"Fatal: getnameinfo: %s\n" , errstr); +exit (1 ); + } +} +static void xgetaddrinfo (const char *node,const char *service,const struct addrinfo *hints,struct addrinfo **res)
@@ -327,6 +342,94 @@ static int copyfd_io(int infd, int peerfd, int outfd)return 0 ; } +static void check_sockaddr (int pf,struct sockaddr_storage *ss, +socklen_t salen) +{ +char addr[INET6_ADDRSTRLEN ]; +char serv[INET6_ADDRSTRLEN ]; +struct sockaddr_in6 *sin6; +struct sockaddr_in *sin; +int wanted_size =0 ; + +switch (pf) { +case AF_INET : + wanted_size =sizeof (*sin); + sin = (void *)ss; +if (!sin->sin_port) +fprintf (stderr,"accept: something wrong: ip connection from port 0" ); +break ; +case AF_INET6 : + wanted_size =sizeof (*sin6); + sin6 = (void *)ss; +if (!sin6->sin6_port) +fprintf (stderr,"accept: something wrong: ipv6 connection from port 0" ); +break ; +default : +fprintf (stderr,"accept: Unknown pf %d, salen %u\n" , pf, salen); +return ; + } + +if (salen != wanted_size) +fprintf (stderr,"accept: size mismatch, got %d expected %d\n" , + (int )salen, wanted_size); + +if (ss->ss_family != pf) +fprintf (stderr,"accept: pf mismatch, expect %d, ss_family is %d\n" , + (int )ss->ss_family, pf); +} + +static void check_getpeername (int fd,struct sockaddr_storage *ss,socklen_t salen) +{ +struct sockaddr_storage peerss; +socklen_t peersalen =sizeof (peerss); + +if (getpeername (fd, (struct sockaddr *)&peerss, &peersalen) <0 ) { +perror ("getpeername" ); +return ; + } + +if (peersalen != salen) { +fprintf (stderr,"%s: %d vs %d\n" , __func__, peersalen, salen); +return ; + } + +if (memcmp (ss, &peerss, peersalen)) { +char a[INET6_ADDRSTRLEN ]; +char b[INET6_ADDRSTRLEN ]; +char c[INET6_ADDRSTRLEN ]; +char d[INET6_ADDRSTRLEN ]; + +xgetnameinfo ((struct sockaddr *)ss, salen, + a,sizeof (a), b,sizeof (b)); + +xgetnameinfo ((struct sockaddr *)&peerss, peersalen, + c,sizeof (c), d,sizeof (d)); + +fprintf (stderr,"%s: memcmp failure: accept %s vs peername %s, %s vs %s salen %d vs %d\n" , + __func__, a, c, b, d, peersalen, salen); + } +} + +static void check_getpeername_connect (int fd) +{ +struct sockaddr_storage ss; +socklen_t salen =sizeof (ss); +char a[INET6_ADDRSTRLEN ]; +char b[INET6_ADDRSTRLEN ]; + +if (getpeername (fd, (struct sockaddr *)&ss, &salen) <0 ) { +perror ("getpeername" ); +return ; + } + +xgetnameinfo ((struct sockaddr *)&ss, salen, + a,sizeof (a), b,sizeof (b)); + +if (strcmp (cfg_host, a) ||strcmp (cfg_port, b)) +fprintf (stderr,"%s: %s vs %s, %s vs %s\n" , __func__, + cfg_host, a, cfg_port, b); +} +int main_loop_s (int listensock) {struct sockaddr_storage ss;
@@ -350,6 +453,9 @@ int main_loop_s(int listensock) salen =sizeof (ss); remotesock =accept (listensock, (struct sockaddr *)&ss, &salen);if (remotesock >=0 ) { +check_sockaddr (pf, &ss, salen); +check_getpeername (remotesock, &ss, salen); +copyfd_io (0 , remotesock,1 );return 0 ; }
@@ -384,6 +490,7 @@ int main_loop(void)if (fd <0 )return 2 ; +check_getpeername_connect (fd);return copyfd_io (0 , fd,1 ); }
Signature · 1 line
2.23.0
Florian Westphal
PATCH v4 3/9 selftests: mptcp: extend mptcp_connect tool for ipv6 family
In reply to Florian WestphalAt this time socket() will fail when requesting an ipv6 mptcp socket. This is ok for now, as the test script won't request ipv6 tests yet.
Once someone starts to implement mptcp v6 support, just set ipv6=true in the script and the selftest will attempt to connect via ipv6.
Tested with a tcp <-> tcp connection.
--- .../selftests/net/mptcp/mptcp_connect.c | 21 +++-- .../selftests/net/mptcp/mptcp_connect.sh | 77 ++++++++++++++++--- 2 files changed, 79 insertions(+), 19 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_connect.c +13 -8
@@ -37,11 +37,11 @@ static const char *cfg_host;static const char *cfg_port ="12000" ;static int cfg_sock_proto =IPPROTO_MPTCP ;static bool tcpulp_audit; - +static int pf =AF_INET ;static void die_usage (void ) { -fprintf (stderr,"Usage: mptcp_connect [-u] [-s MPTCP|TCP] [-p port] " +fprintf (stderr,"Usage: mptcp_connect [-6] [-u] [-s MPTCP|TCP] [-p port] " "[ -l ] [ -t timeout ] connect_address\n" );exit (1 ); }
@@ -94,12 +94,13 @@ static int sock_listen_mptcp(const char * const listenaddr, .ai_flags = AI_PASSIVE | AI_NUMERICHOST }; - hints.ai_family =AF_INET ; + hints.ai_family = pf;struct addrinfo *a, *addr;int one =1 ;xgetaddrinfo (listenaddr, port, &hints, &addr); + hints.ai_family = pf;for (a = addr; a; a = a->ai_next) { sock =socket (a->ai_family, a->ai_socktype, cfg_sock_proto);
@@ -182,7 +183,7 @@ static int sock_connect_mptcp(const char * const remoteaddr,struct addrinfo *a, *addr;int sock =-1 ; - hints.ai_family =AF_INET ; + hints.ai_family = pf;xgetaddrinfo (remoteaddr, port, &hints, &addr);for (a = addr; a; a = a->ai_next) {
@@ -345,11 +346,9 @@ static int copyfd_io(int infd, int peerfd, int outfd)static void check_sockaddr (int pf,struct sockaddr_storage *ss,socklen_t salen) { -char addr[INET6_ADDRSTRLEN ]; -char serv[INET6_ADDRSTRLEN ];struct sockaddr_in6 *sin6;struct sockaddr_in *sin; -int wanted_size =0 ; +socklen_t wanted_size =0 ;switch (pf) {case AF_INET :
@@ -512,7 +511,7 @@ static void parse_opts(int argc, char **argv) {int c; -while ((c =getopt (argc, argv,"lp:s:hut:" )) !=-1 ) { +while ((c =getopt (argc, argv,"6lp:s:hut:" )) !=-1 ) {switch (c) {case 'l' : listen_mode = true;
@@ -529,6 +528,9 @@ static void parse_opts(int argc, char **argv)case 'u' : tcpulp_audit = true;break ; +case '6' : + pf =AF_INET6 ; +break ;case 't' : poll_timeout =atoi (optarg) *1000 ;if (poll_timeout <=0 )
@@ -540,6 +542,9 @@ static void parse_opts(int argc, char **argv)if (optind +1 != argc)die_usage (); cfg_host = argv[optind]; + +if (strchr (cfg_host,':' )) + pf =AF_INET6 ; }int main (int argc,char *argv[])
tools/testing/selftests/net/mptcp/mptcp_connect.sh +66 -11
175 lines not on this page · raw message
Signature · 1 line
2.23.0
Florian Westphal
PATCH v4 4/9 selftests: mptcp: random ethtool tweaking
In reply to Florian WestphalInstead of unconditionally disabling TSO in ns3, turn off any of gso/tso/gro in ns3 and/or ns4.
This gets us various combinations of GRO/GSO/TSO without a large impact on the average test run time.
The old approach is already not deterministic, and cannot possibly be made so. For protocol tests mptcp packetdrill is a better fit.
--- .../selftests/net/mptcp/mptcp_connect.sh | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
tools/testing/selftests/net/mptcp/mptcp_connect.sh +24 -1
@@ -91,7 +91,6 @@ $ipv6 && ip -net ns3 addr add dead:beef:3::2/64 dev ns3eth4 ip -net ns3 link set ns3eth4 up ip -net ns3 route add default via 10.0.2.1 $ipv6 && ip -net ns3 route add default via dead:beef:2::1 -ip netns exec ns3 ethtool -K ns3eth2 tso off 2>/dev/null ip netns exec ns3 sysctl -q net.ipv4.ip_forward=1 $ipv6 && ip netns exec ns3 sysctl -q net.ipv6.conf.all.forwarding=1
@@ -101,6 +100,30 @@ ip -net ns4 link set ns4eth3 up ip -net ns4 route add default via 10.0.3.2 $ipv6 && ip -net ns4 route add default via dead:beef:3::2 +set_ethtool_flags() { + ns=$1 + dev=$2 + + r=$RANDOM + + pick1=$((r & 1)) + pick2=$((r & 2)) + pick3=$((r & 4)) + + flags="" + [ $pick1 -ne 0 ] && flags="tso off" + [ $pick2 -ne 0 ] && flags="$flags gso off" + [ $pick3 -ne 0 ] && flags="$flags gro off" + + [ -z "$flags" ] && return + + ip netns exec $ns ethtool -K $dev $flags 2>/dev/null + [ $? -eq 0 ] && echo "INFO: set $ns dev $dev: ethtool -K $flags" +} + +set_ethtool_flags ns3 ns3eth2 +set_ethtool_flags ns4 ns4eth3 + print_file_err() { ls -l "$1" 1>&2
Signature · 1 line
2.23.0
Florian Westphal
PATCH v4 5/9 selftests: mptcp: allow parallel execution
In reply to Florian WestphalThis allows to run multiple instances of the test script in parallel on the same host.
Should it make easier to spot e.g. resource leaks or race conditions.
--- .../selftests/net/mptcp/mptcp_connect.sh | 165 +++++++++--------- 1 file changed, 86 insertions(+), 79 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_connect.sh +86 -79
@@ -11,6 +11,13 @@ capture=0 timeout=30 ipv6=false +sec=$(date +%s) +rndh=$(printf %x $sec)-$(mktemp -u XXXXXX) +ns1="ns1-$rndh" +ns2="ns2-$rndh" +ns3="ns3-$rndh" +ns4="ns4-$rndh" + TEST_COUNT=0 cleanup()
@@ -19,8 +26,8 @@ cleanup() rm -f "$sin" "$sout" rm -f "$capout" - for i in 1 2 3 4; do - ip netns del ns$i + for netns in "$ns1" "$ns2" "$ns3" "$ns4";do + ip netns del $netns done }
@@ -43,62 +50,62 @@ cout=$(mktemp) capout=$(mktemp) trap cleanup EXIT -for i in 1 2 3 4;do - ip netns add ns$i || exit $ksft_skip - ip -net ns$i link set lo up +for i in "$ns1" "$ns2" "$ns3" "$ns4";do + ip netns add $i || exit $ksft_skip + ip -net $i link set lo up done -# ns1 ns2 ns3 ns4 +# "$ns1" ns2 ns3 ns4 # ns1eth2 ns2eth1 ns2eth3 ns3eth2 ns3eth4 ns4eth3 # - drop 1% -> reorder 25% # <- TSO off - -ip link add ns1eth2 netns ns1 type veth peer name ns2eth1 netns ns2 -ip link add ns2eth3 netns ns2 type veth peer name ns3eth2 netns ns3 -ip link add ns3eth4 netns ns3 type veth peer name ns4eth3 netns ns4 +ip link add ns1eth2 netns "$ns1" type veth peer name ns2eth1 netns "$ns2" +ip link add ns2eth3 netns "$ns2" type veth peer name ns3eth2 netns "$ns3" +ip link add ns3eth4 netns "$ns3" type veth peer name ns4eth3 netns "$ns4" -ip -net ns1 addr add 10.0.1.1/24 dev ns1eth2 +ip -net "$ns1" addr add 10.0.1.1/24 dev ns1eth2 if $ipv6 ; then - ip -net ns1 addr add dead:beef:1::1/64 dev ns1eth2 + ip -net "$ns1" addr add dead:beef:1::1/64 dev ns1eth2 if [ $? -ne 0 ] ;then echo "SKIP: Can't add ipv6 address, skip ipv6 tests" 1>&2 ipv6=false fi fi -ip -net ns1 link set ns1eth2 up -ip -net ns1 route add default via 10.0.1.2 -$ipv6 && ip -net ns1 route add default via dead:beef:1::2 - -ip -net ns2 addr add 10.0.1.2/24 dev ns2eth1 -$ipv6 && ip -net ns2 addr add dead:beef:1::2/64 dev ns2eth1 -ip -net ns2 link set ns2eth1 up - -ip -net ns2 addr add 10.0.2.1/24 dev ns2eth3 -$ipv6 && ip -net ns2 addr add dead:beef:2::1/64 dev ns2eth3 -ip -net ns2 link set ns2eth3 up -ip -net ns2 route add default via 10.0.2.2 -$ipv6 && ip -net ns2 route add default via dead:beef:2::2 -ip netns exec ns2 sysctl -q net.ipv4.ip_forward=1 -$ipv6 && ip netns exec ns2 sysctl -q net.ipv6.conf.all.forwarding=1 - -ip -net ns3 addr add 10.0.2.2/24 dev ns3eth2 -$ipv6 && ip -net ns3 addr add dead:beef:2::2/64 dev ns3eth2 -ip -net ns3 link set ns3eth2 up - -ip -net ns3 addr add 10.0.3.2/24 dev ns3eth4 -$ipv6 && ip -net ns3 addr add dead:beef:3::2/64 dev ns3eth4 -ip -net ns3 link set ns3eth4 up -ip -net ns3 route add default via 10.0.2.1 -$ipv6 && ip -net ns3 route add default via dead:beef:2::1 -ip netns exec ns3 sysctl -q net.ipv4.ip_forward=1 -$ipv6 && ip netns exec ns3 sysctl -q net.ipv6.conf.all.forwarding=1 - -ip -net ns4 addr add 10.0.3.1/24 dev ns4eth3 -$ipv6 && ip -net ns4 addr add dead:beef:3::1/64 dev ns4eth3 -ip -net ns4 link set ns4eth3 up -ip -net ns4 route add default via 10.0.3.2 -$ipv6 && ip -net ns4 route add default via dead:beef:3::2 +ip -net "$ns1" link set ns1eth2 up +ip -net "$ns1" route add default via 10.0.1.2 +$ipv6 && ip -net "$ns1" route add default via dead:beef:1::2 + +ip -net "$ns2" addr add 10.0.1.2/24 dev ns2eth1 +$ipv6 && ip -net "$ns2" addr add dead:beef:1::2/64 dev ns2eth1 +ip -net "$ns2" link set ns2eth1 up + +ip -net "$ns2" addr add 10.0.2.1/24 dev ns2eth3 +$ipv6 && ip -net "$ns2" addr add dead:beef:2::1/64 dev ns2eth3 +ip -net "$ns2" link set ns2eth3 up +ip -net "$ns2" route add default via 10.0.2.2 +$ipv6 && ip -net "$ns2" route add default via dead:beef:2::2 +ip netns exec "$ns2" sysctl -q net.ipv4.ip_forward=1 +$ipv6 && ip netns exec "$ns2" sysctl -q net.ipv6.conf.all.forwarding=1 + +ip -net "$ns3" addr add 10.0.2.2/24 dev ns3eth2 +$ipv6 && ip -net "$ns3" addr add dead:beef:2::2/64 dev ns3eth2 +ip -net "$ns3" link set ns3eth2 up + +ip -net "$ns3" addr add 10.0.3.2/24 dev ns3eth4 +$ipv6 && ip -net "$ns3" addr add dead:beef:3::2/64 dev ns3eth4 +ip -net "$ns3" link set ns3eth4 up +ip -net "$ns3" route add default via 10.0.2.1 +$ipv6 && ip -net "$ns3" route add default via dead:beef:2::1 +ip netns exec "$ns3" sysctl -q net.ipv4.ip_forward=1 +$ipv6 && ip netns exec "$ns3" sysctl -q net.ipv6.conf.all.forwarding=1 + +ip -net "$ns4" addr add 10.0.3.1/24 dev ns4eth3 +$ipv6 && ip -net "$ns4" addr add dead:beef:3::1/64 dev ns4eth3 +ip -net "$ns4" link set ns4eth3 up +ip -net "$ns4" route add default via 10.0.3.2 +$ipv6 && ip -net "$ns4" route add default via dead:beef:3::2 set_ethtool_flags() { ns=$1
@@ -121,8 +128,8 @@ set_ethtool_flags() { [ $? -eq 0 ] && echo "INFO: set $ns dev $dev: ethtool -K $flags" } -set_ethtool_flags ns3 ns3eth2 -set_ethtool_flags ns4 ns4eth3 +set_ethtool_flags "$ns3" ns3eth2 +set_ethtool_flags "$ns4" ns4eth3 print_file_err() {
@@ -151,7 +158,7 @@ check_transfer() check_mptcp_disabled() { - disabled_ns="ns_disabled" + disabled_ns="ns_disabled-$sech-$(mktemp -u XXXXXX)" ip netns add ${disabled_ns} || exit $ksft_skip # net.mptcp.enabled should be enabled by default
@@ -179,7 +186,7 @@ check_mptcp_disabled() check_mptcp_ulp_setsockopt() { - local t="ns_ulp" retval= + local t="ns_ulp-$sech-$(mktemp -u XXXXXX)" retval= ip netns add ${t} || exit $ksft_skip if ! ip netns exec ${t} ./mptcp_connect -u -p 10000 -s TCP 127.0.0.1 2>&1; then
@@ -344,40 +351,40 @@ check_mptcp_ulp_setsockopt # Allow DAD to finish $ipv6 && sleep 2 -for sender in 1 2 3 4;do - do_ping ns1 ns$sender 10.0.1.1 +for sender in "$ns1" "$ns2" "$ns3" "$ns4";do + do_ping "$ns1" $sender 10.0.1.1 if $ipv6;then - do_ping ns1 ns$sender dead:beef:1::1 + do_ping "$ns1" $sender dead:beef:1::1 if [ $? -ne 0 ]; then echo "SKIP: IPv6 tests" 2>&1 ipv6=false fi fi - do_ping ns2 ns$sender 10.0.1.2 - $ipv6 && do_ping ns2 ns$sender dead:beef:1::2 - do_ping ns2 ns$sender 10.0.2.1 - $ipv6 && do_ping ns2 ns$sender dead:beef:2::1 + do_ping "$ns2" $sender 10.0.1.2 + $ipv6 && do_ping "$ns2" $sender dead:beef:1::2 + do_ping "$ns2" $sender 10.0.2.1 + $ipv6 && do_ping "$ns2" $sender dead:beef:2::1 - do_ping ns3 ns$sender 10.0.2.2 - $ipv6 && do_ping ns3 ns$sender dead:beef:2::2 - do_ping ns3 ns$sender 10.0.3.2 - $ipv6 && do_ping ns3 ns$sender dead:beef:3::2 + do_ping "$ns3" $sender 10.0.2.2 + $ipv6 && do_ping "$ns3" $sender dead:beef:2::2 + do_ping "$ns3" $sender 10.0.3.2 + $ipv6 && do_ping "$ns3" $sender dead:beef:3::2 - do_ping ns4 ns$sender 10.0.3.1 - $ipv6 && do_ping ns4 ns$sender dead:beef:3::1 + do_ping ns4 $sender 10.0.3.1 + $ipv6 && do_ping "$ns4" $sender dead:beef:3::1 done loss=$((RANDOM%101)) if [ $loss -eq 100 ] ;then loss=1% - tc -net ns2 qdisc add dev ns2eth3 root netem loss random $loss + tc -net "$ns2" qdisc add dev ns2eth3 root netem loss random $loss elif [ $loss -ge 10 ]; then loss=0.$loss% - tc -net ns2 qdisc add dev ns2eth3 root netem loss random $loss + tc -net "$ns2" qdisc add dev ns2eth3 root netem loss random $loss elif [ $loss -ge 1 ]; then loss=0.0$loss% - tc -net ns2 qdisc add dev ns2eth3 root netem loss random $loss + tc -net "$ns2" qdisc add dev ns2eth3 root netem loss random $loss fi delay=$((RANDOM%400))
@@ -386,35 +393,35 @@ reorder1=$((100 - reorder1)) reorder2=$((RANDOM%100)) if [ $reorder1 -lt 100 ] && [ $reorder2 -gt 0 ]; then - tc -net ns3 qdisc add dev ns3eth4 root netem delay ${delay}ms reorder ${reorder1}% ${reorder2}% + tc -net "$ns3" qdisc add dev ns3eth4 root netem delay ${delay}ms reorder ${reorder1}% ${reorder2}% echo "INFO: Using loss of $loss, delay $delay ms, reorder: $reorder1, $reorder2 on ns3eth4" elif [ $delay -gt 0 ]; then - tc -net ns3 qdisc add dev ns3eth4 root netem delay ${delay}ms + tc -net "$ns3" qdisc add dev ns3eth4 root netem delay ${delay}ms echo "INFO: Using loss of $loss, delay $delay ms on ns3eth4" fi -for sender in 1 2 3 4;do - run_tests ns1 ns$sender 10.0.1.1 0.0.0.0 +for sender in $ns1 $ns2 $ns3 $ns4;do + run_tests "$ns1" $sender 10.0.1.1 0.0.0.0 if $ipv6;then - run_tests ns1 ns$sender dead:beef:1::1 :: + run_tests "$ns1" $sender dead:beef:1::1 :: if [ $? -ne 0 ] ;then echo "SKIP: IPv6 tests" 2>&1 ipv6=false fi fi - run_tests ns2 ns$sender 10.0.1.2 0.0.0.0 - $ipv6 && run_tests ns2 ns$sender dead:beef:1::2 :: - run_tests ns2 ns$sender 10.0.2.1 0.0.0.0 - $ipv6 && run_tests ns2 ns$sender dead:beef:2::1 :: + run_tests "$ns2" $sender 10.0.1.2 0.0.0.0 + $ipv6 && run_tests "$ns2" $sender dead:beef:1::2 :: + run_tests "$ns2" $sender 10.0.2.1 0.0.0.0 + $ipv6 && run_tests "$ns2" $sender dead:beef:2::1 :: - run_tests ns3 ns$sender 10.0.2.2 0.0.0.0 - $ipv6 && run_tests ns3 ns$sender dead:beef:2::2 :: - run_tests ns3 ns$sender 10.0.3.2 0.0.0.0 - $ipv6 && run_tests ns3 ns$sender dead:beef:3::2 :: + run_tests "$ns3" $sender 10.0.2.2 0.0.0.0 + $ipv6 && run_tests "$ns3" $sender dead:beef:2::2 :: + run_tests "$ns3" $sender 10.0.3.2 0.0.0.0 + $ipv6 && run_tests "$ns3" $sender dead:beef:3::2 :: - run_tests ns4 ns$sender 10.0.3.1 0.0.0.0 - $ipv6 && run_tests ns4 ns$sender dead:beef:3::1 :: + run_tests "$ns4" $sender 10.0.3.1 0.0.0.0 + $ipv6 && run_tests "$ns4" $sender dead:beef:3::1 :: done exit $ret
Signature · 1 line
2.23.0
Florian Westphal
PATCH v4 6/9 selftests: mptcp: fix spurious deadlock
In reply to Florian Westphaldo_rnd_write() may call write on the mptcp socket repeatedly. As the peerfd is blocking, this prevents the process from draining the receive buffer.
Its unlikely but possible that both sides are blocked in write() on the tcp socket, with both ends announcing a zero window, waiting for read() to drain the socket receive buffer.
An alternative fix would be to make the peerfds nonblocking. This change instead makes it so we call write at most once after poll revents has the POLLOUT bit set.
--- .../selftests/net/mptcp/mptcp_connect.c | 53 ++++++++++--------- 1 file changed, 28 insertions(+), 25 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_connect.c +28 -25
@@ -207,27 +207,18 @@ static int sock_connect_mptcp(const char * const remoteaddr,static size_t do_rnd_write (const int fd,char *buf,const size_t len) { -size_t offset =0 ; - -while (offset < len) { -unsigned int do_w; -size_t written; -ssize_t bw; +unsigned int do_w; +ssize_t bw; - do_w =rand () &0xffff ; -if (do_w ==0 || do_w > (len - offset)) - do_w = len - offset; + do_w =rand () &0xffff ; +if (do_w ==0 || do_w > len) + do_w = len; - bw =write (fd, buf + offset, do_w); -if (bw <0 ) { -perror ("write" ); -return 0 ; - } + bw =write (fd, buf, do_w); +if (bw <0 ) +perror ("write" ); - written = (size_t )bw; - offset += written; - } -return offset; +return bw; }static size_t do_write (const int fd,char *buf,const size_t len)
@@ -271,9 +262,11 @@ static int copyfd_io(int infd, int peerfd, int outfd) .fd = peerfd, .events = POLLIN | POLLOUT, }; +unsigned int woff =0 , wlen =0 ; +char wbuf[8192 ];for (;;) { -char buf[8192 ]; +char rbuf[8192 ];ssize_t len;if (fds.events ==0 )
@@ -293,7 +286,7 @@ static int copyfd_io(int infd, int peerfd, int outfd) }if (fds.revents &POLLIN ) { - len =do_rnd_read (peerfd, buf,sizeof (buf)); + len =do_rnd_read (peerfd, rbuf,sizeof (rbuf));if (len ==0 ) {/* no more data to receive: * peer has closed its write side
@@ -310,15 +303,25 @@ static int copyfd_io(int infd, int peerfd, int outfd)return 3 ; } -do_write (outfd, buf, len); +do_write (outfd, rbuf, len); }if (fds.revents &POLLOUT ) { - len =do_rnd_read (infd, buf,sizeof (buf)); -if (len >0 ) { -if (!do_rnd_write (peerfd, buf, len)) +if (wlen ==0 ) { + woff =0 ; + wlen =read (infd, wbuf,sizeof (wbuf)); + } + +if (wlen >0 ) { +ssize_t bw; + + bw =do_rnd_write (peerfd, wbuf + woff, wlen); +if (bw <0 )return 111 ; - }else if (len ==0 ) { + + woff += bw; + wlen -= bw; + }else if (wlen ==0 ) {/* We have no more data to send. */ fds.events &= ~POLLOUT ;
Signature · 1 line
2.23.0
Florian Westphal
PATCH v4 7/9 selftests: mptcp: track duration of each test
In reply to Florian WestphalThis allows to detect discrepancies, e.g.
MPTCP -> TCP 1s
TCP -> MPTCP 0s
MPTCP -> MPTCP 41s
The expecation of course is that test duration is pretty similar for tests between the same network namespaces, regardless of wheter MPTCP or TCP fallback is used.
--- tools/testing/selftests/net/mptcp/mptcp_connect.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_connect.sh +7 -2
@@ -256,6 +256,7 @@ do_transfer() sleep 1 + start=$(date +%s) ip netns exec ${connector_ns} ./mptcp_connect -t $timeout -p $port -s ${cl_proto} $connect_addr < "$cin" > "$cout" & cpid=$!
@@ -264,13 +265,17 @@ do_transfer() wait $spid rets=$? + stop=$(date +%s) + if [ $capture -eq 1 ]; then sleep 1 kill $cappid fi + duration=$((stop-start)) + duration=$(printf "(duration %03ss)" $duration) if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then - echo "[ FAIL ] client exit code $retc, server $rets" 1>&2 + echo "$duration [ FAIL ] client exit code $retc, server $rets" 1>&2 echo "\nnetns ${listener_ns} socket stat for $port:" 1>&2 ip netns exec ${listener_ns} ss -nita 1>&2 -o "sport = :$port" echo "\nnetns ${connector_ns} socket stat for $port:" 1>&2
@@ -286,7 +291,7 @@ do_transfer() rets=$? if [ $retc -eq 0 ] && [ $rets -eq 0 ];then - echo "[ OK ]" + echo "$duration [ OK ]" cat "$capout" return 0 fi
Signature · 1 line
2.23.0
Florian Westphal
PATCH v4 8/9 selftests: mptcp: remove the redundant test cases
In reply to Florian WestphalBefore this change we test all combinations, i.e.
ns1 -> ns{1,2,3,4}
ns2 -> ns{1,2,3,4}
ns3 -> ns{1,2,3,4}
ns4 -> ns{1,2,3,4}
and for each we test all of tcp -> mptcp, mptcp -> tcp and mptcp -> mptcp.
This means we have several redundant cases. So only do ns1 -> ns1, but not ns2 -> ns2 and so on.
Also, the fallback test case is supposed to verify that we can still connect, but there is no point in testing this any further.
This change makes it so that we *only* run mptcp -> mptcp tests, and never repeat the loopback case (sender and receiver in same netns). Only exception: ns1->ns1, which also checks that mptcp sender can connect to tcp receiver, and vice versa.
--- .../selftests/net/mptcp/mptcp_connect.sh | 49 ++++++++++++++----- 1 file changed, 38 insertions(+), 11 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_connect.sh +38 -11
@@ -319,22 +319,39 @@ make_file() echo "Created $name (size $TSIZE) containing data sent by $who" } -run_tests() +run_tests_lo() { listener_ns="$1" connector_ns="$2" connect_addr="$3" local_addr="$4" + loopback="$5" lret=0 - for proto in MPTCP TCP;do - do_transfer ${listener_ns} ${connector_ns} MPTCP "$proto" ${connect_addr} ${local_addr} - lret=$? - if [ $lret -ne 0 ]; then - ret=$lret - return 1 - fi - done + # skip if test programs are running inside same netns for subsequent runs. + if [ $loopback -eq 0 ] && [ ${listener_ns} = ${connector_ns} ]; then + ret=$lret + return 1 + fi + + do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} ${local_addr} + lret=$? + if [ $lret -ne 0 ]; then + ret=$lret + return 1 + fi + + # don't bother testing fallback tcp except for loopback case. + if [ ${listener_ns} != ${connector_ns} ]; then + return 0 + fi + + do_transfer ${listener_ns} ${connector_ns} MPTCP TCP ${connect_addr} ${local_addr} + lret=$? + if [ $lret -ne 0 ]; then + ret=$lret + return 1 + fi do_transfer ${listener_ns} ${connector_ns} TCP MPTCP ${connect_addr} ${local_addr} lret=$?
@@ -346,6 +363,11 @@ run_tests() return 0 } +run_tests() +{ + run_tests_lo $1 $2 $3 $4 0 +} + make_file "$cin" "client" make_file "$sin" "server"
@@ -406,11 +428,16 @@ elif [ $delay -gt 0 ]; then fi for sender in $ns1 $ns2 $ns3 $ns4;do - run_tests "$ns1" $sender 10.0.1.1 0.0.0.0 + run_tests_lo "$ns1" "$sender" 10.0.1.1 0.0.0.0 1 + if [ $ret -ne 0 ] ;then + echo "FAIL: Could not even run loopback test" 1>&2 + exit $ret + fi if $ipv6;then - run_tests "$ns1" $sender dead:beef:1::1 :: + run_tests_lo "$ns1" $sender dead:beef:1::1 :: 1 if [ $? -ne 0 ] ;then echo "SKIP: IPv6 tests" 2>&1 + ret=0 ipv6=false fi fi
Signature · 1 line
2.23.0
Florian Westphal
PATCH v4 9/9 selftests: mptcp: add command line options to override netem/ethtool settings
In reply to Florian WestphalThis allows to run the tests with a more consistent/reproduceable setup, e.g:
./mptcp_connect.sh -d 120 -l 0.2 -r "50% 1% gap 5" ./mptcp_connect.sh -d 250 -e tso -e gso -e gro -l 0.01
default is to randomize the settings.
--- .../selftests/net/mptcp/mptcp_connect.sh | 127 +++++++++++++----- 1 file changed, 97 insertions(+), 30 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_connect.sh +97 -30
@@ -1,6 +1,7 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 +optstring="d:e:l:r:h6" ret=0 sin="" sout=""
@@ -10,6 +11,62 @@ ksft_skip=4 capture=0 timeout=30 ipv6=false +ethtool_random_on=true +tc_delay="$((RANDOM%400))" +tc_loss=$((RANDOM%101)) +tc_reorder="" + +if [ $tc_loss -eq 100 ];then + tc_loss=1% +elif [ $tc_loss -ge 10 ]; then + tc_loss=0.$tc_loss% +elif [ $tc_loss -ge 1 ]; then + tc_loss=0.0$tc_loss% +else + tc_loss="" +fi + +usage() { + echo "Usage: $0 [ -a ]" + echo -e "\t-d: tc/netem delay in milliseconds, e.g. \"-d 10\" (default random)" + echo -e "\t-l: tc/netem loss percentage, e.g. \"-l 0.02\" (default random)" + echo -e "\t-r: tc/netem reorder mode, e.g. \"-r 25% 50% gap 5\", use "-r 0" to disable reordering (default random)" + echo -e "\t-e: ethtool features to disable, e.g.: \"-e tso -e gso\" (default: randomly disable any of tso/gso/gro)" +} + +while getopts "$optstring" option;do + case "$option" in + "h") + usage $0 + exit 0 + ;; + "d") + if [ $OPTARG -ge 0 ];then + tc_delay="$OPTARG" + else + echo "-d requires numeric argument, got \"$OPTARG\"" 1>&2 + exit 1 + fi + ;; + "e") + ethtool_args="$ethtool_args $OPTARG off" + ethtool_random_on=false + ;; + "l") + tc_loss="$OPTARG" + ;; + "r") + tc_reorder="$OPTARG" + ;; + "6") + ipv6=true + ;; + "?") + usage $0 + exit 1 + ;; + esac +done sec=$(date +%s) rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
@@ -108,28 +165,38 @@ ip -net "$ns4" route add default via 10.0.3.2 $ipv6 && ip -net "$ns4" route add default via dead:beef:3::2 set_ethtool_flags() { - ns=$1 - dev=$2 + local ns="$1" + local dev="$2" + local flags="$3" + + ip netns exec $ns ethtool -K $dev $flags 2>/dev/null + [ $? -eq 0 ] && echo "INFO: set $ns dev $dev: ethtool -K $flags" +} - r=$RANDOM +set_random_ethtool_flags() { + local flags="" + local r=$RANDOM pick1=$((r & 1)) pick2=$((r & 2)) pick3=$((r & 4)) - flags="" [ $pick1 -ne 0 ] && flags="tso off" [ $pick2 -ne 0 ] && flags="$flags gso off" [ $pick3 -ne 0 ] && flags="$flags gro off" [ -z "$flags" ] && return - ip netns exec $ns ethtool -K $dev $flags 2>/dev/null - [ $? -eq 0 ] && echo "INFO: set $ns dev $dev: ethtool -K $flags" + set_ethtool_flags "$1" "$2" "$flags" } -set_ethtool_flags "$ns3" ns3eth2 -set_ethtool_flags "$ns4" ns4eth3 +if $ethtool_random_on;then + set_random_ethtool_flags "$ns3" ns3eth2 + set_random_ethtool_flags "$ns4" ns4eth3 +else + set_ethtool_flags "$ns3" ns3eth2 "$ethtool_args" + set_ethtool_flags "$ns4" ns4eth3 "$ethtool_args" +fi print_file_err() {
@@ -402,31 +469,31 @@ for sender in "$ns1" "$ns2" "$ns3" "$ns4";do $ipv6 && do_ping "$ns4" $sender dead:beef:3::1 done -loss=$((RANDOM%101)) -if [ $loss -eq 100 ] ;then - loss=1% - tc -net "$ns2" qdisc add dev ns2eth3 root netem loss random $loss -elif [ $loss -ge 10 ]; then - loss=0.$loss% - tc -net "$ns2" qdisc add dev ns2eth3 root netem loss random $loss -elif [ $loss -ge 1 ]; then - loss=0.0$loss% - tc -net "$ns2" qdisc add dev ns2eth3 root netem loss random $loss -fi +[ -n "$tc_loss" ] && tc -net "$ns2" qdisc add dev ns2eth3 root netem loss random $tc_loss +echo -n "INFO: Using loss of $tc_loss " +test "$tc_delay" -gt 0 && echo -n "delay $tc_delay ms " -delay=$((RANDOM%400)) -reorder1=$((RANDOM%10)) -reorder1=$((100 - reorder1)) -reorder2=$((RANDOM%100)) - -if [ $reorder1 -lt 100 ] && [ $reorder2 -gt 0 ]; then - tc -net "$ns3" qdisc add dev ns3eth4 root netem delay ${delay}ms reorder ${reorder1}% ${reorder2}% - echo "INFO: Using loss of $loss, delay $delay ms, reorder: $reorder1, $reorder2 on ns3eth4" -elif [ $delay -gt 0 ]; then - tc -net "$ns3" qdisc add dev ns3eth4 root netem delay ${delay}ms - echo "INFO: Using loss of $loss, delay $delay ms on ns3eth4" +if [ -z "${tc_reorder}" ]; then + reorder1=$((RANDOM%10)) + reorder1=$((100 - reorder1)) + reorder2=$((RANDOM%100)) + + if [ $tc_delay -gt 0 ] && [ $reorder1 -lt 100 ] && [ $reorder2 -gt 0 ]; then + tc_reorder="reorder ${reorder1}% ${reorder2}%" + echo -n "$tc_reorder " + fi +elif [ "$tc_reorder" = "0" ];then + tc_reorder="" +elif [ "$tc_delay" -gt 0 ];then + # reordering requires some delay + tc_reorder="reorder $tc_reorder" + echo -n "$tc_reorder " fi +echo "on ns3eth4" + +tc -net "$ns3" qdisc add dev ns3eth4 root netem delay ${tc_delay}ms $tc_reorder + for sender in $ns1 $ns2 $ns3 $ns4;do run_tests_lo "$ns1" "$sender" 10.0.1.1 0.0.0.0 1 if [ $ret -ne 0 ] ;then
Signature · 1 line
2.23.0
Mat Martineau
[MPTCP] Re: [PATCH 9/9] selftests: mptcp: add command line options to override netem/ethtool settings
Quoted 8 lines · Florian Westphal
This allows to run the tests with a more consistent/reproduceable setup, e.g:
./mptcp_connect.sh -d 120 -l 0.2 -r "50% 1% gap 5" ./mptcp_connect.sh -d 250 -e tso -e gso -e gro -l 0.01default is to randomize the settings.
Signed-off-by Florian Westphal <fw(a)strlen.de>
Thanks for implementing this! It does break the -c (capture) option, though. I have a patch to fix that and will send it right after this.
Mat
Quoted 178 lines
---
.../selftests/net/mptcp/mptcp_connect.sh| 127 +++++++++++++-----1 file changed, 97 insertions(+), 30 deletions(-)tools/testing/selftests/net/mptcp/mptcp_connect.sh +1
-0@@ -1,6 +1,7 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 +optstring="d:e:l:r:h6"ret=0
sin=""
sout=""tools/testing/selftests/net/mptcp/mptcp_connect.sh +0
-0@@ -10,6 +11,62 @@ ksft_skip=4capture=0
timeout=30
ipv6=falsetools/testing/selftests/net/mptcp/mptcp_connect.sh +56
-0+ethtool_random_on=true +tc_delay="$((RANDOM%400))" +tc_loss=$((RANDOM%101)) +tc_reorder="" + +if [ $tc_loss -eq 100 ];then + tc_loss=1% +elif [ $tc_loss -ge 10 ]; then + tc_loss=0.$tc_loss% +elif [ $tc_loss -ge 1 ]; then + tc_loss=0.0$tc_loss% +else + tc_loss="" +fi + +usage() { + echo "Usage: $0 [ -a ]" + echo -e "\t-d: tc/netem delay in milliseconds, e.g. \"-d 10\" (default random)" + echo -e "\t-l: tc/netem loss percentage, e.g. \"-l 0.02\" (default random)" + echo -e "\t-r: tc/netem reorder mode, e.g. \"-r 25% 50% gap 5\", use "-r 0" to disable reordering (default random)" + echo -e "\t-e: ethtool features to disable, e.g.: \"-e tso -e gso\" (default: randomly disable any of tso/gso/gro)" +} + +while getopts "$optstring" option;do + case "$option" in + "h") + usage $0 + exit 0 + ;; + "d") + if [ $OPTARG -ge 0 ];then + tc_delay="$OPTARG" + else + echo "-d requires numeric argument, got \"$OPTARG\"" 1>&2 + exit 1 + fi + ;; + "e") + ethtool_args="$ethtool_args $OPTARG off" + ethtool_random_on=false + ;; + "l") + tc_loss="$OPTARG" + ;; + "r") + tc_reorder="$OPTARG" + ;; + "6") + ipv6=true + ;; + "?") + usage $0 + exit 1 + ;; + esac +donesec=$(date +%s)
rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)tools/testing/selftests/net/mptcp/mptcp_connect.sh +0
-0@@ -108,28 +165,38 @@ ip -net "$ns4" route add default via 10.0.3.2$ipv6 && ip -net "$ns4" route add default via dead:beef:3::2
set_ethtool_flags(){tools/testing/selftests/net/mptcp/mptcp_connect.sh +10
-3- ns=$1 - dev=$2 + local ns="$1" + local dev="$2" + local flags="$3" + + ip netns exec $ns ethtool -K $dev $flags 2>/dev/null + [ $? -eq 0 ] && echo "INFO: set $ns dev $dev: ethtool -K $flags" +} - r=$RANDOM +set_random_ethtool_flags() { + local flags="" + local r=$RANDOMpick1=$((r & 1)) pick2=$((r & 2)) pick3=$((r & 4))tools/testing/selftests/net/mptcp/mptcp_connect.sh +0
-1- flags=""[ $pick1 -ne 0 ] && flags="tso off" [ $pick2 -ne 0 ] && flags="$flags gso off" [ $pick3 -ne 0 ] && flags="$flags gro off" [ -z "$flags" ] && returntools/testing/selftests/net/mptcp/mptcp_connect.sh +1
-2- ip netns exec $ns ethtool -K $dev $flags 2>/dev/null - [ $? -eq 0 ] && echo "INFO: set $ns dev $dev: ethtool -K $flags" + set_ethtool_flags "$1" "$2" "$flags"}
tools/testing/selftests/net/mptcp/mptcp_connect.sh +7
-2-set_ethtool_flags "$ns3" ns3eth2 -set_ethtool_flags "$ns4" ns4eth3 +if $ethtool_random_on;then + set_random_ethtool_flags "$ns3" ns3eth2 + set_random_ethtool_flags "$ns4" ns4eth3 +else + set_ethtool_flags "$ns3" ns3eth2 "$ethtool_args" + set_ethtool_flags "$ns4" ns4eth3 "$ethtool_args" +fi
print_file_err()
{tools/testing/selftests/net/mptcp/mptcp_connect.sh +0
-0@@ -402,31 +469,31 @@ for sender in "$ns1" "$ns2" "$ns3" "$ns4";do $ipv6 && do_ping "$ns4" $sender dead:beef:3::1done
tools/testing/selftests/net/mptcp/mptcp_connect.sh +18
-22-loss=$((RANDOM%101)) -if [ $loss -eq 100 ] ;then - loss=1% - tc -net "$ns2" qdisc add dev ns2eth3 root netem loss random $loss -elif [ $loss -ge 10 ]; then - loss=0.$loss% - tc -net "$ns2" qdisc add dev ns2eth3 root netem loss random $loss -elif [ $loss -ge 1 ]; then - loss=0.0$loss% - tc -net "$ns2" qdisc add dev ns2eth3 root netem loss random $loss -fi +[ -n "$tc_loss" ] && tc -net "$ns2" qdisc add dev ns2eth3 root netem loss random $tc_loss +echo -n "INFO: Using loss of $tc_loss " +test "$tc_delay" -gt 0 && echo -n "delay $tc_delay ms " -delay=$((RANDOM%400)) -reorder1=$((RANDOM%10)) -reorder1=$((100 - reorder1)) -reorder2=$((RANDOM%100)) - -if [ $reorder1 -lt 100 ] && [ $reorder2 -gt 0 ]; then - tc -net "$ns3" qdisc add dev ns3eth4 root netem delay ${delay}ms reorder ${reorder1}% ${reorder2}% - echo "INFO: Using loss of $loss, delay $delay ms, reorder: $reorder1, $reorder2 on ns3eth4" -elif [ $delay -gt 0 ]; then - tc -net "$ns3" qdisc add dev ns3eth4 root netem delay ${delay}ms - echo "INFO: Using loss of $loss, delay $delay ms on ns3eth4" +if [ -z "${tc_reorder}" ]; then + reorder1=$((RANDOM%10)) + reorder1=$((100 - reorder1)) + reorder2=$((RANDOM%100)) + + if [ $tc_delay -gt 0 ] && [ $reorder1 -lt 100 ] && [ $reorder2 -gt 0 ]; then + tc_reorder="reorder ${reorder1}% ${reorder2}%" + echo -n "$tc_reorder " + fi +elif [ "$tc_reorder" = "0" ];then + tc_reorder="" +elif [ "$tc_delay" -gt 0 ];then + # reordering requires some delay + tc_reorder="reorder $tc_reorder" + echo -n "$tc_reorder "fi
tools/testing/selftests/net/mptcp/mptcp_connect.sh +4
-0+echo "on ns3eth4" + +tc -net "$ns3" qdisc add dev ns3eth4 root netem delay ${tc_delay}ms $tc_reorder +for sender in $ns1 $ns2 $ns3 $ns4;do
Quoted 8 lines
run_tests_lo "$ns1" "$sender" 10.0.1.1 0.0.0.0 1 if [ $ret -ne 0 ] ;thenSignature · 4 lines
2.23.0 _______________________________________________ mptcp mailing list -- mptcp(a)lists.01.org To unsubscribe send an email to mptcp-leave(a)lists.01.org
--
Mat Martineau
Intel
Mat Martineau
PATCH 1/1 selftests: mptcp: Restore capture option
In reply to Florian WestphalThe addition of other command line parameter handling made "-c" show the usage message rather than allow packet capture with tcpdump. Integrate "-c" with getops handling and make sure the usage message covers all options.
--- .../selftests/net/mptcp/mptcp_connect.sh | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_connect.sh +9 -10
@@ -1,14 +1,14 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 -optstring="d:e:l:r:h6" +optstring="d:e:l:r:h6c" ret=0 sin="" sout="" cin="" cout="" ksft_skip=4 -capture=0 +capture=false timeout=30 ipv6=false ethtool_random_on=true
@@ -32,6 +32,8 @@ usage() { echo -e "\t-l: tc/netem loss percentage, e.g. \"-l 0.02\" (default random)" echo -e "\t-r: tc/netem reorder mode, e.g. \"-r 25% 50% gap 5\", use "-r 0" to disable reordering (default random)" echo -e "\t-e: ethtool features to disable, e.g.: \"-e tso -e gso\" (default: randomly disable any of tso/gso/gro)" + echo -e "\t-6: enable IPv6 tests (default: only test IPv4)" + echo -e "\t-c: capture packets for each test using tcpdump (default: no capture)" } while getopts "$optstring" option;do
@@ -61,6 +63,9 @@ while getopts "$optstring" option;do "6") ipv6=true ;; + "c") + capture=true + ;; "?") usage $0 exit 1
@@ -88,12 +93,6 @@ cleanup() done } -for arg in "$@"; do - if [ "$arg" = "-c" ]; then - capture=1 - fi -done - ip -Version > /dev/null 2>&1 if [ $? -ne 0 ];then echo "SKIP: Could not run test without ip tool"
@@ -303,7 +302,7 @@ do_transfer() printf "%-4s %-5s -> %-4s (%s:%d) %-5s\t" ${connector_ns} ${cl_proto} ${listener_ns} ${connect_addr} ${port} ${srv_proto} - if [ $capture -eq 1 ]; then + if $capture; then if [ -z $SUDO_USER ] ; then capuser="" else
@@ -334,7 +333,7 @@ do_transfer() stop=$(date +%s) - if [ $capture -eq 1 ]; then + if $capture; then sleep 1 kill $cappid fi
Signature · 1 line
2.23.0
Matthieu Baerts
[MPTCP] Re: [PATCH] selftests: mptcp: Restore capture option
Hi Mat,
Quoted 4 lines · Mat Martineau
The addition of other command line parameter handling made "-c" show the usage message rather than allow packet capture with tcpdump. Integrate "-c" with getops handling and make sure the usage message covers all options.
Good catch! Thanks for the patch!
Quoted 9 lines
Signed-off-by Mat Martineau <mathew.j.martineau(a)linux.intel.com>--- .../selftests/net/mptcp/mptcp_connect.sh | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)tools/testing/selftests/net/mptcp/mptcp_connect.sh +0
-0
[...]
tools/testing/selftests/net/mptcp/mptcp_connect.sh usage() { · line 35
Quoted 5 lines
tools/testing/selftests/net/mptcp/mptcp_connect.sh +1
-0@@ -32,6 +32,8 @@ usage() { echo -e "\t-l: tc/netem loss percentage, e.g. \"-l 0.02\" (default random)" echo -e "\t-r: tc/netem reorder mode, e.g. \"-r 25% 50% gap 5\", use "-r 0" to disable reordering (default random)" echo -e "\t-e: ethtool features to disable, e.g.: \"-e tso -e gso\" (default: randomly disable any of tso/gso/gro)" + echo -e "\t-6: enable IPv6 tests (default: only test IPv4)"
Good catch!
Quoted 4 lines
tools/testing/selftests/net/mptcp/mptcp_connect.sh +1
-0+ echo -e "\t-c: capture packets for each test using tcpdump (default: no capture)" } while getopts "$optstring" option;do
[...]
tools/testing/selftests/net/mptcp/mptcp_connect.sh do_transfer() · line 336
Quoted 6 lines
tools/testing/selftests/net/mptcp/mptcp_connect.sh +1
-1@@ -334,7 +333,7 @@ do_transfer() stop=$(date +%s) - if [ $capture -eq 1 ]; then + if $capture; then
It's maybe just me but I usually prefer to avoid having to execute a binary hidden in a variable to return 0 or 1. ${capture} could be set to another binary/function, we will fork (except with some shells), etc.
But that's just for the tests, we will not launch that on a low end device and we are already doing that with ipv6, random, etc. so it looks good to me to apply this! :)
Cheers,
Matt
Signature · 5 lines
Matthieu Baerts | R&D Engineer matthieu.baerts(a)tessares.net Tessares SA | Hybrid Access Solutions www.tessares.net 1 Avenue Jean Monnet, 1348 Louvain-la-Neuve, Belgium
Mat Martineau
Quoted 10 lines · Florian Westphal
This is the 4th iteration of the selftest patchset.
Changes since v3:
- get rid of unused variable warnings in patch 2
- get rid of bogus fallthrough in patch 4
- add patch 8: Get rid of redundant test cases, no need to test tcp fallback for all netns combinations.
- add patch 9: allow to set delay/loss/reordering etc. to use. Default is random so selftests expose wider combinations.
Quoted 2 lines
All changes can be squashed into "mptcp: add basic kselftest for mptcp".
I think 1-8 are ready to merge, and patch 9 in combination with my capture fix - if that works for Matthieu & Florian.
--
Mat Martineau
Intel
Matthieu Baerts
Hi Florian, Mat,
Quoted 13 lines · Mat Martineau
Quoted 10 lines · Florian Westphal
This is the 4th iteration of the selftest patchset.
Changes since v3:
- get rid of unused variable warnings in patch 2
- get rid of bogus fallthrough in patch 4
- add patch 8: Get rid of redundant test cases, no need to test tcp fallback for all netns combinations.
- add patch 9: allow to set delay/loss/reordering etc. to use. Default is random so selftests expose wider combinations.
Quoted 5 lines
Quoted 2 lines
All changes can be squashed into "mptcp: add basic kselftest for mptcp".
I think 1-8 are ready to merge, and patch 9 in combination with my capture fix - if that works for Matthieu & Florian.
Thank you for the patches, the reviews and the fix!
Florian's patches:
- ccd8bd7d2946: "squashed" patch 1/9 in "mptcp: add basic kselftest for mptcp"
- ba7f2390a07b: "squashed" patch 2/9 in "mptcp: add basic kselftest for mptcp"
- 9558b127f5e2: "squashed" patch 3/9 in "mptcp: add basic kselftest for mptcp"
- 36d6878d373c: "squashed" patch 4/9 in "mptcp: add basic kselftest for mptcp"
- b78662240af1: "squashed" patch 5/9 in "mptcp: add basic kselftest for mptcp"
- c81c93c3b292: "squashed" patch 6/9 in "mptcp: add basic kselftest for mptcp"
- 088e08b5cc4d: "squashed" patch 7/9 in "mptcp: add basic kselftest for mptcp"
- bf62f70fceaa: "squashed" patch 8/9 in "mptcp: add basic kselftest for mptcp"
- fcd6f5fe56e1: "squashed" patch 9/9 in "mptcp: add basic kselftest for mptcp"
- all signed-off already there
Mat's patch:
- 847d38757173: "squashed" in "mptcp: add basic kselftest for mptcp"
- signed-off already there
460e610b3ca4..22b6803a0c48: result
Now in my quick tests, it took me max 44 seconds with the slowest env I have and the default options. But I guess the time is variable depending on the delays/losses/reorders that have been randomly picked.
Do you have a suggestion of new default timeout to set?
Also another question, when you use:
make -C tools/testing/selftests TARGETS=net/mptcp run_tests
how do you pass arguments to mptcp_connect.sh script?
Cheers,
Matt
Signature · 5 lines
Matthieu Baerts | R&D Engineer matthieu.baerts(a)tessares.net Tessares SA | Hybrid Access Solutions www.tessares.net 1 Avenue Jean Monnet, 1348 Louvain-la-Neuve, Belgium