• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3
4time_start=$(date +%s)
5
6optstring="S:R:d:e:l:r:h4cm:f:t"
7ret=0
8sin=""
9sout=""
10cin=""
11cout=""
12ksft_skip=4
13capture=false
14timeout=30
15ipv6=true
16ethtool_random_on=true
17tc_delay="$((RANDOM%50))"
18tc_loss=$((RANDOM%101))
19testmode=""
20sndbuf=0
21rcvbuf=0
22options_log=true
23do_tcp=0
24filesize=0
25
26if [ $tc_loss -eq 100 ];then
27	tc_loss=1%
28elif [ $tc_loss -ge 10 ]; then
29	tc_loss=0.$tc_loss%
30elif [ $tc_loss -ge 1 ]; then
31	tc_loss=0.0$tc_loss%
32else
33	tc_loss=""
34fi
35
36usage() {
37	echo "Usage: $0 [ -a ]"
38	echo -e "\t-d: tc/netem delay in milliseconds, e.g. \"-d 10\" (default random)"
39	echo -e "\t-l: tc/netem loss percentage, e.g. \"-l 0.02\" (default random)"
40	echo -e "\t-r: tc/netem reorder mode, e.g. \"-r 25% 50% gap 5\", use "-r 0" to disable reordering (default random)"
41	echo -e "\t-e: ethtool features to disable, e.g.: \"-e tso -e gso\" (default: randomly disable any of tso/gso/gro)"
42	echo -e "\t-4: IPv4 only: disable IPv6 tests (default: test both IPv4 and IPv6)"
43	echo -e "\t-c: capture packets for each test using tcpdump (default: no capture)"
44	echo -e "\t-f: size of file to transfer in bytes (default random)"
45	echo -e "\t-S: set sndbuf value (default: use kernel default)"
46	echo -e "\t-R: set rcvbuf value (default: use kernel default)"
47	echo -e "\t-m: test mode (poll, sendfile; default: poll)"
48	echo -e "\t-t: also run tests with TCP (use twice to non-fallback tcp)"
49}
50
51while getopts "$optstring" option;do
52	case "$option" in
53	"h")
54		usage $0
55		exit 0
56		;;
57	"d")
58		if [ $OPTARG -ge 0 ];then
59			tc_delay="$OPTARG"
60		else
61			echo "-d requires numeric argument, got \"$OPTARG\"" 1>&2
62			exit 1
63		fi
64		;;
65	"e")
66		ethtool_args="$ethtool_args $OPTARG off"
67		ethtool_random_on=false
68		;;
69	"l")
70		tc_loss="$OPTARG"
71		;;
72	"r")
73		tc_reorder="$OPTARG"
74		;;
75	"4")
76		ipv6=false
77		;;
78	"c")
79		capture=true
80		;;
81	"S")
82		if [ $OPTARG -ge 0 ];then
83			sndbuf="$OPTARG"
84		else
85			echo "-S requires numeric argument, got \"$OPTARG\"" 1>&2
86			exit 1
87		fi
88		;;
89	"R")
90		if [ $OPTARG -ge 0 ];then
91			rcvbuf="$OPTARG"
92		else
93			echo "-R requires numeric argument, got \"$OPTARG\"" 1>&2
94			exit 1
95		fi
96		;;
97	"m")
98		testmode="$OPTARG"
99		;;
100	"f")
101		filesize="$OPTARG"
102		;;
103	"t")
104		do_tcp=$((do_tcp+1))
105		;;
106	"?")
107		usage $0
108		exit 1
109		;;
110	esac
111done
112
113sec=$(date +%s)
114rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
115ns1="ns1-$rndh"
116ns2="ns2-$rndh"
117ns3="ns3-$rndh"
118ns4="ns4-$rndh"
119
120TEST_COUNT=0
121
122cleanup()
123{
124	rm -f "$cin" "$cout"
125	rm -f "$sin" "$sout"
126	rm -f "$capout"
127
128	local netns
129	for netns in "$ns1" "$ns2" "$ns3" "$ns4";do
130		ip netns del $netns
131	done
132}
133
134ip -Version > /dev/null 2>&1
135if [ $? -ne 0 ];then
136	echo "SKIP: Could not run test without ip tool"
137	exit $ksft_skip
138fi
139
140sin=$(mktemp)
141sout=$(mktemp)
142cin=$(mktemp)
143cout=$(mktemp)
144capout=$(mktemp)
145trap cleanup EXIT
146
147for i in "$ns1" "$ns2" "$ns3" "$ns4";do
148	ip netns add $i || exit $ksft_skip
149	ip -net $i link set lo up
150done
151
152#  "$ns1"              ns2                    ns3                     ns4
153# ns1eth2    ns2eth1   ns2eth3      ns3eth2   ns3eth4       ns4eth3
154#                           - drop 1% ->            reorder 25%
155#                           <- TSO off -
156
157ip link add ns1eth2 netns "$ns1" type veth peer name ns2eth1 netns "$ns2"
158ip link add ns2eth3 netns "$ns2" type veth peer name ns3eth2 netns "$ns3"
159ip link add ns3eth4 netns "$ns3" type veth peer name ns4eth3 netns "$ns4"
160
161ip -net "$ns1" addr add 10.0.1.1/24 dev ns1eth2
162ip -net "$ns1" addr add dead:beef:1::1/64 dev ns1eth2 nodad
163
164ip -net "$ns1" link set ns1eth2 up
165ip -net "$ns1" route add default via 10.0.1.2
166ip -net "$ns1" route add default via dead:beef:1::2
167
168ip -net "$ns2" addr add 10.0.1.2/24 dev ns2eth1
169ip -net "$ns2" addr add dead:beef:1::2/64 dev ns2eth1 nodad
170ip -net "$ns2" link set ns2eth1 up
171
172ip -net "$ns2" addr add 10.0.2.1/24 dev ns2eth3
173ip -net "$ns2" addr add dead:beef:2::1/64 dev ns2eth3 nodad
174ip -net "$ns2" link set ns2eth3 up
175ip -net "$ns2" route add default via 10.0.2.2
176ip -net "$ns2" route add default via dead:beef:2::2
177ip netns exec "$ns2" sysctl -q net.ipv4.ip_forward=1
178ip netns exec "$ns2" sysctl -q net.ipv6.conf.all.forwarding=1
179
180ip -net "$ns3" addr add 10.0.2.2/24 dev ns3eth2
181ip -net "$ns3" addr add dead:beef:2::2/64 dev ns3eth2 nodad
182ip -net "$ns3" link set ns3eth2 up
183
184ip -net "$ns3" addr add 10.0.3.2/24 dev ns3eth4
185ip -net "$ns3" addr add dead:beef:3::2/64 dev ns3eth4 nodad
186ip -net "$ns3" link set ns3eth4 up
187ip -net "$ns3" route add default via 10.0.2.1
188ip -net "$ns3" route add default via dead:beef:2::1
189ip netns exec "$ns3" sysctl -q net.ipv4.ip_forward=1
190ip netns exec "$ns3" sysctl -q net.ipv6.conf.all.forwarding=1
191
192ip -net "$ns4" addr add 10.0.3.1/24 dev ns4eth3
193ip -net "$ns4" addr add dead:beef:3::1/64 dev ns4eth3 nodad
194ip -net "$ns4" link set ns4eth3 up
195ip -net "$ns4" route add default via 10.0.3.2
196ip -net "$ns4" route add default via dead:beef:3::2
197
198set_ethtool_flags() {
199	local ns="$1"
200	local dev="$2"
201	local flags="$3"
202
203	ip netns exec $ns ethtool -K $dev $flags 2>/dev/null
204	[ $? -eq 0 ] && echo "INFO: set $ns dev $dev: ethtool -K $flags"
205}
206
207set_random_ethtool_flags() {
208	local flags=""
209	local r=$RANDOM
210
211	local pick1=$((r & 1))
212	local pick2=$((r & 2))
213	local pick3=$((r & 4))
214
215	[ $pick1 -ne 0 ] && flags="tso off"
216	[ $pick2 -ne 0 ] && flags="$flags gso off"
217	[ $pick3 -ne 0 ] && flags="$flags gro off"
218
219	[ -z "$flags" ] && return
220
221	set_ethtool_flags "$1" "$2" "$flags"
222}
223
224if $ethtool_random_on;then
225	set_random_ethtool_flags "$ns3" ns3eth2
226	set_random_ethtool_flags "$ns4" ns4eth3
227else
228	set_ethtool_flags "$ns3" ns3eth2 "$ethtool_args"
229	set_ethtool_flags "$ns4" ns4eth3 "$ethtool_args"
230fi
231
232print_file_err()
233{
234	ls -l "$1" 1>&2
235	echo "Trailing bytes are: "
236	tail -c 27 "$1"
237}
238
239check_transfer()
240{
241	local in=$1
242	local out=$2
243	local what=$3
244
245	cmp "$in" "$out" > /dev/null 2>&1
246	if [ $? -ne 0 ] ;then
247		echo "[ FAIL ] $what does not match (in, out):"
248		print_file_err "$in"
249		print_file_err "$out"
250
251		return 1
252	fi
253
254	return 0
255}
256
257check_mptcp_disabled()
258{
259	local disabled_ns
260	disabled_ns="ns_disabled-$sech-$(mktemp -u XXXXXX)"
261	ip netns add ${disabled_ns} || exit $ksft_skip
262
263	# net.mptcp.enabled should be enabled by default
264	if [ "$(ip netns exec ${disabled_ns} sysctl net.mptcp.enabled | awk '{ print $3 }')" -ne 1 ]; then
265		echo -e "net.mptcp.enabled sysctl is not 1 by default\t\t[ FAIL ]"
266		ret=1
267		return 1
268	fi
269	ip netns exec ${disabled_ns} sysctl -q net.mptcp.enabled=0
270
271	local err=0
272	LANG=C ip netns exec ${disabled_ns} ./mptcp_connect -t $timeout -p 10000 -s MPTCP 127.0.0.1 < "$cin" 2>&1 | \
273		grep -q "^socket: Protocol not available$" && err=1
274	ip netns delete ${disabled_ns}
275
276	if [ ${err} -eq 0 ]; then
277		echo -e "New MPTCP socket cannot be blocked via sysctl\t\t[ FAIL ]"
278		ret=1
279		return 1
280	fi
281
282	echo -e "New MPTCP socket can be blocked via sysctl\t\t[ OK ]"
283	return 0
284}
285
286check_mptcp_ulp_setsockopt()
287{
288	local t retval
289	t="ns_ulp-$sech-$(mktemp -u XXXXXX)"
290
291	ip netns add ${t} || exit $ksft_skip
292	if ! ip netns exec ${t} ./mptcp_connect -u -p 10000 -s TCP 127.0.0.1 2>&1; then
293		printf "setsockopt(..., TCP_ULP, \"mptcp\", ...) allowed\t[ FAIL ]\n"
294		retval=1
295		ret=$retval
296	else
297		printf "setsockopt(..., TCP_ULP, \"mptcp\", ...) blocked\t[ OK ]\n"
298		retval=0
299	fi
300	ip netns del ${t}
301	return $retval
302}
303
304# $1: IP address
305is_v6()
306{
307	[ -z "${1##*:*}" ]
308}
309
310do_ping()
311{
312	local listener_ns="$1"
313	local connector_ns="$2"
314	local connect_addr="$3"
315	local ping_args="-q -c 1"
316
317	if is_v6 "${connect_addr}"; then
318		$ipv6 || return 0
319		ping_args="${ping_args} -6"
320	fi
321
322	ip netns exec ${connector_ns} ping ${ping_args} $connect_addr >/dev/null
323	if [ $? -ne 0 ] ; then
324		echo "$listener_ns -> $connect_addr connectivity [ FAIL ]" 1>&2
325		ret=1
326
327		return 1
328	fi
329
330	return 0
331}
332
333# $1: ns, $2: port
334wait_local_port_listen()
335{
336	local listener_ns="${1}"
337	local port="${2}"
338
339	local port_hex i
340
341	port_hex="$(printf "%04X" "${port}")"
342	for i in $(seq 10); do
343		ip netns exec "${listener_ns}" cat /proc/net/tcp* | \
344			awk "BEGIN {rc=1} {if (\$2 ~ /:${port_hex}\$/ && \$4 ~ /0A/) {rc=0; exit}} END {exit rc}" &&
345			break
346		sleep 0.1
347	done
348}
349
350do_transfer()
351{
352	local listener_ns="$1"
353	local connector_ns="$2"
354	local cl_proto="$3"
355	local srv_proto="$4"
356	local connect_addr="$5"
357	local local_addr="$6"
358	local extra_args=""
359
360	local port
361	port=$((10000+$TEST_COUNT))
362	TEST_COUNT=$((TEST_COUNT+1))
363
364	if [ "$rcvbuf" -gt 0 ]; then
365		extra_args="$extra_args -R $rcvbuf"
366	fi
367
368	if [ "$sndbuf" -gt 0 ]; then
369		extra_args="$extra_args -S $sndbuf"
370	fi
371
372	if [ -n "$testmode" ]; then
373		extra_args="$extra_args -m $testmode"
374	fi
375
376	if [ -n "$extra_args" ] && $options_log; then
377		options_log=false
378		echo "INFO: extra options: $extra_args"
379	fi
380
381	:> "$cout"
382	:> "$sout"
383	:> "$capout"
384
385	local addr_port
386	addr_port=$(printf "%s:%d" ${connect_addr} ${port})
387	printf "%.3s %-5s -> %.3s (%-20s) %-5s\t" ${connector_ns} ${cl_proto} ${listener_ns} ${addr_port} ${srv_proto}
388
389	if $capture; then
390		local capuser
391		if [ -z $SUDO_USER ] ; then
392			capuser=""
393		else
394			capuser="-Z $SUDO_USER"
395		fi
396
397		local capfile="${rndh}-${connector_ns:0:3}-${listener_ns:0:3}-${cl_proto}-${srv_proto}-${connect_addr}-${port}"
398		local capopt="-i any -s 65535 -B 32768 ${capuser}"
399
400		ip netns exec ${listener_ns}  tcpdump ${capopt} -w "${capfile}-listener.pcap"  >> "${capout}" 2>&1 &
401		local cappid_listener=$!
402
403		ip netns exec ${connector_ns} tcpdump ${capopt} -w "${capfile}-connector.pcap" >> "${capout}" 2>&1 &
404		local cappid_connector=$!
405
406		sleep 1
407	fi
408
409	local stat_synrx_last_l=$(ip netns exec ${listener_ns} nstat -z -a MPTcpExtMPCapableSYNRX | while read a count c rest ;do  echo $count;done)
410	local stat_ackrx_last_l=$(ip netns exec ${listener_ns} nstat -z -a MPTcpExtMPCapableACKRX | while read a count c rest ;do  echo $count;done)
411	local stat_cookietx_last=$(ip netns exec ${listener_ns} nstat -z -a TcpExtSyncookiesSent | while read a count c rest ;do  echo $count;done)
412	local stat_cookierx_last=$(ip netns exec ${listener_ns} nstat -z -a TcpExtSyncookiesRecv | while read a count c rest ;do  echo $count;done)
413
414	ip netns exec ${listener_ns} ./mptcp_connect -t $timeout -l -p $port -s ${srv_proto} $extra_args $local_addr < "$sin" > "$sout" &
415	local spid=$!
416
417	wait_local_port_listen "${listener_ns}" "${port}"
418
419	local start
420	start=$(date +%s%3N)
421	ip netns exec ${connector_ns} ./mptcp_connect -t $timeout -p $port -s ${cl_proto} $extra_args $connect_addr < "$cin" > "$cout" &
422	local cpid=$!
423
424	wait $cpid
425	local retc=$?
426	wait $spid
427	local rets=$?
428
429	local stop
430	stop=$(date +%s%3N)
431
432	if $capture; then
433		sleep 1
434		kill ${cappid_listener}
435		kill ${cappid_connector}
436	fi
437
438	local duration
439	duration=$((stop-start))
440	duration=$(printf "(duration %05sms)" $duration)
441	if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then
442		echo "$duration [ FAIL ] client exit code $retc, server $rets" 1>&2
443		echo -e "\nnetns ${listener_ns} socket stat for ${port}:" 1>&2
444		ip netns exec ${listener_ns} ss -nita 1>&2 -o "sport = :$port"
445		echo -e "\nnetns ${connector_ns} socket stat for ${port}:" 1>&2
446		ip netns exec ${connector_ns} ss -nita 1>&2 -o "dport = :$port"
447
448		cat "$capout"
449		return 1
450	fi
451
452	check_transfer $sin $cout "file received by client"
453	retc=$?
454	check_transfer $cin $sout "file received by server"
455	rets=$?
456
457	local stat_synrx_now_l=$(ip netns exec ${listener_ns} nstat -z -a MPTcpExtMPCapableSYNRX  | while read a count c rest ;do  echo $count;done)
458	local stat_ackrx_now_l=$(ip netns exec ${listener_ns} nstat -z -a MPTcpExtMPCapableACKRX  | while read a count c rest ;do  echo $count;done)
459
460	local stat_cookietx_now=$(ip netns exec ${listener_ns} nstat -z -a TcpExtSyncookiesSent | while read a count c rest ;do  echo $count;done)
461	local stat_cookierx_now=$(ip netns exec ${listener_ns} nstat -z -a TcpExtSyncookiesRecv | while read a count c rest ;do  echo $count;done)
462
463	expect_synrx=$((stat_synrx_last_l))
464	expect_ackrx=$((stat_ackrx_last_l))
465
466	cookies=$(ip netns exec ${listener_ns} sysctl net.ipv4.tcp_syncookies)
467	cookies=${cookies##*=}
468
469	if [ ${cl_proto} = "MPTCP" ] && [ ${srv_proto} = "MPTCP" ]; then
470		expect_synrx=$((stat_synrx_last_l+1))
471		expect_ackrx=$((stat_ackrx_last_l+1))
472	fi
473	if [ $cookies -eq 2 ];then
474		if [ $stat_cookietx_last -ge $stat_cookietx_now ] ;then
475			echo "${listener_ns} CookieSent: ${cl_proto} -> ${srv_proto}: did not advance"
476		fi
477		if [ $stat_cookierx_last -ge $stat_cookierx_now ] ;then
478			echo "${listener_ns} CookieRecv: ${cl_proto} -> ${srv_proto}: did not advance"
479		fi
480	else
481		if [ $stat_cookietx_last -ne $stat_cookietx_now ] ;then
482			echo "${listener_ns} CookieSent: ${cl_proto} -> ${srv_proto}: changed"
483		fi
484		if [ $stat_cookierx_last -ne $stat_cookierx_now ] ;then
485			echo "${listener_ns} CookieRecv: ${cl_proto} -> ${srv_proto}: changed"
486		fi
487	fi
488
489	if [ $expect_synrx -ne $stat_synrx_now_l ] ;then
490		echo "${listener_ns} SYNRX: ${cl_proto} -> ${srv_proto}: expect ${expect_synrx}, got ${stat_synrx_now_l}"
491	fi
492	if [ $expect_ackrx -ne $stat_ackrx_now_l ] ;then
493		echo "${listener_ns} ACKRX: ${cl_proto} -> ${srv_proto}: expect ${expect_ackrx}, got ${stat_ackrx_now_l} "
494	fi
495
496	if [ $retc -eq 0 ] && [ $rets -eq 0 ];then
497		echo "$duration [ OK ]"
498		cat "$capout"
499		return 0
500	fi
501
502	cat "$capout"
503	return 1
504}
505
506make_file()
507{
508	local name=$1
509	local who=$2
510	local SIZE=$filesize
511	local ksize
512	local rem
513
514	if [ $SIZE -eq 0 ]; then
515		local MAXSIZE=$((1024 * 1024 * 8))
516		local MINSIZE=$((1024 * 256))
517
518		SIZE=$(((RANDOM * RANDOM + MINSIZE) % MAXSIZE))
519	fi
520
521	ksize=$((SIZE / 1024))
522	rem=$((SIZE - (ksize * 1024)))
523
524	dd if=/dev/urandom of="$name" bs=1024 count=$ksize 2> /dev/null
525	dd if=/dev/urandom conv=notrunc of="$name" bs=1 count=$rem 2> /dev/null
526	echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name"
527
528	echo "Created $name (size $(du -b "$name")) containing data sent by $who"
529}
530
531run_tests_lo()
532{
533	local listener_ns="$1"
534	local connector_ns="$2"
535	local connect_addr="$3"
536	local loopback="$4"
537	local lret=0
538
539	# skip if test programs are running inside same netns for subsequent runs.
540	if [ $loopback -eq 0 ] && [ ${listener_ns} = ${connector_ns} ]; then
541		return 0
542	fi
543
544	# skip if we don't want v6
545	if ! $ipv6 && is_v6 "${connect_addr}"; then
546		return 0
547	fi
548
549	local local_addr
550	if is_v6 "${connect_addr}"; then
551		local_addr="::"
552	else
553		local_addr="0.0.0.0"
554	fi
555
556	do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} ${local_addr}
557	lret=$?
558	if [ $lret -ne 0 ]; then
559		ret=$lret
560		return 1
561	fi
562
563	if [ $do_tcp -eq 0 ]; then
564		# don't bother testing fallback tcp except for loopback case.
565		if [ ${listener_ns} != ${connector_ns} ]; then
566			return 0
567		fi
568	fi
569
570	do_transfer ${listener_ns} ${connector_ns} MPTCP TCP ${connect_addr} ${local_addr}
571	lret=$?
572	if [ $lret -ne 0 ]; then
573		ret=$lret
574		return 1
575	fi
576
577	do_transfer ${listener_ns} ${connector_ns} TCP MPTCP ${connect_addr} ${local_addr}
578	lret=$?
579	if [ $lret -ne 0 ]; then
580		ret=$lret
581		return 1
582	fi
583
584	if [ $do_tcp -gt 1 ] ;then
585		do_transfer ${listener_ns} ${connector_ns} TCP TCP ${connect_addr} ${local_addr}
586		lret=$?
587		if [ $lret -ne 0 ]; then
588			ret=$lret
589			return 1
590		fi
591	fi
592
593	return 0
594}
595
596run_tests()
597{
598	run_tests_lo $1 $2 $3 0
599}
600
601make_file "$cin" "client"
602make_file "$sin" "server"
603
604check_mptcp_disabled
605
606check_mptcp_ulp_setsockopt
607
608echo "INFO: validating network environment with pings"
609for sender in "$ns1" "$ns2" "$ns3" "$ns4";do
610	do_ping "$ns1" $sender 10.0.1.1
611	do_ping "$ns1" $sender dead:beef:1::1
612
613	do_ping "$ns2" $sender 10.0.1.2
614	do_ping "$ns2" $sender dead:beef:1::2
615	do_ping "$ns2" $sender 10.0.2.1
616	do_ping "$ns2" $sender dead:beef:2::1
617
618	do_ping "$ns3" $sender 10.0.2.2
619	do_ping "$ns3" $sender dead:beef:2::2
620	do_ping "$ns3" $sender 10.0.3.2
621	do_ping "$ns3" $sender dead:beef:3::2
622
623	do_ping "$ns4" $sender 10.0.3.1
624	do_ping "$ns4" $sender dead:beef:3::1
625done
626
627[ -n "$tc_loss" ] && tc -net "$ns2" qdisc add dev ns2eth3 root netem loss random $tc_loss delay ${tc_delay}ms
628echo -n "INFO: Using loss of $tc_loss "
629test "$tc_delay" -gt 0 && echo -n "delay $tc_delay ms "
630
631reorder_delay=$(($tc_delay / 4))
632
633if [ -z "${tc_reorder}" ]; then
634	reorder1=$((RANDOM%10))
635	reorder1=$((100 - reorder1))
636	reorder2=$((RANDOM%100))
637
638	if [ $reorder_delay -gt 0 ] && [ $reorder1 -lt 100 ] && [ $reorder2 -gt 0 ]; then
639		tc_reorder="reorder ${reorder1}% ${reorder2}%"
640		echo -n "$tc_reorder with delay ${reorder_delay}ms "
641	fi
642elif [ "$tc_reorder" = "0" ];then
643	tc_reorder=""
644elif [ "$reorder_delay" -gt 0 ];then
645	# reordering requires some delay
646	tc_reorder="reorder $tc_reorder"
647	echo -n "$tc_reorder with delay ${reorder_delay}ms "
648fi
649
650echo "on ns3eth4"
651
652tc -net "$ns3" qdisc add dev ns3eth4 root netem delay ${reorder_delay}ms $tc_reorder
653
654for sender in $ns1 $ns2 $ns3 $ns4;do
655	run_tests_lo "$ns1" "$sender" 10.0.1.1 1
656	if [ $ret -ne 0 ] ;then
657		echo "FAIL: Could not even run loopback test" 1>&2
658		exit $ret
659	fi
660	run_tests_lo "$ns1" $sender dead:beef:1::1 1
661	if [ $ret -ne 0 ] ;then
662		echo "FAIL: Could not even run loopback v6 test" 2>&1
663		exit $ret
664	fi
665
666	# ns1<->ns2 is not subject to reordering/tc delays. Use it to test
667	# mptcp syncookie support.
668	if [ $sender = $ns1 ]; then
669		ip netns exec "$ns2" sysctl -q net.ipv4.tcp_syncookies=2
670	else
671		ip netns exec "$ns2" sysctl -q net.ipv4.tcp_syncookies=1
672	fi
673
674	run_tests "$ns2" $sender 10.0.1.2
675	run_tests "$ns2" $sender dead:beef:1::2
676	run_tests "$ns2" $sender 10.0.2.1
677	run_tests "$ns2" $sender dead:beef:2::1
678
679	run_tests "$ns3" $sender 10.0.2.2
680	run_tests "$ns3" $sender dead:beef:2::2
681	run_tests "$ns3" $sender 10.0.3.2
682	run_tests "$ns3" $sender dead:beef:3::2
683
684	run_tests "$ns4" $sender 10.0.3.1
685	run_tests "$ns4" $sender dead:beef:3::1
686done
687
688time_end=$(date +%s)
689time_run=$((time_end-time_start))
690
691echo "Time: ${time_run} seconds"
692
693exit $ret
694