1 # $NetBSD: t_icmp6_redirect.sh,v 1.1 2015/09/14 05:22:56 ozaki-r Exp $
3 # Copyright (c) 2015 Internet Initiative Japan Inc.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
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.
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.
27 netserver
="rump_server -lrumpnet -lrumpnet_net -lrumpnet_shmif"
28 netserver
="${netserver} -lrumpnet_netinet -lrumpnet_netinet6"
30 SOCK_LOCAL
=unix
://commsock1
31 SOCK_PEER
=unix
://commsock2
32 SOCK_GW1
=unix
://commsock3
33 SOCK_GW2
=unix
://commsock4
39 IP6IF0_LOCAL
=fc00
:1::2
52 export RUMP_SERVER
=${1}
53 rump.ifconfig
${2} inet6 |
awk "/fe80/ {sub(/%$2/, \"\"); print \$2;}"
59 atf_test_case basic cleanup
64 atf_set
"descr" "Test for the basically function of the ICMP6 redirect"
65 atf_set
"require.progs" "rump_server rump.route rump.ping rump.ifconfig"
74 atf_check
-s exit:0 ${netserver} ${SOCK_LOCAL}
75 atf_check
-s exit:0 ${netserver} ${SOCK_PEER}
76 atf_check
-s exit:0 ${netserver} ${SOCK_GW1}
77 atf_check
-s exit:0 ${netserver} ${SOCK_GW2}
82 # Setup gateway #1 (real gateway)
83 export RUMP_SERVER
=${SOCK_GW1}
84 atf_check
-s exit:0 rump.ifconfig shmif0 create
85 atf_check
-s exit:0 rump.ifconfig shmif0 linkstr
${BUS1}
86 atf_check
-s exit:0 rump.ifconfig shmif0 inet6
${IP6IF0_GW1}
87 atf_check
-s exit:0 rump.ifconfig shmif0 up
89 atf_check
-s exit:0 rump.ifconfig shmif1 create
90 atf_check
-s exit:0 rump.ifconfig shmif1 linkstr
${BUS2}
91 atf_check
-s exit:0 rump.ifconfig shmif1 inet6
${IP6IF1_GW1}
92 atf_check
-s exit:0 rump.ifconfig shmif1 up
94 atf_check
-s exit:0 -o match
:'0.->.1' rump.sysctl
-w \
95 net.inet6.ip6.forwarding
=1
98 gw1_lladdr0
=`get_lladdr ${SOCK_GW1} shmif0`
99 gw1_lladdr1
=`get_lladdr ${SOCK_GW1} shmif1`
101 # Setup a peer behind gateway #1
102 export RUMP_SERVER
=${SOCK_PEER}
103 atf_check
-s exit:0 rump.ifconfig shmif0 create
104 atf_check
-s exit:0 rump.ifconfig shmif0 linkstr
${BUS2}
105 atf_check
-s exit:0 rump.ifconfig shmif0 inet6
${IP6IF0_PEER}
106 atf_check
-s exit:0 rump.ifconfig shmif0 up
107 atf_check
-s exit:0 -o ignore rump.route add \
108 -inet6 default
${gw1_lladdr1}%shmif0
111 # Setup gateway #2 (fake gateway)
112 export RUMP_SERVER
=${SOCK_GW2}
113 atf_check
-s exit:0 rump.ifconfig shmif0 create
114 atf_check
-s exit:0 rump.ifconfig shmif0 linkstr
${BUS1}
115 atf_check
-s exit:0 rump.ifconfig shmif0 inet6
${IP6IF0_GW2}
116 atf_check
-s exit:0 rump.ifconfig shmif0 up
118 atf_check
-s exit:0 -o ignore rump.route add \
119 -inet6 ${IP6BUS2} ${gw1_lladdr0}%shmif0
120 atf_check
-s exit:0 -o match
:'0.->.1' rump.sysctl
-w \
121 net.inet6.ip6.forwarding
=1
124 gw2_lladdr0
=`get_lladdr ${SOCK_GW2} shmif0`
126 export RUMP_SERVER
=${SOCK_LOCAL}
127 atf_check
-s exit:0 rump.ifconfig shmif0 create
128 atf_check
-s exit:0 rump.ifconfig shmif0 linkstr
${BUS1}
129 atf_check
-s exit:0 rump.ifconfig shmif0 inet6
${IP6IF0_LOCAL}
130 atf_check
-s exit:0 rump.ifconfig shmif0 up
132 # Teach the fake gateway as the default gateway
133 atf_check
-s exit:0 -o ignore rump.route add \
134 -inet6 default
${gw2_lladdr0}%shmif0
135 $DEBUG && rump.route get
-inet6 ${IP6IF0_PEER}
137 atf_check
-s exit:0 -o ignore rump.sysctl
-w \
138 net.inet6.icmp6.redirtimeout
=$REDIRECT_TIMEOUT
143 atf_check
-s exit:0 -o ignore rump.ping6
-c 1 -n ${IP6IF0_PEER}
144 $DEBUG && rump.route show
-inet6
145 # Check if a created route is correctly redirected to gateway #1
146 atf_check
-s exit:0 -o match
:"gateway: ${gw1_lladdr0}" rump.route get \
147 -inet6 ${IP6IF0_PEER}
149 atf_check
-s exit:0 sleep $
((REDIRECT_TIMEOUT
+ 2))
150 $DEBUG && rump.route show
-inet6
151 # Check if the created route is expired
152 atf_check
-s exit:0 -o not-match
:"gateway: ${gw1_lladdr0}" rump.route get \
153 -inet6 ${IP6IF0_PEER}
161 env RUMP_SERVER
=$SOCK_LOCAL rump.halt
162 env RUMP_SERVER
=$SOCK_PEER rump.halt
163 env RUMP_SERVER
=$SOCK_GW1 rump.halt
164 env RUMP_SERVER
=$SOCK_GW2 rump.halt
167 atf_init_test_cases
()
170 atf_add_test_case basic