1 # $NetBSD: t_ipv6address.sh,v 1.7 2016/08/10 21:33:52 kre 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 -lrumpnet_shmif -lrumpdev"
28 SERVER6="$SERVER -lrumpnet_netinet6"
30 SOCKSRC=unix://commsock1
31 SOCKFWD=unix://commsock2
32 SOCKDST=unix://commsock3
46 atf_test_case linklocal cleanup
47 atf_test_case linklocal_ops cleanup
51 atf_check -s exit:0 ${SERVER6} ${SOCKSRC}
52 atf_check -s exit:0 ${SERVER6} ${SOCKFWD}
53 atf_check -s exit:0 ${SERVER6} ${SOCKDST}
55 export RUMP_SERVER=${SOCKSRC}
56 atf_check -s exit:0 rump.ifconfig shmif0 create
57 atf_check -s exit:0 rump.ifconfig shmif1 create
60 export RUMP_SERVER=${SOCKDST}
61 atf_check -s exit:0 rump.ifconfig shmif0 create
62 atf_check -s exit:0 rump.ifconfig shmif1 create
65 export RUMP_SERVER=${SOCKFWD}
66 atf_check -s exit:0 rump.ifconfig shmif0 create
67 atf_check -s exit:0 rump.ifconfig shmif1 create
68 atf_check -s exit:0 -o match:"0 -> 1" rump.sysctl \
69 -w net.inet6.ip6.forwarding=1
74 export RUMP_SERVER=${SOCKSRC}
75 $DEBUG && rump.ifconfig
76 $DEBUG && rump.netstat -rn -f inet6
79 export RUMP_SERVER=${SOCKDST}
80 $DEBUG && rump.ifconfig
81 $DEBUG && rump.netstat -rn -f inet6
84 export RUMP_SERVER=${SOCKFWD}
85 $DEBUG && rump.ifconfig
86 $DEBUG && rump.netstat -rn -f inet6
91 export RUMP_SERVER=${SOCKSRC}
92 atf_check -s exit:0 rump.ifconfig shmif0 linkstr ${BUS1}
93 atf_check -s exit:0 rump.ifconfig shmif0 up
94 atf_check -s exit:0 rump.ifconfig shmif1 linkstr ${BUSSRC}
95 atf_check -s exit:0 rump.ifconfig shmif1 up
96 atf_check -s exit:0 -o ignore rump.ifconfig -w 10
99 export RUMP_SERVER=${SOCKDST}
100 atf_check -s exit:0 rump.ifconfig shmif0 linkstr ${BUS2}
101 atf_check -s exit:0 rump.ifconfig shmif0 up
102 atf_check -s exit:0 rump.ifconfig shmif1 linkstr ${BUSDST}
103 atf_check -s exit:0 rump.ifconfig shmif1 up
104 atf_check -s exit:0 -o ignore rump.ifconfig -w 10
107 export RUMP_SERVER=${SOCKFWD}
108 atf_check -s exit:0 rump.ifconfig shmif0 linkstr ${BUS1}
109 atf_check -s exit:0 rump.ifconfig shmif0 up
111 atf_check -s exit:0 rump.ifconfig shmif1 linkstr ${BUS2}
112 atf_check -s exit:0 rump.ifconfig shmif1 up
113 atf_check -s exit:0 -o ignore rump.ifconfig -w 10
119 local tmp_rump_server=$RUMP_SERVER
121 local src_if0_lladdr=`get_lladdr ${SOCKSRC} shmif0`
122 local dst_if0_lladdr=`get_lladdr ${SOCKDST} shmif0`
123 local fwd_if0_lladdr=`get_lladdr ${SOCKFWD} shmif0`
124 local fwd_if1_lladdr=`get_lladdr ${SOCKFWD} shmif1`
126 export RUMP_SERVER=${SOCKSRC}
127 atf_check -s ignore -o ignore -e ignore rump.route delete -inet6 default \
128 ${fwd_if0_lladdr}%shmif0
129 atf_check -s exit:0 -o match:"add net default:" rump.route add -inet6 default \
130 ${fwd_if0_lladdr}%shmif0
131 atf_check -s exit:0 rump.ifconfig shmif1 inet6 ${IP6SRC}
132 atf_check -s exit:0 -o ignore rump.ifconfig -w 10
133 $DEBUG && rump.netstat -rn -f inet6
136 export RUMP_SERVER=${SOCKDST}
137 atf_check -s ignore -o ignore -e ignore rump.route delete -inet6 default \
138 ${fwd_if1_lladdr}%shmif0
139 atf_check -s exit:0 -o match:"add net default:" rump.route add -inet6 default \
140 ${fwd_if1_lladdr}%shmif0
141 atf_check -s exit:0 rump.ifconfig shmif1 inet6 ${IP6DST}
142 atf_check -s exit:0 -o ignore rump.ifconfig -w 10
143 $DEBUG && rump.netstat -rn -f inet6
146 export RUMP_SERVER=${SOCKFWD}
147 atf_check -s ignore -o ignore -e ignore rump.route delete -inet6 ${IP6SRCNW} \
148 ${src_if0_lladdr}%shmif0
149 atf_check -s exit:0 -o match:"add net" rump.route add -inet6 ${IP6SRCNW} \
150 ${src_if0_lladdr}%shmif0
152 atf_check -s ignore -o ignore -e ignore rump.route delete -inet6 ${IP6DSTNW} \
153 ${dst_if0_lladdr}%shmif1
154 atf_check -s exit:0 -o match:"add net" rump.route add -inet6 ${IP6DSTNW} \
155 ${dst_if0_lladdr}%shmif1
156 atf_check -s exit:0 -o ignore rump.ifconfig -w 10
157 $DEBUG && rump.netstat -rn -f inet6
160 export RUMP_SERVER=$tmp_rump_server
165 local tmp_rump_server=$RUMP_SERVER
169 export RUMP_SERVER=${SOCKSRC}
170 atf_check -s exit:0 rump.ifconfig shmif0 down
171 atf_check -s exit:0 rump.ifconfig shmif0 -linkstr
172 atf_check -s exit:0 rump.ifconfig shmif1 down
173 atf_check -s exit:0 rump.ifconfig shmif1 -linkstr
176 export RUMP_SERVER=${SOCKDST}
177 atf_check -s exit:0 rump.ifconfig shmif0 down
178 atf_check -s exit:0 rump.ifconfig shmif0 -linkstr
179 atf_check -s exit:0 rump.ifconfig shmif1 down
180 atf_check -s exit:0 rump.ifconfig shmif1 -linkstr
183 export RUMP_SERVER=${SOCKFWD}
184 atf_check -s exit:0 rump.ifconfig shmif0 down
185 atf_check -s exit:0 rump.ifconfig shmif0 -linkstr
186 atf_check -s exit:0 rump.ifconfig shmif1 down
187 atf_check -s exit:0 rump.ifconfig shmif1 -linkstr
190 atf_check -s exit:0 rm ${BUSSRC}
191 atf_check -s exit:0 rm ${BUSDST}
192 atf_check -s exit:0 rm ${BUS1}
193 atf_check -s exit:0 rm ${BUS2}
197 export RUMP_SERVER=$tmp_rump_server
203 export RUMP_SERVER=${1}
204 rump.ifconfig ${2} inet6 | grep "fe80" \
205 | awk '{print $2}' | sed -e "s/%$2//g"
211 cleanup_rump_servers()
214 env RUMP_SERVER=${SOCKSRC} rump.halt
215 env RUMP_SERVER=${SOCKDST} rump.halt
216 env RUMP_SERVER=${SOCKFWD} rump.halt
222 shmif_dumpbus -p - ${BUSSRC} 2>/dev/null| tcpdump -n -e -r -
223 shmif_dumpbus -p - ${BUSDST} 2>/dev/null| tcpdump -n -e -r -
224 shmif_dumpbus -p - ${BUS1} 2>/dev/null| tcpdump -n -e -r -
225 shmif_dumpbus -p - ${BUS2} 2>/dev/null| tcpdump -n -e -r -
231 export RUMP_SERVER=${SOCKSRC}
233 rump.netstat -nr -f inet6
234 export RUMP_SERVER=${SOCKDST}
236 rump.netstat -nr -f inet6
237 export RUMP_SERVER=${SOCKFWD}
239 rump.netstat -nr -f inet6
245 atf_set "descr" "Test for bassically function of the IPv6 linklocal address"
246 atf_set "require.progs" "rump_server rump.route rump.ifconfig rump.ping6"
253 local src_if0_lladdr=`get_lladdr ${SOCKSRC} shmif0`
254 local src_if1_lladdr=`get_lladdr ${SOCKSRC} shmif1`
255 local dst_if0_lladdr=`get_lladdr ${SOCKDST} shmif0`
256 local fwd_if0_lladdr=`get_lladdr ${SOCKFWD} shmif0`
257 local fwd_if1_lladdr=`get_lladdr ${SOCKFWD} shmif1`
259 export RUMP_SERVER=${SOCKSRC}
260 $DEBUG && rump.ifconfig
261 $DEBUG && rump.netstat -rn -f inet6
263 # link local address to link local address
265 atf_check -s not-exit:0 -e match:"No route to host" \
266 rump.ping6 -c 1 -X $TIMEOUT -n ${fwd_if0_lladdr}
268 atf_check -s exit:0 -o match:"0.0% packet loss" \
269 rump.ping6 -c 1 -X $TIMEOUT -n ${fwd_if0_lladdr}%shmif0
271 atf_check -s ignore -o empty -e ignore \
272 -x "shmif_dumpbus -p - ${BUSSRC} | tcpdump -r - -n -p icmp6"
273 atf_check -s ignore -o not-empty -e ignore \
274 -x "shmif_dumpbus -p - ${BUS1} | tcpdump -r - -n -p icmp6"
278 atf_check -s not-exit:0 -o ignore -e ignore \
279 rump.ping6 -c 1 -X $TIMEOUT -n -S ${src_if1_lladdr}%shmif1 \
280 ${fwd_if0_lladdr}%shmif0
281 atf_check -s ignore -o not-match:"${src_if1_lladdr}" -e ignore \
282 -x "shmif_dumpbus -p - ${BUS1} | tcpdump -r - -n -p icmp6"
283 $DEBUG && shmif_dumpbus -p - ${BUS1} | tcpdump -r - -n -p icmp6
286 # link local address to host address
287 export RUMP_SERVER=${SOCKFWD}
288 atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${IP6FWD0}
289 atf_check -s exit:0 -o ignore rump.ifconfig -w 10
292 export RUMP_SERVER=${SOCKSRC}
293 atf_check -s exit:0 -o match:"add net default:" rump.route add -inet6 default \
294 ${fwd_if0_lladdr}%shmif0
295 atf_check -s exit:0 -o ignore rump.ifconfig -w 10
297 $DEBUG && rump.ifconfig shmif0
300 export RUMP_SERVER=${SOCKSRC}
301 atf_check -s exit:0 -o match:"0.0% packet loss" \
302 rump.ping6 -c 1 -X $TIMEOUT -n -S ${src_if0_lladdr}%shmif0 ${IP6FWD0}
305 export RUMP_SERVER=${SOCKFWD}
306 # host address to link local address
307 atf_check -s exit:0 -o match:"0.0% packet loss" \
308 rump.ping6 -c 1 -X $TIMEOUT -n ${src_if0_lladdr}%shmif0
309 atf_check -s not-exit:0 -o match:"100.0% packet loss" \
310 rump.ping6 -c 1 -X $TIMEOUT -n ${src_if1_lladdr}%shmif0
312 atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${IP6FWD0} delete
316 # forwarding with link local address
319 export RUMP_SERVER=${SOCKSRC}
320 atf_check -s exit:0 -o match:"0.0% packet loss" rump.ping6 -c 1 \
321 -X $TIMEOUT -n -S ${IP6SRC} ${IP6DST}
324 $DEBUG && rump.ifconfig shmif0
325 atf_check -s not-exit:0 -o match:"100.0% packet loss" rump.ping6 -c 1 \
326 -X $TIMEOUT -n -S ${src_if0_lladdr}%shmif0 ${IP6DST}
327 atf_check -s ignore -o not-match:"${src_if0_lladdr}" -e ignore \
328 -x "shmif_dumpbus -p - ${BUS2} | tcpdump -r - -n -p icmp6"
331 atf_check -s not-exit:0 -o match:"100.0% packet loss" rump.ping6 -c 1 \
332 -X $TIMEOUT -n -S ${IP6SRC} ${dst_if0_lladdr}%shmif0
333 atf_check -s ignore -o not-empty -e ignore \
334 -x "shmif_dumpbus -p - ${BUS2} | tcpdump -r - -n -p icmp6"
351 atf_set "descr" "Test for various operations to IPv6 linklocal addresses"
352 atf_set "require.progs" "rump_server rump.route rump.ndp"
357 local src_if0_lladdr=
361 src_if0_lladdr=`get_lladdr ${SOCKSRC} shmif0`
363 export RUMP_SERVER=${SOCKSRC}
366 atf_check -s exit:0 -o match:"${src_if0_lladdr}" \
367 rump.route get -inet6 ${src_if0_lladdr}%shmif0
369 # route get without an interface name (zone index)
370 atf_check -s not-exit:0 -e match:"not in table" \
371 rump.route get -inet6 ${src_if0_lladdr}
374 atf_check -s exit:0 -o match:"${src_if0_lladdr}" \
375 rump.ndp -n ${src_if0_lladdr}%shmif0
377 # ndp without an interface name (zone index)
378 atf_check -s not-exit:0 -o ignore -e match:"no entry" \
379 rump.ndp -n ${src_if0_lladdr}
383 linklocal_ops_cleanup()
389 atf_init_test_cases()
392 atf_add_test_case linklocal
393 atf_add_test_case linklocal_ops