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