xref: /freebsd/contrib/netbsd-tests/net/ndp/t_ra.sh (revision 7ef62cebc2f965b0f640263e179276928885e33d)
1#	$NetBSD: t_ra.sh,v 1.24 2017/01/13 08:11:01 ozaki-r Exp $
2#
3# Copyright (c) 2015 Internet Initiative Japan Inc.
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9# 1. Redistributions of source code must retain the above copyright
10#    notice, this list of conditions and the following disclaimer.
11# 2. Redistributions in binary form must reproduce the above copyright
12#    notice, this list of conditions and the following disclaimer in the
13#    documentation and/or other materials provided with the distribution.
14#
15# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25# POSSIBILITY OF SUCH DAMAGE.
26#
27
28RUMPSRV=unix://r1
29RUMPSRV1_2=unix://r12
30RUMPCLI=unix://r2
31RUMPSRV3=unix://r3
32RUMPSRV4=unix://r4
33IP6SRV=fc00:1::1
34IP6SRV1_2=fc00:1::2
35IP6SRV_PREFIX=fc00:1:
36IP6CLI=fc00:2::2
37IP6SRV3=fc00:3::1
38IP6SRV3_PREFIX=fc00:3:
39IP6SRV4=fc00:4::1
40IP6SRV4_PREFIX=fc00:4:
41PIDFILE=./rump.rtadvd.pid
42PIDFILE1_2=./rump.rtadvd.pid12
43PIDFILE3=./rump.rtadvd.pid3
44PIDFILE4=./rump.rtadvd.pid4
45CONFIG=./rtadvd.conf
46WAITTIME=2
47DEBUG=${DEBUG:-true}
48
49init_server()
50{
51
52	export RUMP_SERVER=$1
53	atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.forwarding=1
54	export LD_PRELOAD=/usr/lib/librumphijack.so
55	atf_check -s exit:0 mkdir -p /rump/var/chroot/rtadvd
56	unset LD_PRELOAD
57	unset RUMP_SERVER
58}
59
60setup_shmif0()
61{
62	local sock=$1
63	local IP6ADDR=$2
64
65	rump_server_add_iface $sock shmif0 bus1
66
67	export RUMP_SERVER=$sock
68	atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${IP6ADDR}
69	atf_check -s exit:0 rump.ifconfig shmif0 up
70	atf_check -s exit:0 rump.ifconfig -w 10
71
72	$DEBUG && rump.ifconfig
73}
74
75wait_term()
76{
77	local PIDFILE=${1}
78	shift
79
80	while [ -f ${PIDFILE} ]
81	do
82		sleep 0.2
83	done
84
85	return 0
86}
87
88create_rtadvdconfig()
89{
90
91	cat << _EOF > ${CONFIG}
92shmif0:\
93	:mtu#1300:maxinterval#4:mininterval#3:
94_EOF
95}
96
97start_rtadvd()
98{
99	local sock=$1
100	local pidfile=$2
101
102	export RUMP_SERVER=$sock
103	atf_check -s exit:0 rump.rtadvd -c ${CONFIG} -p $pidfile shmif0
104	while [ ! -f $pidfile ]; do
105		sleep 0.2
106	done
107	unset RUMP_SERVER
108}
109
110check_entries()
111{
112	local cli=$1
113	local srv=$2
114	local addr_prefix=$3
115	local mac_srv= ll_srv=
116
117	ll_srv=$(get_linklocal_addr $srv shmif0)
118	mac_srv=$(get_macaddr $srv shmif0)
119
120	export RUMP_SERVER=$cli
121	$DEBUG && dump_entries
122	atf_check -s exit:0 -o match:'if=shmif0' rump.ndp -r
123	atf_check -s exit:0 -o match:'advertised' rump.ndp -p
124	atf_check -s exit:0 -o match:"${ll_srv}%shmif0 \(reachable\)" rump.ndp -p
125	atf_check -s exit:0 -o match:'linkmtu=1300' rump.ndp -n -i shmif0
126	atf_check -s exit:0 \
127	    -o match:"$ll_srv%shmif0 +$mac_srv +shmif0 +(23h59m|1d0h0m)..s S R" \
128	    rump.ndp -n -a
129	atf_check -s exit:0 -o match:$addr_prefix rump.ndp -n -a
130	atf_check -s exit:0 \
131	    -o match:"$addr_prefix.+<(TENTATIVE,)?AUTOCONF>" \
132	    rump.ifconfig shmif0 inet6
133	unset RUMP_SERVER
134}
135
136dump_entries()
137{
138
139	echo ndp -n -a
140	rump.ndp -n -a
141	echo ndp -p
142	rump.ndp -p
143	echo ndp -r
144	rump.ndp -r
145}
146
147atf_test_case ra_basic cleanup
148ra_basic_head()
149{
150
151	atf_set "descr" "Tests for basic functions of router advaertisement(RA)"
152	atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig"
153}
154
155ra_basic_body()
156{
157
158	rump_server_fs_start $RUMPSRV netinet6
159	rump_server_start $RUMPCLI netinet6
160
161	setup_shmif0 ${RUMPSRV} ${IP6SRV}
162	init_server $RUMPSRV
163
164	setup_shmif0 ${RUMPCLI} ${IP6CLI}
165	export RUMP_SERVER=${RUMPCLI}
166	$DEBUG && rump.ndp -n -a
167	atf_check -s exit:0 -o match:'= 0' rump.sysctl net.inet6.ip6.accept_rtadv
168	unset RUMP_SERVER
169
170	create_rtadvdconfig
171	start_rtadvd $RUMPSRV $PIDFILE
172	sleep $WAITTIME
173
174	export RUMP_SERVER=${RUMPCLI}
175	atf_check -s exit:0 -o empty rump.ndp -r
176	atf_check -s exit:0 -o not-match:'advertised' rump.ndp -p
177	atf_check -s exit:0 -o match:'linkmtu=0' rump.ndp -n -i shmif0
178	atf_check -s exit:0 -o not-match:'S R' rump.ndp -n -a
179	atf_check -s exit:0 -o not-match:'fc00:1:' rump.ndp -n -a
180	atf_check -s exit:0 -o not-match:'fc00:1:' rump.ifconfig shmif0 inet6
181	unset RUMP_SERVER
182
183	atf_check -s exit:0 kill -TERM `cat ${PIDFILE}`
184	wait_term ${PIDFILE}
185
186	export RUMP_SERVER=${RUMPCLI}
187	atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.accept_rtadv=1
188	unset RUMP_SERVER
189
190	start_rtadvd $RUMPSRV $PIDFILE
191	sleep $WAITTIME
192
193	check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX
194
195	atf_check -s exit:0 kill -TERM `cat ${PIDFILE}`
196	wait_term ${PIDFILE}
197
198	rump_server_destroy_ifaces
199}
200
201ra_basic_cleanup()
202{
203
204	if [ -f ${PIDFILE} ]; then
205		kill -TERM `cat ${PIDFILE}`
206		wait_term ${PIDFILE}
207	fi
208
209	$DEBUG && dump
210	cleanup
211}
212
213atf_test_case ra_flush_prefix_entries cleanup
214ra_flush_prefix_entries_head()
215{
216
217	atf_set "descr" "Tests for flushing prefixes (ndp -P)"
218	atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig"
219}
220
221ra_flush_prefix_entries_body()
222{
223
224	rump_server_fs_start $RUMPSRV netinet6
225	rump_server_start $RUMPCLI netinet6
226
227	setup_shmif0 ${RUMPSRV} ${IP6SRV}
228	setup_shmif0 ${RUMPCLI} ${IP6CLI}
229
230	init_server $RUMPSRV
231
232	create_rtadvdconfig
233
234	export RUMP_SERVER=${RUMPCLI}
235	atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.accept_rtadv=1
236	unset RUMP_SERVER
237
238	start_rtadvd $RUMPSRV $PIDFILE
239	sleep $WAITTIME
240
241	check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX
242
243	export RUMP_SERVER=${RUMPCLI}
244
245	# Terminate rtadvd to prevent new RA messages from coming
246	# Note that ifconfig down; kill -TERM doesn't work
247	kill -KILL `cat ${PIDFILE}`
248
249	# Flush all the entries in the prefix list
250	atf_check -s exit:0 rump.ndp -P
251
252	$DEBUG && dump_entries
253	atf_check -s exit:0 -o match:'if=shmif0' rump.ndp -r
254	atf_check -s exit:0 -o empty rump.ndp -p
255	atf_check -s exit:0 -o match:'linkmtu=1300' rump.ndp -n -i shmif0
256	atf_check -s exit:0 -o match:'(23h59m|1d0h0m)..s S R' rump.ndp -n -a
257	atf_check -s exit:0 -o match:'fc00:1:' rump.ndp -n -a
258	atf_check -s exit:0 -o not-match:'fc00:1:' rump.ifconfig shmif0 inet6
259	unset RUMP_SERVER
260
261	rump_server_destroy_ifaces
262}
263
264ra_flush_prefix_entries_cleanup()
265{
266
267	$DEBUG && dump
268	cleanup
269}
270
271atf_test_case ra_flush_defrouter_entries cleanup
272ra_flush_defrouter_entries_head()
273{
274
275	atf_set "descr" "Tests for flushing default routers (ndp -R)"
276	atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig"
277}
278
279ra_flush_defrouter_entries_body()
280{
281
282	rump_server_fs_start $RUMPSRV netinet6
283	rump_server_start $RUMPCLI netinet6
284
285	setup_shmif0 ${RUMPSRV} ${IP6SRV}
286	setup_shmif0 ${RUMPCLI} ${IP6CLI}
287
288	init_server $RUMPSRV
289
290	create_rtadvdconfig
291
292	export RUMP_SERVER=${RUMPCLI}
293	atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.accept_rtadv=1
294	unset RUMP_SERVER
295
296	start_rtadvd $RUMPSRV $PIDFILE
297	sleep $WAITTIME
298
299	check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX
300
301	export RUMP_SERVER=${RUMPCLI}
302
303	# Terminate rtadvd to prevent new RA messages from coming
304	# Note that ifconfig down; kill -TERM doesn't work
305	kill -KILL `cat ${PIDFILE}`
306
307	# Flush all the entries in the default router list
308	atf_check -s exit:0 rump.ndp -R
309
310	$DEBUG && dump_entries
311	atf_check -s exit:0 -o empty rump.ndp -r
312	atf_check -s exit:0 -o match:'No advertising router' rump.ndp -p
313	atf_check -s exit:0 -o match:'linkmtu=1300' rump.ndp -n -i shmif0
314	atf_check -s exit:0 -o match:'(23h59m|1d0h0m)..s S R' rump.ndp -n -a
315	atf_check -s exit:0 -o match:'fc00:1:' rump.ndp -n -a
316	atf_check -s exit:0 -o match:'fc00:1:' rump.ifconfig shmif0 inet6
317	unset RUMP_SERVER
318
319	rump_server_destroy_ifaces
320}
321
322ra_flush_defrouter_entries_cleanup()
323{
324
325	$DEBUG && dump
326	cleanup
327}
328
329atf_test_case ra_delete_address cleanup
330ra_delete_address_head()
331{
332
333	atf_set "descr" "Tests for deleting auto-configured address"
334	atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig"
335}
336
337ra_delete_address_body()
338{
339
340	rump_server_fs_start $RUMPSRV netinet6
341	rump_server_start $RUMPCLI netinet6
342
343	setup_shmif0 ${RUMPSRV} ${IP6SRV}
344	setup_shmif0 ${RUMPCLI} ${IP6CLI}
345
346	init_server $RUMPSRV
347
348	create_rtadvdconfig
349
350	export RUMP_SERVER=${RUMPCLI}
351	atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.accept_rtadv=1
352	unset RUMP_SERVER
353
354	start_rtadvd $RUMPSRV $PIDFILE
355	sleep $WAITTIME
356
357	check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX
358
359	export RUMP_SERVER=${RUMPCLI}
360	$DEBUG && rump.ifconfig shmif0
361	atf_check -s exit:0 rump.ifconfig shmif0 inet6 \
362	    $(rump.ifconfig shmif0 |awk '/AUTOCONF/ {print $2}') delete
363	unset RUMP_SERVER
364
365	atf_check -s exit:0 kill -TERM `cat ${PIDFILE}`
366	wait_term ${PIDFILE}
367
368	rump_server_destroy_ifaces
369}
370
371ra_delete_address_cleanup()
372{
373
374	if [ -f ${PIDFILE} ]; then
375		kill -TERM `cat ${PIDFILE}`
376		wait_term ${PIDFILE}
377	fi
378
379	$DEBUG && dump
380	cleanup
381}
382
383atf_test_case ra_multiple_routers cleanup
384ra_multiple_routers_head()
385{
386
387	atf_set "descr" "Tests for multiple routers"
388	atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig"
389}
390
391ra_multiple_routers_body()
392{
393	local n=
394
395	rump_server_fs_start $RUMPSRV netinet6
396	rump_server_fs_start $RUMPSRV3 netinet6
397	rump_server_start $RUMPCLI netinet6
398
399	setup_shmif0 ${RUMPSRV} ${IP6SRV}
400	setup_shmif0 ${RUMPSRV3} ${IP6SRV3}
401	setup_shmif0 ${RUMPCLI} ${IP6CLI}
402
403	init_server $RUMPSRV
404	init_server $RUMPSRV3
405
406	create_rtadvdconfig
407
408	export RUMP_SERVER=${RUMPCLI}
409	atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.accept_rtadv=1
410	unset RUMP_SERVER
411
412	start_rtadvd $RUMPSRV $PIDFILE
413	start_rtadvd $RUMPSRV3 $PIDFILE3
414	sleep $WAITTIME
415
416	check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX
417	check_entries $RUMPCLI $RUMPSRV3 $IP6SRV3_PREFIX
418
419	export RUMP_SERVER=$RUMPCLI
420	# Two prefixes are advertised by differnt two routers
421	n=$(rump.ndp -p |grep 'advertised by' |wc -l)
422	atf_check_equal $n 2
423	unset RUMP_SERVER
424
425	atf_check -s exit:0 kill -TERM `cat ${PIDFILE}`
426	wait_term ${PIDFILE}
427	atf_check -s exit:0 kill -TERM `cat ${PIDFILE3}`
428	wait_term ${PIDFILE3}
429
430	rump_server_destroy_ifaces
431}
432
433ra_multiple_routers_cleanup()
434{
435
436	if [ -f ${PIDFILE} ]; then
437		kill -TERM `cat ${PIDFILE}`
438		wait_term ${PIDFILE}
439	fi
440	if [ -f ${PIDFILE3} ]; then
441		kill -TERM `cat ${PIDFILE3}`
442		wait_term ${PIDFILE3}
443	fi
444
445	$DEBUG && dump
446	cleanup
447}
448
449atf_test_case ra_multiple_routers_single_prefix cleanup
450ra_multiple_routers_single_prefix_head()
451{
452
453	atf_set "descr" "Tests for multiple routers with a single prefix"
454	atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig"
455}
456
457ra_multiple_routers_single_prefix_body()
458{
459	local n=
460
461	rump_server_fs_start $RUMPSRV netinet6
462	rump_server_fs_start $RUMPSRV1_2 netinet6
463	rump_server_start $RUMPCLI netinet6
464
465	setup_shmif0 ${RUMPSRV} ${IP6SRV}
466	setup_shmif0 ${RUMPSRV1_2} ${IP6SRV1_2}
467	setup_shmif0 ${RUMPCLI} ${IP6CLI}
468
469	init_server $RUMPSRV
470	init_server $RUMPSRV1_2
471
472	create_rtadvdconfig
473
474	export RUMP_SERVER=${RUMPCLI}
475	atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.accept_rtadv=1
476	unset RUMP_SERVER
477
478	start_rtadvd $RUMPSRV $PIDFILE
479	start_rtadvd $RUMPSRV1_2 $PIDFILE1_2
480	sleep $WAITTIME
481
482	check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX
483	check_entries $RUMPCLI $RUMPSRV1_2 $IP6SRV_PREFIX
484
485	export RUMP_SERVER=$RUMPCLI
486	# One prefix is advertised by differnt two routers
487	n=$(rump.ndp -p |grep 'advertised by' |wc -l)
488	atf_check_equal $n 1
489	unset RUMP_SERVER
490
491	atf_check -s exit:0 kill -TERM `cat ${PIDFILE}`
492	wait_term ${PIDFILE}
493	atf_check -s exit:0 kill -TERM `cat ${PIDFILE1_2}`
494	wait_term ${PIDFILE1_2}
495
496	rump_server_destroy_ifaces
497}
498
499ra_multiple_routers_single_prefix_cleanup()
500{
501
502	if [ -f ${PIDFILE} ]; then
503		kill -TERM `cat ${PIDFILE}`
504		wait_term ${PIDFILE}
505	fi
506	if [ -f ${PIDFILE1_2} ]; then
507		kill -TERM `cat ${PIDFILE1_2}`
508		wait_term ${PIDFILE1_2}
509	fi
510
511	$DEBUG && dump
512	cleanup
513}
514
515atf_test_case ra_multiple_routers_maxifprefixes cleanup
516ra_multiple_routers_maxifprefixes_head()
517{
518
519	atf_set "descr" "Tests for exceeding the number of maximum prefixes"
520	atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig"
521}
522
523ra_multiple_routers_maxifprefixes_body()
524{
525	local n=
526
527	rump_server_fs_start $RUMPSRV netinet6
528	rump_server_fs_start $RUMPSRV3 netinet6
529	rump_server_fs_start $RUMPSRV4 netinet6
530	rump_server_start $RUMPCLI netinet6
531
532	setup_shmif0 ${RUMPSRV} ${IP6SRV}
533	setup_shmif0 ${RUMPSRV3} ${IP6SRV3}
534	setup_shmif0 ${RUMPSRV4} ${IP6SRV4}
535	setup_shmif0 ${RUMPCLI} ${IP6CLI}
536
537	init_server $RUMPSRV
538	init_server $RUMPSRV3
539	init_server $RUMPSRV4
540
541	create_rtadvdconfig
542
543	export RUMP_SERVER=${RUMPCLI}
544	atf_check -s exit:0 -o match:'0.->.1' \
545	    rump.sysctl -w net.inet6.ip6.accept_rtadv=1
546	# Limit the maximum number of prefix entries to 2
547	atf_check -s exit:0 -o match:'16.->.2' \
548	    rump.sysctl -w net.inet6.ip6.maxifprefixes=2
549	unset RUMP_SERVER
550
551	start_rtadvd $RUMPSRV $PIDFILE
552	start_rtadvd $RUMPSRV3 $PIDFILE3
553	sleep $WAITTIME
554
555	check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX
556	check_entries $RUMPCLI $RUMPSRV3 $IP6SRV3_PREFIX
557
558	start_rtadvd $RUMPSRV4 $PIDFILE4
559	sleep $WAITTIME
560
561	export RUMP_SERVER=${RUMPCLI}
562	$DEBUG && dump_entries
563	# There should remain two prefixes
564	n=$(rump.ndp -p |grep 'advertised by' |wc -l)
565	atf_check_equal $n 2
566	# TODO check other conditions
567	unset RUMP_SERVER
568
569	atf_check -s exit:0 kill -TERM `cat ${PIDFILE}`
570	wait_term ${PIDFILE}
571	atf_check -s exit:0 kill -TERM `cat ${PIDFILE3}`
572	wait_term ${PIDFILE3}
573	atf_check -s exit:0 kill -TERM `cat ${PIDFILE4}`
574	wait_term ${PIDFILE4}
575
576	rump_server_destroy_ifaces
577}
578
579ra_multiple_routers_maxifprefixes_cleanup()
580{
581
582	if [ -f ${PIDFILE} ]; then
583		kill -TERM `cat ${PIDFILE}`
584		wait_term ${PIDFILE}
585	fi
586	if [ -f ${PIDFILE3} ]; then
587		kill -TERM `cat ${PIDFILE3}`
588		wait_term ${PIDFILE3}
589	fi
590	if [ -f ${PIDFILE4} ]; then
591		kill -TERM `cat ${PIDFILE4}`
592		wait_term ${PIDFILE4}
593	fi
594
595	$DEBUG && dump
596	cleanup
597}
598
599atf_test_case ra_temporary_address cleanup
600ra_temporary_address_head()
601{
602
603	atf_set "descr" "Tests for IPv6 temporary address"
604	atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig"
605}
606
607check_echo_request_pkt()
608{
609	local pkt="$2 > $3: .+ echo request"
610
611	extract_new_packets $1 > ./out
612	$DEBUG && echo $pkt
613	$DEBUG && cat ./out
614	atf_check -s exit:0 -o match:"$pkt" cat ./out
615}
616
617ra_temporary_address_body()
618{
619	local ip_auto= ip_temp=
620
621	rump_server_fs_start $RUMPSRV netinet6
622	rump_server_start $RUMPCLI netinet6
623
624	setup_shmif0 $RUMPSRV $IP6SRV
625	init_server $RUMPSRV
626	setup_shmif0 $RUMPCLI $IP6CLI
627
628	export RUMP_SERVER=$RUMPCLI
629	atf_check -s exit:0 -o match:'0.->.1' \
630	    rump.sysctl -w net.inet6.ip6.accept_rtadv=1
631	atf_check -s exit:0 -o match:'0.->.1' \
632	    rump.sysctl -w net.inet6.ip6.use_tempaddr=1
633	unset RUMP_SERVER
634
635	create_rtadvdconfig
636	start_rtadvd $RUMPSRV $PIDFILE
637	sleep $WAITTIME
638
639	check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX
640
641	export RUMP_SERVER=$RUMPCLI
642
643	# Check temporary address
644	atf_check -s exit:0 \
645	    -o match:"$IP6SRV_PREFIX.+<(TENTATIVE,)?AUTOCONF,TEMPORARY>" \
646	    rump.ifconfig shmif0 inet6
647
648	#
649	# Testing net.inet6.ip6.prefer_tempaddr
650	#
651	atf_check -s exit:0 rump.ifconfig -w 10
652	$DEBUG && rump.ifconfig shmif0
653	ip_auto=$(rump.ifconfig shmif0 |awk '/<AUTOCONF>/ {sub(/\/[0-9]*/, ""); print $2;}')
654	ip_temp=$(rump.ifconfig shmif0 |awk '/<AUTOCONF,TEMPORARY>/ {sub(/\/[0-9]*/, ""); print $2;}')
655	$DEBUG && echo $ip_auto $ip_temp
656
657	# Ignore old packets
658	extract_new_packets bus1 > /dev/null
659
660	atf_check -s exit:0 -o ignore rump.ping6 -n -X 2 -c 1 $IP6SRV
661	# autoconf (non-temporal) address should be used as the source address
662	check_echo_request_pkt bus1 $ip_auto $IP6SRV
663
664	# Enable net.inet6.ip6.prefer_tempaddr
665	atf_check -s exit:0 -o match:'0.->.1' \
666	    rump.sysctl -w net.inet6.ip6.prefer_tempaddr=1
667
668	atf_check -s exit:0 -o ignore rump.ping6 -n -X 2 -c 1 $IP6SRV
669	# autoconf, temporal address should be used as the source address
670	check_echo_request_pkt bus1 $ip_temp $IP6SRV
671
672	unset RUMP_SERVER
673
674	atf_check -s exit:0 kill -TERM `cat ${PIDFILE}`
675	wait_term $PIDFILE
676
677	rump_server_destroy_ifaces
678}
679
680ra_temporary_address_cleanup()
681{
682
683	if [ -f ${PIDFILE} ]; then
684		kill -TERM `cat ${PIDFILE}`
685		wait_term ${PIDFILE}
686	fi
687
688	$DEBUG && dump
689	cleanup
690}
691
692atf_init_test_cases()
693{
694
695	atf_add_test_case ra_basic
696	atf_add_test_case ra_flush_prefix_entries
697	atf_add_test_case ra_flush_defrouter_entries
698	atf_add_test_case ra_delete_address
699	atf_add_test_case ra_multiple_routers
700	atf_add_test_case ra_multiple_routers_single_prefix
701	atf_add_test_case ra_multiple_routers_maxifprefixes
702	atf_add_test_case ra_temporary_address
703}
704