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?

Reply via email to