Home | History | Annotate | Line # | Download | only in arp
t_arp.sh revision 1.21
      1 #	$NetBSD: t_arp.sh,v 1.21 2016/11/24 09:07:09 ozaki-r Exp $
      2 #
      3 # Copyright (c) 2015 The NetBSD Foundation, Inc.
      4 # All rights reserved.
      5 #
      6 # Redistribution and use in source and binary forms, with or without
      7 # modification, are permitted provided that the following conditions
      8 # are met:
      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.
     14 #
     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.
     26 #
     27 
     28 inetlib="-lrumpnet_shmif -lrumpnet_tap -lrumpnet -lrumpnet_net -lrumpnet_netinet"
     29 inetserver="rump_server $inetlib -lrumpdev"
     30 
     31 SOCKSRC=unix://commsock1
     32 SOCKDST=unix://commsock2
     33 IP4SRC=10.0.1.1
     34 IP4DST=10.0.1.2
     35 IP4DST_PROXYARP1=10.0.1.3
     36 IP4DST_PROXYARP2=10.0.1.4
     37 
     38 DEBUG=${DEBUG:-false}
     39 TIMEOUT=1
     40 
     41 atf_test_case arp_cache_expiration_5s cleanup
     42 atf_test_case arp_cache_expiration_10s cleanup
     43 atf_test_case arp_command cleanup
     44 atf_test_case arp_garp cleanup
     45 atf_test_case arp_cache_overwriting cleanup
     46 atf_test_case arp_proxy_arp_pub cleanup
     47 atf_test_case arp_proxy_arp_pubproxy cleanup
     48 atf_test_case arp_link_activation cleanup
     49 atf_test_case arp_static cleanup
     50 
     51 arp_cache_expiration_5s_head()
     52 {
     53 	atf_set "descr" "Tests for ARP cache expiration (5s)"
     54 	atf_set "require.progs" "rump_server"
     55 }
     56 
     57 arp_cache_expiration_10s_head()
     58 {
     59 	atf_set "descr" "Tests for ARP cache expiration (10s)"
     60 	atf_set "require.progs" "rump_server"
     61 }
     62 
     63 arp_command_head()
     64 {
     65 	atf_set "descr" "Tests for arp_commands of arp(8)"
     66 	atf_set "require.progs" "rump_server"
     67 }
     68 
     69 arp_garp_head()
     70 {
     71 	atf_set "descr" "Tests for GARP"
     72 	atf_set "require.progs" "rump_server"
     73 }
     74 
     75 arp_cache_overwriting_head()
     76 {
     77 	atf_set "descr" "Tests for behavior of overwriting ARP caches"
     78 	atf_set "require.progs" "rump_server"
     79 }
     80 
     81 arp_proxy_arp_pub_head()
     82 {
     83 	atf_set "descr" "Tests for Proxy ARP (pub)"
     84 	atf_set "require.progs" "rump_server"
     85 }
     86 
     87 arp_proxy_arp_pubproxy_head()
     88 {
     89 	atf_set "descr" "Tests for Proxy ARP (pub proxy)"
     90 	atf_set "require.progs" "rump_server"
     91 }
     92 
     93 arp_link_activation_head()
     94 {
     95 	atf_set "descr" "Tests for activating a new MAC address"
     96 	atf_set "require.progs" "rump_server"
     97 }
     98 
     99 arp_static_head()
    100 {
    101 
    102 	atf_set "descr" "Tests for static ARP entries"
    103 	atf_set "require.progs" "rump_server"
    104 }
    105 
    106 setup_dst_server()
    107 {
    108 	export RUMP_SERVER=$SOCKDST
    109 	atf_check -s exit:0 rump.ifconfig shmif0 create
    110 	atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1
    111 	atf_check -s exit:0 rump.ifconfig shmif0 inet $IP4DST/24
    112 	atf_check -s exit:0 rump.ifconfig shmif0 up
    113 	atf_check -s exit:0 rump.ifconfig -w 10
    114 
    115 	$DEBUG && rump.ifconfig shmif0
    116 	$DEBUG && rump.arp -n -a
    117 }
    118 
    119 setup_src_server()
    120 {
    121 	local keep=$1
    122 
    123 	export RUMP_SERVER=$SOCKSRC
    124 
    125 	# Adjust ARP parameters
    126 	atf_check -s exit:0 -o ignore rump.sysctl -w net.inet.arp.keep=$keep
    127 
    128 	# Setup an interface
    129 	atf_check -s exit:0 rump.ifconfig shmif0 create
    130 	atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1
    131 	atf_check -s exit:0 rump.ifconfig shmif0 inet $IP4SRC/24
    132 	atf_check -s exit:0 rump.ifconfig shmif0 up
    133 	atf_check -s exit:0 rump.ifconfig -w 10
    134 
    135 	# Sanity check
    136 	$DEBUG && rump.ifconfig shmif0
    137 	$DEBUG && rump.arp -n -a
    138 	atf_check -s exit:0 -o ignore rump.arp -n $IP4SRC
    139 	atf_check -s not-exit:0 -e ignore rump.arp -n $IP4DST
    140 }
    141 
    142 test_cache_expiration()
    143 {
    144 	local arp_keep=$1
    145 	local bonus=2
    146 
    147 	atf_check -s exit:0 ${inetserver} $SOCKSRC
    148 	atf_check -s exit:0 ${inetserver} $SOCKDST
    149 
    150 	setup_dst_server
    151 	setup_src_server $arp_keep
    152 
    153 	#
    154 	# Check if a cache is expired expectedly
    155 	#
    156 	export RUMP_SERVER=$SOCKSRC
    157 	atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 $IP4DST
    158 
    159 	$DEBUG && rump.arp -n -a
    160 	atf_check -s exit:0 -o ignore rump.arp -n $IP4SRC
    161 	# Should be cached
    162 	atf_check -s exit:0 -o ignore rump.arp -n $IP4DST
    163 
    164 	atf_check -s exit:0 sleep $(($arp_keep + $bonus))
    165 
    166 	$DEBUG && rump.arp -n -a
    167 	atf_check -s exit:0 -o ignore rump.arp -n $IP4SRC
    168 	# Should be expired
    169 	atf_check -s not-exit:0 -e ignore rump.arp -n $IP4DST
    170 }
    171 
    172 arp_cache_expiration_5s_body()
    173 {
    174 	test_cache_expiration 5
    175 }
    176 
    177 arp_cache_expiration_10s_body()
    178 {
    179 	test_cache_expiration 10
    180 }
    181 
    182 arp_command_body()
    183 {
    184 	local arp_keep=5
    185 	local bonus=2
    186 
    187 	atf_check -s exit:0 ${inetserver} $SOCKSRC
    188 	atf_check -s exit:0 ${inetserver} $SOCKDST
    189 
    190 	setup_dst_server
    191 	setup_src_server $arp_keep
    192 
    193 	export RUMP_SERVER=$SOCKSRC
    194 
    195 	# We can delete the entry for the interface's IP address
    196 	atf_check -s exit:0 -o ignore rump.arp -d $IP4SRC
    197 
    198 	# Add and delete a static entry
    199 	$DEBUG && rump.arp -n -a
    200 	atf_check -s exit:0 -o ignore rump.arp -s 10.0.1.10 b2:a0:20:00:00:10
    201 	$DEBUG && rump.arp -n -a
    202 	atf_check -s exit:0 -o match:'b2:a0:20:00:00:10' rump.arp -n 10.0.1.10
    203 	atf_check -s exit:0 -o match:'permanent' rump.arp -n 10.0.1.10
    204 	atf_check -s exit:0 -o ignore rump.arp -d 10.0.1.10
    205 	$DEBUG && rump.arp -n -a
    206 	atf_check -s not-exit:0 -e ignore rump.arp -n 10.0.1.10
    207 
    208 	# Add multiple entries via a file
    209 	cat - > ./list <<-EOF
    210 	10.0.1.11 b2:a0:20:00:00:11
    211 	10.0.1.12 b2:a0:20:00:00:12
    212 	10.0.1.13 b2:a0:20:00:00:13
    213 	10.0.1.14 b2:a0:20:00:00:14
    214 	10.0.1.15 b2:a0:20:00:00:15
    215 	EOF
    216 	$DEBUG && rump.arp -n -a
    217 	atf_check -s exit:0 -o ignore rump.arp -f ./list
    218 	$DEBUG && rump.arp -n -a
    219 	atf_check -s exit:0 -o match:'b2:a0:20:00:00:11' rump.arp -n 10.0.1.11
    220 	atf_check -s exit:0 -o match:'permanent' rump.arp -n 10.0.1.11
    221 	atf_check -s exit:0 -o match:'b2:a0:20:00:00:12' rump.arp -n 10.0.1.12
    222 	atf_check -s exit:0 -o match:'permanent' rump.arp -n 10.0.1.12
    223 	atf_check -s exit:0 -o match:'b2:a0:20:00:00:13' rump.arp -n 10.0.1.13
    224 	atf_check -s exit:0 -o match:'permanent' rump.arp -n 10.0.1.13
    225 	atf_check -s exit:0 -o match:'b2:a0:20:00:00:14' rump.arp -n 10.0.1.14
    226 	atf_check -s exit:0 -o match:'permanent' rump.arp -n 10.0.1.14
    227 	atf_check -s exit:0 -o match:'b2:a0:20:00:00:15' rump.arp -n 10.0.1.15
    228 	atf_check -s exit:0 -o match:'permanent' rump.arp -n 10.0.1.15
    229 
    230 	# Test arp -a
    231 	atf_check -s exit:0 -o match:'10.0.1.11' rump.arp -n -a
    232 	atf_check -s exit:0 -o match:'10.0.1.12' rump.arp -n -a
    233 	atf_check -s exit:0 -o match:'10.0.1.13' rump.arp -n -a
    234 	atf_check -s exit:0 -o match:'10.0.1.14' rump.arp -n -a
    235 	atf_check -s exit:0 -o match:'10.0.1.15' rump.arp -n -a
    236 
    237 	# Flush all entries
    238 	$DEBUG && rump.arp -n -a
    239 	atf_check -s exit:0 -o ignore rump.arp -d -a
    240 	atf_check -s not-exit:0 -e ignore rump.arp -n 10.0.1.11
    241 	atf_check -s not-exit:0 -e ignore rump.arp -n 10.0.1.12
    242 	atf_check -s not-exit:0 -e ignore rump.arp -n 10.0.1.13
    243 	atf_check -s not-exit:0 -e ignore rump.arp -n 10.0.1.14
    244 	atf_check -s not-exit:0 -e ignore rump.arp -n 10.0.1.15
    245 	atf_check -s not-exit:0 -e ignore rump.arp -n 10.0.1.1
    246 
    247 	# Test temp option
    248 	$DEBUG && rump.arp -n -a
    249 	atf_check -s exit:0 -o ignore rump.arp -s 10.0.1.10 b2:a0:20:00:00:10 temp
    250 	$DEBUG && rump.arp -n -a
    251 	atf_check -s exit:0 -o match:'b2:a0:20:00:00:10' rump.arp -n 10.0.1.10
    252 	atf_check -s exit:0 -o not-match:'permanent' rump.arp -n 10.0.1.10
    253 
    254 	# Hm? the cache doesn't expire...
    255 	atf_check -s exit:0 sleep $(($arp_keep + $bonus))
    256 	$DEBUG && rump.arp -n -a
    257 	#atf_check -s not-exit:0 -e ignore rump.arp -n 10.0.1.10
    258 
    259 	return 0
    260 }
    261 
    262 make_pkt_str_arpreq()
    263 {
    264 	local target=$1
    265 	local sender=$2
    266 	pkt="> ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42:"
    267 	pkt="$pkt Request who-has $target tell $sender, length 28"
    268 	echo $pkt
    269 }
    270 
    271 arp_garp_body()
    272 {
    273 	local pkt=
    274 
    275 	atf_check -s exit:0 ${inetserver} $SOCKSRC
    276 	export RUMP_SERVER=$SOCKSRC
    277 
    278 	# Setup an interface
    279 	atf_check -s exit:0 rump.ifconfig shmif0 create
    280 	atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1
    281 	atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.1/24
    282 	atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.2/24 alias
    283 	atf_check -s exit:0 rump.ifconfig shmif0 up
    284 	$DEBUG && rump.ifconfig shmif0
    285 
    286 	atf_check -s exit:0 sleep 1
    287 	shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r - > ./out
    288 
    289 	# A GARP packet is sent for the primary address
    290 	pkt=$(make_pkt_str_arpreq 10.0.0.1 10.0.0.1)
    291 	atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'"
    292 	# No GARP packet is sent for the alias address
    293 	pkt=$(make_pkt_str_arpreq 10.0.0.2 10.0.0.2)
    294 	atf_check -s not-exit:0 -x "cat ./out |grep -q '$pkt'"
    295 
    296 	atf_check -s exit:0 rump.ifconfig -w 10
    297 	atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.3/24
    298 	atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.4/24 alias
    299 
    300 	# No GARP packets are sent during IFF_UP
    301 	shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r - > ./out
    302 	pkt=$(make_pkt_str_arpreq 10.0.0.3 10.0.0.3)
    303 	atf_check -s not-exit:0 -x "cat ./out |grep -q '$pkt'"
    304 	pkt=$(make_pkt_str_arpreq 10.0.0.4 10.0.0.4)
    305 	atf_check -s not-exit:0 -x "cat ./out |grep -q '$pkt'"
    306 }
    307 
    308 arp_cache_overwriting_body()
    309 {
    310 	local arp_keep=5
    311 	local bonus=2
    312 
    313 	atf_check -s exit:0 ${inetserver} $SOCKSRC
    314 	atf_check -s exit:0 ${inetserver} $SOCKDST
    315 
    316 	setup_dst_server
    317 	setup_src_server $arp_keep
    318 
    319 	export RUMP_SERVER=$SOCKSRC
    320 
    321 	# Cannot overwrite a permanent cache
    322 	atf_check -s not-exit:0 -e match:'File exists' \
    323 	    rump.arp -s $IP4SRC b2:a0:20:00:00:ff
    324 	$DEBUG && rump.arp -n -a
    325 
    326 	atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 $IP4DST
    327 	$DEBUG && rump.arp -n -a
    328 	# Can overwrite a dynamic cache
    329 	atf_check -s exit:0 -o ignore rump.arp -s $IP4DST b2:a0:20:00:00:00
    330 	$DEBUG && rump.arp -n -a
    331 	atf_check -s exit:0 -o match:'b2:a0:20:00:00:00' rump.arp -n $IP4DST
    332 	atf_check -s exit:0 -o match:'permanent' rump.arp -n $IP4DST
    333 
    334 	atf_check -s exit:0 -o ignore rump.arp -s 10.0.1.10 b2:a0:20:00:00:10 temp
    335 	$DEBUG && rump.arp -n -a
    336 	atf_check -s exit:0 -o match:'b2:a0:20:00:00:10' rump.arp -n 10.0.1.10
    337 	atf_check -s exit:0 -o not-match:'permanent' rump.arp -n 10.0.1.10
    338 	# Can overwrite a temp cache
    339 	atf_check -s exit:0 -o ignore rump.arp -s 10.0.1.10 b2:a0:20:00:00:ff
    340 	atf_check -s exit:0 -o match:'b2:a0:20:00:00:ff' rump.arp -n 10.0.1.10
    341 	$DEBUG && rump.arp -n -a
    342 
    343 	return 0
    344 }
    345 
    346 make_pkt_str_arprep()
    347 {
    348 	local ip=$1
    349 	local mac=$2
    350 	pkt="ethertype ARP (0x0806), length 42: "
    351 	pkt="Reply $ip is-at $mac, length 28"
    352 	echo $pkt
    353 }
    354 
    355 make_pkt_str_garp()
    356 {
    357 	local ip=$1
    358 	local mac=$2
    359 	local pkt=
    360 	pkt="$mac > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806),"
    361 	pkt="$pkt length 42: Request who-has $ip tell $ip, length 28"
    362 	echo $pkt
    363 }
    364 
    365 test_proxy_arp()
    366 {
    367 	local arp_keep=5
    368 	local opts= title= flags=
    369 	local type=$1
    370 
    371 	atf_check -s exit:0 ${inetserver} $SOCKSRC
    372 	atf_check -s exit:0 ${inetserver} $SOCKDST
    373 
    374 	setup_dst_server
    375 	setup_src_server $arp_keep
    376 
    377 	export RUMP_SERVER=$SOCKDST
    378 	atf_check -s exit:0 -o ignore rump.sysctl -w net.inet.ip.forwarding=1
    379 	macaddr_dst=$(get_macaddr $SOCKDST shmif0)
    380 
    381 	if [ "$type" = "pub" ]; then
    382 		opts="pub"
    383 		title="permanent published"
    384 	else
    385 		opts="pub proxy"
    386 		title='permanent published \(proxy only\)'
    387 	fi
    388 
    389 	#
    390 	# Test#1: First setup an endpoint then create proxy arp entry
    391 	#
    392 	export RUMP_SERVER=$SOCKDST
    393 	atf_check -s exit:0 rump.ifconfig tap1 create
    394 	atf_check -s exit:0 rump.ifconfig tap1 $IP4DST_PROXYARP1/24 up
    395 	atf_check -s exit:0 rump.ifconfig -w 10
    396 
    397 	# Try to ping (should fail w/o proxy arp)
    398 	export RUMP_SERVER=$SOCKSRC
    399 	atf_check -s not-exit:0 -o ignore -e ignore \
    400 	    rump.ping -n -w 1 -c 1 $IP4DST_PROXYARP1
    401 
    402 	# Flushing
    403 	extract_new_packets bus1 > ./out
    404 
    405 	# Set up proxy ARP entry
    406 	export RUMP_SERVER=$SOCKDST
    407 	atf_check -s exit:0 -o ignore \
    408 	    rump.arp -s $IP4DST_PROXYARP1 $macaddr_dst $opts
    409 	atf_check -s exit:0 -o match:"$title" rump.arp -n $IP4DST_PROXYARP1
    410 
    411 	# Try to ping
    412 	export RUMP_SERVER=$SOCKSRC
    413 	if [ "$type" = "pub" ]; then
    414 		# XXX fails
    415 		atf_check -s not-exit:0 -o ignore -e ignore \
    416 		    rump.ping -n -w 1 -c 1 $IP4DST_PROXYARP1
    417 	else
    418 		atf_check -s exit:0 -o ignore \
    419 		    rump.ping -n -w 1 -c 1 $IP4DST_PROXYARP1
    420 	fi
    421 
    422 	extract_new_packets bus1 > ./out
    423 	$DEBUG && cat ./out
    424 
    425 	pkt1=$(make_pkt_str_arprep $IP4DST_PROXYARP1 $macaddr_dst)
    426 	pkt2=$(make_pkt_str_garp $IP4DST_PROXYARP1 $macaddr_dst)
    427 	if [ "$type" = "pub" ]; then
    428 		atf_check -s not-exit:0 -x \
    429 		    "cat ./out |grep -q -e '$pkt1' -e '$pkt2'"
    430 	else
    431 		atf_check -s exit:0 -x "cat ./out |grep -q -e '$pkt1' -e '$pkt2'"
    432 	fi
    433 
    434 	#
    435 	# Test#2: Create proxy arp entry then set up an endpoint
    436 	#
    437 	export RUMP_SERVER=$SOCKDST
    438 	atf_check -s exit:0 -o ignore \
    439 	    rump.arp -s $IP4DST_PROXYARP2 $macaddr_dst $opts
    440 	atf_check -s exit:0 -o match:"$title" rump.arp -n $IP4DST_PROXYARP2
    441 	$DEBUG && rump.netstat -nr -f inet
    442 
    443 	# Try to ping (should fail because no endpoint exists)
    444 	export RUMP_SERVER=$SOCKSRC
    445 	atf_check -s not-exit:0 -o ignore -e ignore \
    446 	    rump.ping -n -w 1 -c 1 $IP4DST_PROXYARP2
    447 
    448 	extract_new_packets bus1 > ./out
    449 	$DEBUG && cat ./out
    450 
    451 	# ARP reply should be sent
    452 	pkt=$(make_pkt_str_arprep $IP4DST_PROXYARP2 $macaddr_dst)
    453 	atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'"
    454 
    455 	export RUMP_SERVER=$SOCKDST
    456 	atf_check -s exit:0 rump.ifconfig tap2 create
    457 	atf_check -s exit:0 rump.ifconfig tap2 $IP4DST_PROXYARP2/24 up
    458 	atf_check -s exit:0 rump.ifconfig -w 10
    459 
    460 	# Try to ping
    461 	export RUMP_SERVER=$SOCKSRC
    462 	atf_check -s exit:0 -o ignore rump.ping -n -w 1 -c 1 $IP4DST_PROXYARP2
    463 }
    464 
    465 arp_proxy_arp_pub_body()
    466 {
    467 
    468 	test_proxy_arp pub
    469 }
    470 
    471 arp_proxy_arp_pubproxy_body()
    472 {
    473 
    474 	test_proxy_arp pubproxy
    475 }
    476 
    477 arp_link_activation_body()
    478 {
    479 	local arp_keep=5
    480 	local bonus=2
    481 
    482 	atf_check -s exit:0 ${inetserver} $SOCKSRC
    483 	atf_check -s exit:0 ${inetserver} $SOCKDST
    484 
    485 	setup_dst_server
    486 	setup_src_server $arp_keep
    487 
    488 	# flush old packets
    489 	extract_new_packets bus1 > ./out
    490 
    491 	export RUMP_SERVER=$SOCKSRC
    492 
    493 	atf_check -s exit:0 -o ignore rump.ifconfig shmif0 link \
    494 	    b2:a1:00:00:00:01
    495 
    496 	atf_check -s exit:0 sleep 1
    497 	extract_new_packets bus1 > ./out
    498 	$DEBUG && cat ./out
    499 
    500 	pkt=$(make_pkt_str_arpreq $IP4SRC $IP4SRC)
    501 	atf_check -s not-exit:0 -x "cat ./out |grep -q '$pkt'"
    502 
    503 	atf_check -s exit:0 -o ignore rump.ifconfig shmif0 link \
    504 	    b2:a1:00:00:00:02 active
    505 
    506 	atf_check -s exit:0 sleep 1
    507 	extract_new_packets bus1 > ./out
    508 	$DEBUG && cat ./out
    509 
    510 	pkt=$(make_pkt_str_arpreq $IP4SRC $IP4SRC)
    511 	atf_check -s exit:0 -x \
    512 	    "cat ./out |grep '$pkt' |grep -q 'b2:a1:00:00:00:02'"
    513 }
    514 
    515 arp_static_body()
    516 {
    517 	local arp_keep=5
    518 	local macaddr_src=
    519 
    520 	atf_check -s exit:0 ${inetserver} $SOCKSRC
    521 	atf_check -s exit:0 ${inetserver} $SOCKDST
    522 
    523 	setup_dst_server
    524 	setup_src_server $arp_keep
    525 
    526 	macaddr_src=$(get_macaddr $SOCKSRC shmif0)
    527 
    528 	# Set a (valid) static ARP entry for the src server
    529 	export RUMP_SERVER=$SOCKDST
    530 	$DEBUG && rump.arp -n -a
    531 	atf_check -s exit:0 -o ignore rump.arp -s $IP4SRC $macaddr_src
    532 	$DEBUG && rump.arp -n -a
    533 
    534 	# Test receiving an ARP request with the static ARP entry (as spa/sha)
    535 	export RUMP_SERVER=$SOCKSRC
    536 	atf_check -s exit:0 -o ignore rump.ping -n -w 1 -c 1 $IP4DST
    537 }
    538 
    539 cleanup()
    540 {
    541 	env RUMP_SERVER=$SOCKSRC rump.halt
    542 	env RUMP_SERVER=$SOCKDST rump.halt
    543 }
    544 
    545 dump_src()
    546 {
    547 	export RUMP_SERVER=$SOCKSRC
    548 	rump.netstat -nr
    549 	rump.arp -n -a
    550 	rump.ifconfig
    551 	$HIJACKING dmesg
    552 }
    553 
    554 dump_dst()
    555 {
    556 	export RUMP_SERVER=$SOCKDST
    557 	rump.netstat -nr
    558 	rump.arp -n -a
    559 	rump.ifconfig
    560 	$HIJACKING dmesg
    561 }
    562 
    563 dump()
    564 {
    565 	dump_src
    566 	dump_dst
    567 	shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r -
    568 }
    569 
    570 arp_cache_expiration_5s_cleanup()
    571 {
    572 	$DEBUG && dump
    573 	cleanup
    574 }
    575 
    576 arp_cache_expiration_10s_cleanup()
    577 {
    578 	$DEBUG && dump
    579 	cleanup
    580 }
    581 
    582 arp_command_cleanup()
    583 {
    584 	$DEBUG && dump
    585 	cleanup
    586 }
    587 
    588 arp_garp_cleanup()
    589 {
    590 	$DEBUG && dump_src
    591 	$DEBUG && shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r -
    592 	env RUMP_SERVER=$SOCKSRC rump.halt
    593 }
    594 
    595 arp_cache_overwriting_cleanup()
    596 {
    597 	$DEBUG && dump
    598 	cleanup
    599 }
    600 
    601 arp_proxy_arp_pub_cleanup()
    602 {
    603 	$DEBUG && dump
    604 	cleanup
    605 }
    606 
    607 arp_proxy_arp_pubproxy_cleanup()
    608 {
    609 	$DEBUG && dump
    610 	cleanup
    611 }
    612 
    613 arp_link_activation_cleanup()
    614 {
    615 	$DEBUG && dump
    616 	cleanup
    617 }
    618 
    619 arp_static_cleanup()
    620 {
    621 	$DEBUG && dump
    622 	cleanup
    623 }
    624 
    625 atf_init_test_cases()
    626 {
    627 	atf_add_test_case arp_cache_expiration_5s
    628 	atf_add_test_case arp_cache_expiration_10s
    629 	atf_add_test_case arp_command
    630 	atf_add_test_case arp_garp
    631 	atf_add_test_case arp_cache_overwriting
    632 	atf_add_test_case arp_proxy_arp_pub
    633 	atf_add_test_case arp_proxy_arp_pubproxy
    634 	atf_add_test_case arp_link_activation
    635 	atf_add_test_case arp_static
    636 }
    637