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
198# use TCP syn cookies, even if no flooding was detected.
199ip netns exec "$ns2" sysctl -q net.ipv4.tcp_syncookies=2
200
201set_ethtool_flags() {
202	local ns="$1"
203	local dev="$2"
204	local flags="$3"
205
206	ip netns exec $ns ethtool -K $dev $flags 2>/dev/null
207	[ $? -eq 0 ] && echo "INFO: set $ns dev $dev: ethtool -K $flags"
208}
209
210set_random_ethtool_flags() {
211	local flags=""
212	local r=$RANDOM
213
214	local pick1=$((r & 1))
215	local pick2=$((r & 2))
216	local pick3=$((r & 4))
217
218	[ $pick1 -ne 0 ] && flags="tso off"
219	[ $pick2 -ne 0 ] && flags="$flags gso off"
220	[ $pick3 -ne 0 ] && flags="$flags gro off"
221
222	[ -z "$flags" ] && return
223
224	set_ethtool_flags "$1" "$2" "$flags"
225}
226
227if $ethtool_random_on;then
228	set_random_ethtool_flags "$ns3" ns3eth2
229	set_random_ethtool_flags "$ns4" ns4eth3
230else
231	set_ethtool_flags "$ns3" ns3eth2 "$ethtool_args"
232	set_ethtool_flags "$ns4" ns4eth3 "$ethtool_args"
233fi
234
235print_file_err()
236{
237	ls -l "$1" 1>&2
238	echo "Trailing bytes are: "
239	tail -c 27 "$1"
240}
241
242check_transfer()
243{
244	local in=$1
245	local out=$2
246	local what=$3
247
248	cmp "$in" "$out" > /dev/null 2>&1
249	if [ $? -ne 0 ] ;then
250		echo "[ FAIL ] $what does not match (in, out):"
251		print_file_err "$in"
252		print_file_err "$out"
253
254		return 1
255	fi
256
257	return 0
258}
259
260check_mptcp_disabled()
261{
262	local disabled_ns
263	disabled_ns="ns_disabled-$sech-$(mktemp -u XXXXXX)"
264	ip netns add ${disabled_ns} || exit $ksft_skip
265
266	# net.mptcp.enabled should be enabled by default
267	if [ "$(ip netns exec ${disabled_ns} sysctl net.mptcp.enabled | awk '{ print $3 }')" -ne 1 ]; then
268		echo -e "net.mptcp.enabled sysctl is not 1 by default\t\t[ FAIL ]"
269		ret=1
270		return 1
271	fi
272	ip netns exec ${disabled_ns} sysctl -q net.mptcp.enabled=0
273
274	local err=0
275	LANG=C ip netns exec ${disabled_ns} ./mptcp_connect -t $timeout -p 10000 -s MPTCP 127.0.0.1 < "$cin" 2>&1 | \
276		grep -q "^socket: Protocol not available$" && err=1
277	ip netns delete ${disabled_ns}
278
279	if [ ${err} -eq 0 ]; then
280		echo -e "New MPTCP socket cannot be blocked via sysctl\t\t[ FAIL ]"
281		ret=1
282		return 1
283	fi
284
285	echo -e "New MPTCP socket can be blocked via sysctl\t\t[ OK ]"
286	return 0
287}
288
289check_mptcp_ulp_setsockopt()
290{
291	local t retval
292	t="ns_ulp-$sech-$(mktemp -u XXXXXX)"
293
294	ip netns add ${t} || exit $ksft_skip
295	if ! ip netns exec ${t} ./mptcp_connect -u -p 10000 -s TCP 127.0.0.1 2>&1; then
296		printf "setsockopt(..., TCP_ULP, \"mptcp\", ...) allowed\t[ FAIL ]\n"
297		retval=1
298		ret=$retval
299	else
300		printf "setsockopt(..., TCP_ULP, \"mptcp\", ...) blocked\t[ OK ]\n"
301		retval=0
302	fi
303	ip netns del ${t}
304	return $retval
305}
306
307# $1: IP address
308is_v6()
309{
310	[ -z "${1##*:*}" ]
311}
312
313do_ping()
314{
315	local listener_ns="$1"
316	local connector_ns="$2"
317	local connect_addr="$3"
318	local ping_args="-q -c 1"
319
320	if is_v6 "${connect_addr}"; then
321		$ipv6 || return 0
322		ping_args="${ping_args} -6"
323	fi
324
325	ip netns exec ${connector_ns} ping ${ping_args} $connect_addr >/dev/null
326	if [ $? -ne 0 ] ; then
327		echo "$listener_ns -> $connect_addr connectivity [ FAIL ]" 1>&2
328		ret=1
329
330		return 1
331	fi
332
333	return 0
334}
335
336# $1: ns, $2: port
337wait_local_port_listen()
338{
339	local listener_ns="${1}"
340	local port="${2}"
341
342	local port_hex i
343
344	port_hex="$(printf "%04X" "${port}")"
345	for i in $(seq 10); do
346		ip netns exec "${listener_ns}" cat /proc/net/tcp* | \
347			awk "BEGIN {rc=1} {if (\$2 ~ /:${port_hex}\$/ && \$4 ~ /0A/) {rc=0; exit}} END {exit rc}" &&
348			break
349		sleep 0.1
350	done
351}
352
353do_transfer()
354{
355	local listener_ns="$1"
356	local connector_ns="$2"
357	local cl_proto="$3"
358	local srv_proto="$4"
359	local connect_addr="$5"
360	local local_addr="$6"
361	local extra_args=""
362
363	local port
364	port=$((10000+$TEST_COUNT))
365	TEST_COUNT=$((TEST_COUNT+1))
366
367	if [ "$rcvbuf" -gt 0 ]; then
368		extra_args="$extra_args -R $rcvbuf"
369	fi
370
371	if [ "$sndbuf" -gt 0 ]; then
372		extra_args="$extra_args -S $sndbuf"
373	fi
374
375	if [ -n "$testmode" ]; then
376		extra_args="$extra_args -m $testmode"
377	fi
378
379	if [ -n "$extra_args" ] && $options_log; then
380		options_log=false
381		echo "INFO: extra options: $extra_args"
382	fi
383
384	:> "$cout"
385	:> "$sout"
386	:> "$capout"
387
388	local addr_port
389	addr_port=$(printf "%s:%d" ${connect_addr} ${port})
390	printf "%.3s %-5s -> %.3s (%-20s) %-5s\t" ${connector_ns} ${cl_proto} ${listener_ns} ${addr_port} ${srv_proto}
391
392	if $capture; then
393		local capuser
394		if [ -z $SUDO_USER ] ; then
395			capuser=""
396		else
397			capuser="-Z $SUDO_USER"
398		fi
399
400		local capfile="${rndh}-${connector_ns:0:3}-${listener_ns:0:3}-${cl_proto}-${srv_proto}-${connect_addr}-${port}"
401		local capopt="-i any -s 65535 -B 32768 ${capuser}"
402
403		ip netns exec ${listener_ns}  tcpdump ${capopt} -w "${capfile}-listener.pcap"  >> "${capout}" 2>&1 &
404		local cappid_listener=$!
405
406		ip netns exec ${connector_ns} tcpdump ${capopt} -w "${capfile}-connector.pcap" >> "${capout}" 2>&1 &
407		local cappid_connector=$!
408
409		sleep 1
410	fi
411
412	local stat_synrx_last_l=$(ip netns exec ${listener_ns} nstat -z -a MPTcpExtMPCapableSYNRX | while read a count c rest ;do  echo $count;done)
413	local stat_ackrx_last_l=$(ip netns exec ${listener_ns} nstat -z -a MPTcpExtMPCapableACKRX | while read a count c rest ;do  echo $count;done)
414	local stat_cookietx_last=$(ip netns exec ${listener_ns} nstat -z -a TcpExtSyncookiesSent | while read a count c rest ;do  echo $count;done)
415	local stat_cookierx_last=$(ip netns exec ${listener_ns} nstat -z -a TcpExtSyncookiesRecv | while read a count c rest ;do  echo $count;done)
416
417	ip netns exec ${listener_ns} ./mptcp_connect -t $timeout -l -p $port -s ${srv_proto} $extra_args $local_addr < "$sin" > "$sout" &
418	local spid=$!
419
420	wait_local_port_listen "${listener_ns}" "${port}"
421
422	local start
423	start=$(date +%s%3N)
424	ip netns exec ${connector_ns} ./mptcp_connect -t $timeout -p $port -s ${cl_proto} $extra_args $connect_addr < "$cin" > "$cout" &
425	local cpid=$!
426
427	wait $cpid
428	local retc=$?
429	wait $spid
430	local rets=$?
431
432	local stop
433	stop=$(date +%s%3N)
434
435	if $capture; then
436		sleep 1
437		kill ${cappid_listener}
438		kill ${cappid_connector}
439	fi
440
441	local duration
442	duration=$((stop-start))
443	duration=$(printf "(duration %05sms)" $duration)
444	if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then
445		echo "$duration [ FAIL ] client exit code $retc, server $rets" 1>&2
446		echo -e "\nnetns ${listener_ns} socket stat for ${port}:" 1>&2
447		ip netns exec ${listener_ns} ss -nita 1>&2 -o "sport = :$port"
448		echo -e "\nnetns ${connector_ns} socket stat for ${port}:" 1>&2
449		ip netns exec ${connector_ns} ss -nita 1>&2 -o "dport = :$port"
450
451		cat "$capout"
452		return 1
453	fi
454
455	check_transfer $sin $cout "file received by client"
456	retc=$?
457	check_transfer $cin $sout "file received by server"
458	rets=$?
459
460	local stat_synrx_now_l=$(ip netns exec ${listener_ns} nstat -z -a MPTcpExtMPCapableSYNRX  | while read a count c rest ;do  echo $count;done)
461	local stat_ackrx_now_l=$(ip netns exec ${listener_ns} nstat -z -a MPTcpExtMPCapableACKRX  | while read a count c rest ;do  echo $count;done)
462
463	local stat_cookietx_now=$(ip netns exec ${listener_ns} nstat -z -a TcpExtSyncookiesSent | while read a count c rest ;do  echo $count;done)
464	local stat_cookierx_now=$(ip netns exec ${listener_ns} nstat -z -a TcpExtSyncookiesRecv | while read a count c rest ;do  echo $count;done)
465
466	expect_synrx=$((stat_synrx_last_l))
467	expect_ackrx=$((stat_ackrx_last_l))
468
469	cookies=$(ip netns exec ${listener_ns} sysctl net.ipv4.tcp_syncookies)
470	cookies=${cookies##*=}
471
472	if [ ${cl_proto} = "MPTCP" ] && [ ${srv_proto} = "MPTCP" ]; then
473		expect_synrx=$((stat_synrx_last_l+1))
474		expect_ackrx=$((stat_ackrx_last_l+1))
475	fi
476	if [ $cookies -eq 2 ];then
477		if [ $stat_cookietx_last -ge $stat_cookietx_now ] ;then
478			echo "${listener_ns} CookieSent: ${cl_proto} -> ${srv_proto}: did not advance"
479		fi
480		if [ $stat_cookierx_last -ge $stat_cookierx_now ] ;then
481			echo "${listener_ns} CookieRecv: ${cl_proto} -> ${srv_proto}: did not advance"
482		fi
483	else
484		if [ $stat_cookietx_last -ne $stat_cookietx_now ] ;then
485			echo "${listener_ns} CookieSent: ${cl_proto} -> ${srv_proto}: changed"
486		fi
487		if [ $stat_cookierx_last -ne $stat_cookierx_now ] ;then
488			echo "${listener_ns} CookieRecv: ${cl_proto} -> ${srv_proto}: changed"
489		fi
490	fi
491
492	if [ $expect_synrx -ne $stat_synrx_now_l ] ;then
493		echo "${listener_ns} SYNRX: ${cl_proto} -> ${srv_proto}: expect ${expect_synrx}, got ${stat_synrx_now_l}"
494	fi
495	if [ $expect_ackrx -ne $stat_ackrx_now_l ] ;then
496		echo "${listener_ns} ACKRX: ${cl_proto} -> ${srv_proto}: expect ${expect_synrx}, got ${stat_synrx_now_l}"
497	fi
498
499	if [ $retc -eq 0 ] && [ $rets -eq 0 ];then
500		echo "$duration [ OK ]"
501		cat "$capout"
502		return 0
503	fi
504
505	cat "$capout"
506	return 1
507}
508
509make_file()
510{
511	local name=$1
512	local who=$2
513	local SIZE=$filesize
514	local ksize
515	local rem
516
517	if [ $SIZE -eq 0 ]; then
518		local MAXSIZE=$((1024 * 1024 * 8))
519		local MINSIZE=$((1024 * 256))
520
521		SIZE=$(((RANDOM * RANDOM + MINSIZE) % MAXSIZE))
522	fi
523
524	ksize=$((SIZE / 1024))
525	rem=$((SIZE - (ksize * 1024)))
526
527	dd if=/dev/urandom of="$name" bs=1024 count=$ksize 2> /dev/null
528	dd if=/dev/urandom conv=notrunc of="$name" bs=1 count=$rem 2> /dev/null
529	echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name"
530
531	echo "Created $name (size $(du -b "$name")) containing data sent by $who"
532}
533
534run_tests_lo()
535{
536	local listener_ns="$1"
537	local connector_ns="$2"
538	local connect_addr="$3"
539	local loopback="$4"
540	local lret=0
541
542	# skip if test programs are running inside same netns for subsequent runs.
543	if [ $loopback -eq 0 ] && [ ${listener_ns} = ${connector_ns} ]; then
544		return 0
545	fi
546
547	# skip if we don't want v6
548	if ! $ipv6 && is_v6 "${connect_addr}"; then
549		return 0
550	fi
551
552	local local_addr
553	if is_v6 "${connect_addr}"; then
554		local_addr="::"
555	else
556		local_addr="0.0.0.0"
557	fi
558
559	do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} ${local_addr}
560	lret=$?
561	if [ $lret -ne 0 ]; then
562		ret=$lret
563		return 1
564	fi
565
566	if [ $do_tcp -eq 0 ]; then
567		# don't bother testing fallback tcp except for loopback case.
568		if [ ${listener_ns} != ${connector_ns} ]; then
569			return 0
570		fi
571	fi
572
573	do_transfer ${listener_ns} ${connector_ns} MPTCP TCP ${connect_addr} ${local_addr}
574	lret=$?
575	if [ $lret -ne 0 ]; then
576		ret=$lret
577		return 1
578	fi
579
580	do_transfer ${listener_ns} ${connector_ns} TCP MPTCP ${connect_addr} ${local_addr}
581	lret=$?
582	if [ $lret -ne 0 ]; then
583		ret=$lret
584		return 1
585	fi
586
587	if [ $do_tcp -gt 1 ] ;then
588		do_transfer ${listener_ns} ${connector_ns} TCP TCP ${connect_addr} ${local_addr}
589		lret=$?
590		if [ $lret -ne 0 ]; then
591			ret=$lret
592			return 1
593		fi
594	fi
595
596	return 0
597}
598
599run_tests()
600{
601	run_tests_lo $1 $2 $3 0
602}
603
604make_file "$cin" "client"
605make_file "$sin" "server"
606
607check_mptcp_disabled
608
609check_mptcp_ulp_setsockopt
610
611echo "INFO: validating network environment with pings"
612for sender in "$ns1" "$ns2" "$ns3" "$ns4";do
613	do_ping "$ns1" $sender 10.0.1.1
614	do_ping "$ns1" $sender dead:beef:1::1
615
616	do_ping "$ns2" $sender 10.0.1.2
617	do_ping "$ns2" $sender dead:beef:1::2
618	do_ping "$ns2" $sender 10.0.2.1
619	do_ping "$ns2" $sender dead:beef:2::1
620
621	do_ping "$ns3" $sender 10.0.2.2
622	do_ping "$ns3" $sender dead:beef:2::2
623	do_ping "$ns3" $sender 10.0.3.2
624	do_ping "$ns3" $sender dead:beef:3::2
625
626	do_ping "$ns4" $sender 10.0.3.1
627	do_ping "$ns4" $sender dead:beef:3::1
628done
629
630[ -n "$tc_loss" ] && tc -net "$ns2" qdisc add dev ns2eth3 root netem loss random $tc_loss delay ${tc_delay}ms
631echo -n "INFO: Using loss of $tc_loss "
632test "$tc_delay" -gt 0 && echo -n "delay $tc_delay ms "
633
634reorder_delay=$(($tc_delay / 4))
635
636if [ -z "${tc_reorder}" ]; then
637	reorder1=$((RANDOM%10))
638	reorder1=$((100 - reorder1))
639	reorder2=$((RANDOM%100))
640
641	if [ $reorder_delay -gt 0 ] && [ $reorder1 -lt 100 ] && [ $reorder2 -gt 0 ]; then
642		tc_reorder="reorder ${reorder1}% ${reorder2}%"
643		echo -n "$tc_reorder with delay ${reorder_delay}ms "
644	fi
645elif [ "$tc_reorder" = "0" ];then
646	tc_reorder=""
647elif [ "$reorder_delay" -gt 0 ];then
648	# reordering requires some delay
649	tc_reorder="reorder $tc_reorder"
650	echo -n "$tc_reorder with delay ${reorder_delay}ms "
651fi
652
653echo "on ns3eth4"
654
655tc -net "$ns3" qdisc add dev ns3eth4 root netem delay ${reorder_delay}ms $tc_reorder
656
657for sender in $ns1 $ns2 $ns3 $ns4;do
658	run_tests_lo "$ns1" "$sender" 10.0.1.1 1
659	if [ $ret -ne 0 ] ;then
660		echo "FAIL: Could not even run loopback test" 1>&2
661		exit $ret
662	fi
663	run_tests_lo "$ns1" $sender dead:beef:1::1 1
664	if [ $ret -ne 0 ] ;then
665		echo "FAIL: Could not even run loopback v6 test" 2>&1
666		exit $ret
667	fi
668
669	run_tests "$ns2" $sender 10.0.1.2
670	run_tests "$ns2" $sender dead:beef:1::2
671	run_tests "$ns2" $sender 10.0.2.1
672	run_tests "$ns2" $sender dead:beef:2::1
673
674	run_tests "$ns3" $sender 10.0.2.2
675	run_tests "$ns3" $sender dead:beef:2::2
676	run_tests "$ns3" $sender 10.0.3.2
677	run_tests "$ns3" $sender dead:beef:3::2
678
679	run_tests "$ns4" $sender 10.0.3.1
680	run_tests "$ns4" $sender dead:beef:3::1
681done
682
683time_end=$(date +%s)
684time_run=$((time_end-time_start))
685
686echo "Time: ${time_run} seconds"
687
688exit $ret
689