selftests: prepare for mptcp ipv6 support
Subsystems (3)
Florian Westphal
cover selftests: prepare for mptcp ipv6 support
This patch series inceases self test coverage:
1. ipv6 support. So all someone needs to do is actually implement ipv6 support in mptcp. Then, set ipv6=true in the selftest script and it should 'just work'.
2. Check accept/getpeername. In case of connect side, we also check that getpeername returned addresses are the ones we connected to.
3. less predictable topology: tso/gso/gro and tc parameters are more random.
I suggest to apply them with no squashing, once we go for another RFC tests/selftest can be a single patch and all commits can be squashed.
If you disagree, I don't mind if this gets squashed right away.
No changes to mptcp stack itself here.
Florian Westphal
PATCH 1/5 selftests: mptcp: make tc delays random
test with less predictable setups:
tc qdisc delay is now random, same for reordering and loss. Main motivation is to cover more scenarious without a large increase in test-time.
--- .../selftests/net/mptcp/mptcp_connect.sh | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_connect.sh +26 -2
@@ -277,8 +277,32 @@ 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%1200)) +reorder1=$((RANDOM%25)) +reorder2=$((RANDOM%50)) +gap=$((RANDOM%100)) +if [ $gap -gt 0 ]; then + gap="gap $gap" +else + gap="" +fi + +if [ $reorder1 -gt 0 ] && [ $reorder2 -gt 0 ]; then + tc -net ns3 qdisc add dev ns3eth4 root netem delay ${delay}ms reorder ${reorder1}% ${reorder2}% $gap +fi +echo "INFO: Using loss of $loss, delay $delay ms, reorder: $reorder1, $reorder2 $gap on ns3eth4" for sender in 1 2 3 4;do run_tests ns1 ns$sender 10.0.1.1
Signature · 1 line
2.21.0
Florian Westphal
PATCH 2/5 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.
Tested with a tcp <-> tcp connection.
--- .../testing/selftests/net/mptcp/mptcp_connect.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_connect.c +12 -5
@@ -32,11 +32,11 @@ static int poll_timeout;static const char *cfg_host;static const char *cfg_port ="12000" ;static int cfg_sock_proto =IPPROTO_MPTCP ; - +static int pf =AF_INET ;static void die_usage (void ) { -fprintf (stderr,"Usage: mptcp_connect [-s MPTCP|TCP] [-p port] " +fprintf (stderr,"Usage: mptcp_connect [ -6 ] [-s MPTCP|TCP] [-p port] " "[ -l ] [ -t timeout ] connect_address\n" );exit (1 ); }
@@ -74,12 +74,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);
@@ -124,7 +125,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) {
@@ -362,7 +363,7 @@ static void parse_opts(int argc, char **argv) {int c; -while ((c =getopt (argc, argv,"lp:s:ht:" )) !=-1 ) { +while ((c =getopt (argc, argv,"6lp:s:ht:" )) !=-1 ) {switch (c) {case 'l' : listen_mode = true;
@@ -376,6 +377,9 @@ static void parse_opts(int argc, char **argv)case 'h' :die_usage ();break ; +case '6' : + pf =AF_INET6 ; +break ;case 't' : poll_timeout =atoi (optarg) *1000 ;if (poll_timeout <=0 )
@@ -387,6 +391,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[])
Signature · 1 line
2.21.0
Florian Westphal
PATCH 3/5 selftests: mptcp: add accept/getpeername 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 | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+)
tools/testing/selftests/net/mptcp/mptcp_connect.c +106 -0
@@ -49,6 +49,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)
@@ -285,6 +300,93 @@ 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)) { +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); + +if (getpeername (fd, (struct sockaddr *)&ss, &salen)) { +char a[INET6_ADDRSTRLEN ]; +char b[INET6_ADDRSTRLEN ]; + +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;
@@ -308,6 +410,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 ; }
@@ -342,6 +447,7 @@ int main_loop(void)if (fd <0 )return 2 ; +check_getpeername_connect (fd);return copyfd_io (0 , fd,1 ); }
Signature · 1 line
2.21.0
Florian Westphal
Re: [MPTCP] [PATCH selftests 3/5] selftests: mptcp: add accept/getpeername checks
tools/testing/selftests/net/mptcp/mptcp_connect.c static int copyfd_io(int infd, int peerfd, int outfd) · line 378
Quoted 8 lines · Florian Westphal
tools/testing/selftests/net/mptcp/mptcp_connect.c +8
-0+static void check_getpeername_connect (int fd) +{ +struct sockaddr_storage ss; +socklen_t salen =sizeof (ss); + +if (getpeername (fd, (struct sockaddr *)&ss, &salen)) { +char a[INET6_ADDRSTRLEN ]; +char b[INET6_ADDRSTRLEN ];
Grrr. This is not what I intended.
Instead of sending a v2, you could also pull the series (with the above fixed) via
git pull git://git.breakpoint.cc/fw/mptcp-next.git selftests_13092019
Otherwise I can just send a v2. Let me know, thanks.
Florian Westphal
PATCH 4/5 selftests: mptcp: add ipv6 connectivity
In reply to Florian Westphalprepare for ipv6 mptcp tests.
Once someone starts to implement mptcp v6 support, just set ipv6=true in the script and the selftest will attempt to connect via ipv6.
--- .../selftests/net/mptcp/mptcp_connect.sh | 77 ++++++++++++++++--- 1 file changed, 66 insertions(+), 11 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_connect.sh +66 -11
@@ -9,6 +9,7 @@ cout="" ksft_skip=4 capture=0 timeout=30 +ipv6=false TEST_COUNT=0
@@ -58,29 +59,48 @@ 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 +if $ipv6 ; then + 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 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 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 print_file_err() {
@@ -138,7 +158,11 @@ do_ping() if [ $? -ne 0 ] ; then echo "$listener_ns -> $connect_addr connectivity [ FAIL ]" 1>&2 ret=1 + + return 1 fi + + return 0 } do_transfer()
@@ -148,6 +172,7 @@ do_transfer() cl_proto="$3" srv_proto="$4" connect_addr="$5" + local_addr="$6" port=$((10000+$TEST_COUNT)) TEST_COUNT=$((TEST_COUNT+1))
@@ -173,7 +198,7 @@ do_transfer() sleep 1 fi - ip netns exec ${listener_ns} ./mptcp_connect -t $timeout -l -p $port -s ${srv_proto} 0.0.0.0 < "$sin" > "$sout" & + ip netns exec ${listener_ns} ./mptcp_connect -t $timeout -l -p $port -s ${srv_proto} $local_addr < "$sin" > "$sout" & spid=$! sleep 1
@@ -241,23 +266,26 @@ run_tests() listener_ns="$1" connector_ns="$2" connect_addr="$3" + local_addr="$4" lret=0 for proto in MPTCP TCP;do - do_transfer ${listener_ns} ${connector_ns} MPTCP "$proto" ${connect_addr} + do_transfer ${listener_ns} ${connector_ns} MPTCP "$proto" ${connect_addr} ${local_addr} lret=$? if [ $lret -ne 0 ]; then ret=$lret - return + return 1 fi done - do_transfer ${listener_ns} ${connector_ns} TCP MPTCP ${connect_addr} + do_transfer ${listener_ns} ${connector_ns} TCP MPTCP ${connect_addr} ${local_addr} lret=$? if [ $lret -ne 0 ]; then ret=$lret - return + return 1 fi + + return 0 } make_file "$cin" "client"
@@ -265,16 +293,31 @@ make_file "$sin" "server" check_mptcp_disabled +# Allow DAD to finish +$ipv6 && sleep 2 + for sender in 1 2 3 4;do do_ping ns1 ns$sender 10.0.1.1 + if $ipv6;then + do_ping ns1 ns$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 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 ns4 ns$sender 10.0.3.1 + $ipv6 && do_ping ns4 ns$sender dead:beef:3::1 done loss=$((RANDOM%101))
@@ -305,15 +348,27 @@ fi echo "INFO: Using loss of $loss, delay $delay ms, reorder: $reorder1, $reorder2 $gap on ns3eth4" for sender in 1 2 3 4;do - run_tests ns1 ns$sender 10.0.1.1 + run_tests ns1 ns$sender 10.0.1.1 0.0.0.0 + if $ipv6;then + run_tests ns1 ns$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 - run_tests ns2 ns$sender 10.0.2.1 + 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 ns3 ns$sender 10.0.2.2 - run_tests ns3 ns$sender 10.0.3.2 + 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 ns4 ns$sender 10.0.3.1 + run_tests ns4 ns$sender 10.0.3.1 0.0.0.0 + $ipv6 && run_tests ns4 ns$sender dead:beef:3::1 :: done exit $ret
Signature · 1 line
2.21.0
Florian Westphal
PATCH 5/5 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 test time.
--- .../selftests/net/mptcp/mptcp_connect.sh | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)
tools/testing/selftests/net/mptcp/mptcp_connect.sh +28 -1
@@ -92,7 +92,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
@@ -102,6 +101,34 @@ 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)) + r=$((r>>1)) + pick2=$((r & 1)) + r=$((r>>1)) + pick3=$((r & 1)) + + comma="" + flags="" + [ $pick1 -ne 0 ] && flags="tso" + [ $pick1 -ne 0 ] && comma="," + [ $pick2 -ne 0 ] && flags=${flags}${comma}"gso" + [ $pick3 -ne 0 ] && flags=${flags}${comma}"gro" + + [ -z $flags ] && return + + ip netns exec $ns ethtool -K $dev $flags off 2>/dev/null + [ $? -eq 0 ] && echo "INFO: set $ns dev $dev: ethtool -K $flags off" +} + +set_ethtool_flags ns3 ns3eth2 +set_ethtool_flags ns4 ns4eth3 + print_file_err() { ls -l "$1" 1>&2
Signature · 1 line
2.21.0
Peter Krystad
Quoted 5 lines · Florian Westphal
This patch series inceases self test coverage:
1. ipv6 support. So all someone needs to do is actually implement ipv6 support in mptcp. Then, set ipv6=true in the selftest script and it should 'just work'.
I am planning to begin work on IPv6 support, unless someone else wants to arm-wrestle me for it....
Peter.
Quoted 17 lines
2. Check accept/getpeername. In case of connect side, we also check that getpeername returned addresses are the ones we connected to.
3. less predictable topology: tso/gso/gro and tc parameters are more random.I suggest to apply them with no squashing, once we go for another RFC tests/selftest can be a single patch and all commits can be squashed.
If you disagree, I don't mind if this gets squashed right away.
No changes to mptcp stack itself here.
_______________________________________________
mptcp mailing list
mptcp(a)lists.01.org
https://lists.01.org/mailman/listinfo/mptcp
Paolo Abeni
Hi,
Quoted 9 lines · Peter Krystad
Quoted 5 lines · Florian Westphal
This patch series inceases self test coverage:
1. ipv6 support. So all someone needs to do is actually implement ipv6 support in mptcp. Then, set ipv6=true in the selftest script and it should 'just work'.
I am planning to begin work on IPv6 support, unless someone else wants to arm-wrestle me for it....
Thank you for doing that!
I was also planning to try to estimate the effort there, but I sure do not want to arm-wrestle you! I'll fallback to other tasks - recvmsg cleanup? mp_join debug? - but please let me know if I can help somehow!
Thanks,
Paolo
Florian Westphal
Quoted 3 lines · Paolo Abeni
I was also planning to try to estimate the effort there, but I sure do not want to arm-wrestle you! I'll fallback to other tasks - recvmsg cleanup?
mp_joindebug? - but please let me know if I can help somehow!
Someone could add sha256 support for mptcpv1 support.
Peter Krystad
Quoted 10 lines · Paolo Abeni
Hi,
Quoted 7 lines · Peter Krystad
Quoted 5 lines · Florian Westphal
This patch series inceases self test coverage:
1. ipv6 support. So all someone needs to do is actually implement ipv6 support in mptcp. Then, set ipv6=true in the selftest script and it should 'just work'.
Quoted 9 lines
Quoted 2 lines
I am planning to begin work on IPv6 support, unless someone else wants to arm-wrestle me for it....
Thank you for doing that!
I was also planning to try to estimate the effort there, but I sure do not want to arm-wrestle you! I'll fallback to other tasks - recvmsg cleanup?
mp_joindebug? - but please let me know if I can help somehow!
Well, if we are going to go with v1 for our initial submission, maybe it makes sense for me to work on the v1 MP_CAPABLE exchange since I did the original MP_CAPABLE work and leave IPv6 for you or....
Peter.
Quoted 4 lines
Thanks,
Paolo