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