CVS commit: src/tests/net/if_bridge

2018-11-08 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Nov  9 06:45:03 UTC 2018

Modified Files:
src/tests/net/if_bridge: t_rtable.sh

Log Message:
Add a test to show a large number of MAC addresses cached in a bridge


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/net/if_bridge/t_rtable.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/net/if_bridge/t_rtable.sh
diff -u src/tests/net/if_bridge/t_rtable.sh:1.3 src/tests/net/if_bridge/t_rtable.sh:1.4
--- src/tests/net/if_bridge/t_rtable.sh:1.3	Wed Apr 18 04:03:12 2018
+++ src/tests/net/if_bridge/t_rtable.sh	Fri Nov  9 06:45:03 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: t_rtable.sh,v 1.3 2018/04/18 04:03:12 ozaki-r Exp $
+#	$NetBSD: t_rtable.sh,v 1.4 2018/11/09 06:45:03 ozaki-r Exp $
 #
 # Copyright (c) 2017 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -96,7 +96,7 @@ get_number_of_caches()
 
 	export RUMP_SERVER=$SOCK2
 	export LD_PRELOAD=/usr/lib/librumphijack.so
-	echo $(($(/sbin/brconfig bridge0 |grep -A 100 "Address cache" |wc -l) - 1))
+	echo $(/sbin/brconfig bridge0 addr |wc -l)
 	unset LD_PRELOAD
 }
 
@@ -441,6 +441,49 @@ bridge_rtable_delete_member_cleanup()
 }
 
 
+atf_test_case bridge_rtable_manyaddrs cleanup
+bridge_rtable_manyaddrs_head()
+{
+
+	atf_set "descr" "Tests brconfig addr under many MAC addresses"
+	atf_set "require.progs" "rump_server"
+}
+
+bridge_rtable_manyaddrs_body()
+{
+	local addr=
+
+	setup
+	setup_bridge
+
+	export RUMP_SERVER=$SOCK2
+	export LD_PRELOAD=/usr/lib/librumphijack.so
+	atf_check -s exit:0 -o ignore /sbin/brconfig bridge0 maxaddr 1024
+
+	# Fill the MAC addresses
+	for i in 1 2 3 4; do
+		for j in $(seq 0 255); do
+			addr="00:11:22:33:4$i:$(printf "%02x" $j)"
+			atf_check -s exit:0 -o empty \
+			/sbin/brconfig bridge0 static shmif0 $addr
+		done
+
+		n=$(get_number_of_caches)
+		atf_check_equal $n $((i * 256))
+	done
+
+
+	rump_server_destroy_ifaces
+}
+
+bridge_rtable_manyaddrs_cleanup()
+{
+
+	$DEBUG && dump
+	cleanup
+}
+
+
 atf_init_test_cases()
 {
 
@@ -449,5 +492,6 @@ atf_init_test_cases()
 	atf_add_test_case bridge_rtable_timeout
 	atf_add_test_case bridge_rtable_maxaddr
 	atf_add_test_case bridge_rtable_delete_member
+	atf_add_test_case bridge_rtable_manyaddrs
 	# TODO: brconfig static/flushall/discover/learn
 }



CVS commit: src/tests/net/if_bridge

2018-04-17 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Apr 18 04:03:12 UTC 2018

Modified Files:
src/tests/net/if_bridge: t_rtable.sh

Log Message:
Add a test that checks if brconfig flush surely removes all entries


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/net/if_bridge/t_rtable.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/net/if_bridge/t_rtable.sh
diff -u src/tests/net/if_bridge/t_rtable.sh:1.2 src/tests/net/if_bridge/t_rtable.sh:1.3
--- src/tests/net/if_bridge/t_rtable.sh:1.2	Tue Apr 10 07:09:00 2018
+++ src/tests/net/if_bridge/t_rtable.sh	Wed Apr 18 04:03:12 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: t_rtable.sh,v 1.2 2018/04/10 07:09:00 ozaki-r Exp $
+#	$NetBSD: t_rtable.sh,v 1.3 2018/04/18 04:03:12 ozaki-r Exp $
 #
 # Copyright (c) 2017 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -169,6 +169,7 @@ bridge_rtable_flush_head()
 bridge_rtable_flush_body()
 {
 	local addr1= addr3=
+	local n=
 
 	setup
 	setup_bridge
@@ -195,6 +196,34 @@ bridge_rtable_flush_body()
 	atf_check -s exit:0 -o not-match:"$addr3 shmif1" /sbin/brconfig bridge0
 	unset LD_PRELOAD
 
+	# Add extra interfaces and addresses
+	export RUMP_SERVER=$SOCK1
+	rump_server_add_iface $SOCK1 shmif1 bus1
+	atf_check -s exit:0 rump.ifconfig shmif1 10.0.0.11/24
+	atf_check -s exit:0 rump.ifconfig -w 10
+
+	export RUMP_SERVER=$SOCK3
+	rump_server_add_iface $SOCK3 shmif1 bus2
+	atf_check -s exit:0 rump.ifconfig shmif1 10.0.0.12/24
+	atf_check -s exit:0 rump.ifconfig -w 10
+
+	# Let cache entries
+	export RUMP_SERVER=$SOCK1
+	atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 10.0.0.12
+	export RUMP_SERVER=$SOCK3
+	atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 10.0.0.11
+
+	export RUMP_SERVER=$SOCK2
+	export LD_PRELOAD=/usr/lib/librumphijack.so
+	$DEBUG && /sbin/brconfig bridge0
+	n=$(get_number_of_caches)
+	atf_check_equal $n 4
+
+	atf_check -s exit:0 -o ignore /sbin/brconfig bridge0 flush
+	n=$(get_number_of_caches)
+	atf_check_equal $n 0
+	unset LD_PRELOAD
+
 	rump_server_destroy_ifaces
 }
 



CVS commit: src/tests/net/if_bridge

2018-04-10 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Apr 10 07:09:00 UTC 2018

Modified Files:
src/tests/net/if_bridge: t_rtable.sh

Log Message:
Add a test case for bridge_rtdelete


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/net/if_bridge/t_rtable.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/net/if_bridge/t_rtable.sh
diff -u src/tests/net/if_bridge/t_rtable.sh:1.1 src/tests/net/if_bridge/t_rtable.sh:1.2
--- src/tests/net/if_bridge/t_rtable.sh:1.1	Sat Mar 11 04:24:52 2017
+++ src/tests/net/if_bridge/t_rtable.sh	Tue Apr 10 07:09:00 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: t_rtable.sh,v 1.1 2017/03/11 04:24:52 ozaki-r Exp $
+#	$NetBSD: t_rtable.sh,v 1.2 2018/04/10 07:09:00 ozaki-r Exp $
 #
 # Copyright (c) 2017 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -342,6 +342,76 @@ bridge_rtable_maxaddr_cleanup()
 }
 
 
+atf_test_case bridge_rtable_delete_member cleanup
+bridge_rtable_delete_member_head()
+{
+
+	atf_set "descr" "Tests belonging rtable entries are removed on deleting an interface"
+	atf_set "require.progs" "rump_server"
+}
+
+bridge_rtable_delete_member_body()
+{
+	local addr10= addr30= addr11= addr31=
+	local n=
+
+	setup
+	setup_bridge
+
+	# Add extra interfaces and addresses
+	export RUMP_SERVER=$SOCK1
+	rump_server_add_iface $SOCK1 shmif1 bus1
+	atf_check -s exit:0 rump.ifconfig shmif1 10.0.0.11/24
+	atf_check -s exit:0 rump.ifconfig -w 10
+
+	export RUMP_SERVER=$SOCK3
+	rump_server_add_iface $SOCK3 shmif1 bus2
+	atf_check -s exit:0 rump.ifconfig shmif1 10.0.0.12/24
+	atf_check -s exit:0 rump.ifconfig -w 10
+
+	# Get MAC addresses of the endpoints.
+	addr10=$(get_macaddr $SOCK1 shmif0)
+	addr30=$(get_macaddr $SOCK3 shmif0)
+	addr11=$(get_macaddr $SOCK1 shmif1)
+	addr31=$(get_macaddr $SOCK3 shmif1)
+
+	# Make the bridge learn the MAC addresses of the endpoints.
+	export RUMP_SERVER=$SOCK1
+	atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 10.0.0.12
+	export RUMP_SERVER=$SOCK3
+	atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 10.0.0.11
+
+	export RUMP_SERVER=$SOCK2
+	export LD_PRELOAD=/usr/lib/librumphijack.so
+	$DEBUG && /sbin/brconfig bridge0
+	atf_check -s exit:0 -o match:"$addr10 shmif0" /sbin/brconfig bridge0
+	atf_check -s exit:0 -o match:"$addr11 shmif0" /sbin/brconfig bridge0
+	atf_check -s exit:0 -o match:"$addr30 shmif1" /sbin/brconfig bridge0
+	atf_check -s exit:0 -o match:"$addr31 shmif1" /sbin/brconfig bridge0
+
+	atf_check -s exit:0 -o ignore /sbin/brconfig bridge0 delete shmif0
+	atf_check -s exit:0 -o not-match:"$addr10 shmif0" /sbin/brconfig bridge0
+	atf_check -s exit:0 -o not-match:"$addr11 shmif0" /sbin/brconfig bridge0
+	atf_check -s exit:0 -o match:"$addr30 shmif1" /sbin/brconfig bridge0
+	atf_check -s exit:0 -o match:"$addr31 shmif1" /sbin/brconfig bridge0
+
+	atf_check -s exit:0 -o ignore /sbin/brconfig bridge0 delete shmif1
+	atf_check -s exit:0 -o not-match:"$addr10 shmif0" /sbin/brconfig bridge0
+	atf_check -s exit:0 -o not-match:"$addr11 shmif0" /sbin/brconfig bridge0
+	atf_check -s exit:0 -o not-match:"$addr30 shmif1" /sbin/brconfig bridge0
+	atf_check -s exit:0 -o not-match:"$addr31 shmif1" /sbin/brconfig bridge0
+
+	rump_server_destroy_ifaces
+}
+
+bridge_rtable_delete_member_cleanup()
+{
+
+	$DEBUG && dump
+	cleanup
+}
+
+
 atf_init_test_cases()
 {
 
@@ -349,5 +419,6 @@ atf_init_test_cases()
 	atf_add_test_case bridge_rtable_flush
 	atf_add_test_case bridge_rtable_timeout
 	atf_add_test_case bridge_rtable_maxaddr
+	atf_add_test_case bridge_rtable_delete_member
 	# TODO: brconfig static/flushall/discover/learn
 }



CVS commit: src/tests/net/if_bridge

2016-11-25 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Nov 25 08:10:50 UTC 2016

Modified Files:
src/tests/net/if_bridge: t_bridge.sh

Log Message:
Add $DEBUG and remove a unused function


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/tests/net/if_bridge/t_bridge.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/net/if_bridge/t_bridge.sh
diff -u src/tests/net/if_bridge/t_bridge.sh:1.14 src/tests/net/if_bridge/t_bridge.sh:1.15
--- src/tests/net/if_bridge/t_bridge.sh:1.14	Thu Nov 24 09:07:09 2016
+++ src/tests/net/if_bridge/t_bridge.sh	Fri Nov 25 08:10:50 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: t_bridge.sh,v 1.14 2016/11/24 09:07:09 ozaki-r Exp $
+#	$NetBSD: t_bridge.sh,v 1.15 2016/11/25 08:10:50 ozaki-r Exp $
 #
 # Copyright (c) 2014 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -44,6 +44,7 @@ IPBR2=10.0.0.12
 IP6BR1=fc00::11
 IP6BR2=fc00::12
 
+DEBUG=${DEBUG:-false}
 TIMEOUT=5
 
 atf_test_case bridge_ipv4 cleanup
@@ -99,7 +100,7 @@ setup_endpoint()
 	fi
 
 	atf_check -s exit:0 rump.ifconfig shmif0 up
-	rump.ifconfig shmif0
+	$DEBUG && rump.ifconfig shmif0
 }
 
 test_endpoint()
@@ -118,14 +119,6 @@ test_endpoint()
 	fi
 }
 
-show_endpoint()
-{
-	sock=${1}
-
-	export RUMP_SERVER=${sock}
-	rump.ifconfig -v shmif0
-}
-
 test_setup()
 {
 	test_endpoint $SOCK1 $IP1 bus1 ipv4
@@ -451,7 +444,7 @@ bridge_rtable_body()
 	# Confirm there is no MAC address caches.
 	export RUMP_SERVER=$SOCK2
 	export LD_PRELOAD=/usr/lib/librumphijack.so
-	/sbin/brconfig bridge0
+	$DEBUG && /sbin/brconfig bridge0
 	atf_check -s exit:0 -o not-match:"$addr1" /sbin/brconfig bridge0
 	atf_check -s exit:0 -o not-match:"$addr3" /sbin/brconfig bridge0
 	unset LD_PRELOAD
@@ -464,7 +457,7 @@ bridge_rtable_body()
 	# Tests the addresses are in the cache.
 	export RUMP_SERVER=$SOCK2
 	export LD_PRELOAD=/usr/lib/librumphijack.so
-	/sbin/brconfig bridge0
+	$DEBUG && /sbin/brconfig bridge0
 	atf_check -s exit:0 -o match:"$addr1 shmif0" /sbin/brconfig bridge0
 	atf_check -s exit:0 -o match:"$addr3 shmif1" /sbin/brconfig bridge0
 
@@ -481,7 +474,7 @@ bridge_rtable_body()
 	unset RUMP_SERVER
 	export RUMP_SERVER=$SOCK2
 	export LD_PRELOAD=/usr/lib/librumphijack.so
-	/sbin/brconfig bridge0
+	$DEBUG && /sbin/brconfig bridge0
 	atf_check -s exit:0 -o match:"$addr1 shmif0" /sbin/brconfig bridge0
 	atf_check -s exit:0 -o match:"$addr3 shmif1" /sbin/brconfig bridge0
 



CVS commit: src/tests/net/if_bridge

2016-08-10 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Wed Aug 10 22:37:07 UTC 2016

Modified Files:
src/tests/net/if_bridge: t_bridge.sh

Log Message:
+ -lrumpdev (and avoid doing stuff twice).


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/tests/net/if_bridge/t_bridge.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/net/if_bridge/t_bridge.sh
diff -u src/tests/net/if_bridge/t_bridge.sh:1.12 src/tests/net/if_bridge/t_bridge.sh:1.13
--- src/tests/net/if_bridge/t_bridge.sh:1.12	Tue Jun 21 05:04:16 2016
+++ src/tests/net/if_bridge/t_bridge.sh	Wed Aug 10 22:37:07 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: t_bridge.sh,v 1.12 2016/06/21 05:04:16 ozaki-r Exp $
+#	$NetBSD: t_bridge.sh,v 1.13 2016/08/10 22:37:07 kre Exp $
 #
 # Copyright (c) 2014 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -25,8 +25,12 @@
 # POSSIBILITY OF SUCH DAMAGE.
 #
 
-inetserver="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_bridge -lrumpnet_shmif"
-inet6server="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_netinet6 -lrumpnet_bridge -lrumpnet_shmif"
+libs1="-lrumpnet -lrumpnet_net -lrumpnet_netinet"
+libs2="-lrumpnet_bridge -lrumpnet_shmif -lrumpdev"
+libs6="-lrumpnet_netinet6"
+
+inetserver="rump_server ${libs1} ${libs2}"
+inet6server="rump_server ${libs1} ${libs6} ${libs2}"
 
 SOCK1=unix://commsock1
 SOCK2=unix://commsock2



CVS commit: src/tests/net/if_bridge

2015-07-23 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Jul 23 11:05:34 UTC 2015

Modified Files:
src/tests/net/if_bridge: t_bridge.sh

Log Message:
Reflect a fix for bridge

Due to PR 48104, some tests of ping/ping6 were failed but the tests now
should be successful. So reverse atf_check.

Bonus: the fix for PR 48104 also fixes another uknown failure.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/net/if_bridge/t_bridge.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/net/if_bridge/t_bridge.sh
diff -u src/tests/net/if_bridge/t_bridge.sh:1.9 src/tests/net/if_bridge/t_bridge.sh:1.10
--- src/tests/net/if_bridge/t_bridge.sh:1.9	Wed Jun 10 03:29:37 2015
+++ src/tests/net/if_bridge/t_bridge.sh	Thu Jul 23 11:05:34 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: t_bridge.sh,v 1.9 2015/06/10 03:29:37 ozaki-r Exp $
+#	$NetBSD: t_bridge.sh,v 1.10 2015/07/23 11:05:34 ozaki-r Exp $
 #
 # Copyright (c) 2014 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -319,14 +319,14 @@ test_ping_member()
 	rump.ifconfig -v shmif0
 	atf_check -s exit:0 -o ignore rump.ping -q -n -w $TIMEOUT -c 1 $IPBR1
 	rump.ifconfig -v shmif0
-	# It's known to fail. See PR#48104
-	atf_check -s not-exit:0 -o ignore rump.ping -q -n -w $TIMEOUT -c 1 $IPBR2
+	# Test for PR#48104
+	atf_check -s exit:0 -o ignore rump.ping -q -n -w $TIMEOUT -c 1 $IPBR2
 	rump.ifconfig -v shmif0
 
 	export RUMP_SERVER=$SOCK3
 	rump.ifconfig -v shmif0
-	# It's known to fail. See PR#48104
-	atf_check -s not-exit:0 -o ignore rump.ping -q -n -w $TIMEOUT -c 1 $IPBR1
+	# Test for PR#48104
+	atf_check -s exit:0 -o ignore rump.ping -q -n -w $TIMEOUT -c 1 $IPBR1
 	rump.ifconfig -v shmif0
 	atf_check -s exit:0 -o ignore rump.ping -q -n -w $TIMEOUT -c 1 $IPBR2
 	rump.ifconfig -v shmif0
@@ -340,16 +340,15 @@ test_ping6_member()
 	rump.ifconfig -v shmif0
 	atf_check -s exit:0 -o ignore ping6 -q -n -X $TIMEOUT -c 1 $IP6BR1
 	rump.ifconfig -v shmif0
-	# It's known to fail. See PR#48104
-	atf_check -s not-exit:0 -o ignore ping6 -q -n -X $TIMEOUT -c 1 $IP6BR2
+	# Test for PR#48104
+	atf_check -s exit:0 -o ignore ping6 -q -n -X $TIMEOUT -c 1 $IP6BR2
 	rump.ifconfig -v shmif0
 
 	export RUMP_SERVER=$SOCK3
 	rump.ifconfig -v shmif0
-	# It's known to fail. See PR#48104
-	atf_check -s not-exit:0 -o ignore ping6 -q -n -X $TIMEOUT -c 1 $IP6BR1
+	# Test for PR#48104
+	atf_check -s exit:0 -o ignore ping6 -q -n -X $TIMEOUT -c 1 $IP6BR1
 	rump.ifconfig -v shmif0
-	# FIXME: it doesn't work for some reason
 	atf_check -s exit:0 -o ignore ping6 -q -n -X $TIMEOUT -c 1 $IP6BR2
 	rump.ifconfig -v shmif0
 



CVS commit: src/tests/net/if_bridge

2015-06-09 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Jun 10 03:29:37 UTC 2015

Modified Files:
src/tests/net/if_bridge: t_bridge.sh

Log Message:
Add missing cleanup


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/net/if_bridge/t_bridge.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/net/if_bridge/t_bridge.sh
diff -u src/tests/net/if_bridge/t_bridge.sh:1.8 src/tests/net/if_bridge/t_bridge.sh:1.9
--- src/tests/net/if_bridge/t_bridge.sh:1.8	Tue Jun  9 00:39:53 2015
+++ src/tests/net/if_bridge/t_bridge.sh	Wed Jun 10 03:29:37 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: t_bridge.sh,v 1.8 2015/06/09 00:39:53 ozaki-r Exp $
+#	$NetBSD: t_bridge.sh,v 1.9 2015/06/10 03:29:37 ozaki-r Exp $
 #
 # Copyright (c) 2014 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -45,6 +45,8 @@ TIMEOUT=5
 atf_test_case basic cleanup
 atf_test_case basic6 cleanup
 atf_test_case rtable cleanup
+atf_test_case member_ip cleanup
+atf_test_case member_ip6 cleanup
 
 basic_head()
 {



CVS commit: src/tests/net/if_bridge

2015-06-08 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Jun  9 00:39:53 UTC 2015

Modified Files:
src/tests/net/if_bridge: t_bridge.sh

Log Message:
Add tests for bridge members with an IP address

The tests include checks for PR#48104 which is not fixed yet.

Note that one test unexpectedly fails for some reason
(unrelated to PR#48104). We have to fix it somehow.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/net/if_bridge/t_bridge.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/net/if_bridge/t_bridge.sh
diff -u src/tests/net/if_bridge/t_bridge.sh:1.7 src/tests/net/if_bridge/t_bridge.sh:1.8
--- src/tests/net/if_bridge/t_bridge.sh:1.7	Fri May 29 10:08:52 2015
+++ src/tests/net/if_bridge/t_bridge.sh	Tue Jun  9 00:39:53 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: t_bridge.sh,v 1.7 2015/05/29 10:08:52 ozaki-r Exp $
+#	$NetBSD: t_bridge.sh,v 1.8 2015/06/09 00:39:53 ozaki-r Exp $
 #
 # Copyright (c) 2014 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -35,6 +35,10 @@ IP1=10.0.0.1
 IP2=10.0.0.2
 IP61=fc00::1
 IP62=fc00::2
+IPBR1=10.0.0.11
+IPBR2=10.0.0.12
+IP6BR1=fc00::11
+IP6BR2=fc00::12
 
 TIMEOUT=5
 
@@ -60,6 +64,18 @@ rtable_head()
 	atf_set require.progs rump_server
 }
 
+member_ip_head()
+{
+	atf_set descr Tests if_bridge with members with an IP address
+	atf_set require.progs rump_server
+}
+
+member_ip6_head()
+{
+	atf_set descr Tests if_bridge with members with an IP address (IPv6)
+	atf_set require.progs rump_server
+}
+
 setup_endpoint()
 {
 	sock=${1}
@@ -175,6 +191,32 @@ setup_bridge()
 	rump.ifconfig shmif1
 }
 
+setup_member_ip()
+{
+	export RUMP_SERVER=$SOCK2
+	export LD_PRELOAD=/usr/lib/librumphijack.so
+	atf_check -s exit:0 rump.ifconfig shmif0 $IPBR1/24
+	atf_check -s exit:0 rump.ifconfig shmif1 $IPBR2/24
+	atf_check -s exit:0 rump.ifconfig -w 10
+	/sbin/brconfig bridge0
+	unset LD_PRELOAD
+	rump.ifconfig shmif0
+	rump.ifconfig shmif1
+}
+
+setup_member_ip6()
+{
+	export RUMP_SERVER=$SOCK2
+	export LD_PRELOAD=/usr/lib/librumphijack.so
+	atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6BR1
+	atf_check -s exit:0 rump.ifconfig shmif1 inet6 $IP6BR2
+	atf_check -s exit:0 rump.ifconfig -w 10
+	/sbin/brconfig bridge0
+	unset LD_PRELOAD
+	rump.ifconfig shmif0
+	rump.ifconfig shmif1
+}
+
 teardown_bridge()
 {
 	export RUMP_SERVER=$SOCK2
@@ -269,6 +311,49 @@ test_ping6_success()
 	rump.ifconfig -v shmif0
 }
 
+test_ping_member()
+{
+	export RUMP_SERVER=$SOCK1
+	rump.ifconfig -v shmif0
+	atf_check -s exit:0 -o ignore rump.ping -q -n -w $TIMEOUT -c 1 $IPBR1
+	rump.ifconfig -v shmif0
+	# It's known to fail. See PR#48104
+	atf_check -s not-exit:0 -o ignore rump.ping -q -n -w $TIMEOUT -c 1 $IPBR2
+	rump.ifconfig -v shmif0
+
+	export RUMP_SERVER=$SOCK3
+	rump.ifconfig -v shmif0
+	# It's known to fail. See PR#48104
+	atf_check -s not-exit:0 -o ignore rump.ping -q -n -w $TIMEOUT -c 1 $IPBR1
+	rump.ifconfig -v shmif0
+	atf_check -s exit:0 -o ignore rump.ping -q -n -w $TIMEOUT -c 1 $IPBR2
+	rump.ifconfig -v shmif0
+}
+
+test_ping6_member()
+{
+	export LD_PRELOAD=/usr/lib/librumphijack.so
+
+	export RUMP_SERVER=$SOCK1
+	rump.ifconfig -v shmif0
+	atf_check -s exit:0 -o ignore ping6 -q -n -X $TIMEOUT -c 1 $IP6BR1
+	rump.ifconfig -v shmif0
+	# It's known to fail. See PR#48104
+	atf_check -s not-exit:0 -o ignore ping6 -q -n -X $TIMEOUT -c 1 $IP6BR2
+	rump.ifconfig -v shmif0
+
+	export RUMP_SERVER=$SOCK3
+	rump.ifconfig -v shmif0
+	# It's known to fail. See PR#48104
+	atf_check -s not-exit:0 -o ignore ping6 -q -n -X $TIMEOUT -c 1 $IP6BR1
+	rump.ifconfig -v shmif0
+	# FIXME: it doesn't work for some reason
+	atf_check -s exit:0 -o ignore ping6 -q -n -X $TIMEOUT -c 1 $IP6BR2
+	rump.ifconfig -v shmif0
+
+	unset LD_PRELOAD
+}
+
 get_number_of_caches()
 {
 	export RUMP_SERVER=$SOCK2
@@ -435,6 +520,45 @@ rtable_body()
 	#   wait here so long. Should we have a sysctl to change the period?
 }
 
+member_ip_body()
+{
+	setup
+	test_setup
+
+	# Enable once PR kern/49219 is fixed
+	#test_ping_failure
+
+	setup_bridge
+	sleep 1
+	test_setup_bridge
+	test_ping_success
+
+	setup_member_ip
+	test_ping_member
+
+	teardown_bridge
+	test_ping_failure
+}
+
+member_ip6_body()
+{
+	setup6
+	test_setup6
+
+	test_ping6_failure
+
+	setup_bridge
+	sleep 1
+	test_setup_bridge
+	test_ping6_success
+
+	setup_member_ip6
+	test_ping6_member
+
+	teardown_bridge
+	test_ping6_failure
+}
+
 basic_cleanup()
 {
 	dump_bus
@@ -453,9 +577,23 @@ rtable_cleanup()
 	cleanup
 }
 
+member_ip_cleanup()
+{
+	dump_bus
+	cleanup
+}
+
+member_ip6_cleanup()
+{
+	dump_bus
+	cleanup
+}
+
 atf_init_test_cases()
 {
 	atf_add_test_case basic
 	atf_add_test_case basic6
 	atf_add_test_case rtable
+	atf_add_test_case member_ip
+	atf_add_test_case member_ip6
 }



CVS commit: src/tests/net/if_bridge

2015-05-28 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri May 29 01:54:56 UTC 2015

Modified Files:
src/tests/net/if_bridge: t_bridge.sh

Log Message:
Get rid of unnecessary shebang

It will be added when it's built.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/net/if_bridge/t_bridge.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/net/if_bridge/t_bridge.sh
diff -u src/tests/net/if_bridge/t_bridge.sh:1.4 src/tests/net/if_bridge/t_bridge.sh:1.5
--- src/tests/net/if_bridge/t_bridge.sh:1.4	Sat May 16 14:29:37 2015
+++ src/tests/net/if_bridge/t_bridge.sh	Fri May 29 01:54:56 2015
@@ -1,5 +1,4 @@
-#! /usr/bin/atf-sh
-#	$NetBSD: t_bridge.sh,v 1.4 2015/05/16 14:29:37 ozaki-r Exp $
+#	$NetBSD: t_bridge.sh,v 1.5 2015/05/29 01:54:56 ozaki-r Exp $
 #
 # Copyright (c) 2014 The NetBSD Foundation, Inc.
 # All rights reserved.



CVS commit: src/tests/net/if_bridge

2015-01-07 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Jan  7 08:55:01 UTC 2015

Modified Files:
src/tests/net/if_bridge: t_bridge.sh

Log Message:
Add some tests for rtable operations of if_bridge


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/net/if_bridge/t_bridge.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/net/if_bridge/t_bridge.sh
diff -u src/tests/net/if_bridge/t_bridge.sh:1.1 src/tests/net/if_bridge/t_bridge.sh:1.2
--- src/tests/net/if_bridge/t_bridge.sh:1.1	Thu Sep 18 15:13:27 2014
+++ src/tests/net/if_bridge/t_bridge.sh	Wed Jan  7 08:55:01 2015
@@ -1,5 +1,5 @@
 #! /usr/bin/atf-sh
-#	$NetBSD: t_bridge.sh,v 1.1 2014/09/18 15:13:27 ozaki-r Exp $
+#	$NetBSD: t_bridge.sh,v 1.2 2015/01/07 08:55:01 ozaki-r Exp $
 #
 # Copyright (c) 2014 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -39,6 +39,7 @@ IP62=fc00::2
 
 atf_test_case basic cleanup
 atf_test_case basic6 cleanup
+atf_test_case rtable cleanup
 
 basic_head()
 {
@@ -52,6 +53,12 @@ basic6_head()
 	atf_set require.progs rump_server
 }
 
+rtable_head()
+{
+	atf_set descr Tests route table operations of if_bridge
+	atf_set require.progs rump_server
+}
+
 setup_endpoint()
 {
 	sock=${1}
@@ -293,6 +300,76 @@ basic6_body()
 	#test_ping6_failure
 }
 
+rtable_body()
+{
+	addr1= addr3=
+
+	setup
+	setup_bridge
+
+	# Get MAC addresses of the endpoints.
+	export RUMP_SERVER=$SOCK1
+	addr1=$(rump.ifconfig shmif0 |awk '/address:/ { print $2;}')
+	export RUMP_SERVER=$SOCK3
+	addr3=$(rump.ifconfig shmif0 |awk '/address:/ { print $2;}')
+	unset RUMP_SERVER
+
+	# Confirm there is no MAC address caches.
+	export RUMP_SERVER=$SOCK2
+	export LD_PRELOAD=/usr/lib/librumphijack.so
+	/sbin/brconfig bridge0
+	atf_check -s exit:0 -o not-match:$addr1 /sbin/brconfig bridge0
+	atf_check -s exit:0 -o not-match:$addr3 /sbin/brconfig bridge0
+	unset LD_PRELOAD
+
+	# Make the bridge learn the MAC addresses of the endpoints.
+	export RUMP_SERVER=$SOCK1
+	atf_check -s exit:0 -o ignore rump.ping -n -w 1 -c 1 $IP2
+	unset RUMP_SERVER
+
+	# Tests the addresses are in the cache.
+	export RUMP_SERVER=$SOCK2
+	export LD_PRELOAD=/usr/lib/librumphijack.so
+	/sbin/brconfig bridge0
+	atf_check -s exit:0 -o match:$addr1 shmif0 /sbin/brconfig bridge0
+	atf_check -s exit:0 -o match:$addr3 shmif1 /sbin/brconfig bridge0
+
+	# Tests brconfig deladdr
+	atf_check -s exit:0 -o ignore /sbin/brconfig bridge0 deladdr $addr1
+	atf_check -s exit:0 -o not-match:$addr1 shmif0 /sbin/brconfig bridge0
+	atf_check -s exit:0 -o ignore /sbin/brconfig bridge0 deladdr $addr3
+	atf_check -s exit:0 -o not-match:$addr3 shmif1 /sbin/brconfig bridge0
+	unset LD_PRELOAD
+
+	# Refill the MAC addresses of the endpoints.
+	export RUMP_SERVER=$SOCK1
+	atf_check -s exit:0 -o ignore rump.ping -n -w 1 -c 1 $IP2
+	unset RUMP_SERVER
+	export RUMP_SERVER=$SOCK2
+	export LD_PRELOAD=/usr/lib/librumphijack.so
+	/sbin/brconfig bridge0
+	atf_check -s exit:0 -o match:$addr1 shmif0 /sbin/brconfig bridge0
+	atf_check -s exit:0 -o match:$addr3 shmif1 /sbin/brconfig bridge0
+
+	# Tests brconfig flush.
+	atf_check -s exit:0 -o ignore /sbin/brconfig bridge0 flush
+	atf_check -s exit:0 -o not-match:$addr1 shmif0 /sbin/brconfig bridge0
+	atf_check -s exit:0 -o not-match:$addr3 shmif1 /sbin/brconfig bridge0
+	unset LD_PRELOAD
+
+	# Tests brconfig timeout.
+	export RUMP_SERVER=$SOCK2
+	export LD_PRELOAD=/usr/lib/librumphijack.so
+	atf_check -s exit:0 -o match:timeout: 1200 /sbin/brconfig bridge0
+	atf_check -s exit:0 -o ignore /sbin/brconfig bridge0 timeout 10
+	atf_check -s exit:0 -o match:timeout: 10 /sbin/brconfig bridge0
+	unset LD_PRELOAD
+
+	# TODO: brconfig static/flushall/discover/learn
+	# TODO: cache expiration; it takes 5 minutes at least and we want to
+	#   wait here so long. Should we have a sysctl to change the period?
+}
+
 basic_cleanup()
 {
 	dump_bus
@@ -305,8 +382,15 @@ basic6_cleanup()
 	cleanup
 }
 
+rtable_cleanup()
+{
+	dump_bus
+	cleanup
+}
+
 atf_init_test_cases()
 {
 	atf_add_test_case basic
 	atf_add_test_case basic6
+	atf_add_test_case rtable
 }



CVS commit: src/tests/net/if_bridge

2015-01-07 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Jan  8 06:33:11 UTC 2015

Modified Files:
src/tests/net/if_bridge: t_bridge.sh

Log Message:
Add tests for brconfig maxaddr


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/net/if_bridge/t_bridge.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/net/if_bridge/t_bridge.sh
diff -u src/tests/net/if_bridge/t_bridge.sh:1.2 src/tests/net/if_bridge/t_bridge.sh:1.3
--- src/tests/net/if_bridge/t_bridge.sh:1.2	Wed Jan  7 08:55:01 2015
+++ src/tests/net/if_bridge/t_bridge.sh	Thu Jan  8 06:33:11 2015
@@ -1,5 +1,5 @@
 #! /usr/bin/atf-sh
-#	$NetBSD: t_bridge.sh,v 1.2 2015/01/07 08:55:01 ozaki-r Exp $
+#	$NetBSD: t_bridge.sh,v 1.3 2015/01/08 06:33:11 ozaki-r Exp $
 #
 # Copyright (c) 2014 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -268,6 +268,66 @@ test_ping6_success()
 	rump.ifconfig -v shmif0
 }
 
+get_number_of_caches()
+{
+	export RUMP_SERVER=$SOCK2
+	export LD_PRELOAD=/usr/lib/librumphijack.so
+	echo $(($(/sbin/brconfig bridge0 |grep -A 100 Address cache |wc -l) - 1))
+	unset LD_PRELOAD
+}
+
+test_brconfig_maxaddr()
+{
+	addr1= addr3= n=
+
+	# Get MAC addresses of the endpoints.
+	export RUMP_SERVER=$SOCK1
+	addr1=$(rump.ifconfig shmif0 |awk '/address:/ { print $2;}')
+	export RUMP_SERVER=$SOCK3
+	addr3=$(rump.ifconfig shmif0 |awk '/address:/ { print $2;}')
+	unset RUMP_SERVER
+
+	# Refill the MAC addresses of the endpoints.
+	export RUMP_SERVER=$SOCK1
+	atf_check -s exit:0 -o ignore rump.ping -n -w 1 -c 1 $IP2
+	export RUMP_SERVER=$SOCK2
+	export LD_PRELOAD=/usr/lib/librumphijack.so
+	/sbin/brconfig bridge0
+	atf_check -s exit:0 -o match:$addr1 shmif0 /sbin/brconfig bridge0
+	atf_check -s exit:0 -o match:$addr3 shmif1 /sbin/brconfig bridge0
+
+	# Check the default # of caches is 100
+	atf_check -s exit:0 -o match:max cache: 100 /sbin/brconfig bridge0
+
+	# Test two MAC addresses are cached
+	n=$(get_number_of_caches)
+	atf_check_equal $n 2
+
+	# Limit # of caches to one
+	atf_check -s exit:0 -o ignore /sbin/brconfig bridge0 maxaddr 1
+	atf_check -s exit:0 -o match:max cache: 1 /sbin/brconfig bridge0
+	/sbin/brconfig bridge0
+
+	# Test just one address is cached
+	n=$(get_number_of_caches)
+	atf_check_equal $n 1
+
+	# Increase # of caches to two
+	atf_check -s exit:0 -o ignore /sbin/brconfig bridge0 maxaddr 2
+	atf_check -s exit:0 -o match:max cache: 2 /sbin/brconfig bridge0
+	unset LD_PRELOAD
+
+	# Test we can cache two addresses again
+	export RUMP_SERVER=$SOCK1
+	atf_check -s exit:0 -o ignore rump.ping -n -w 1 -c 1 $IP2
+	export RUMP_SERVER=$SOCK2
+	export LD_PRELOAD=/usr/lib/librumphijack.so
+	/sbin/brconfig bridge0
+	atf_check -s exit:0 -o match:$addr1 shmif0 /sbin/brconfig bridge0
+	atf_check -s exit:0 -o match:$addr3 shmif1 /sbin/brconfig bridge0
+	unset LD_PRELOAD
+}
+
 basic_body()
 {
 	setup
@@ -365,6 +425,9 @@ rtable_body()
 	atf_check -s exit:0 -o match:timeout: 10 /sbin/brconfig bridge0
 	unset LD_PRELOAD
 
+	# Tests brconfig maxaddr.
+	test_brconfig_maxaddr
+
 	# TODO: brconfig static/flushall/discover/learn
 	# TODO: cache expiration; it takes 5 minutes at least and we want to
 	#   wait here so long. Should we have a sysctl to change the period?