1 # $NetBSD: t_ipv6address.sh,v 1.12 2016/12/14 02:50:42 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 SERVER="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet"
28 SERVER="${SERVER} -lrumpnet_shmif -lrumpdev"
29 SERVER6="${SERVER} -lrumpnet_netinet6"
31 SOCKSRC=unix://commsock1
32 SOCKFWD=unix://commsock2
33 SOCKDST=unix://commsock3
47 atf_test_case linklocal cleanup
48 atf_test_case linklocal_ops cleanup
52 atf_check -s exit:0 ${SERVER6} ${SOCKSRC}
53 atf_check -s exit:0 ${SERVER6} ${SOCKFWD}
54 atf_check -s exit:0 ${SERVER6} ${SOCKDST}
56 export RUMP_SERVER=${SOCKSRC}
57 atf_check -s exit:0 rump.ifconfig shmif0 create
58 atf_check -s exit:0 rump.ifconfig shmif1 create
61 export RUMP_SERVER=${SOCKDST}
62 atf_check -s exit:0 rump.ifconfig shmif0 create
63 atf_check -s exit:0 rump.ifconfig shmif1 create
66 export RUMP_SERVER=${SOCKFWD}
67 atf_check -s exit:0 rump.ifconfig shmif0 create
68 atf_check -s exit:0 rump.ifconfig shmif1 create
69 atf_check -s exit:0 -o match:"0 -> 1" rump.sysctl \
70 -w net.inet6.ip6.forwarding=1
75 export RUMP_SERVER=${SOCKSRC}
76 $DEBUG && rump.ifconfig
77 $DEBUG && rump.netstat -rn -f inet6
80 export RUMP_SERVER=${SOCKDST}
81 $DEBUG && rump.ifconfig
82 $DEBUG && rump.netstat -rn -f inet6
85 export RUMP_SERVER=${SOCKFWD}
86 $DEBUG && rump.ifconfig
87 $DEBUG && rump.netstat -rn -f inet6
92 export RUMP_SERVER=${SOCKSRC}
93 atf_check -s exit:0 rump.ifconfig shmif0 linkstr ${BUS1}
94 atf_check -s exit:0 rump.ifconfig shmif0 up
95 atf_check -s exit:0 rump.ifconfig shmif1 linkstr ${BUSSRC}
96 atf_check -s exit:0 rump.ifconfig shmif1 up
97 atf_check -s exit:0 -o ignore rump.ifconfig -w 10
100 export RUMP_SERVER=${SOCKDST}
101 atf_check -s exit:0 rump.ifconfig shmif0 linkstr ${BUS2}
102 atf_check -s exit:0 rump.ifconfig shmif0 up
103 atf_check -s exit:0 rump.ifconfig shmif1 linkstr ${BUSDST}
104 atf_check -s exit:0 rump.ifconfig shmif1 up
105 atf_check -s exit:0 -o ignore rump.ifconfig -w 10
108 export RUMP_SERVER=${SOCKFWD}
109 atf_check -s exit:0 rump.ifconfig shmif0 linkstr ${BUS1}
110 atf_check -s exit:0 rump.ifconfig shmif0 up
112 atf_check -s exit:0 rump.ifconfig shmif1 linkstr ${BUS2}
113 atf_check -s exit:0 rump.ifconfig shmif1 up
114 atf_check -s exit:0 -o ignore rump.ifconfig -w 10
120 local tmp_rump_server=$RUMP_SERVER
122 local src_if0_lladdr=`get_linklocal_addr ${SOCKSRC} shmif0`
123 local dst_if0_lladdr=`get_linklocal_addr ${SOCKDST} shmif0`
124 local fwd_if0_lladdr=`get_linklocal_addr ${SOCKFWD} shmif0`
125 local fwd_if1_lladdr=`get_linklocal_addr ${SOCKFWD} shmif1`
127 export RUMP_SERVER=${SOCKSRC}
128 atf_check -s ignore -o ignore -e ignore \
129 rump.route delete -inet6 default ${fwd_if0_lladdr}%shmif0
130 atf_check -s exit:0 -o match:"add net default:" \
131 rump.route add -inet6 default ${fwd_if0_lladdr}%shmif0
132 atf_check -s exit:0 rump.ifconfig shmif1 inet6 ${IP6SRC}
133 atf_check -s exit:0 -o ignore rump.ifconfig -w 10
134 $DEBUG && rump.netstat -rn -f inet6
137 export RUMP_SERVER=${SOCKDST}
138 atf_check -s ignore -o ignore -e ignore \
139 rump.route delete -inet6 default ${fwd_if1_lladdr}%shmif0
140 atf_check -s exit:0 -o match:"add net default:" \
141 rump.route add -inet6 default ${fwd_if1_lladdr}%shmif0
142 atf_check -s exit:0 rump.ifconfig shmif1 inet6 ${IP6DST}
143 atf_check -s exit:0 -o ignore rump.ifconfig -w 10
144 $DEBUG && rump.netstat -rn -f inet6
147 export RUMP_SERVER=${SOCKFWD}
148 atf_check -s ignore -o ignore -e ignore \
149 rump.route delete -inet6 ${IP6SRCNW} ${src_if0_lladdr}%shmif0
150 atf_check -s exit:0 -o match:"add net" \
151 rump.route add -inet6 ${IP6SRCNW} ${src_if0_lladdr}%shmif0
153 atf_check -s ignore -o ignore -e ignore \
154 rump.route delete -inet6 ${IP6DSTNW} ${dst_if0_lladdr}%shmif1
155 atf_check -s exit:0 -o match:"add net" \
156 rump.route add -inet6 ${IP6DSTNW} ${dst_if0_lladdr}%shmif1
157 atf_check -s exit:0 -o ignore rump.ifconfig -w 10
158 $DEBUG && rump.netstat -rn -f inet6
161 export RUMP_SERVER=$tmp_rump_server
166 local tmp_rump_server=$RUMP_SERVER
170 export RUMP_SERVER=${SOCKSRC}
171 atf_check -s exit:0 rump.ifconfig shmif0 down
172 atf_check -s exit:0 rump.ifconfig shmif0 -linkstr
173 atf_check -s exit:0 rump.ifconfig shmif1 down
174 atf_check -s exit:0 rump.ifconfig shmif1 -linkstr
177 export RUMP_SERVER=${SOCKDST}
178 atf_check -s exit:0 rump.ifconfig shmif0 down
179 atf_check -s exit:0 rump.ifconfig shmif0 -linkstr
180 atf_check -s exit:0 rump.ifconfig shmif1 down
181 atf_check -s exit:0 rump.ifconfig shmif1 -linkstr
184 export RUMP_SERVER=${SOCKFWD}
185 atf_check -s exit:0 rump.ifconfig shmif0 down
186 atf_check -s exit:0 rump.ifconfig shmif0 -linkstr
187 atf_check -s exit:0 rump.ifconfig shmif1 down
188 atf_check -s exit:0 rump.ifconfig shmif1 -linkstr
191 atf_check -s exit:0 rm ${BUSSRC}
192 atf_check -s exit:0 rm ${BUSDST}
193 atf_check -s exit:0 rm ${BUS1}
194 atf_check -s exit:0 rm ${BUS2}
198 export RUMP_SERVER=$tmp_rump_server
201 cleanup_rump_servers()
204 env RUMP_SERVER=${SOCKSRC} rump.halt
205 env RUMP_SERVER=${SOCKDST} rump.halt
206 env RUMP_SERVER=${SOCKFWD} rump.halt
212 shmif_dumpbus -p - ${BUSSRC} 2>/dev/null| tcpdump -n -e -r -
213 shmif_dumpbus -p - ${BUSDST} 2>/dev/null| tcpdump -n -e -r -
214 shmif_dumpbus -p - ${BUS1} 2>/dev/null| tcpdump -n -e -r -
215 shmif_dumpbus -p - ${BUS2} 2>/dev/null| tcpdump -n -e -r -
221 export RUMP_SERVER=${SOCKSRC}
223 rump.netstat -nr -f inet6
224 export RUMP_SERVER=${SOCKDST}
226 rump.netstat -nr -f inet6
227 export RUMP_SERVER=${SOCKFWD}
229 rump.netstat -nr -f inet6
236 "Test for bassically function of the IPv6 linklocal address"
237 atf_set "require.progs" \
238 "rump_server rump.route rump.ifconfig rump.ping6"
245 local src_if0_lladdr=`get_linklocal_addr ${SOCKSRC} shmif0`
246 local src_if1_lladdr=`get_linklocal_addr ${SOCKSRC} shmif1`
247 local dst_if0_lladdr=`get_linklocal_addr ${SOCKDST} shmif0`
248 local fwd_if0_lladdr=`get_linklocal_addr ${SOCKFWD} shmif0`
249 local fwd_if1_lladdr=`get_linklocal_addr ${SOCKFWD} shmif1`
251 export RUMP_SERVER=${SOCKSRC}
252 $DEBUG && rump.ifconfig
253 $DEBUG && rump.netstat -rn -f inet6
255 # link local address to link local address
257 atf_check -s not-exit:0 -e match:"No route to host" \
258 rump.ping6 -c 1 -X $TIMEOUT -n ${fwd_if0_lladdr}
260 atf_check -s exit:0 -o match:"0.0% packet loss" \
261 rump.ping6 -c 1 -X $TIMEOUT -n ${fwd_if0_lladdr}%shmif0
263 atf_check -s ignore -o empty -e ignore \
264 -x "shmif_dumpbus -p - ${BUSSRC} | tcpdump -r - -n -p icmp6"
265 atf_check -s ignore -o not-empty -e ignore \
266 -x "shmif_dumpbus -p - ${BUS1} | tcpdump -r - -n -p icmp6"
270 atf_check -s not-exit:0 -o ignore -e ignore \
271 rump.ping6 -c 1 -X $TIMEOUT -n -S ${src_if1_lladdr}%shmif1 \
272 ${fwd_if0_lladdr}%shmif0
273 atf_check -s ignore -o not-match:"${src_if1_lladdr}" -e ignore \
274 -x "shmif_dumpbus -p - ${BUS1} | tcpdump -r - -n -p icmp6"
275 $DEBUG && shmif_dumpbus -p - ${BUS1} | tcpdump -r - -n -p icmp6
278 # link local address to host address
279 export RUMP_SERVER=${SOCKFWD}
280 atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${IP6FWD0}
281 atf_check -s exit:0 -o ignore rump.ifconfig -w 10
284 export RUMP_SERVER=${SOCKSRC}
285 atf_check -s exit:0 -o match:"add net default:" \
286 rump.route add -inet6 default ${fwd_if0_lladdr}%shmif0
287 atf_check -s exit:0 -o ignore rump.ifconfig -w 10
289 $DEBUG && rump.ifconfig shmif0
292 export RUMP_SERVER=${SOCKSRC}
293 atf_check -s exit:0 -o match:"0.0% packet loss" \
294 rump.ping6 -c 1 -X $TIMEOUT -n -S ${src_if0_lladdr}%shmif0 ${IP6FWD0}
297 export RUMP_SERVER=${SOCKFWD}
298 # host address to link local address
299 atf_check -s exit:0 -o match:"0.0% packet loss" \
300 rump.ping6 -c 1 -X $TIMEOUT -n ${src_if0_lladdr}%shmif0
301 atf_check -s not-exit:0 -o match:"100.0% packet loss" \
302 rump.ping6 -c 1 -X $TIMEOUT -n ${src_if1_lladdr}%shmif0
304 atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${IP6FWD0} delete
308 # forwarding with link local address
311 export RUMP_SERVER=${SOCKSRC}
312 atf_check -s exit:0 -o match:"0.0% packet loss" rump.ping6 -c 1 \
313 -X $TIMEOUT -n -S ${IP6SRC} ${IP6DST}
316 $DEBUG && rump.ifconfig shmif0
317 atf_check -s not-exit:0 -o match:"100.0% packet loss" rump.ping6 -c 1 \
318 -X $TIMEOUT -n -S ${src_if0_lladdr}%shmif0 ${IP6DST}
319 atf_check -s ignore -o not-match:"${src_if0_lladdr}" -e ignore \
320 -x "shmif_dumpbus -p - ${BUS2} | tcpdump -r - -n -p icmp6"
323 atf_check -s not-exit:0 -o match:"100.0% packet loss" rump.ping6 -c 1 \
324 -X $TIMEOUT -n -S ${IP6SRC} ${dst_if0_lladdr}%shmif0
325 atf_check -s ignore -o not-empty -e ignore \
326 -x "shmif_dumpbus -p - ${BUS2} | tcpdump -r - -n -p icmp6"
344 "Test for various operations to IPv6 linklocal addresses"
345 atf_set "require.progs" "rump_server rump.route rump.ndp"
350 local src_if0_lladdr=
354 src_if0_lladdr=`get_linklocal_addr ${SOCKSRC} shmif0`
356 export RUMP_SERVER=${SOCKSRC}
359 atf_check -s exit:0 -o match:"${src_if0_lladdr}" \
360 rump.route get -inet6 ${src_if0_lladdr}%shmif0
362 # route get without an interface name (zone index)
363 atf_check -s not-exit:0 -e match:"not in table" \
364 rump.route get -inet6 ${src_if0_lladdr}
367 atf_check -s exit:0 -o match:"${src_if0_lladdr}" \
368 rump.ndp -n ${src_if0_lladdr}%shmif0
370 # ndp without an interface name (zone index)
371 atf_check -s not-exit:0 -o ignore -e match:"no entry" \
372 rump.ndp -n ${src_if0_lladdr}
376 linklocal_ops_cleanup()
382 atf_init_test_cases()
385 atf_add_test_case linklocal
386 atf_add_test_case linklocal_ops