1 # $NetBSD: t_ndp.sh,v 1.6 2015/08/18 00:58:35 ozaki-r Exp $
3 # Copyright (c) 2015 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.
28 inetserver
="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet"
29 inetserver
="$inetserver -lrumpnet_netinet6 -lrumpnet_shmif"
30 HIJACKING
="env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=sysctl=yes"
32 SOCKSRC
=unix
://commsock1
33 SOCKDST
=unix
://commsock2
40 atf_test_case cache_expiration cleanup
41 atf_test_case
command cleanup
42 atf_test_case cache_overwriting cleanup
44 cache_expiration_head
()
46 atf_set
"descr" "Tests for NDP cache expiration"
47 atf_set
"require.progs" "rump_server"
52 atf_set
"descr" "Tests for commands of ndp(8)"
53 atf_set
"require.progs" "rump_server"
56 cache_overwriting_head
()
58 atf_set
"descr" "Tests for behavior of overwriting NDP caches"
59 atf_set
"require.progs" "rump_server"
64 export RUMP_SERVER
=$SOCKDST
65 atf_check
-s exit:0 rump.ifconfig shmif0 create
66 atf_check
-s exit:0 rump.ifconfig shmif0 linkstr bus1
67 atf_check
-s exit:0 rump.ifconfig shmif0 inet6
$IP6DST
68 atf_check
-s exit:0 rump.ifconfig shmif0 up
69 atf_check
-s exit:0 rump.ifconfig
-w 10
71 $DEBUG && rump.ifconfig shmif0
72 $DEBUG && rump.ndp
-n -a
77 $DEBUG && ulimit -c unlimited
78 export RUMP_SERVER
=$SOCKSRC
81 atf_check
-s exit:0 rump.ifconfig shmif0 create
82 atf_check
-s exit:0 rump.ifconfig shmif0 linkstr bus1
83 atf_check
-s exit:0 rump.ifconfig shmif0 inet6
$IP6SRC
84 atf_check
-s exit:0 rump.ifconfig shmif0 up
85 atf_check
-s exit:0 rump.ifconfig
-w 10
88 $DEBUG && rump.ifconfig shmif0
89 $DEBUG && rump.ndp
-n -a
90 atf_check
-s exit:0 -o ignore rump.ndp
-n $IP6SRC
91 atf_check
-s not-exit
:0 -o ignore
-e ignore rump.ndp
-n $IP6DST
96 local timeout
=$
(env RUMP_SERVER
=$SOCKSRC rump.ndp
-n $IP6DST |
grep $IP6DST|
awk '{print $4;}')
101 cache_expiration_body
()
103 atf_check
-s exit:0 ${inetserver} $SOCKSRC
104 atf_check
-s exit:0 ${inetserver} $SOCKDST
110 # Check if a cache is expired expectedly
112 export RUMP_SERVER
=$SOCKSRC
113 atf_check
-s exit:0 -o ignore rump.ping6
-n -X $TIMEOUT -c 1 $IP6DST
115 $DEBUG && rump.ndp
-n -a
116 atf_check
-s exit:0 -o match
:'permanent' rump.ndp
-n $IP6SRC
118 atf_check
-s exit:0 -o not-match
:'permanent' rump.ndp
-n $IP6DST
120 timeout
=$
(get_timeout
$IP6DST)
122 atf_check
-s exit:0 sleep $
(($timeout + 1))
124 $DEBUG && rump.ndp
-n -a
125 atf_check
-s exit:0 -o match
:'permanent' rump.ndp
-n $IP6SRC
126 # Expired but remains until GC sweaps it (1 day)
127 atf_check
-s exit:0 -o match
:'(1d0h0m|23h59m)' rump.ndp
-n $IP6DST
132 export RUMP_SERVER
=$SOCKDST
133 atf_check
-s exit:0 rump.ifconfig shmif0 down
134 export RUMP_SERVER
=$SOCKSRC
139 atf_check
-s exit:0 ${inetserver} $SOCKSRC
140 atf_check
-s exit:0 ${inetserver} $SOCKDST
145 export RUMP_SERVER
=$SOCKSRC
147 # Add and delete a static entry
148 $DEBUG && rump.ndp
-n -a
149 atf_check
-s exit:0 -o ignore rump.ndp
-s fc00
::10 b2
:a0
:20:00:00:10
150 $DEBUG && rump.ndp
-n -a
151 atf_check
-s exit:0 -o match
:'permanent' rump.ndp
-n fc00
::10
152 atf_check
-s exit:0 -o match
:'deleted' rump.ndp
-d fc00
::10
153 $DEBUG && rump.ndp
-n -a
154 atf_check
-s not-exit
:0 -o ignore
-e ignore rump.ndp
-n fc00
::10
156 # Add multiple entries via a file (XXX not implemented)
157 #cat - > ./list <<-EOF
158 #fc00::11 b2:a0:20:00:00:11
159 #fc00::12 b2:a0:20:00:00:12
160 #fc00::13 b2:a0:20:00:00:13
161 #fc00::14 b2:a0:20:00:00:14
162 #fc00::15 b2:a0:20:00:00:15
164 #$DEBUG && rump.ndp -n -a
165 #atf_check -s exit:0 -o ignore rump.ndp -f ./list
166 #$DEBUG && rump.ndp -n -a
168 atf_check
-s exit:0 -o ignore rump.ping6
-n -X $TIMEOUT -c 1 $IP6DST
169 atf_check
-s exit:0 -o ignore rump.ndp
-s fc00
::11 b2
:a0
:20:00:00:11
170 atf_check
-s exit:0 -o ignore rump.ndp
-s fc00
::12 b2
:a0
:20:00:00:12
172 atf_check
-s exit:0 -o not-match
:'permanent' rump.ndp
-n $IP6DST
173 atf_check
-s exit:0 -o match
:'permanent' rump.ndp
-n fc00
::11
174 atf_check
-s exit:0 -o match
:'permanent' rump.ndp
-n fc00
::12
177 atf_check
-s exit:0 -o match
:'fc00::11' rump.ndp
-n -a
178 atf_check
-s exit:0 -o match
:'fc00::12' rump.ndp
-n -a
180 # Ensure no packet upsets the src server
183 # Flush all entries (-c)
184 $DEBUG && rump.ndp
-n -a
185 atf_check
-s exit:0 -o ignore rump.ndp
-c
186 atf_check
-s not-exit
:0 -o ignore
-e ignore rump.ndp
-n $IP6DST
187 # Only the static caches are not deleted
188 atf_check
-s exit:0 -o ignore
-e ignore rump.ndp
-n fc00
::11
189 atf_check
-s exit:0 -o ignore
-e ignore rump.ndp
-n fc00
::12
191 # Test temp option (XXX it doesn't work; expire time isn't set)
192 $DEBUG && rump.ndp
-n -a
193 #atf_check -s exit:0 -o ignore rump.ndp -s fc00::10 b2:a0:20:00:00:10 temp
194 rump.ndp
-s fc00
::10 b2
:a0
:20:00:00:10 temp
195 $DEBUG && rump.ndp
-n -a
196 #atf_check -s exit:0 -o not-match:'permanent' rump.ndp -n fc00::10
201 cache_overwriting_body
()
203 atf_check
-s exit:0 ${inetserver} $SOCKSRC
204 atf_check
-s exit:0 ${inetserver} $SOCKDST
209 export RUMP_SERVER
=$SOCKSRC
211 # Cannot overwrite a permanent cache
212 atf_check
-s not-exit
:0 -e ignore rump.ndp
-s $IP6SRC b2
:a0
:20:00:00:ff
213 $DEBUG && rump.ndp
-n -a
215 atf_check
-s exit:0 -o ignore rump.ping6
-n -X $TIMEOUT -c 1 $IP6DST
216 $DEBUG && rump.ndp
-n -a
217 # Can overwrite a dynamic cache
218 atf_check
-s exit:0 -o ignore rump.ndp
-s $IP6DST b2
:a0
:20:00:00:00
219 $DEBUG && rump.ndp
-n -a
220 atf_check
-s exit:0 -o match
:'permanent' rump.ndp
-n $IP6DST
222 # Test temp option (XXX it doesn't work; expire time isn't set)
223 #atf_check -s exit:0 -o ignore rump.ndp -s fc00::10 b2:a0:20:00:00:10 temp
224 #$DEBUG && rump.ndp -n -a
225 #atf_check -s exit:0 -o not-match:'permanent' rump.ndp -n fc00::10
226 # Cannot overwrite a temp cache
227 #atf_check -s not-exit:0 -e ignore rump.ndp -s fc00::10 b2:a0:20:00:00:ff
228 #$DEBUG && rump.ndp -n -a
235 env RUMP_SERVER
=$SOCKSRC rump.halt
236 env RUMP_SERVER
=$SOCKDST rump.halt
241 export RUMP_SERVER
=$SOCKSRC
250 export RUMP_SERVER
=$SOCKDST
261 shmif_dumpbus
-p - bus1
2>/dev
/null| tcpdump
-n -e -r -
262 $DEBUG && gdb
-ex bt
/usr
/bin
/rump_server rump_server.core
263 $DEBUG && gdb
-ex bt
/usr
/sbin
/rump.ndp rump.ndp.core
266 cache_expiration_cleanup
()
278 cache_overwriting_cleanup
()
284 atf_init_test_cases
()
286 atf_add_test_case cache_expiration
287 atf_add_test_case
command
288 atf_add_test_case cache_overwriting