1 # $NetBSD: t_change.sh,v 1.8 2016/08/10 23:00:39 roy Exp $
3 # Copyright (c) 2011 The NetBSD Foundation, 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.
29 "rump_server -lrumpdev -lrumpnet -lrumpnet_net \
30 -lrumpnet_netinet -lrumpnet_shmif"
31 export RUMP_SERVER=unix://commsock
35 atf_test_case route_change_reject2blackhole cleanup
36 route_change_reject2blackhole_head()
39 atf_set "descr" "Change a reject route to blackhole"
40 atf_set "require.progs" "rump_server"
43 route_change_reject2blackhole_body()
46 atf_check -s exit:0 ${netserver} ${RUMP_SERVER}
48 atf_check -s exit:0 -o ignore \
49 rump.route add 207.46.197.32 127.0.0.1 -reject
50 atf_check -s exit:0 -o match:UGHR -x \
51 "rump.route -n show -inet | grep ^207.46"
52 atf_check -s exit:0 -o ignore \
53 rump.route change 207.46.197.32 127.0.0.1 -blackhole
54 atf_check -s exit:0 -o match:' UGHBS ' -e ignore -x \
55 "rump.netstat -rn -f inet | grep ^207.46"
58 route_change_reject2blackhole_cleanup()
61 env RUMP_SERVER=unix://commsock rump.halt
64 atf_test_case route_change_gateway cleanup
65 route_change_gateway_head()
68 atf_set "descr" "Change the gateway of a route"
69 atf_set "require.progs" "rump_server"
72 route_change_gateway_body()
75 atf_check -s exit:0 ${netserver} ${RUMP_SERVER}
77 atf_check -s exit:0 rump.ifconfig shmif0 create
78 atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus
79 atf_check -s exit:0 rump.ifconfig shmif0 10.0.0.10/24 up
81 atf_check -s exit:0 -o ignore \
82 rump.route add -net 192.168.0.0/24 10.0.0.1
83 atf_check -s exit:0 -o match:'10.0.0.1' -x \
84 "rump.route -n show -inet | grep ^192.168"
85 atf_check -s exit:0 -o ignore \
86 rump.route change -net 192.168.0.0/24 10.0.0.254
87 atf_check -s exit:0 -o match:'10.0.0.254' -x \
88 "rump.route -n show -inet | grep ^192.168"
91 route_change_gateway_cleanup()
94 env RUMP_SERVER=unix://commsock rump.halt
97 atf_test_case route_change_ifa cleanup
98 route_change_ifa_head()
101 atf_set "descr" "Change the ifa (local address) of a route"
102 atf_set "require.progs" "rump_server"
105 route_change_ifa_body()
108 atf_check -s exit:0 ${netserver} ${RUMP_SERVER}
110 atf_check -s exit:0 rump.ifconfig shmif0 create
111 atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus
112 atf_check -s exit:0 rump.ifconfig shmif0 10.0.0.10/24
113 atf_check -s exit:0 rump.ifconfig shmif0 alias 10.0.0.11/24
114 atf_check -s exit:0 rump.ifconfig shmif0 up
116 atf_check -s exit:0 -o ignore \
117 rump.route add -net 192.168.0.0/24 10.0.0.1
118 atf_check -s exit:0 -o match:'10.0.0.1' -x \
119 "rump.route -n show -inet | grep ^192.168"
120 $DEBUG && rump.route -n show -inet
122 route to: 192.168.0.1
123 destination: 192.168.0.0
126 local addr: 10.0.0.10
128 flags: <UP,GATEWAY,DONE,STATIC>
129 recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire
131 rump.route -n get 192.168.0.1 > ./output
132 $DEBUG && cat ./expect ./output
134 atf_check -s exit:0 diff ./expect ./output
136 # Change the local address of the route
137 atf_check -s exit:0 -o ignore \
138 rump.route change -net 192.168.0.0/24 10.0.0.1 -ifa 10.0.0.11
139 $DEBUG && rump.route -n show -inet
141 route to: 192.168.0.1
142 destination: 192.168.0.0
145 local addr: 10.0.0.11
147 flags: <UP,GATEWAY,DONE,STATIC>
148 recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire
150 rump.route -n get 192.168.0.1 > ./output
151 $DEBUG && cat ./expect ./output
153 atf_check -s exit:0 diff ./expect ./output
156 route_change_ifa_cleanup()
159 env RUMP_SERVER=unix://commsock rump.halt
162 atf_test_case route_change_ifp cleanup
163 route_change_ifp_head()
166 atf_set "descr" "Change a route based on an interface (ifp)"
167 atf_set "require.progs" "rump_server"
170 route_change_ifp_body()
173 atf_check -s exit:0 ${netserver} ${RUMP_SERVER}
175 atf_check -s exit:0 rump.ifconfig shmif0 create
176 atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus
177 atf_check -s exit:0 rump.ifconfig shmif0 10.0.0.10/24 up
179 atf_check -s exit:0 rump.ifconfig shmif1 create
180 atf_check -s exit:0 rump.ifconfig shmif1 linkstr bus
181 atf_check -s exit:0 rump.ifconfig shmif1 10.0.0.11/24 up
183 atf_check -s exit:0 -o ignore \
184 rump.route add -net 192.168.0.0/24 10.0.0.1
185 atf_check -s exit:0 -o match:'10.0.0.1' -x \
186 "rump.route -n show -inet | grep ^192.168"
187 $DEBUG && rump.route -n show -inet
189 route to: 192.168.0.1
190 destination: 192.168.0.0
193 local addr: 10.0.0.10
195 flags: <UP,GATEWAY,DONE,STATIC>
196 recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire
198 rump.route -n get 192.168.0.1 > ./output
199 $DEBUG && cat ./expect ./output
201 atf_check -s exit:0 diff ./expect ./output
203 # Change a route based on an interface
204 atf_check -s exit:0 -o ignore \
205 rump.route change -net 192.168.0.0/24 10.0.0.1 -ifp shmif1
206 $DEBUG && rump.route -n show -inet
208 route to: 192.168.0.1
209 destination: 192.168.0.0
212 local addr: 10.0.0.11
214 flags: <UP,GATEWAY,DONE,STATIC>
215 recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire
217 rump.route -n get 192.168.0.1 > ./output
218 $DEBUG && cat ./expect ./output
220 atf_check -s exit:0 diff ./expect ./output
223 route_change_ifp_cleanup()
226 env RUMP_SERVER=unix://commsock rump.halt
229 atf_test_case route_change_ifp_ifa cleanup
230 route_change_ifp_head()
233 atf_set "descr" "Change a route with -ifp and -ifa"
234 atf_set "require.progs" "rump_server"
237 route_change_ifp_ifa_body()
240 atf_check -s exit:0 ${netserver} ${RUMP_SERVER}
242 atf_check -s exit:0 rump.ifconfig shmif0 create
243 atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus
244 atf_check -s exit:0 rump.ifconfig shmif0 10.0.0.10/24 up
246 atf_check -s exit:0 rump.ifconfig shmif1 create
247 atf_check -s exit:0 rump.ifconfig shmif1 linkstr bus
248 atf_check -s exit:0 rump.ifconfig shmif1 10.0.0.11/24 up
250 atf_check -s exit:0 -o ignore \
251 rump.route add -net 192.168.0.0/24 10.0.0.1
252 atf_check -s exit:0 -o match:'10.0.0.1' -x \
253 "rump.route -n show -inet | grep ^192.168"
254 $DEBUG && rump.route -n show -inet
256 route to: 192.168.0.1
257 destination: 192.168.0.0
260 local addr: 10.0.0.10
262 flags: <UP,GATEWAY,DONE,STATIC>
263 recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire
265 rump.route -n get 192.168.0.1 > ./output
266 $DEBUG && cat ./expect ./output
268 atf_check -s exit:0 diff ./expect ./output
270 # Change a route with -ifa and -ifp
271 atf_check -s exit:0 -o ignore \
272 rump.route change -net 192.168.0.0/24 -ifa 10.0.0.1 -ifp shmif1
273 $DEBUG && rump.route -n show -inet
275 route to: 192.168.0.1
276 destination: 192.168.0.0
279 local addr: 10.0.0.11
281 flags: <UP,GATEWAY,DONE,STATIC>
282 recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire
284 rump.route -n get 192.168.0.1 > ./output
285 $DEBUG && cat ./expect ./output
287 atf_check -s exit:0 diff ./expect ./output
290 route_change_ifp_ifa_cleanup()
293 env RUMP_SERVER=unix://commsock rump.halt
296 atf_init_test_cases()
299 atf_add_test_case route_change_reject2blackhole
300 atf_add_test_case route_change_gateway
301 atf_add_test_case route_change_ifa
302 atf_add_test_case route_change_ifp
303 atf_add_test_case route_change_ifp_ifa