t_gif.sh revision 1.3 1 # $NetBSD: t_gif.sh,v 1.3 2015/12/08 05:56:18 knakahara 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
28 server="rump_server -v -lrumpnet -lrumpnet_net -lrumpnet_netinet \
29 -lrumpnet_netinet6 -lrumpnet_shmif -lrumpnet_gif"
30 HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=sysctl=yes"
31
32 SOCK1=unix://commsock1 # for ROUTER1
33 SOCK2=unix://commsock2 # for ROUTER2
34 ROUTER1_LANIP=192.168.1.1
35 ROUTER1_LANNET=192.168.1.0/24
36 ROUTER1_WANIP=10.0.0.1
37 ROUTER1_GIFIP=172.16.1.1
38 ROUTER1_WANIP_DUMMY=10.0.0.11
39 ROUTER1_GIFIP_DUMMY=172.16.11.1
40 ROUTER1_GIFIP_RECURSIVE1=172.16.101.1
41 ROUTER1_GIFIP_RECURSIVE2=172.16.201.1
42 ROUTER2_LANIP=192.168.2.1
43 ROUTER2_LANNET=192.168.2.0/24
44 ROUTER2_WANIP=10.0.0.2
45 ROUTER2_GIFIP=172.16.2.1
46 ROUTER2_WANIP_DUMMY=10.0.0.12
47 ROUTER2_GIFIP_DUMMY=172.16.12.1
48 ROUTER2_GIFIP_RECURSIVE1=172.16.102.1
49 ROUTER2_GIFIP_RECURSIVE2=172.16.202.1
50
51 ROUTER1_LANIP6=fc00:1::1
52 ROUTER1_LANNET6=fc00:1::/64
53 ROUTER1_WANIP6=fc00::1
54 ROUTER1_GIFIP6=fc00:3::1
55 ROUTER1_WANIP6_DUMMY=fc00::11
56 ROUTER1_GIFIP6_DUMMY=fc00:13::1
57 ROUTER1_GIFIP6_RECURSIVE1=fc00:103::1
58 ROUTER1_GIFIP6_RECURSIVE2=fc00:203::1
59 ROUTER2_LANIP6=fc00:2::1
60 ROUTER2_LANNET6=fc00:2::/64
61 ROUTER2_WANIP6=fc00::2
62 ROUTER2_GIFIP6=fc00:4::1
63 ROUTER2_WANIP6_DUMMY=fc00::12
64 ROUTER2_GIFIP6_DUMMY=fc00:14::1
65 ROUTER2_GIFIP6_RECURSIVE1=fc00:104::1
66 ROUTER2_GIFIP6_RECURSIVE2=fc00:204::1
67
68 TIMEOUT=5
69
70 atf_test_case basicv4overv4 cleanup
71 atf_test_case basicv4overv6 cleanup
72 atf_test_case basicv6overv4 cleanup
73 atf_test_case basicv6overv6 cleanup
74 atf_test_case ioctlv4overv4 cleanup
75 atf_test_case ioctlv4overv6 cleanup
76 atf_test_case ioctlv6overv4 cleanup
77 atf_test_case ioctlv6overv6 cleanup
78 atf_test_case recursivev4overv4 cleanup
79 atf_test_case recursivev4overv6 cleanup
80 atf_test_case recursivev6overv4 cleanup
81 atf_test_case recursivev6overv6 cleanup
82
83 basicv4overv4_head()
84 {
85 atf_set "descr" "Does IPv4 over IPv4 if_gif basic tests"
86 atf_set "require.progs" "rump_server"
87 }
88
89 basicv4overv6_head()
90 {
91 atf_set "descr" "Does IPv4 over IPv6 if_gif basic tests"
92 atf_set "require.progs" "rump_server"
93 }
94
95 basicv6overv4_head()
96 {
97 atf_set "descr" "Does IPv6 over IPv4 if_gif basic tests"
98 atf_set "require.progs" "rump_server"
99 }
100
101 basicv6overv6_head()
102 {
103 atf_set "descr" "Does IPv6 over IPv6 if_gif basic tests"
104 atf_set "require.progs" "rump_server"
105 }
106
107 ioctlv4overv4_head()
108 {
109 atf_set "descr" "Does IPv4 over IPv4 if_gif ioctl tests"
110 atf_set "require.progs" "rump_server"
111 }
112
113 ioctlv4overv6_head()
114 {
115 atf_set "descr" "Does IPv4 over IPv6 if_gif ioctl tests"
116 atf_set "require.progs" "rump_server"
117 }
118
119 ioctlv6overv4_head()
120 {
121 atf_set "descr" "Does IPv6 over IPv4 if_gif ioctl tests"
122 atf_set "require.progs" "rump_server"
123 }
124
125 ioctlv6overv6_head()
126 {
127 atf_set "descr" "Does IPv6 over IPv6 if_gif ioctl tests"
128 atf_set "require.progs" "rump_server"
129 }
130
131 recursivev4overv4_head()
132 {
133 atf_set "descr" "Does IPv4 over IPv4 if_gif recursive check tests"
134 atf_set "require.progs" "rump_server"
135 }
136
137 recursivev4overv6_head()
138 {
139 atf_set "descr" "Does IPv4 over IPv6 if_gif recursive check tests"
140 atf_set "require.progs" "rump_server"
141 }
142
143 recursivev6overv4_head()
144 {
145 atf_set "descr" "Does IPv6 over IPv4 if_gif recursive check tests"
146 atf_set "require.progs" "rump_server"
147 }
148
149 recursivev6overv6_head()
150 {
151 atf_set "descr" "Does IPv6 over IPv6 if_gif recursive check tests"
152 atf_set "require.progs" "rump_server"
153 }
154
155 setup_router()
156 {
157 sock=${1}
158 lan=${2}
159 lan_mode=${3}
160 wan=${4}
161 wan_mode=${5}
162
163 export RUMP_SERVER=${sock}
164 atf_check -s exit:0 rump.ifconfig shmif0 create
165 atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus0
166 if [ ${lan_mode} = "ipv6" ]; then
167 atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${lan}
168 else
169 atf_check -s exit:0 rump.ifconfig shmif0 inet ${lan} netmask 0xffffff00
170 fi
171 atf_check -s exit:0 rump.ifconfig shmif0 up
172 rump.ifconfig shmif0
173
174 atf_check -s exit:0 rump.ifconfig shmif1 create
175 atf_check -s exit:0 rump.ifconfig shmif1 linkstr bus1
176 if [ ${wan_mode} = "ipv6" ]; then
177 atf_check -s exit:0 rump.ifconfig shmif1 inet6 ${wan}
178 else
179 atf_check -s exit:0 rump.ifconfig shmif1 inet ${wan} netmask 0xff000000
180 fi
181 atf_check -s exit:0 rump.ifconfig shmif1 up
182 rump.ifconfig shmif1
183 }
184
185 test_router()
186 {
187 sock=${1}
188 lan=${2}
189 lan_mode=${3}
190 wan=${4}
191 wan_mode=${5}
192
193 export RUMP_SERVER=${sock}
194 atf_check -s exit:0 -o match:shmif0 rump.ifconfig
195 if [ ${lan_mode} = "ipv6" ]; then
196 atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT ${lan}
197 else
198 atf_check -s exit:0 -o ignore rump.ping -n -c 1 -w $TIMEOUT ${lan}
199 fi
200
201 atf_check -s exit:0 -o match:shmif1 rump.ifconfig
202 if [ ${wan_mode} = "ipv6" ]; then
203 atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT ${wan}
204 else
205 atf_check -s exit:0 -o ignore rump.ping -n -c 1 -w $TIMEOUT ${wan}
206 fi
207 }
208
209 setup()
210 {
211 inner=${1}
212 outer=${2}
213
214 atf_check -s exit:0 ${server} $SOCK1
215 atf_check -s exit:0 ${server} $SOCK2
216
217 router1_lan=""
218 router1_lan_mode=""
219 router2_lan=""
220 router2_lan_mode=""
221 if [ ${inner} = "ipv6" ]; then
222 router1_lan=$ROUTER1_LANIP6
223 router1_lan_mode="ipv6"
224 router2_lan=$ROUTER2_LANIP6
225 router2_lan_mode="ipv6"
226 else
227 router1_lan=$ROUTER1_LANIP
228 router1_lan_mode="ipv4"
229 router2_lan=$ROUTER2_LANIP
230 router2_lan_mode="ipv4"
231 fi
232
233 if [ ${outer} = "ipv6" ]; then
234 setup_router $SOCK1 ${router1_lan} ${router1_lan_mode} \
235 $ROUTER1_WANIP6 ipv6
236 setup_router $SOCK2 ${router2_lan} ${router2_lan_mode} \
237 $ROUTER2_WANIP6 ipv6
238 else
239 setup_router $SOCK1 ${router1_lan} ${router1_lan_mode} \
240 $ROUTER1_WANIP ipv4
241 setup_router $SOCK2 ${router2_lan} ${router2_lan_mode} \
242 $ROUTER2_WANIP ipv4
243 fi
244 }
245
246 test_setup()
247 {
248 inner=${1}
249 outer=${2}
250
251 router1_lan=""
252 router1_lan_mode=""
253 router2_lan=""
254 router2_lan_mode=""
255 if [ ${inner} = "ipv6" ]; then
256 router1_lan=$ROUTER1_LANIP6
257 router1_lan_mode="ipv6"
258 router2_lan=$ROUTER2_LANIP6
259 router2_lan_mode="ipv6"
260 else
261 router1_lan=$ROUTER1_LANIP
262 router1_lan_mode="ipv4"
263 router2_lan=$ROUTER2_LANIP
264 router2_lan_mode="ipv4"
265 fi
266 if [ ${outer} = "ipv6" ]; then
267 test_router $SOCK1 ${router1_lan} ${router1_lan_mode} \
268 $ROUTER1_WANIP6 ipv6
269 test_router $SOCK2 ${router2_lan} ${router2_lan_mode} \
270 $ROUTER2_WANIP6 ipv6
271 else
272 test_router $SOCK1 ${router1_lan} ${router1_lan_mode} \
273 $ROUTER1_WANIP ipv4
274 test_router $SOCK2 ${router2_lan} ${router2_lan_mode} \
275 $ROUTER2_WANIP ipv4
276 fi
277 }
278
279 setup_if_gif()
280 {
281 sock=${1}
282 addr=${2}
283 remote=${3}
284 inner=${4}
285 src=${5}
286 dst=${6}
287 peernet=${7}
288
289 export RUMP_SERVER=${sock}
290 atf_check -s exit:0 rump.ifconfig gif0 create
291 atf_check -s exit:0 rump.ifconfig gif0 tunnel ${src} ${dst}
292 if [ ${inner} = "ipv6" ]; then
293 atf_check -s exit:0 rump.ifconfig gif0 inet6 ${addr}/128 ${remote}
294 atf_check -s exit:0 -o ignore rump.route add -inet6 ${peernet} ${addr}
295 else
296 atf_check -s exit:0 rump.ifconfig gif0 inet ${addr}/32 ${remote}
297 atf_check -s exit:0 -o ignore rump.route add -inet ${peernet} ${addr}
298 fi
299
300 rump.ifconfig gif0
301 rump.route -nL show
302 }
303
304 setup_tunnel()
305 {
306 inner=${1}
307 outer=${2}
308
309 addr=""
310 remote=""
311 src=""
312 dst=""
313 peernet=""
314
315 if [ ${inner} = "ipv6" ]; then
316 addr=$ROUTER1_GIFIP6
317 remote=$ROUTER2_GIFIP6
318 peernet=$ROUTER2_LANNET6
319 else
320 addr=$ROUTER1_GIFIP
321 remote=$ROUTER2_GIFIP
322 peernet=$ROUTER2_LANNET
323 fi
324 if [ ${outer} = "ipv6" ]; then
325 src=$ROUTER1_WANIP6
326 dst=$ROUTER2_WANIP6
327 else
328 src=$ROUTER1_WANIP
329 dst=$ROUTER2_WANIP
330 fi
331 setup_if_gif $SOCK1 ${addr} ${remote} ${inner} \
332 ${src} ${dst} ${peernet}
333
334 if [ $inner = "ipv6" ]; then
335 addr=$ROUTER2_GIFIP6
336 remote=$ROUTER1_GIFIP6
337 peernet=$ROUTER1_LANNET6
338 else
339 addr=$ROUTER2_GIFIP
340 remote=$ROUTER1_GIFIP
341 peernet=$ROUTER1_LANNET
342 fi
343 if [ $outer = "ipv6" ]; then
344 src=$ROUTER2_WANIP6
345 dst=$ROUTER1_WANIP6
346 else
347 src=$ROUTER2_WANIP
348 dst=$ROUTER1_WANIP
349 fi
350 setup_if_gif $SOCK2 ${addr} ${remote} ${inner} \
351 ${src} ${dst} ${peernet}
352 }
353
354 test_setup_tunnel()
355 {
356 mode=${1}
357
358 peernet=""
359 opt=""
360 if [ ${mode} = "ipv6" ]; then
361 peernet=$ROUTER2_LANNET6
362 opt="-inet6"
363 else
364 peernet=$ROUTER2_LANNET
365 opt="-inet"
366 fi
367 export RUMP_SERVER=$SOCK1
368 atf_check -s exit:0 -o match:gif0 rump.ifconfig
369 atf_check -s exit:0 -o match:gif0 rump.route -nL get ${opt} ${peernet}
370
371 if [ ${mode} = "ipv6" ]; then
372 peernet=$ROUTER1_LANNET6
373 opt="-inet6"
374 else
375 peernet=$ROUTER1_LANNET
376 opt="-inet"
377 fi
378 export RUMP_SERVER=$SOCK2
379 atf_check -s exit:0 -o match:gif0 rump.ifconfig
380 atf_check -s exit:0 -o match:gif0 rump.route -nL get ${opt} ${peernet}
381 }
382
383 teardown_tunnel()
384 {
385 export RUMP_SERVER=$SOCK1
386 atf_check -s exit:0 rump.ifconfig gif0 deletetunnel
387 atf_check -s exit:0 rump.ifconfig gif0 destroy
388
389 export RUMP_SERVER=$SOCK2
390 atf_check -s exit:0 rump.ifconfig gif0 deletetunnel
391 atf_check -s exit:0 rump.ifconfig gif0 destroy
392 }
393
394 setup_dummy_if_gif()
395 {
396 sock=${1}
397 addr=${2}
398 remote=${3}
399 inner=${4}
400 src=${5}
401 dst=${6}
402
403 export RUMP_SERVER=${sock}
404 atf_check -s exit:0 rump.ifconfig gif1 create
405 atf_check -s exit:0 rump.ifconfig gif1 tunnel ${src} ${dst}
406 if [ ${inner} = "ipv6" ]; then
407 atf_check -s exit:0 rump.ifconfig gif1 inet6 ${addr}/128 ${remote}
408 else
409 atf_check -s exit:0 rump.ifconfig gif1 inet ${addr}/32 ${remote}
410 fi
411
412 rump.ifconfig gif1
413 }
414
415 setup_dummy_tunnel()
416 {
417 inner=${1}
418 outer=${2}
419
420 addr=""
421 remote=""
422 src=""
423 dst=""
424
425 if [ ${inner} = "ipv6" ]; then
426 addr=$ROUTER1_GIFIP6_DUMMY
427 remote=$ROUTER2_GIFIP6_DUMMY
428 else
429 addr=$ROUTER1_GIFIP_DUMMY
430 remote=$ROUTER2_GIFIP_DUMMY
431 fi
432 if [ ${outer} = "ipv6" ]; then
433 src=$ROUTER1_WANIP6_DUMMY
434 dst=$ROUTER2_WANIP6_DUMMY
435 else
436 src=$ROUTER1_WANIP_DUMMY
437 dst=$ROUTER2_WANIP_DUMMY
438 fi
439 setup_dummy_if_gif $SOCK1 ${addr} ${remote} ${inner} \
440 ${src} ${dst}
441
442 if [ $inner = "ipv6" ]; then
443 addr=$ROUTER2_GIFIP6_DUMMY
444 remote=$ROUTER1_GIFIP6_DUMMY
445 else
446 addr=$ROUTER2_GIFIP_DUMMY
447 remote=$ROUTER1_GIFIP_DUMMY
448 fi
449 if [ $outer = "ipv6" ]; then
450 src=$ROUTER2_WANIP6_DUMMY
451 dst=$ROUTER1_WANIP6_DUMMY
452 else
453 src=$ROUTER2_WANIP_DUMMY
454 dst=$ROUTER1_WANIP_DUMMY
455 fi
456 setup_dummy_if_gif $SOCK2 ${addr} ${remote} ${inner} \
457 ${src} ${dst}
458 }
459
460 test_setup_dummy_tunnel()
461 {
462 export RUMP_SERVER=$SOCK1
463 atf_check -s exit:0 -o match:gif1 rump.ifconfig
464
465 export RUMP_SERVER=$SOCK2
466 atf_check -s exit:0 -o match:gif1 rump.ifconfig
467 }
468
469 teardown_dummy_tunnel()
470 {
471 export RUMP_SERVER=$SOCK1
472 atf_check -s exit:0 rump.ifconfig gif1 deletetunnel
473 atf_check -s exit:0 rump.ifconfig gif1 destroy
474
475 export RUMP_SERVER=$SOCK2
476 atf_check -s exit:0 rump.ifconfig gif1 deletetunnel
477 atf_check -s exit:0 rump.ifconfig gif1 destroy
478 }
479
480 setup_recursive_if_gif()
481 {
482 sock=${1}
483 gif=${2}
484 addr=${3}
485 remote=${4}
486 inner=${5}
487 src=${6}
488 dst=${7}
489
490 export RUMP_SERVER=${sock}
491 atf_check -s exit:0 rump.ifconfig ${gif} create
492 atf_check -s exit:0 rump.ifconfig ${gif} tunnel ${src} ${dst}
493 if [ ${inner} = "ipv6" ]; then
494 atf_check -s exit:0 rump.ifconfig ${gif} inet6 ${addr}/128 ${remote}
495 else
496 atf_check -s exit:0 rump.ifconfig ${gif} inet ${addr}/32 ${remote}
497 fi
498
499 rump.ifconfig ${gif}
500 }
501
502 # test in ROUTER1 only
503 setup_recursive_tunnels()
504 {
505 mode=${1}
506
507 addr=""
508 remote=""
509 src=""
510 dst=""
511
512 if [ ${mode} = "ipv6" ]; then
513 addr=$ROUTER1_GIFIP6_RECURSIVE1
514 remote=$ROUTER2_GIFIP6_RECURSIVE1
515 src=$ROUTER1_GIFIP6
516 dst=$ROUTER2_GIFIP6
517 else
518 addr=$ROUTER1_GIFIP_RECURSIVE1
519 remote=$ROUTER2_GIFIP_RECURSIVE1
520 src=$ROUTER1_GIFIP
521 dst=$ROUTER2_GIFIP
522 fi
523 setup_recursive_if_gif $SOCK1 gif1 ${addr} ${remote} ${mode} \
524 ${src} ${dst}
525
526 if [ ${mode} = "ipv6" ]; then
527 addr=$ROUTER1_GIFIP6_RECURSIVE2
528 remote=$ROUTER2_GIFIP6_RECURSIVE2
529 src=$ROUTER1_GIFIP6_RECURSIVE1
530 dst=$ROUTER2_GIFIP6_RECURSIVE1
531 else
532 addr=$ROUTER1_GIFIP_RECURSIVE2
533 remote=$ROUTER2_GIFIP_RECURSIVE2
534 src=$ROUTER1_GIFIP_RECURSIVE1
535 dst=$ROUTER2_GIFIP_RECURSIVE1
536 fi
537 setup_recursive_if_gif $SOCK1 gif2 ${addr} ${remote} ${mode} \
538 ${src} ${dst}
539 }
540
541 # test in router1 only
542 test_recursive_check()
543 {
544 mode=$1
545
546 export RUMP_SERVER=$SOCK1
547 if [ ${mode} = "ipv6" ]; then
548 atf_check -s not-exit:0 -o ignore -e ignore \
549 rump.ping6 -n -X $TIMEOUT -c 1 $ROUTER2_GIFIP6_RECURSIVE2
550 else
551 atf_check -s not-exit:0 -o ignore -e ignore \
552 rump.ping -n -w $TIMEOUT -c 1 $ROUTER2_GIFIP_RECURSIVE2
553 fi
554
555 atf_check -o match:'gif0: recursively called too many times' \
556 -x "$HIJACKING dmesg"
557
558 $HIJACKING dmesg
559 }
560
561 teardown_recursive_tunnels()
562 {
563 export RUMP_SERVER=$SOCK1
564 atf_check -s exit:0 rump.ifconfig gif1 deletetunnel
565 atf_check -s exit:0 rump.ifconfig gif1 destroy
566 atf_check -s exit:0 rump.ifconfig gif2 deletetunnel
567 atf_check -s exit:0 rump.ifconfig gif2 destroy
568 }
569
570 cleanup()
571 {
572 env RUMP_SERVER=$SOCK1 rump.halt
573 env RUMP_SERVER=$SOCK2 rump.halt
574 }
575
576 dump_bus()
577 {
578 /usr/bin/shmif_dumpbus -p - bus0 2>/dev/null| /usr/sbin/tcpdump -n -e -r -
579 /usr/bin/shmif_dumpbus -p - bus1 2>/dev/null| /usr/sbin/tcpdump -n -e -r -
580 }
581
582 test_ping_failure()
583 {
584 mode=$1
585
586 export RUMP_SERVER=$SOCK1
587 if [ ${mode} = "ipv6" ]; then
588 atf_check -s not-exit:0 -o ignore -e ignore \
589 rump.ping6 -n -X $TIMEOUT -c 1 -S $ROUTER1_LANIP6 \
590 $ROUTER2_LANIP6
591 else
592 atf_check -s not-exit:0 -o ignore -e ignore \
593 rump.ping -n -w $TIMEOUT -c 1 -I $ROUTER1_LANIP \
594 $ROUTER2_LANIP
595 fi
596
597 export RUMP_SERVER=$SOCK2
598 if [ ${mode} = "ipv6" ]; then
599 atf_check -s not-exit:0 -o ignore -e ignore \
600 rump.ping6 -n -X $TIMEOUT -c 1 -S $ROUTER2_LANIP6 \
601 $ROUTER1_LANIP6
602 else
603 atf_check -s not-exit:0 -o ignore -e ignore \
604 rump.ping -n -w $TIMEOUT -c 1 -I $ROUTER1_LANIP \
605 $ROUTER2_LANIP
606 fi
607 }
608
609 test_ping_success()
610 {
611 mode=$1
612
613 export RUMP_SERVER=$SOCK1
614 rump.ifconfig -v gif0
615 if [ ${mode} = "ipv6" ]; then
616 # XXX
617 # rump.ping6 rarely fails with the message that
618 # "failed to get receiving hop limit".
619 # This is a known issue being analyzed.
620 atf_check -s exit:0 -o ignore \
621 rump.ping6 -n -X $TIMEOUT -c 1 -S $ROUTER1_LANIP6 \
622 $ROUTER2_LANIP6
623 else
624 atf_check -s exit:0 -o ignore \
625 rump.ping -n -w $TIMEOUT -c 1 -I $ROUTER1_LANIP \
626 $ROUTER2_LANIP
627 fi
628 rump.ifconfig -v gif0
629
630 export RUMP_SERVER=$SOCK2
631 rump.ifconfig -v gif0
632 if [ ${mode} = "ipv6" ]; then
633 atf_check -s exit:0 -o ignore \
634 rump.ping6 -n -X $TIMEOUT -c 1 -S $ROUTER2_LANIP6 \
635 $ROUTER1_LANIP6
636 else
637 atf_check -s exit:0 -o ignore \
638 rump.ping -n -w $TIMEOUT -c 1 -I $ROUTER2_LANIP \
639 $ROUTER1_LANIP
640 fi
641 rump.ifconfig -v gif0
642 }
643
644 test_change_tunnel_duplicate()
645 {
646 mode=$1
647
648 newsrc=""
649 newdst=""
650 if [ ${mode} = "ipv6" ]; then
651 newsrc=$ROUTER1_WANIP6_DUMMY
652 newdst=$ROUTER2_WANIP6_DUMMY
653 else
654 newsrc=$ROUTER1_WANIP_DUMMY
655 newdst=$ROUTER2_WANIP_DUMMY
656 fi
657 export RUMP_SERVER=$SOCK1
658 rump.ifconfig -v gif0
659 rump.ifconfig -v gif1
660 atf_check -s exit:0 -e match:SIOCSLIFPHYADDR \
661 rump.ifconfig gif0 tunnel ${newsrc} ${newdst}
662 rump.ifconfig -v gif0
663 rump.ifconfig -v gif1
664
665 if [ ${mode} = "ipv6" ]; then
666 newsrc=$ROUTER2_WANIP6_DUMMY
667 newdst=$ROUTER1_WANIP6_DUMMY
668 else
669 newsrc=$ROUTER2_WANIP_DUMMY
670 newdst=$ROUTER1_WANIP_DUMMY
671 fi
672 export RUMP_SERVER=$SOCK2
673 rump.ifconfig -v gif0
674 rump.ifconfig -v gif1
675 atf_check -s exit:0 -e match:SIOCSLIFPHYADDR \
676 rump.ifconfig gif0 tunnel ${newsrc} ${newdst}
677 rump.ifconfig -v gif0
678 rump.ifconfig -v gif1
679 }
680
681 test_change_tunnel_success()
682 {
683 mode=$1
684
685 newsrc=""
686 newdst=""
687 if [ ${mode} = "ipv6" ]; then
688 newsrc=$ROUTER1_WANIP6_DUMMY
689 newdst=$ROUTER2_WANIP6_DUMMY
690 else
691 newsrc=$ROUTER1_WANIP_DUMMY
692 newdst=$ROUTER2_WANIP_DUMMY
693 fi
694 export RUMP_SERVER=$SOCK1
695 rump.ifconfig -v gif0
696 atf_check -s exit:0 \
697 rump.ifconfig gif0 tunnel ${newsrc} ${newdst}
698 rump.ifconfig -v gif0
699
700 if [ ${mode} = "ipv6" ]; then
701 newsrc=$ROUTER2_WANIP6_DUMMY
702 newdst=$ROUTER1_WANIP6_DUMMY
703 else
704 newsrc=$ROUTER2_WANIP_DUMMY
705 newdst=$ROUTER1_WANIP_DUMMY
706 fi
707 export RUMP_SERVER=$SOCK2
708 rump.ifconfig -v gif0
709 atf_check -s exit:0 \
710 rump.ifconfig gif0 tunnel ${newsrc} ${newdst}
711 rump.ifconfig -v gif0
712 }
713
714 basicv4overv4_body()
715 {
716 setup ipv4 ipv4
717 test_setup ipv4 ipv4
718
719 # Enable once PR kern/49219 is fixed
720 #test_ping_failure
721
722 setup_tunnel ipv4 ipv4
723 sleep 1
724 test_setup_tunnel ipv4
725 test_ping_success ipv4
726
727 teardown_tunnel
728 test_ping_failure ipv4
729 }
730
731 basicv4overv6_body()
732 {
733 setup ipv4 ipv6
734 test_setup ipv4 ipv6
735
736 # Enable once PR kern/49219 is fixed
737 #test_ping_failure
738
739 setup_tunnel ipv4 ipv6
740 sleep 1
741 test_setup_tunnel ipv4
742 test_ping_success ipv4
743
744 teardown_tunnel
745 test_ping_failure ipv4
746 }
747
748 basicv6overv4_body()
749 {
750 setup ipv6 ipv4
751 test_setup ipv6 ipv4
752
753 # Enable once PR kern/49219 is fixed
754 #test_ping_failure
755
756 setup_tunnel ipv6 ipv4
757 sleep 1
758 test_setup_tunnel ipv6
759 test_ping_success ipv6
760
761 teardown_tunnel
762 test_ping_failure ipv6
763 }
764
765 basicv6overv6_body()
766 {
767 setup ipv6 ipv6
768 test_setup ipv6 ipv6
769
770 # Enable once PR kern/49219 is fixed
771 #test_ping_failure
772
773 setup_tunnel ipv6 ipv6
774 sleep 1
775 test_setup_tunnel ipv6
776 test_ping_success ipv6
777
778 teardown_tunnel
779 test_ping_failure ipv6
780 }
781
782 basicv4overv4_cleanup()
783 {
784 dump_bus
785 cleanup
786 }
787
788 basicv4overv6_cleanup()
789 {
790 dump_bus
791 cleanup
792 }
793
794 basicv6overv4_cleanup()
795 {
796 dump_bus
797 cleanup
798 }
799
800 basicv6overv6_cleanup()
801 {
802 dump_bus
803 cleanup
804 }
805
806 ioctlv4overv4_body()
807 {
808 setup ipv4 ipv4
809 test_setup ipv4 ipv4
810
811 # Enable once PR kern/49219 is fixed
812 #test_ping_failure
813
814 setup_tunnel ipv4 ipv4
815 setup_dummy_tunnel ipv4 ipv4
816 sleep 1
817 test_setup_tunnel ipv4
818 test_setup_dummy_tunnel
819 test_ping_success ipv4
820
821 test_change_tunnel_duplicate ipv4
822
823 teardown_dummy_tunnel
824 test_change_tunnel_success ipv4
825
826 teardown_tunnel
827 test_ping_failure ipv4
828 }
829
830 ioctlv4overv6_body()
831 {
832 setup ipv4 ipv6
833 test_setup ipv4 ipv6
834
835 # Enable once PR kern/49219 is fixed
836 #test_ping_failure
837
838 setup_tunnel ipv4 ipv6
839 setup_dummy_tunnel ipv4 ipv6
840 sleep 1
841 test_setup_tunnel ipv4
842 test_setup_dummy_tunnel
843 test_ping_success ipv4
844
845 test_change_tunnel_duplicate ipv6
846
847 teardown_dummy_tunnel
848 test_change_tunnel_success ipv6
849
850 teardown_tunnel
851 test_ping_failure ipv4
852 }
853
854 ioctlv6overv4_body()
855 {
856 setup ipv6 ipv4
857 test_setup ipv6 ipv4
858
859 # Enable once PR kern/49219 is fixed
860 #test_ping_failure
861
862 setup_tunnel ipv6 ipv4
863 setup_dummy_tunnel ipv6 ipv4
864 sleep 1
865 test_setup_tunnel ipv6
866 test_setup_dummy_tunnel
867 test_ping_success ipv6
868
869 test_change_tunnel_duplicate ipv4
870
871 teardown_dummy_tunnel
872 test_change_tunnel_success ipv4
873
874 teardown_tunnel
875 test_ping_failure ipv6
876 }
877
878 ioctlv6overv6_body()
879 {
880 setup ipv6 ipv6
881 test_setup ipv6 ipv6
882
883 # Enable once PR kern/49219 is fixed
884 #test_ping_failure
885
886 setup_tunnel ipv6 ipv6
887 setup_dummy_tunnel ipv6 ipv6
888 sleep 1
889 test_setup_tunnel ipv6
890 test_setup_dummy_tunnel
891 test_ping_success ipv6
892
893 test_change_tunnel_duplicate ipv6
894
895 teardown_dummy_tunnel
896 test_change_tunnel_success ipv6
897
898 teardown_tunnel
899 test_ping_failure ipv6
900 }
901
902 ioctlv4overv4_cleanup()
903 {
904 dump_bus
905 cleanup
906 }
907
908 ioctlv4overv6_cleanup()
909 {
910 dump_bus
911 cleanup
912 }
913
914 ioctlv6overv4_cleanup()
915 {
916 dump_bus
917 cleanup
918 }
919
920 ioctlv6overv6_cleanup()
921 {
922 dump_bus
923 cleanup
924 }
925
926 recursivev4overv4_body()
927 {
928 setup ipv4 ipv4
929 test_setup ipv4 ipv4
930
931 # Enable once PR kern/49219 is fixed
932 #test_ping_failure
933
934 setup_tunnel ipv4 ipv4
935 setup_recursive_tunnels ipv4
936 sleep 1
937
938 test_recursive_check ipv4
939
940 teardown_recursive_tunnels
941 teardown_tunnel
942 }
943
944 recursivev4overv6_body()
945 {
946 setup ipv4 ipv6
947 test_setup ipv4 ipv6
948
949 # Enable once PR kern/49219 is fixed
950 #test_ping_failure
951
952 setup_tunnel ipv4 ipv6
953 setup_recursive_tunnels ipv4
954 sleep 1
955
956 test_recursive_check ipv4
957
958 teardown_recursive_tunnels
959 teardown_tunnel
960 }
961
962 recursivev6overv4_body()
963 {
964 setup ipv6 ipv4
965 test_setup ipv6 ipv4
966
967 # Enable once PR kern/49219 is fixed
968 #test_ping_failure
969
970 setup_tunnel ipv6 ipv4
971 setup_recursive_tunnels ipv6
972 sleep 1
973
974 test_recursive_check ipv6
975
976 teardown_recursive_tunnels
977 teardown_tunnel
978 }
979
980 recursivev6overv6_body()
981 {
982 setup ipv6 ipv6
983 test_setup ipv6 ipv6
984
985 # Enable once PR kern/49219 is fixed
986 #test_ping_failure
987
988 setup_tunnel ipv6 ipv6
989 setup_recursive_tunnels ipv6
990 sleep 1
991
992 test_recursive_check ipv6
993
994 teardown_recursive_tunnels
995 teardown_tunnel
996 test_ping_failure ipv6
997 }
998
999 recursivev4overv4_cleanup()
1000 {
1001 dump_bus
1002 cleanup
1003 }
1004
1005 recursivev4overv6_cleanup()
1006 {
1007 dump_bus
1008 cleanup
1009 }
1010
1011 recursivev6overv4_cleanup()
1012 {
1013 dump_bus
1014 cleanup
1015 }
1016
1017 recursivev6overv6_cleanup()
1018 {
1019 dump_bus
1020 cleanup
1021 }
1022
1023 atf_init_test_cases()
1024 {
1025 atf_add_test_case basicv4overv4
1026 atf_add_test_case basicv4overv6
1027 atf_add_test_case basicv6overv4
1028 atf_add_test_case basicv6overv6
1029
1030 atf_add_test_case ioctlv4overv4
1031 atf_add_test_case ioctlv4overv6
1032 atf_add_test_case ioctlv6overv4
1033 atf_add_test_case ioctlv6overv6
1034
1035 atf_add_test_case recursivev4overv4
1036 atf_add_test_case recursivev4overv6
1037 atf_add_test_case recursivev6overv4
1038 atf_add_test_case recursivev6overv6
1039 }
1040