1b08fbf24SPaolo Abeni#!/bin/bash
2b08fbf24SPaolo Abeni# SPDX-License-Identifier: GPL-2.0
3b08fbf24SPaolo Abeni
4b08fbf24SPaolo Abeniret=0
5b08fbf24SPaolo Abenisin=""
6b08fbf24SPaolo Abenisout=""
7b08fbf24SPaolo Abenicin=""
8b08fbf24SPaolo Abenicout=""
9b08fbf24SPaolo Abeniksft_skip=4
10b08fbf24SPaolo Abenitimeout=30
11b08fbf24SPaolo Abenicapture=0
12b08fbf24SPaolo Abeni
13b08fbf24SPaolo AbeniTEST_COUNT=0
14b08fbf24SPaolo Abeni
15b08fbf24SPaolo Abeniinit()
16b08fbf24SPaolo Abeni{
17b08fbf24SPaolo Abeni	capout=$(mktemp)
18b08fbf24SPaolo Abeni
19b08fbf24SPaolo Abeni	rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
20b08fbf24SPaolo Abeni
21b08fbf24SPaolo Abeni	ns1="ns1-$rndh"
22b08fbf24SPaolo Abeni	ns2="ns2-$rndh"
23b08fbf24SPaolo Abeni
24b08fbf24SPaolo Abeni	for netns in "$ns1" "$ns2";do
25b08fbf24SPaolo Abeni		ip netns add $netns || exit $ksft_skip
26b08fbf24SPaolo Abeni		ip -net $netns link set lo up
27b08fbf24SPaolo Abeni		ip netns exec $netns sysctl -q net.mptcp.enabled=1
28b08fbf24SPaolo Abeni		ip netns exec $netns sysctl -q net.ipv4.conf.all.rp_filter=0
29b08fbf24SPaolo Abeni		ip netns exec $netns sysctl -q net.ipv4.conf.default.rp_filter=0
30b08fbf24SPaolo Abeni	done
31b08fbf24SPaolo Abeni
32b08fbf24SPaolo Abeni	#  ns1              ns2
33b08fbf24SPaolo Abeni	# ns1eth1    ns2eth1
34b08fbf24SPaolo Abeni	# ns1eth2    ns2eth2
35b08fbf24SPaolo Abeni	# ns1eth3    ns2eth3
36b08fbf24SPaolo Abeni	# ns1eth4    ns2eth4
37b08fbf24SPaolo Abeni
38b08fbf24SPaolo Abeni	for i in `seq 1 4`; do
39b08fbf24SPaolo Abeni		ip link add ns1eth$i netns "$ns1" type veth peer name ns2eth$i netns "$ns2"
40b08fbf24SPaolo Abeni		ip -net "$ns1" addr add 10.0.$i.1/24 dev ns1eth$i
41b08fbf24SPaolo Abeni		ip -net "$ns1" addr add dead:beef:$i::1/64 dev ns1eth$i nodad
42b08fbf24SPaolo Abeni		ip -net "$ns1" link set ns1eth$i up
43b08fbf24SPaolo Abeni
44b08fbf24SPaolo Abeni		ip -net "$ns2" addr add 10.0.$i.2/24 dev ns2eth$i
45b08fbf24SPaolo Abeni		ip -net "$ns2" addr add dead:beef:$i::2/64 dev ns2eth$i nodad
46b08fbf24SPaolo Abeni		ip -net "$ns2" link set ns2eth$i up
47b08fbf24SPaolo Abeni
48b08fbf24SPaolo Abeni		# let $ns2 reach any $ns1 address from any interface
49b08fbf24SPaolo Abeni		ip -net "$ns2" route add default via 10.0.$i.1 dev ns2eth$i metric 10$i
50b08fbf24SPaolo Abeni	done
51b08fbf24SPaolo Abeni}
52b08fbf24SPaolo Abeni
53b08fbf24SPaolo Abenicleanup_partial()
54b08fbf24SPaolo Abeni{
55b08fbf24SPaolo Abeni	rm -f "$capout"
56b08fbf24SPaolo Abeni
57b08fbf24SPaolo Abeni	for netns in "$ns1" "$ns2"; do
58b08fbf24SPaolo Abeni		ip netns del $netns
59b08fbf24SPaolo Abeni	done
60b08fbf24SPaolo Abeni}
61b08fbf24SPaolo Abeni
62b08fbf24SPaolo Abenicleanup()
63b08fbf24SPaolo Abeni{
64b08fbf24SPaolo Abeni	rm -f "$cin" "$cout"
65b08fbf24SPaolo Abeni	rm -f "$sin" "$sout"
66b08fbf24SPaolo Abeni	cleanup_partial
67b08fbf24SPaolo Abeni}
68b08fbf24SPaolo Abeni
69b08fbf24SPaolo Abenireset()
70b08fbf24SPaolo Abeni{
71b08fbf24SPaolo Abeni	cleanup_partial
72b08fbf24SPaolo Abeni	init
73b08fbf24SPaolo Abeni}
74b08fbf24SPaolo Abeni
7500587187SFlorian Westphalreset_with_cookies()
7600587187SFlorian Westphal{
7700587187SFlorian Westphal	reset
7800587187SFlorian Westphal
7900587187SFlorian Westphal	for netns in "$ns1" "$ns2";do
8000587187SFlorian Westphal		ip netns exec $netns sysctl -q net.ipv4.tcp_syncookies=2
8100587187SFlorian Westphal	done
8200587187SFlorian Westphal}
8300587187SFlorian Westphal
84b08fbf24SPaolo Abenifor arg in "$@"; do
85b08fbf24SPaolo Abeni	if [ "$arg" = "-c" ]; then
86b08fbf24SPaolo Abeni		capture=1
87b08fbf24SPaolo Abeni	fi
88b08fbf24SPaolo Abenidone
89b08fbf24SPaolo Abeni
90b08fbf24SPaolo Abeniip -Version > /dev/null 2>&1
91b08fbf24SPaolo Abeniif [ $? -ne 0 ];then
92b08fbf24SPaolo Abeni	echo "SKIP: Could not run test without ip tool"
93b08fbf24SPaolo Abeni	exit $ksft_skip
94b08fbf24SPaolo Abenifi
95b08fbf24SPaolo Abeni
96b08fbf24SPaolo Abeni
97b08fbf24SPaolo Abenicheck_transfer()
98b08fbf24SPaolo Abeni{
99b08fbf24SPaolo Abeni	in=$1
100b08fbf24SPaolo Abeni	out=$2
101b08fbf24SPaolo Abeni	what=$3
102b08fbf24SPaolo Abeni
103b08fbf24SPaolo Abeni	cmp "$in" "$out" > /dev/null 2>&1
104b08fbf24SPaolo Abeni	if [ $? -ne 0 ] ;then
105b08fbf24SPaolo Abeni		echo "[ FAIL ] $what does not match (in, out):"
106b08fbf24SPaolo Abeni		print_file_err "$in"
107b08fbf24SPaolo Abeni		print_file_err "$out"
108b08fbf24SPaolo Abeni
109b08fbf24SPaolo Abeni		return 1
110b08fbf24SPaolo Abeni	fi
111b08fbf24SPaolo Abeni
112b08fbf24SPaolo Abeni	return 0
113b08fbf24SPaolo Abeni}
114b08fbf24SPaolo Abeni
115b08fbf24SPaolo Abenido_ping()
116b08fbf24SPaolo Abeni{
117b08fbf24SPaolo Abeni	listener_ns="$1"
118b08fbf24SPaolo Abeni	connector_ns="$2"
119b08fbf24SPaolo Abeni	connect_addr="$3"
120b08fbf24SPaolo Abeni
121b08fbf24SPaolo Abeni	ip netns exec ${connector_ns} ping -q -c 1 $connect_addr >/dev/null
122b08fbf24SPaolo Abeni	if [ $? -ne 0 ] ; then
123b08fbf24SPaolo Abeni		echo "$listener_ns -> $connect_addr connectivity [ FAIL ]" 1>&2
124b08fbf24SPaolo Abeni		ret=1
125b08fbf24SPaolo Abeni	fi
126b08fbf24SPaolo Abeni}
127b08fbf24SPaolo Abeni
128b08fbf24SPaolo Abenido_transfer()
129b08fbf24SPaolo Abeni{
130b08fbf24SPaolo Abeni	listener_ns="$1"
131b08fbf24SPaolo Abeni	connector_ns="$2"
132b08fbf24SPaolo Abeni	cl_proto="$3"
133b08fbf24SPaolo Abeni	srv_proto="$4"
134b08fbf24SPaolo Abeni	connect_addr="$5"
135b08fbf24SPaolo Abeni
136b08fbf24SPaolo Abeni	port=$((10000+$TEST_COUNT))
137b08fbf24SPaolo Abeni	TEST_COUNT=$((TEST_COUNT+1))
138b08fbf24SPaolo Abeni
139b08fbf24SPaolo Abeni	:> "$cout"
140b08fbf24SPaolo Abeni	:> "$sout"
141b08fbf24SPaolo Abeni	:> "$capout"
142b08fbf24SPaolo Abeni
143b08fbf24SPaolo Abeni	if [ $capture -eq 1 ]; then
144b08fbf24SPaolo Abeni		if [ -z $SUDO_USER ] ; then
145b08fbf24SPaolo Abeni			capuser=""
146b08fbf24SPaolo Abeni		else
147b08fbf24SPaolo Abeni			capuser="-Z $SUDO_USER"
148b08fbf24SPaolo Abeni		fi
149b08fbf24SPaolo Abeni
15000587187SFlorian Westphal		capfile=$(printf "mp_join-%02u-%s.pcap" "$TEST_COUNT" "${listener_ns}")
151b08fbf24SPaolo Abeni
152b08fbf24SPaolo Abeni		echo "Capturing traffic for test $TEST_COUNT into $capfile"
153b08fbf24SPaolo Abeni		ip netns exec ${listener_ns} tcpdump -i any -s 65535 -B 32768 $capuser -w $capfile > "$capout" 2>&1 &
154b08fbf24SPaolo Abeni		cappid=$!
155b08fbf24SPaolo Abeni
156b08fbf24SPaolo Abeni		sleep 1
157b08fbf24SPaolo Abeni	fi
158b08fbf24SPaolo Abeni
159b08fbf24SPaolo Abeni	ip netns exec ${listener_ns} ./mptcp_connect -j -t $timeout -l -p $port -s ${srv_proto} 0.0.0.0 < "$sin" > "$sout" &
160b08fbf24SPaolo Abeni	spid=$!
161b08fbf24SPaolo Abeni
162b08fbf24SPaolo Abeni	sleep 1
163b08fbf24SPaolo Abeni
164b08fbf24SPaolo Abeni	ip netns exec ${connector_ns} ./mptcp_connect -j -t $timeout -p $port -s ${cl_proto} $connect_addr < "$cin" > "$cout" &
165b08fbf24SPaolo Abeni	cpid=$!
166b08fbf24SPaolo Abeni
167b08fbf24SPaolo Abeni	wait $cpid
168b08fbf24SPaolo Abeni	retc=$?
169b08fbf24SPaolo Abeni	wait $spid
170b08fbf24SPaolo Abeni	rets=$?
171b08fbf24SPaolo Abeni
172b08fbf24SPaolo Abeni	if [ $capture -eq 1 ]; then
173b08fbf24SPaolo Abeni	    sleep 1
174b08fbf24SPaolo Abeni	    kill $cappid
175b08fbf24SPaolo Abeni	fi
176b08fbf24SPaolo Abeni
177b08fbf24SPaolo Abeni	if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then
178b08fbf24SPaolo Abeni		echo " client exit code $retc, server $rets" 1>&2
179*8b974778SMatthieu Baerts		echo -e "\nnetns ${listener_ns} socket stat for ${port}:" 1>&2
180b08fbf24SPaolo Abeni		ip netns exec ${listener_ns} ss -nita 1>&2 -o "sport = :$port"
181*8b974778SMatthieu Baerts		echo -e "\nnetns ${connector_ns} socket stat for ${port}:" 1>&2
182b08fbf24SPaolo Abeni		ip netns exec ${connector_ns} ss -nita 1>&2 -o "dport = :$port"
183b08fbf24SPaolo Abeni
184b08fbf24SPaolo Abeni		cat "$capout"
185b08fbf24SPaolo Abeni		return 1
186b08fbf24SPaolo Abeni	fi
187b08fbf24SPaolo Abeni
188b08fbf24SPaolo Abeni	check_transfer $sin $cout "file received by client"
189b08fbf24SPaolo Abeni	retc=$?
190b08fbf24SPaolo Abeni	check_transfer $cin $sout "file received by server"
191b08fbf24SPaolo Abeni	rets=$?
192b08fbf24SPaolo Abeni
193b08fbf24SPaolo Abeni	if [ $retc -eq 0 ] && [ $rets -eq 0 ];then
194b08fbf24SPaolo Abeni		cat "$capout"
195b08fbf24SPaolo Abeni		return 0
196b08fbf24SPaolo Abeni	fi
197b08fbf24SPaolo Abeni
198b08fbf24SPaolo Abeni	cat "$capout"
199b08fbf24SPaolo Abeni	return 1
200b08fbf24SPaolo Abeni}
201b08fbf24SPaolo Abeni
202b08fbf24SPaolo Abenimake_file()
203b08fbf24SPaolo Abeni{
204b08fbf24SPaolo Abeni	name=$1
205b08fbf24SPaolo Abeni	who=$2
206b08fbf24SPaolo Abeni
207b08fbf24SPaolo Abeni	SIZE=1
208b08fbf24SPaolo Abeni
209b08fbf24SPaolo Abeni	dd if=/dev/urandom of="$name" bs=1024 count=$SIZE 2> /dev/null
210b08fbf24SPaolo Abeni	echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name"
211b08fbf24SPaolo Abeni
212b08fbf24SPaolo Abeni	echo "Created $name (size $SIZE KB) containing data sent by $who"
213b08fbf24SPaolo Abeni}
214b08fbf24SPaolo Abeni
215b08fbf24SPaolo Abenirun_tests()
216b08fbf24SPaolo Abeni{
217b08fbf24SPaolo Abeni	listener_ns="$1"
218b08fbf24SPaolo Abeni	connector_ns="$2"
219b08fbf24SPaolo Abeni	connect_addr="$3"
220b08fbf24SPaolo Abeni	lret=0
221b08fbf24SPaolo Abeni
222b08fbf24SPaolo Abeni	do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr}
223b08fbf24SPaolo Abeni	lret=$?
224b08fbf24SPaolo Abeni	if [ $lret -ne 0 ]; then
225b08fbf24SPaolo Abeni		ret=$lret
226b08fbf24SPaolo Abeni		return
227b08fbf24SPaolo Abeni	fi
228b08fbf24SPaolo Abeni}
229b08fbf24SPaolo Abeni
230b08fbf24SPaolo Abenichk_join_nr()
231b08fbf24SPaolo Abeni{
232b08fbf24SPaolo Abeni	local msg="$1"
233b08fbf24SPaolo Abeni	local syn_nr=$2
234b08fbf24SPaolo Abeni	local syn_ack_nr=$3
235b08fbf24SPaolo Abeni	local ack_nr=$4
236b08fbf24SPaolo Abeni	local count
237b08fbf24SPaolo Abeni	local dump_stats
238b08fbf24SPaolo Abeni
23900587187SFlorian Westphal	printf "%02u %-36s %s" "$TEST_COUNT" "$msg" "syn"
240b08fbf24SPaolo Abeni	count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinSynRx | awk '{print $2}'`
241b08fbf24SPaolo Abeni	[ -z "$count" ] && count=0
242b08fbf24SPaolo Abeni	if [ "$count" != "$syn_nr" ]; then
243b08fbf24SPaolo Abeni		echo "[fail] got $count JOIN[s] syn expected $syn_nr"
244b08fbf24SPaolo Abeni		ret=1
245b08fbf24SPaolo Abeni		dump_stats=1
246b08fbf24SPaolo Abeni	else
247b08fbf24SPaolo Abeni		echo -n "[ ok ]"
248b08fbf24SPaolo Abeni	fi
249b08fbf24SPaolo Abeni
250b08fbf24SPaolo Abeni	echo -n " - synack"
251b08fbf24SPaolo Abeni	count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPJoinSynAckRx | awk '{print $2}'`
252b08fbf24SPaolo Abeni	[ -z "$count" ] && count=0
253b08fbf24SPaolo Abeni	if [ "$count" != "$syn_ack_nr" ]; then
254b08fbf24SPaolo Abeni		echo "[fail] got $count JOIN[s] synack expected $syn_ack_nr"
255b08fbf24SPaolo Abeni		ret=1
256b08fbf24SPaolo Abeni		dump_stats=1
257b08fbf24SPaolo Abeni	else
258b08fbf24SPaolo Abeni		echo -n "[ ok ]"
259b08fbf24SPaolo Abeni	fi
260b08fbf24SPaolo Abeni
261b08fbf24SPaolo Abeni	echo -n " - ack"
262b08fbf24SPaolo Abeni	count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinAckRx | awk '{print $2}'`
263b08fbf24SPaolo Abeni	[ -z "$count" ] && count=0
264b08fbf24SPaolo Abeni	if [ "$count" != "$ack_nr" ]; then
265b08fbf24SPaolo Abeni		echo "[fail] got $count JOIN[s] ack expected $ack_nr"
266b08fbf24SPaolo Abeni		ret=1
267b08fbf24SPaolo Abeni		dump_stats=1
268b08fbf24SPaolo Abeni	else
269b08fbf24SPaolo Abeni		echo "[ ok ]"
270b08fbf24SPaolo Abeni	fi
271b08fbf24SPaolo Abeni	if [ "${dump_stats}" = 1 ]; then
272b08fbf24SPaolo Abeni		echo Server ns stats
273b08fbf24SPaolo Abeni		ip netns exec $ns1 nstat -as | grep MPTcp
274b08fbf24SPaolo Abeni		echo Client ns stats
275b08fbf24SPaolo Abeni		ip netns exec $ns2 nstat -as | grep MPTcp
276b08fbf24SPaolo Abeni	fi
277b08fbf24SPaolo Abeni}
278b08fbf24SPaolo Abeni
279b08fbf24SPaolo Abenisin=$(mktemp)
280b08fbf24SPaolo Abenisout=$(mktemp)
281b08fbf24SPaolo Abenicin=$(mktemp)
282b08fbf24SPaolo Abenicout=$(mktemp)
283b08fbf24SPaolo Abeniinit
284b08fbf24SPaolo Abenimake_file "$cin" "client"
285b08fbf24SPaolo Abenimake_file "$sin" "server"
286b08fbf24SPaolo Abenitrap cleanup EXIT
287b08fbf24SPaolo Abeni
288b08fbf24SPaolo Abenirun_tests $ns1 $ns2 10.0.1.1
289b08fbf24SPaolo Abenichk_join_nr "no JOIN" "0" "0" "0"
290b08fbf24SPaolo Abeni
291b08fbf24SPaolo Abeni# subflow limted by client
292b08fbf24SPaolo Abenireset
293b08fbf24SPaolo Abeniip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
294b08fbf24SPaolo Abenirun_tests $ns1 $ns2 10.0.1.1
295b08fbf24SPaolo Abenichk_join_nr "single subflow, limited by client" 0 0 0
296b08fbf24SPaolo Abeni
297b08fbf24SPaolo Abeni# subflow limted by server
298b08fbf24SPaolo Abenireset
299b08fbf24SPaolo Abeniip netns exec $ns2 ./pm_nl_ctl limits 0 1
300b08fbf24SPaolo Abeniip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
301b08fbf24SPaolo Abenirun_tests $ns1 $ns2 10.0.1.1
302b08fbf24SPaolo Abenichk_join_nr "single subflow, limited by server" 1 1 0
303b08fbf24SPaolo Abeni
304b08fbf24SPaolo Abeni# subflow
305b08fbf24SPaolo Abenireset
306b08fbf24SPaolo Abeniip netns exec $ns1 ./pm_nl_ctl limits 0 1
307b08fbf24SPaolo Abeniip netns exec $ns2 ./pm_nl_ctl limits 0 1
308b08fbf24SPaolo Abeniip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
309b08fbf24SPaolo Abenirun_tests $ns1 $ns2 10.0.1.1
310b08fbf24SPaolo Abenichk_join_nr "single subflow" 1 1 1
311b08fbf24SPaolo Abeni
312b08fbf24SPaolo Abeni# multiple subflows
313b08fbf24SPaolo Abenireset
314b08fbf24SPaolo Abeniip netns exec $ns1 ./pm_nl_ctl limits 0 2
315b08fbf24SPaolo Abeniip netns exec $ns2 ./pm_nl_ctl limits 0 2
316b08fbf24SPaolo Abeniip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
317b08fbf24SPaolo Abeniip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow
318b08fbf24SPaolo Abenirun_tests $ns1 $ns2 10.0.1.1
319b08fbf24SPaolo Abenichk_join_nr "multiple subflows" 2 2 2
320b08fbf24SPaolo Abeni
321b08fbf24SPaolo Abeni# multiple subflows limited by serverf
322b08fbf24SPaolo Abenireset
323b08fbf24SPaolo Abeniip netns exec $ns1 ./pm_nl_ctl limits 0 1
324b08fbf24SPaolo Abeniip netns exec $ns2 ./pm_nl_ctl limits 0 2
325b08fbf24SPaolo Abeniip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
326b08fbf24SPaolo Abeniip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow
327b08fbf24SPaolo Abenirun_tests $ns1 $ns2 10.0.1.1
328b08fbf24SPaolo Abenichk_join_nr "multiple subflows, limited by server" 2 2 1
329b08fbf24SPaolo Abeni
330b08fbf24SPaolo Abeni# add_address, unused
331b08fbf24SPaolo Abenireset
332b08fbf24SPaolo Abeniip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal
333b08fbf24SPaolo Abenirun_tests $ns1 $ns2 10.0.1.1
334b08fbf24SPaolo Abenichk_join_nr "unused signal address" 0 0 0
335b08fbf24SPaolo Abeni
336b08fbf24SPaolo Abeni# accept and use add_addr
337b08fbf24SPaolo Abenireset
338b08fbf24SPaolo Abeniip netns exec $ns1 ./pm_nl_ctl limits 0 1
339b08fbf24SPaolo Abeniip netns exec $ns2 ./pm_nl_ctl limits 1 1
340b08fbf24SPaolo Abeniip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal
341b08fbf24SPaolo Abenirun_tests $ns1 $ns2 10.0.1.1
342b08fbf24SPaolo Abenichk_join_nr "signal address" 1 1 1
343b08fbf24SPaolo Abeni
344b08fbf24SPaolo Abeni# accept and use add_addr with an additional subflow
345b08fbf24SPaolo Abeni# note: signal address in server ns and local addresses in client ns must
346b08fbf24SPaolo Abeni# belong to different subnets or one of the listed local address could be
347b08fbf24SPaolo Abeni# used for 'add_addr' subflow
348b08fbf24SPaolo Abenireset
349b08fbf24SPaolo Abeniip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal
350b08fbf24SPaolo Abeniip netns exec $ns1 ./pm_nl_ctl limits 0 2
351b08fbf24SPaolo Abeniip netns exec $ns2 ./pm_nl_ctl limits 1 2
352b08fbf24SPaolo Abeniip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
353b08fbf24SPaolo Abenirun_tests $ns1 $ns2 10.0.1.1
354b08fbf24SPaolo Abenichk_join_nr "subflow and signal" 2 2 2
355b08fbf24SPaolo Abeni
356b08fbf24SPaolo Abeni# accept and use add_addr with additional subflows
357b08fbf24SPaolo Abenireset
358b08fbf24SPaolo Abeniip netns exec $ns1 ./pm_nl_ctl limits 0 3
359b08fbf24SPaolo Abeniip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal
360b08fbf24SPaolo Abeniip netns exec $ns2 ./pm_nl_ctl limits 1 3
361b08fbf24SPaolo Abeniip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
362b08fbf24SPaolo Abeniip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow
363b08fbf24SPaolo Abenirun_tests $ns1 $ns2 10.0.1.1
364b08fbf24SPaolo Abenichk_join_nr "multiple subflows and signal" 3 3 3
365b08fbf24SPaolo Abeni
36600587187SFlorian Westphal# single subflow, syncookies
36700587187SFlorian Westphalreset_with_cookies
36800587187SFlorian Westphalip netns exec $ns1 ./pm_nl_ctl limits 0 1
36900587187SFlorian Westphalip netns exec $ns2 ./pm_nl_ctl limits 0 1
37000587187SFlorian Westphalip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
37100587187SFlorian Westphalrun_tests $ns1 $ns2 10.0.1.1
37200587187SFlorian Westphalchk_join_nr "single subflow with syn cookies" 1 1 1
37300587187SFlorian Westphal
37400587187SFlorian Westphal# multiple subflows with syn cookies
37500587187SFlorian Westphalreset_with_cookies
37600587187SFlorian Westphalip netns exec $ns1 ./pm_nl_ctl limits 0 2
37700587187SFlorian Westphalip netns exec $ns2 ./pm_nl_ctl limits 0 2
37800587187SFlorian Westphalip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
37900587187SFlorian Westphalip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow
38000587187SFlorian Westphalrun_tests $ns1 $ns2 10.0.1.1
38100587187SFlorian Westphalchk_join_nr "multiple subflows with syn cookies" 2 2 2
38200587187SFlorian Westphal
38300587187SFlorian Westphal# multiple subflows limited by server
38400587187SFlorian Westphalreset_with_cookies
38500587187SFlorian Westphalip netns exec $ns1 ./pm_nl_ctl limits 0 1
38600587187SFlorian Westphalip netns exec $ns2 ./pm_nl_ctl limits 0 2
38700587187SFlorian Westphalip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
38800587187SFlorian Westphalip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow
38900587187SFlorian Westphalrun_tests $ns1 $ns2 10.0.1.1
39000587187SFlorian Westphalchk_join_nr "subflows limited by server w cookies" 2 2 1
39100587187SFlorian Westphal
39200587187SFlorian Westphal# test signal address with cookies
39300587187SFlorian Westphalreset_with_cookies
39400587187SFlorian Westphalip netns exec $ns1 ./pm_nl_ctl limits 0 1
39500587187SFlorian Westphalip netns exec $ns2 ./pm_nl_ctl limits 1 1
39600587187SFlorian Westphalip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal
39700587187SFlorian Westphalrun_tests $ns1 $ns2 10.0.1.1
39800587187SFlorian Westphalchk_join_nr "signal address with syn cookies" 1 1 1
39900587187SFlorian Westphal
40000587187SFlorian Westphal# test cookie with subflow and signal
40100587187SFlorian Westphalreset_with_cookies
40200587187SFlorian Westphalip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal
40300587187SFlorian Westphalip netns exec $ns1 ./pm_nl_ctl limits 0 2
40400587187SFlorian Westphalip netns exec $ns2 ./pm_nl_ctl limits 1 2
40500587187SFlorian Westphalip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
40600587187SFlorian Westphalrun_tests $ns1 $ns2 10.0.1.1
40700587187SFlorian Westphalchk_join_nr "subflow and signal w cookies" 2 2 2
40800587187SFlorian Westphal
40900587187SFlorian Westphal# accept and use add_addr with additional subflows
41000587187SFlorian Westphalreset_with_cookies
41100587187SFlorian Westphalip netns exec $ns1 ./pm_nl_ctl limits 0 3
41200587187SFlorian Westphalip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal
41300587187SFlorian Westphalip netns exec $ns2 ./pm_nl_ctl limits 1 3
41400587187SFlorian Westphalip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
41500587187SFlorian Westphalip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow
41600587187SFlorian Westphalrun_tests $ns1 $ns2 10.0.1.1
41700587187SFlorian Westphalchk_join_nr "subflows and signal w. cookies" 3 3 3
41800587187SFlorian Westphal
419b08fbf24SPaolo Abeniexit $ret
420