1 # $NetBSD: t_ipaddress.sh,v 1.9 2016/12/15 02:43: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.
28 SOCK_LOCAL=unix://commsock1
38 rump_server_start $SOCK_LOCAL
39 rump_server_add_iface $SOCK_LOCAL shmif0 $BUS
41 export RUMP_SERVER=$SOCK_LOCAL
43 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 $ip/24
44 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up
45 atf_check -s exit:0 -o ignore rump.ifconfig -w 10
47 $DEBUG && rump.netstat -nr -f inet
49 check_route $ip 'link#2' UHl lo0
50 check_route $net 'link#2' UC shmif0
53 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 $ip delete
55 $DEBUG && rump.netstat -nr -f inet
57 check_route_no_entry $ip
58 check_route_no_entry $net
60 # Assign the same address again
61 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 $ip/24
62 atf_check -s exit:0 -o ignore rump.ifconfig -w 10
64 $DEBUG && rump.netstat -nr -f inet
66 check_route $ip 'link#2' UHl lo0
67 check_route $net 'link#2' UC shmif0
69 # Delete the address again
70 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 $ip delete
72 $DEBUG && rump.netstat -nr -f inet
74 check_route_no_entry $ip
75 check_route_no_entry $net
77 rump_server_destroy_ifaces
85 rump_server_start $SOCK_LOCAL netinet6
86 rump_server_add_iface $SOCK_LOCAL shmif0 $BUS
88 export RUMP_SERVER=$SOCK_LOCAL
90 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 $ip
91 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up
92 atf_check -s exit:0 -o ignore rump.ifconfig -w 10
94 $DEBUG && rump.netstat -nr -f inet6
96 check_route $ip 'link#2' UHl lo0
97 check_route $net 'link#2' UC shmif0
100 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 $ip delete
102 $DEBUG && rump.netstat -nr -f inet6
104 check_route_no_entry $ip
105 check_route_no_entry $net
107 # Assign the same address again
108 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 $ip
109 atf_check -s exit:0 -o ignore rump.ifconfig -w 10
111 $DEBUG && rump.netstat -nr -f inet6
113 check_route $ip 'link#2' UHl lo0
114 check_route $net 'link#2' UC shmif0
116 # Delete the address again
117 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 $ip delete
119 $DEBUG && rump.netstat -nr -f inet6
121 check_route_no_entry $ip
122 check_route_no_entry $net
124 rump_server_destroy_ifaces
127 test_auto_linklocal()
130 rump_server_start $SOCK_LOCAL netinet6
131 rump_server_add_iface $SOCK_LOCAL shmif0 $BUS
133 export RUMP_SERVER=$SOCK_LOCAL
136 # Test enabled auto linklocal
139 # Check default value
140 atf_check -s exit:0 -o match:"1" rump.sysctl -n net.inet6.ip6.auto_linklocal
142 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up
143 atf_check -s exit:0 -o ignore rump.ifconfig -w 10
145 $DEBUG && rump.netstat -nr -f inet
147 # IPv6 link-local address is set
148 atf_check -s exit:0 -o match:"inet6 fe80::" rump.ifconfig shmif0
151 # Test disabled auto linklocal
153 atf_check -s exit:0 -o ignore rump.sysctl -w -q net.inet6.ip6.auto_linklocal=0
155 rump_server_add_iface $SOCK_LOCAL shmif1 $BUS
156 atf_check -s exit:0 -o ignore rump.ifconfig shmif1 up
157 atf_check -s exit:0 -o ignore rump.ifconfig -w 10
159 $DEBUG && rump.netstat -nr -f inet
161 # IPv6 link-local address is not set
162 atf_check -s exit:0 -o not-match:"inet6 fe80::" rump.ifconfig shmif1
164 rump_server_destroy_ifaces
172 atf_test_case "ipaddr_${name}" cleanup
173 eval "ipaddr_${name}_head() { \
174 atf_set \"descr\" \"${desc}\"; \
175 atf_set \"require.progs\" \"rump_server\"; \
177 ipaddr_${name}_body() { \
180 ipaddr_${name}_cleanup() { \
184 atf_add_test_case "ipaddr_${name}"
187 atf_init_test_cases()
190 add_test same_address "Assigning/deleting an IP address twice"
191 add_test same_address6 "Assigning/deleting an IPv6 address twice"
192 add_test auto_linklocal "Assigning an IPv6 link-local address automatically"