1 # $NetBSD: t_ipaddress.sh,v 1.3 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.
28 SERVER="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_shmif -lrumpdev"
29 SERVER6="$SERVER -lrumpnet_netinet6"
30 SOCK_LOCAL=unix://commsock1
37 local ip=$(echo $1 |sed 's/\./\\./g')
40 atf_check -s exit:0 -o match:"$word" -e ignore -x \
41 "rump.netstat -rn | grep ^'$ip'"
46 local ip=$(echo $1 |sed 's/\./\\./g')
47 local flags=$2 # Not used currently
49 atf_check -s not-exit:0 -e ignore -x \
50 "rump.netstat -rn | grep ^'$ip'"
58 atf_check -s exit:0 ${SERVER} ${SOCK_LOCAL}
59 export RUMP_SERVER=$SOCK_LOCAL
61 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 create
62 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 linkstr ${BUS}
63 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 $ip/24
64 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up
65 atf_check -s exit:0 -o ignore rump.ifconfig -w 10
67 $DEBUG && rump.netstat -nr -f inet
71 check_entry $ip 'link#2'
73 check_entry $net shmif0
74 check_entry $net 'link#2'
77 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 $ip delete
79 $DEBUG && rump.netstat -nr -f inet
84 # Assign the same address again
85 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 $ip/24
86 atf_check -s exit:0 -o ignore rump.ifconfig -w 10
88 $DEBUG && rump.netstat -nr -f inet
92 check_entry $ip 'link#2'
94 check_entry $net shmif0
95 check_entry $net 'link#2'
97 # Delete the address again
98 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 $ip delete
100 $DEBUG && rump.netstat -nr -f inet
103 check_entry_fail $net
111 atf_check -s exit:0 ${SERVER6} ${SOCK_LOCAL}
112 export RUMP_SERVER=$SOCK_LOCAL
114 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 create
115 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 linkstr ${BUS}
116 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 $ip
117 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up
118 atf_check -s exit:0 -o ignore rump.ifconfig -w 10
120 $DEBUG && rump.netstat -nr -f inet6
124 check_entry $ip 'link#2'
126 check_entry $net shmif0
127 check_entry $net 'link#2'
130 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 $ip delete
132 $DEBUG && rump.netstat -nr -f inet6
135 check_entry_fail $net
137 # Assign the same address again
138 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 $ip
139 atf_check -s exit:0 -o ignore rump.ifconfig -w 10
141 $DEBUG && rump.netstat -nr -f inet6
145 check_entry $ip 'link#2'
147 check_entry $net shmif0
148 check_entry $net 'link#2'
150 # Delete the address again
151 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 $ip delete
153 $DEBUG && rump.netstat -nr -f inet6
156 check_entry_fail $net
162 $DEBUG && shmif_dumpbus -p - $BUS 2>/dev/null | tcpdump -n -e -r -
163 env RUMP_SERVER=$SOCK_LOCAL rump.halt
171 atf_test_case "ipaddr_${name}" cleanup
172 eval "ipaddr_${name}_head() { \
173 atf_set \"descr\" \"${desc}\"; \
174 atf_set \"require.progs\" \"rump_server\"; \
176 ipaddr_${name}_body() { \
179 ipaddr_${name}_cleanup() { \
182 atf_add_test_case "ipaddr_${name}"
185 atf_init_test_cases()
188 add_test same_address "Assigning/deleting an IP address twice"
189 add_test same_address6 "Assigning/deleting an IPv6 address twice"