summaryrefslogtreecommitdiffstats
path: root/contrib/netbsd-tests/net/arp/t_dad.sh
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/netbsd-tests/net/arp/t_dad.sh')
-rwxr-xr-xcontrib/netbsd-tests/net/arp/t_dad.sh100
1 files changed, 26 insertions, 74 deletions
diff --git a/contrib/netbsd-tests/net/arp/t_dad.sh b/contrib/netbsd-tests/net/arp/t_dad.sh
index aefcb0b..57a7d4b0 100755
--- a/contrib/netbsd-tests/net/arp/t_dad.sh
+++ b/contrib/netbsd-tests/net/arp/t_dad.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_dad.sh,v 1.7 2016/08/10 22:05:07 kre Exp $
+# $NetBSD: t_dad.sh,v 1.13 2016/11/25 08:51:16 ozaki-r Exp $
#
# Copyright (c) 2015 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -25,14 +25,10 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-inetserver="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_shmif"
-inetserver="${inetserver} -lrumpdev"
-HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=sysctl=yes"
-
SOCKLOCAL=unix://commsock1
SOCKPEER=unix://commsock2
-DEBUG=false
+DEBUG=${DEBUG:-false}
atf_test_case dad_basic cleanup
atf_test_case dad_duplicated cleanup
@@ -54,10 +50,9 @@ setup_server()
local sock=$1
local ip=$2
- export RUMP_SERVER=$sock
+ rump_server_add_iface $sock shmif0 bus1
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1
+ export RUMP_SERVER=$sock
atf_check -s exit:0 rump.ifconfig shmif0 inet $ip/24
atf_check -s exit:0 rump.ifconfig shmif0 up
atf_check -s exit:0 rump.ifconfig -w 10
@@ -74,30 +69,15 @@ make_pkt_str()
echo $pkt
}
-extract_new_packets()
-{
- local old=./old
-
- if [ ! -f $old ]; then
- old=/dev/null
- fi
-
- shmif_dumpbus -p - bus1 2>/dev/null| \
- tcpdump -n -e -r - 2>/dev/null > ./new
- diff -u $old ./new |grep '^+' |cut -d '+' -f 2 > ./diff
- mv -f ./new ./old
- cat ./diff
-}
-
dad_basic_body()
{
local pkt=
- atf_check -s exit:0 ${inetserver} $SOCKLOCAL
+ rump_server_start $SOCKLOCAL
+ rump_server_add_iface $SOCKLOCAL shmif0 bus1
+
export RUMP_SERVER=$SOCKLOCAL
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1
atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.1/24
atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.2/24 alias
$DEBUG && rump.ifconfig shmif0
@@ -107,13 +87,13 @@ dad_basic_body()
$DEBUG && cat ./out
# The primary address doesn't start with tentative state
- atf_check -s not-exit:0 -x "cat ./out |grep 10.0.0.1 |grep -q tentative"
+ atf_check -s not-exit:0 -x "cat ./out |grep 10.0.0.1 |grep -iq tentative"
# The alias address starts with tentative state
# XXX we have no stable way to check this, so skip for now
- #atf_check -s exit:0 -x "cat ./out |grep 10.0.0.2 |grep -q tentative"
+ #atf_check -s exit:0 -x "cat ./out |grep 10.0.0.2 |grep -iq tentative"
atf_check -s exit:0 sleep 2
- extract_new_packets > ./out
+ extract_new_packets bus1 > ./out
$DEBUG && cat ./out
# Check DAD probe packets
@@ -127,14 +107,14 @@ dad_basic_body()
atf_check -s exit:0 rump.ifconfig -w 10
# Give a chance to send a DAD announce packet
atf_check -s exit:0 sleep 1
- extract_new_packets > ./out
+ extract_new_packets bus1 > ./out
$DEBUG && cat ./out
# Check the DAD announce packet
pkt=$(make_pkt_str 10.0.0.2 10.0.0.2)
atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'"
# The alias address left tentative
- atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep 10.0.0.2 |grep -q tentative"
+ atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep 10.0.0.2 |grep -iq tentative"
#
# Add a new address on the fly
@@ -143,11 +123,11 @@ dad_basic_body()
# The new address starts with tentative state
# XXX we have no stable way to check this, so skip for now
- #atf_check -s exit:0 -x "rump.ifconfig shmif0 |grep 10.0.0.3 |grep -q tentative"
+ #atf_check -s exit:0 -x "rump.ifconfig shmif0 |grep 10.0.0.3 |grep -iq tentative"
# Check DAD probe packets
atf_check -s exit:0 sleep 2
- extract_new_packets > ./out
+ extract_new_packets bus1 > ./out
$DEBUG && cat ./out
pkt=$(make_pkt_str 10.0.0.3 0.0.0.0)
atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'"
@@ -156,14 +136,16 @@ dad_basic_body()
atf_check -s exit:0 rump.ifconfig -w 10
# Give a chance to send a DAD announce packet
atf_check -s exit:0 sleep 1
- extract_new_packets > ./out
+ extract_new_packets bus1 > ./out
$DEBUG && cat ./out
# Check the DAD announce packet
pkt=$(make_pkt_str 10.0.0.3 10.0.0.3)
atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'"
# The new address left tentative
- atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep 10.0.0.3 |grep -q tentative"
+ atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep 10.0.0.3 |grep -iq tentative"
+
+ rump_server_destroy_ifaces
}
dad_duplicated_body()
@@ -172,8 +154,8 @@ dad_duplicated_body()
local localip2=10.0.1.11
local peerip=10.0.1.2
- atf_check -s exit:0 ${inetserver} $SOCKLOCAL
- atf_check -s exit:0 ${inetserver} $SOCKPEER
+ rump_server_start $SOCKLOCAL
+ rump_server_start $SOCKPEER
setup_server $SOCKLOCAL $localip1
setup_server $SOCKPEER $peerip
@@ -181,7 +163,7 @@ dad_duplicated_body()
export RUMP_SERVER=$SOCKLOCAL
# The primary address isn't marked as duplicated
- atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep $localip1 |grep -q duplicated"
+ atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep $localip1 |grep -iq duplicated"
#
# Add a new address duplicated with the peer server
@@ -190,50 +172,20 @@ dad_duplicated_body()
atf_check -s exit:0 sleep 1
# The new address is marked as duplicated
- atf_check -s exit:0 -x "rump.ifconfig shmif0 |grep $peerip |grep -q duplicated"
+ atf_check -s exit:0 -x "rump.ifconfig shmif0 |grep $peerip |grep -iq duplicated"
# A unique address isn't marked as duplicated
atf_check -s exit:0 rump.ifconfig shmif0 inet $localip2 alias
atf_check -s exit:0 sleep 1
- atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep $localip2 |grep -q duplicated"
-}
-
-cleanup()
-{
- env RUMP_SERVER=$SOCKLOCAL rump.halt
- env RUMP_SERVER=$SOCKPEER rump.halt
-}
-
-dump_local()
-{
- export RUMP_SERVER=$SOCKLOCAL
- rump.netstat -nr
- rump.arp -n -a
- rump.ifconfig
- $HIJACKING dmesg
-}
+ atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep $localip2 |grep -iq duplicated"
-dump_peer()
-{
- export RUMP_SERVER=$SOCKPEER
- rump.netstat -nr
- rump.arp -n -a
- rump.ifconfig
- $HIJACKING dmesg
-}
-
-dump()
-{
- dump_local
- dump_peer
- shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r -
+ rump_server_destroy_ifaces
}
dad_basic_cleanup()
{
- $DEBUG && dump_local
- $DEBUG && shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r -
- env RUMP_SERVER=$SOCKLOCAL rump.halt
+ $DEBUG && dump
+ cleanup
}
dad_duplicated_cleanup()
OpenPOWER on IntegriCloud