xref: /minix3/tests/net/if_bridge/t_bridge.sh (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc#	$NetBSD: t_bridge.sh,v 1.11 2015/08/07 00:50:12 ozaki-r Exp $
2*0a6a1f1dSLionel Sambuc#
3*0a6a1f1dSLionel Sambuc# Copyright (c) 2014 The NetBSD Foundation, Inc.
4*0a6a1f1dSLionel Sambuc# All rights reserved.
5*0a6a1f1dSLionel Sambuc#
6*0a6a1f1dSLionel Sambuc# Redistribution and use in source and binary forms, with or without
7*0a6a1f1dSLionel Sambuc# modification, are permitted provided that the following conditions
8*0a6a1f1dSLionel Sambuc# are met:
9*0a6a1f1dSLionel Sambuc# 1. Redistributions of source code must retain the above copyright
10*0a6a1f1dSLionel Sambuc#    notice, this list of conditions and the following disclaimer.
11*0a6a1f1dSLionel Sambuc# 2. Redistributions in binary form must reproduce the above copyright
12*0a6a1f1dSLionel Sambuc#    notice, this list of conditions and the following disclaimer in the
13*0a6a1f1dSLionel Sambuc#    documentation and/or other materials provided with the distribution.
14*0a6a1f1dSLionel Sambuc#
15*0a6a1f1dSLionel Sambuc# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16*0a6a1f1dSLionel Sambuc# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17*0a6a1f1dSLionel Sambuc# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18*0a6a1f1dSLionel Sambuc# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19*0a6a1f1dSLionel Sambuc# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20*0a6a1f1dSLionel Sambuc# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21*0a6a1f1dSLionel Sambuc# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22*0a6a1f1dSLionel Sambuc# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23*0a6a1f1dSLionel Sambuc# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24*0a6a1f1dSLionel Sambuc# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25*0a6a1f1dSLionel Sambuc# POSSIBILITY OF SUCH DAMAGE.
26*0a6a1f1dSLionel Sambuc#
27*0a6a1f1dSLionel Sambuc
28*0a6a1f1dSLionel Sambucinetserver="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_bridge -lrumpnet_shmif"
29*0a6a1f1dSLionel Sambucinet6server="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_netinet6 -lrumpnet_bridge -lrumpnet_shmif"
30*0a6a1f1dSLionel Sambuc
31*0a6a1f1dSLionel SambucSOCK1=unix://commsock1
32*0a6a1f1dSLionel SambucSOCK2=unix://commsock2
33*0a6a1f1dSLionel SambucSOCK3=unix://commsock3
34*0a6a1f1dSLionel SambucIP1=10.0.0.1
35*0a6a1f1dSLionel SambucIP2=10.0.0.2
36*0a6a1f1dSLionel SambucIP61=fc00::1
37*0a6a1f1dSLionel SambucIP62=fc00::2
38*0a6a1f1dSLionel SambucIPBR1=10.0.0.11
39*0a6a1f1dSLionel SambucIPBR2=10.0.0.12
40*0a6a1f1dSLionel SambucIP6BR1=fc00::11
41*0a6a1f1dSLionel SambucIP6BR2=fc00::12
42*0a6a1f1dSLionel Sambuc
43*0a6a1f1dSLionel SambucTIMEOUT=5
44*0a6a1f1dSLionel Sambuc
45*0a6a1f1dSLionel Sambucatf_test_case basic cleanup
46*0a6a1f1dSLionel Sambucatf_test_case basic6 cleanup
47*0a6a1f1dSLionel Sambucatf_test_case rtable cleanup
48*0a6a1f1dSLionel Sambucatf_test_case member_ip cleanup
49*0a6a1f1dSLionel Sambucatf_test_case member_ip6 cleanup
50*0a6a1f1dSLionel Sambuc
51*0a6a1f1dSLionel Sambucbasic_head()
52*0a6a1f1dSLionel Sambuc{
53*0a6a1f1dSLionel Sambuc	atf_set "descr" "Does simple if_bridge tests"
54*0a6a1f1dSLionel Sambuc	atf_set "require.progs" "rump_server"
55*0a6a1f1dSLionel Sambuc}
56*0a6a1f1dSLionel Sambuc
57*0a6a1f1dSLionel Sambucbasic6_head()
58*0a6a1f1dSLionel Sambuc{
59*0a6a1f1dSLionel Sambuc	atf_set "descr" "Does simple if_bridge tests (IPv6)"
60*0a6a1f1dSLionel Sambuc	atf_set "require.progs" "rump_server"
61*0a6a1f1dSLionel Sambuc}
62*0a6a1f1dSLionel Sambuc
63*0a6a1f1dSLionel Sambucrtable_head()
64*0a6a1f1dSLionel Sambuc{
65*0a6a1f1dSLionel Sambuc	atf_set "descr" "Tests route table operations of if_bridge"
66*0a6a1f1dSLionel Sambuc	atf_set "require.progs" "rump_server"
67*0a6a1f1dSLionel Sambuc}
68*0a6a1f1dSLionel Sambuc
69*0a6a1f1dSLionel Sambucmember_ip_head()
70*0a6a1f1dSLionel Sambuc{
71*0a6a1f1dSLionel Sambuc	atf_set "descr" "Tests if_bridge with members with an IP address"
72*0a6a1f1dSLionel Sambuc	atf_set "require.progs" "rump_server"
73*0a6a1f1dSLionel Sambuc}
74*0a6a1f1dSLionel Sambuc
75*0a6a1f1dSLionel Sambucmember_ip6_head()
76*0a6a1f1dSLionel Sambuc{
77*0a6a1f1dSLionel Sambuc	atf_set "descr" "Tests if_bridge with members with an IP address (IPv6)"
78*0a6a1f1dSLionel Sambuc	atf_set "require.progs" "rump_server"
79*0a6a1f1dSLionel Sambuc}
80*0a6a1f1dSLionel Sambuc
81*0a6a1f1dSLionel Sambucsetup_endpoint()
82*0a6a1f1dSLionel Sambuc{
83*0a6a1f1dSLionel Sambuc	sock=${1}
84*0a6a1f1dSLionel Sambuc	addr=${2}
85*0a6a1f1dSLionel Sambuc	bus=${3}
86*0a6a1f1dSLionel Sambuc	mode=${4}
87*0a6a1f1dSLionel Sambuc
88*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=${sock}
89*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 rump.ifconfig shmif0 create
90*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 rump.ifconfig shmif0 linkstr ${bus}
91*0a6a1f1dSLionel Sambuc	if [ $mode = "ipv6" ]; then
92*0a6a1f1dSLionel Sambuc		atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${addr}
93*0a6a1f1dSLionel Sambuc	else
94*0a6a1f1dSLionel Sambuc		atf_check -s exit:0 rump.ifconfig shmif0 inet ${addr} netmask 0xffffff00
95*0a6a1f1dSLionel Sambuc	fi
96*0a6a1f1dSLionel Sambuc
97*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 rump.ifconfig shmif0 up
98*0a6a1f1dSLionel Sambuc	rump.ifconfig shmif0
99*0a6a1f1dSLionel Sambuc}
100*0a6a1f1dSLionel Sambuc
101*0a6a1f1dSLionel Sambuctest_endpoint()
102*0a6a1f1dSLionel Sambuc{
103*0a6a1f1dSLionel Sambuc	sock=${1}
104*0a6a1f1dSLionel Sambuc	addr=${2}
105*0a6a1f1dSLionel Sambuc	bus=${3}
106*0a6a1f1dSLionel Sambuc	mode=${4}
107*0a6a1f1dSLionel Sambuc
108*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=${sock}
109*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o match:shmif0 rump.ifconfig
110*0a6a1f1dSLionel Sambuc	if [ $mode = "ipv6" ]; then
111*0a6a1f1dSLionel Sambuc		atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT ${addr}
112*0a6a1f1dSLionel Sambuc	else
113*0a6a1f1dSLionel Sambuc		atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 ${addr}
114*0a6a1f1dSLionel Sambuc	fi
115*0a6a1f1dSLionel Sambuc}
116*0a6a1f1dSLionel Sambuc
117*0a6a1f1dSLionel Sambucshow_endpoint()
118*0a6a1f1dSLionel Sambuc{
119*0a6a1f1dSLionel Sambuc	sock=${1}
120*0a6a1f1dSLionel Sambuc
121*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=${sock}
122*0a6a1f1dSLionel Sambuc	rump.ifconfig -v shmif0
123*0a6a1f1dSLionel Sambuc}
124*0a6a1f1dSLionel Sambuc
125*0a6a1f1dSLionel Sambuctest_setup()
126*0a6a1f1dSLionel Sambuc{
127*0a6a1f1dSLionel Sambuc	test_endpoint $SOCK1 $IP1 bus1 ipv4
128*0a6a1f1dSLionel Sambuc	test_endpoint $SOCK3 $IP2 bus2 ipv4
129*0a6a1f1dSLionel Sambuc
130*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK2
131*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o match:shmif0 rump.ifconfig
132*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o match:shmif1 rump.ifconfig
133*0a6a1f1dSLionel Sambuc}
134*0a6a1f1dSLionel Sambuc
135*0a6a1f1dSLionel Sambuctest_setup6()
136*0a6a1f1dSLionel Sambuc{
137*0a6a1f1dSLionel Sambuc	test_endpoint $SOCK1 $IP61 bus1 ipv6
138*0a6a1f1dSLionel Sambuc	test_endpoint $SOCK3 $IP62 bus2 ipv6
139*0a6a1f1dSLionel Sambuc
140*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK2
141*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o match:shmif0 rump.ifconfig
142*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o match:shmif1 rump.ifconfig
143*0a6a1f1dSLionel Sambuc}
144*0a6a1f1dSLionel Sambuc
145*0a6a1f1dSLionel Sambucsetup_bridge_server()
146*0a6a1f1dSLionel Sambuc{
147*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK2
148*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 rump.ifconfig shmif0 create
149*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1
150*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 rump.ifconfig shmif0 up
151*0a6a1f1dSLionel Sambuc
152*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 rump.ifconfig shmif1 create
153*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 rump.ifconfig shmif1 linkstr bus2
154*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 rump.ifconfig shmif1 up
155*0a6a1f1dSLionel Sambuc}
156*0a6a1f1dSLionel Sambuc
157*0a6a1f1dSLionel Sambucsetup()
158*0a6a1f1dSLionel Sambuc{
159*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 ${inetserver} $SOCK1
160*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 ${inetserver} $SOCK2
161*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 ${inetserver} $SOCK3
162*0a6a1f1dSLionel Sambuc
163*0a6a1f1dSLionel Sambuc	setup_endpoint $SOCK1 $IP1 bus1 ipv4
164*0a6a1f1dSLionel Sambuc	setup_endpoint $SOCK3 $IP2 bus2 ipv4
165*0a6a1f1dSLionel Sambuc	setup_bridge_server
166*0a6a1f1dSLionel Sambuc}
167*0a6a1f1dSLionel Sambuc
168*0a6a1f1dSLionel Sambucsetup6()
169*0a6a1f1dSLionel Sambuc{
170*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 ${inet6server} $SOCK1
171*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 ${inet6server} $SOCK2
172*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 ${inet6server} $SOCK3
173*0a6a1f1dSLionel Sambuc
174*0a6a1f1dSLionel Sambuc	setup_endpoint $SOCK1 $IP61 bus1 ipv6
175*0a6a1f1dSLionel Sambuc	setup_endpoint $SOCK3 $IP62 bus2 ipv6
176*0a6a1f1dSLionel Sambuc	setup_bridge_server
177*0a6a1f1dSLionel Sambuc}
178*0a6a1f1dSLionel Sambuc
179*0a6a1f1dSLionel Sambucsetup_bridge()
180*0a6a1f1dSLionel Sambuc{
181*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK2
182*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 rump.ifconfig bridge0 create
183*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 rump.ifconfig bridge0 up
184*0a6a1f1dSLionel Sambuc
185*0a6a1f1dSLionel Sambuc	export LD_PRELOAD=/usr/lib/librumphijack.so
186*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 /sbin/brconfig bridge0 add shmif0
187*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 /sbin/brconfig bridge0 add shmif1
188*0a6a1f1dSLionel Sambuc	/sbin/brconfig bridge0
189*0a6a1f1dSLionel Sambuc	unset LD_PRELOAD
190*0a6a1f1dSLionel Sambuc	rump.ifconfig shmif0
191*0a6a1f1dSLionel Sambuc	rump.ifconfig shmif1
192*0a6a1f1dSLionel Sambuc}
193*0a6a1f1dSLionel Sambuc
194*0a6a1f1dSLionel Sambucsetup_member_ip()
195*0a6a1f1dSLionel Sambuc{
196*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK2
197*0a6a1f1dSLionel Sambuc	export LD_PRELOAD=/usr/lib/librumphijack.so
198*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 rump.ifconfig shmif0 $IPBR1/24
199*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 rump.ifconfig shmif1 $IPBR2/24
200*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 rump.ifconfig -w 10
201*0a6a1f1dSLionel Sambuc	/sbin/brconfig bridge0
202*0a6a1f1dSLionel Sambuc	unset LD_PRELOAD
203*0a6a1f1dSLionel Sambuc	rump.ifconfig shmif0
204*0a6a1f1dSLionel Sambuc	rump.ifconfig shmif1
205*0a6a1f1dSLionel Sambuc}
206*0a6a1f1dSLionel Sambuc
207*0a6a1f1dSLionel Sambucsetup_member_ip6()
208*0a6a1f1dSLionel Sambuc{
209*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK2
210*0a6a1f1dSLionel Sambuc	export LD_PRELOAD=/usr/lib/librumphijack.so
211*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6BR1
212*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 rump.ifconfig shmif1 inet6 $IP6BR2
213*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 rump.ifconfig -w 10
214*0a6a1f1dSLionel Sambuc	/sbin/brconfig bridge0
215*0a6a1f1dSLionel Sambuc	unset LD_PRELOAD
216*0a6a1f1dSLionel Sambuc	rump.ifconfig shmif0
217*0a6a1f1dSLionel Sambuc	rump.ifconfig shmif1
218*0a6a1f1dSLionel Sambuc}
219*0a6a1f1dSLionel Sambuc
220*0a6a1f1dSLionel Sambucteardown_bridge()
221*0a6a1f1dSLionel Sambuc{
222*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK2
223*0a6a1f1dSLionel Sambuc	export LD_PRELOAD=/usr/lib/librumphijack.so
224*0a6a1f1dSLionel Sambuc	/sbin/brconfig bridge0
225*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 /sbin/brconfig bridge0 delete shmif0
226*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 /sbin/brconfig bridge0 delete shmif1
227*0a6a1f1dSLionel Sambuc	/sbin/brconfig bridge0
228*0a6a1f1dSLionel Sambuc	unset LD_PRELOAD
229*0a6a1f1dSLionel Sambuc	rump.ifconfig shmif0
230*0a6a1f1dSLionel Sambuc	rump.ifconfig shmif1
231*0a6a1f1dSLionel Sambuc}
232*0a6a1f1dSLionel Sambuc
233*0a6a1f1dSLionel Sambuctest_setup_bridge()
234*0a6a1f1dSLionel Sambuc{
235*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK2
236*0a6a1f1dSLionel Sambuc	export LD_PRELOAD=/usr/lib/librumphijack.so
237*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o match:shmif0 /sbin/brconfig bridge0
238*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o match:shmif1 /sbin/brconfig bridge0
239*0a6a1f1dSLionel Sambuc	/sbin/brconfig bridge0
240*0a6a1f1dSLionel Sambuc	unset LD_PRELOAD
241*0a6a1f1dSLionel Sambuc}
242*0a6a1f1dSLionel Sambuc
243*0a6a1f1dSLionel Sambuccleanup()
244*0a6a1f1dSLionel Sambuc{
245*0a6a1f1dSLionel Sambuc	env RUMP_SERVER=$SOCK1 rump.halt
246*0a6a1f1dSLionel Sambuc	env RUMP_SERVER=$SOCK2 rump.halt
247*0a6a1f1dSLionel Sambuc	env RUMP_SERVER=$SOCK3 rump.halt
248*0a6a1f1dSLionel Sambuc}
249*0a6a1f1dSLionel Sambuc
250*0a6a1f1dSLionel Sambucdump_bus()
251*0a6a1f1dSLionel Sambuc{
252*0a6a1f1dSLionel Sambuc	/usr/bin/shmif_dumpbus -p - bus1 2>/dev/null| /usr/sbin/tcpdump -n -e -r -
253*0a6a1f1dSLionel Sambuc	/usr/bin/shmif_dumpbus -p - bus2 2>/dev/null| /usr/sbin/tcpdump -n -e -r -
254*0a6a1f1dSLionel Sambuc}
255*0a6a1f1dSLionel Sambuc
256*0a6a1f1dSLionel Sambucdown_up_interfaces()
257*0a6a1f1dSLionel Sambuc{
258*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK1
259*0a6a1f1dSLionel Sambuc	rump.ifconfig shmif0 down
260*0a6a1f1dSLionel Sambuc	rump.ifconfig shmif0 up
261*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK3
262*0a6a1f1dSLionel Sambuc	rump.ifconfig shmif0 down
263*0a6a1f1dSLionel Sambuc	rump.ifconfig shmif0 up
264*0a6a1f1dSLionel Sambuc}
265*0a6a1f1dSLionel Sambuc
266*0a6a1f1dSLionel Sambuctest_ping_failure()
267*0a6a1f1dSLionel Sambuc{
268*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK1
269*0a6a1f1dSLionel Sambuc	atf_check -s not-exit:0 -o ignore rump.ping -q -n -w $TIMEOUT -c 1 $IP2
270*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK3
271*0a6a1f1dSLionel Sambuc	atf_check -s not-exit:0 -o ignore rump.ping -q -n -w $TIMEOUT -c 1 $IP1
272*0a6a1f1dSLionel Sambuc}
273*0a6a1f1dSLionel Sambuc
274*0a6a1f1dSLionel Sambuctest_ping_success()
275*0a6a1f1dSLionel Sambuc{
276*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK1
277*0a6a1f1dSLionel Sambuc	rump.ifconfig -v shmif0
278*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o ignore rump.ping -q -n -w $TIMEOUT -c 1 $IP2
279*0a6a1f1dSLionel Sambuc	rump.ifconfig -v shmif0
280*0a6a1f1dSLionel Sambuc
281*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK3
282*0a6a1f1dSLionel Sambuc	rump.ifconfig -v shmif0
283*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o ignore rump.ping -q -n -w $TIMEOUT -c 1 $IP1
284*0a6a1f1dSLionel Sambuc	rump.ifconfig -v shmif0
285*0a6a1f1dSLionel Sambuc}
286*0a6a1f1dSLionel Sambuc
287*0a6a1f1dSLionel Sambuctest_ping6_failure()
288*0a6a1f1dSLionel Sambuc{
289*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK1
290*0a6a1f1dSLionel Sambuc	atf_check -s not-exit:0 -o ignore rump.ping6 -q -n -c 1 -X $TIMEOUT $IP62
291*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK3
292*0a6a1f1dSLionel Sambuc	atf_check -s not-exit:0 -o ignore rump.ping6 -q -n -c 1 -X $TIMEOUT $IP61
293*0a6a1f1dSLionel Sambuc}
294*0a6a1f1dSLionel Sambuc
295*0a6a1f1dSLionel Sambuctest_ping6_success()
296*0a6a1f1dSLionel Sambuc{
297*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK1
298*0a6a1f1dSLionel Sambuc	rump.ifconfig -v shmif0
299*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o ignore rump.ping6 -q -n -c 1 -X $TIMEOUT $IP62
300*0a6a1f1dSLionel Sambuc	rump.ifconfig -v shmif0
301*0a6a1f1dSLionel Sambuc
302*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK3
303*0a6a1f1dSLionel Sambuc	rump.ifconfig -v shmif0
304*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o ignore rump.ping6 -q -n -c 1 -X $TIMEOUT $IP61
305*0a6a1f1dSLionel Sambuc	rump.ifconfig -v shmif0
306*0a6a1f1dSLionel Sambuc}
307*0a6a1f1dSLionel Sambuc
308*0a6a1f1dSLionel Sambuctest_ping_member()
309*0a6a1f1dSLionel Sambuc{
310*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK1
311*0a6a1f1dSLionel Sambuc	rump.ifconfig -v shmif0
312*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o ignore rump.ping -q -n -w $TIMEOUT -c 1 $IPBR1
313*0a6a1f1dSLionel Sambuc	rump.ifconfig -v shmif0
314*0a6a1f1dSLionel Sambuc	# Test for PR#48104
315*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o ignore rump.ping -q -n -w $TIMEOUT -c 1 $IPBR2
316*0a6a1f1dSLionel Sambuc	rump.ifconfig -v shmif0
317*0a6a1f1dSLionel Sambuc
318*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK3
319*0a6a1f1dSLionel Sambuc	rump.ifconfig -v shmif0
320*0a6a1f1dSLionel Sambuc	# Test for PR#48104
321*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o ignore rump.ping -q -n -w $TIMEOUT -c 1 $IPBR1
322*0a6a1f1dSLionel Sambuc	rump.ifconfig -v shmif0
323*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o ignore rump.ping -q -n -w $TIMEOUT -c 1 $IPBR2
324*0a6a1f1dSLionel Sambuc	rump.ifconfig -v shmif0
325*0a6a1f1dSLionel Sambuc}
326*0a6a1f1dSLionel Sambuc
327*0a6a1f1dSLionel Sambuctest_ping6_member()
328*0a6a1f1dSLionel Sambuc{
329*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK1
330*0a6a1f1dSLionel Sambuc	rump.ifconfig -v shmif0
331*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o ignore rump.ping6 -q -n -X $TIMEOUT -c 1 $IP6BR1
332*0a6a1f1dSLionel Sambuc	rump.ifconfig -v shmif0
333*0a6a1f1dSLionel Sambuc	# Test for PR#48104
334*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o ignore rump.ping6 -q -n -X $TIMEOUT -c 1 $IP6BR2
335*0a6a1f1dSLionel Sambuc	rump.ifconfig -v shmif0
336*0a6a1f1dSLionel Sambuc
337*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK3
338*0a6a1f1dSLionel Sambuc	rump.ifconfig -v shmif0
339*0a6a1f1dSLionel Sambuc	# Test for PR#48104
340*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o ignore rump.ping6 -q -n -X $TIMEOUT -c 1 $IP6BR1
341*0a6a1f1dSLionel Sambuc	rump.ifconfig -v shmif0
342*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o ignore rump.ping6 -q -n -X $TIMEOUT -c 1 $IP6BR2
343*0a6a1f1dSLionel Sambuc	rump.ifconfig -v shmif0
344*0a6a1f1dSLionel Sambuc}
345*0a6a1f1dSLionel Sambuc
346*0a6a1f1dSLionel Sambucget_number_of_caches()
347*0a6a1f1dSLionel Sambuc{
348*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK2
349*0a6a1f1dSLionel Sambuc	export LD_PRELOAD=/usr/lib/librumphijack.so
350*0a6a1f1dSLionel Sambuc	echo $(($(/sbin/brconfig bridge0 |grep -A 100 "Address cache" |wc -l) - 1))
351*0a6a1f1dSLionel Sambuc	unset LD_PRELOAD
352*0a6a1f1dSLionel Sambuc}
353*0a6a1f1dSLionel Sambuc
354*0a6a1f1dSLionel Sambuctest_brconfig_maxaddr()
355*0a6a1f1dSLionel Sambuc{
356*0a6a1f1dSLionel Sambuc	addr1= addr3= n=
357*0a6a1f1dSLionel Sambuc
358*0a6a1f1dSLionel Sambuc	# Get MAC addresses of the endpoints.
359*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK1
360*0a6a1f1dSLionel Sambuc	addr1=$(rump.ifconfig shmif0 |awk '/address:/ { print $2;}')
361*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK3
362*0a6a1f1dSLionel Sambuc	addr3=$(rump.ifconfig shmif0 |awk '/address:/ { print $2;}')
363*0a6a1f1dSLionel Sambuc	unset RUMP_SERVER
364*0a6a1f1dSLionel Sambuc
365*0a6a1f1dSLionel Sambuc	# Refill the MAC addresses of the endpoints.
366*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK1
367*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 $IP2
368*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK2
369*0a6a1f1dSLionel Sambuc	export LD_PRELOAD=/usr/lib/librumphijack.so
370*0a6a1f1dSLionel Sambuc	/sbin/brconfig bridge0
371*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o match:"$addr1 shmif0" /sbin/brconfig bridge0
372*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o match:"$addr3 shmif1" /sbin/brconfig bridge0
373*0a6a1f1dSLionel Sambuc
374*0a6a1f1dSLionel Sambuc	# Check the default # of caches is 100
375*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o match:"max cache: 100" /sbin/brconfig bridge0
376*0a6a1f1dSLionel Sambuc
377*0a6a1f1dSLionel Sambuc	# Test two MAC addresses are cached
378*0a6a1f1dSLionel Sambuc	n=$(get_number_of_caches)
379*0a6a1f1dSLionel Sambuc	atf_check_equal $n 2
380*0a6a1f1dSLionel Sambuc
381*0a6a1f1dSLionel Sambuc	# Limit # of caches to one
382*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o ignore /sbin/brconfig bridge0 maxaddr 1
383*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o match:"max cache: 1" /sbin/brconfig bridge0
384*0a6a1f1dSLionel Sambuc	/sbin/brconfig bridge0
385*0a6a1f1dSLionel Sambuc
386*0a6a1f1dSLionel Sambuc	# Test just one address is cached
387*0a6a1f1dSLionel Sambuc	n=$(get_number_of_caches)
388*0a6a1f1dSLionel Sambuc	atf_check_equal $n 1
389*0a6a1f1dSLionel Sambuc
390*0a6a1f1dSLionel Sambuc	# Increase # of caches to two
391*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o ignore /sbin/brconfig bridge0 maxaddr 2
392*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o match:"max cache: 2" /sbin/brconfig bridge0
393*0a6a1f1dSLionel Sambuc	unset LD_PRELOAD
394*0a6a1f1dSLionel Sambuc
395*0a6a1f1dSLionel Sambuc	# Test we can cache two addresses again
396*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK1
397*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 $IP2
398*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK2
399*0a6a1f1dSLionel Sambuc	export LD_PRELOAD=/usr/lib/librumphijack.so
400*0a6a1f1dSLionel Sambuc	/sbin/brconfig bridge0
401*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o match:"$addr1 shmif0" /sbin/brconfig bridge0
402*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o match:"$addr3 shmif1" /sbin/brconfig bridge0
403*0a6a1f1dSLionel Sambuc	unset LD_PRELOAD
404*0a6a1f1dSLionel Sambuc}
405*0a6a1f1dSLionel Sambuc
406*0a6a1f1dSLionel Sambucbasic_body()
407*0a6a1f1dSLionel Sambuc{
408*0a6a1f1dSLionel Sambuc	setup
409*0a6a1f1dSLionel Sambuc	test_setup
410*0a6a1f1dSLionel Sambuc
411*0a6a1f1dSLionel Sambuc	# Enable once PR kern/49219 is fixed
412*0a6a1f1dSLionel Sambuc	#test_ping_failure
413*0a6a1f1dSLionel Sambuc
414*0a6a1f1dSLionel Sambuc	setup_bridge
415*0a6a1f1dSLionel Sambuc	sleep 1
416*0a6a1f1dSLionel Sambuc	test_setup_bridge
417*0a6a1f1dSLionel Sambuc	test_ping_success
418*0a6a1f1dSLionel Sambuc
419*0a6a1f1dSLionel Sambuc	teardown_bridge
420*0a6a1f1dSLionel Sambuc	test_ping_failure
421*0a6a1f1dSLionel Sambuc}
422*0a6a1f1dSLionel Sambuc
423*0a6a1f1dSLionel Sambucbasic6_body()
424*0a6a1f1dSLionel Sambuc{
425*0a6a1f1dSLionel Sambuc	setup6
426*0a6a1f1dSLionel Sambuc	test_setup6
427*0a6a1f1dSLionel Sambuc
428*0a6a1f1dSLionel Sambuc	test_ping6_failure
429*0a6a1f1dSLionel Sambuc
430*0a6a1f1dSLionel Sambuc	setup_bridge
431*0a6a1f1dSLionel Sambuc	sleep 1
432*0a6a1f1dSLionel Sambuc	test_setup_bridge
433*0a6a1f1dSLionel Sambuc	test_ping6_success
434*0a6a1f1dSLionel Sambuc
435*0a6a1f1dSLionel Sambuc	teardown_bridge
436*0a6a1f1dSLionel Sambuc	test_ping6_failure
437*0a6a1f1dSLionel Sambuc}
438*0a6a1f1dSLionel Sambuc
439*0a6a1f1dSLionel Sambucrtable_body()
440*0a6a1f1dSLionel Sambuc{
441*0a6a1f1dSLionel Sambuc	addr1= addr3=
442*0a6a1f1dSLionel Sambuc
443*0a6a1f1dSLionel Sambuc	setup
444*0a6a1f1dSLionel Sambuc	setup_bridge
445*0a6a1f1dSLionel Sambuc
446*0a6a1f1dSLionel Sambuc	# Get MAC addresses of the endpoints.
447*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK1
448*0a6a1f1dSLionel Sambuc	addr1=$(rump.ifconfig shmif0 |awk '/address:/ { print $2;}')
449*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK3
450*0a6a1f1dSLionel Sambuc	addr3=$(rump.ifconfig shmif0 |awk '/address:/ { print $2;}')
451*0a6a1f1dSLionel Sambuc	unset RUMP_SERVER
452*0a6a1f1dSLionel Sambuc
453*0a6a1f1dSLionel Sambuc	# Confirm there is no MAC address caches.
454*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK2
455*0a6a1f1dSLionel Sambuc	export LD_PRELOAD=/usr/lib/librumphijack.so
456*0a6a1f1dSLionel Sambuc	/sbin/brconfig bridge0
457*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o not-match:"$addr1" /sbin/brconfig bridge0
458*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o not-match:"$addr3" /sbin/brconfig bridge0
459*0a6a1f1dSLionel Sambuc	unset LD_PRELOAD
460*0a6a1f1dSLionel Sambuc
461*0a6a1f1dSLionel Sambuc	# Make the bridge learn the MAC addresses of the endpoints.
462*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK1
463*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 $IP2
464*0a6a1f1dSLionel Sambuc	unset RUMP_SERVER
465*0a6a1f1dSLionel Sambuc
466*0a6a1f1dSLionel Sambuc	# Tests the addresses are in the cache.
467*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK2
468*0a6a1f1dSLionel Sambuc	export LD_PRELOAD=/usr/lib/librumphijack.so
469*0a6a1f1dSLionel Sambuc	/sbin/brconfig bridge0
470*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o match:"$addr1 shmif0" /sbin/brconfig bridge0
471*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o match:"$addr3 shmif1" /sbin/brconfig bridge0
472*0a6a1f1dSLionel Sambuc
473*0a6a1f1dSLionel Sambuc	# Tests brconfig deladdr
474*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o ignore /sbin/brconfig bridge0 deladdr "$addr1"
475*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o not-match:"$addr1 shmif0" /sbin/brconfig bridge0
476*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o ignore /sbin/brconfig bridge0 deladdr "$addr3"
477*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o not-match:"$addr3 shmif1" /sbin/brconfig bridge0
478*0a6a1f1dSLionel Sambuc	unset LD_PRELOAD
479*0a6a1f1dSLionel Sambuc
480*0a6a1f1dSLionel Sambuc	# Refill the MAC addresses of the endpoints.
481*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK1
482*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 $IP2
483*0a6a1f1dSLionel Sambuc	unset RUMP_SERVER
484*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK2
485*0a6a1f1dSLionel Sambuc	export LD_PRELOAD=/usr/lib/librumphijack.so
486*0a6a1f1dSLionel Sambuc	/sbin/brconfig bridge0
487*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o match:"$addr1 shmif0" /sbin/brconfig bridge0
488*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o match:"$addr3 shmif1" /sbin/brconfig bridge0
489*0a6a1f1dSLionel Sambuc
490*0a6a1f1dSLionel Sambuc	# Tests brconfig flush.
491*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o ignore /sbin/brconfig bridge0 flush
492*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o not-match:"$addr1 shmif0" /sbin/brconfig bridge0
493*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o not-match:"$addr3 shmif1" /sbin/brconfig bridge0
494*0a6a1f1dSLionel Sambuc	unset LD_PRELOAD
495*0a6a1f1dSLionel Sambuc
496*0a6a1f1dSLionel Sambuc	# Tests brconfig timeout.
497*0a6a1f1dSLionel Sambuc	export RUMP_SERVER=$SOCK2
498*0a6a1f1dSLionel Sambuc	export LD_PRELOAD=/usr/lib/librumphijack.so
499*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o match:"timeout: 1200" /sbin/brconfig bridge0
500*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o ignore /sbin/brconfig bridge0 timeout 10
501*0a6a1f1dSLionel Sambuc	atf_check -s exit:0 -o match:"timeout: 10" /sbin/brconfig bridge0
502*0a6a1f1dSLionel Sambuc	unset LD_PRELOAD
503*0a6a1f1dSLionel Sambuc
504*0a6a1f1dSLionel Sambuc	# Tests brconfig maxaddr.
505*0a6a1f1dSLionel Sambuc	test_brconfig_maxaddr
506*0a6a1f1dSLionel Sambuc
507*0a6a1f1dSLionel Sambuc	# TODO: brconfig static/flushall/discover/learn
508*0a6a1f1dSLionel Sambuc	# TODO: cache expiration; it takes 5 minutes at least and we want to
509*0a6a1f1dSLionel Sambuc	#       wait here so long. Should we have a sysctl to change the period?
510*0a6a1f1dSLionel Sambuc}
511*0a6a1f1dSLionel Sambuc
512*0a6a1f1dSLionel Sambucmember_ip_body()
513*0a6a1f1dSLionel Sambuc{
514*0a6a1f1dSLionel Sambuc	setup
515*0a6a1f1dSLionel Sambuc	test_setup
516*0a6a1f1dSLionel Sambuc
517*0a6a1f1dSLionel Sambuc	# Enable once PR kern/49219 is fixed
518*0a6a1f1dSLionel Sambuc	#test_ping_failure
519*0a6a1f1dSLionel Sambuc
520*0a6a1f1dSLionel Sambuc	setup_bridge
521*0a6a1f1dSLionel Sambuc	sleep 1
522*0a6a1f1dSLionel Sambuc	test_setup_bridge
523*0a6a1f1dSLionel Sambuc	test_ping_success
524*0a6a1f1dSLionel Sambuc
525*0a6a1f1dSLionel Sambuc	setup_member_ip
526*0a6a1f1dSLionel Sambuc	test_ping_member
527*0a6a1f1dSLionel Sambuc
528*0a6a1f1dSLionel Sambuc	teardown_bridge
529*0a6a1f1dSLionel Sambuc	test_ping_failure
530*0a6a1f1dSLionel Sambuc}
531*0a6a1f1dSLionel Sambuc
532*0a6a1f1dSLionel Sambucmember_ip6_body()
533*0a6a1f1dSLionel Sambuc{
534*0a6a1f1dSLionel Sambuc	setup6
535*0a6a1f1dSLionel Sambuc	test_setup6
536*0a6a1f1dSLionel Sambuc
537*0a6a1f1dSLionel Sambuc	test_ping6_failure
538*0a6a1f1dSLionel Sambuc
539*0a6a1f1dSLionel Sambuc	setup_bridge
540*0a6a1f1dSLionel Sambuc	sleep 1
541*0a6a1f1dSLionel Sambuc	test_setup_bridge
542*0a6a1f1dSLionel Sambuc	test_ping6_success
543*0a6a1f1dSLionel Sambuc
544*0a6a1f1dSLionel Sambuc	setup_member_ip6
545*0a6a1f1dSLionel Sambuc	test_ping6_member
546*0a6a1f1dSLionel Sambuc
547*0a6a1f1dSLionel Sambuc	teardown_bridge
548*0a6a1f1dSLionel Sambuc	test_ping6_failure
549*0a6a1f1dSLionel Sambuc}
550*0a6a1f1dSLionel Sambuc
551*0a6a1f1dSLionel Sambucbasic_cleanup()
552*0a6a1f1dSLionel Sambuc{
553*0a6a1f1dSLionel Sambuc	dump_bus
554*0a6a1f1dSLionel Sambuc	cleanup
555*0a6a1f1dSLionel Sambuc}
556*0a6a1f1dSLionel Sambuc
557*0a6a1f1dSLionel Sambucbasic6_cleanup()
558*0a6a1f1dSLionel Sambuc{
559*0a6a1f1dSLionel Sambuc	dump_bus
560*0a6a1f1dSLionel Sambuc	cleanup
561*0a6a1f1dSLionel Sambuc}
562*0a6a1f1dSLionel Sambuc
563*0a6a1f1dSLionel Sambucrtable_cleanup()
564*0a6a1f1dSLionel Sambuc{
565*0a6a1f1dSLionel Sambuc	dump_bus
566*0a6a1f1dSLionel Sambuc	cleanup
567*0a6a1f1dSLionel Sambuc}
568*0a6a1f1dSLionel Sambuc
569*0a6a1f1dSLionel Sambucmember_ip_cleanup()
570*0a6a1f1dSLionel Sambuc{
571*0a6a1f1dSLionel Sambuc	dump_bus
572*0a6a1f1dSLionel Sambuc	cleanup
573*0a6a1f1dSLionel Sambuc}
574*0a6a1f1dSLionel Sambuc
575*0a6a1f1dSLionel Sambucmember_ip6_cleanup()
576*0a6a1f1dSLionel Sambuc{
577*0a6a1f1dSLionel Sambuc	dump_bus
578*0a6a1f1dSLionel Sambuc	cleanup
579*0a6a1f1dSLionel Sambuc}
580*0a6a1f1dSLionel Sambuc
581*0a6a1f1dSLionel Sambucatf_init_test_cases()
582*0a6a1f1dSLionel Sambuc{
583*0a6a1f1dSLionel Sambuc	atf_add_test_case basic
584*0a6a1f1dSLionel Sambuc	atf_add_test_case basic6
585*0a6a1f1dSLionel Sambuc	atf_add_test_case rtable
586*0a6a1f1dSLionel Sambuc	atf_add_test_case member_ip
587*0a6a1f1dSLionel Sambuc	atf_add_test_case member_ip6
588*0a6a1f1dSLionel Sambuc}
589