xref: /freebsd/contrib/netbsd-tests/net/if_pppoe/t_pppoe.sh (revision d370fd1cd8fc69e87dc63f4f4a82e5a8b4956c93)
1*cdebaff8SEnji Cooper#	$NetBSD: t_pppoe.sh,v 1.16 2016/12/14 03:30:30 knakahara Exp $
2640235e2SEnji Cooper#
3640235e2SEnji Cooper# Copyright (c) 2016 Internet Initiative Japan Inc.
4640235e2SEnji Cooper# All rights reserved.
5640235e2SEnji Cooper#
6640235e2SEnji Cooper# Redistribution and use in source and binary forms, with or without
7640235e2SEnji Cooper# modification, are permitted provided that the following conditions
8640235e2SEnji Cooper# are met:
9640235e2SEnji Cooper# 1. Redistributions of source code must retain the above copyright
10640235e2SEnji Cooper#    notice, this list of conditions and the following disclaimer.
11640235e2SEnji Cooper# 2. Redistributions in binary form must reproduce the above copyright
12640235e2SEnji Cooper#    notice, this list of conditions and the following disclaimer in the
13640235e2SEnji Cooper#    documentation and/or other materials provided with the distribution.
14640235e2SEnji Cooper#
15640235e2SEnji Cooper# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16640235e2SEnji Cooper# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17640235e2SEnji Cooper# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18640235e2SEnji Cooper# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19640235e2SEnji Cooper# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20640235e2SEnji Cooper# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21640235e2SEnji Cooper# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22640235e2SEnji Cooper# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23640235e2SEnji Cooper# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24640235e2SEnji Cooper# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25640235e2SEnji Cooper# POSSIBILITY OF SUCH DAMAGE.
26640235e2SEnji Cooper#
27640235e2SEnji Cooper
28640235e2SEnji Cooperserver="rump_server -lrump -lrumpnet -lrumpnet_net -lrumpnet_netinet	\
29640235e2SEnji Cooper		    -lrumpnet_netinet6 -lrumpnet_shmif -lrumpdev	\
30640235e2SEnji Cooper		    -lrumpnet_pppoe"
31*cdebaff8SEnji Cooper# pppoectl doesn't work with RUMPHIJACK=sysctl=yes
32640235e2SEnji CooperHIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so"
33640235e2SEnji Cooper
34640235e2SEnji CooperSERVER=unix://commsock1
35640235e2SEnji CooperCLIENT=unix://commsock2
36640235e2SEnji Cooper
37640235e2SEnji CooperSERVER_IP=10.3.3.1
38640235e2SEnji CooperCLIENT_IP=10.3.3.3
39*cdebaff8SEnji CooperSERVER_IP6=fc00::1
40*cdebaff8SEnji CooperCLIENT_IP6=fc00::3
41640235e2SEnji CooperAUTHNAME=foobar@baz.com
42640235e2SEnji CooperSECRET=oink
43640235e2SEnji CooperBUS=bus0
44640235e2SEnji CooperTIMEOUT=3
45*cdebaff8SEnji CooperWAITTIME=10
46*cdebaff8SEnji CooperDEBUG=${DEBUG:-false}
47640235e2SEnji Cooper
48640235e2SEnji Coopersetup()
49640235e2SEnji Cooper{
50*cdebaff8SEnji Cooper	inet=true
51*cdebaff8SEnji Cooper
52*cdebaff8SEnji Cooper	if [ $# -ne 0 ]; then
53*cdebaff8SEnji Cooper		eval $@
54*cdebaff8SEnji Cooper	fi
55*cdebaff8SEnji Cooper
56640235e2SEnji Cooper	atf_check -s exit:0 ${server} $SERVER
57640235e2SEnji Cooper	atf_check -s exit:0 ${server} $CLIENT
58640235e2SEnji Cooper
59640235e2SEnji Cooper	export RUMP_SERVER=$SERVER
60640235e2SEnji Cooper	atf_check -s exit:0 rump.ifconfig shmif0 create
61640235e2SEnji Cooper	atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS
62640235e2SEnji Cooper	atf_check -s exit:0 rump.ifconfig shmif0 up
63640235e2SEnji Cooper
64640235e2SEnji Cooper	atf_check -s exit:0 rump.ifconfig pppoe0 create
65*cdebaff8SEnji Cooper	$inet && atf_check -s exit:0 rump.ifconfig pppoe0 \
66*cdebaff8SEnji Cooper	    inet $SERVER_IP $CLIENT_IP down
67640235e2SEnji Cooper	atf_check -s exit:0 rump.ifconfig pppoe0 link0
68640235e2SEnji Cooper
69640235e2SEnji Cooper	$DEBUG && rump.ifconfig
70640235e2SEnji Cooper	$DEBUG && $HIJACKING pppoectl -d pppoe0
71640235e2SEnji Cooper
72640235e2SEnji Cooper	atf_check -s exit:0 -x "$HIJACKING pppoectl -e shmif0 pppoe0"
73640235e2SEnji Cooper	unset RUMP_SERVER
74640235e2SEnji Cooper
75640235e2SEnji Cooper	export RUMP_SERVER=$CLIENT
76640235e2SEnji Cooper	atf_check -s exit:0 rump.ifconfig shmif0 create
77640235e2SEnji Cooper	atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS
78640235e2SEnji Cooper	atf_check -s exit:0 rump.ifconfig shmif0 up
79640235e2SEnji Cooper
80640235e2SEnji Cooper	atf_check -s exit:0 rump.ifconfig pppoe0 create
81*cdebaff8SEnji Cooper	$inet && atf_check -s exit:0 rump.ifconfig pppoe0 \
82*cdebaff8SEnji Cooper	    inet 0.0.0.0 0.0.0.1 down
83640235e2SEnji Cooper
84640235e2SEnji Cooper	atf_check -s exit:0 -x "$HIJACKING pppoectl -e shmif0 pppoe0"
85640235e2SEnji Cooper	unset RUMP_SERVER
86640235e2SEnji Cooper}
87*cdebaff8SEnji Cooper
88640235e2SEnji Coopercleanup()
89640235e2SEnji Cooper{
90640235e2SEnji Cooper	env RUMP_SERVER=$SERVER rump.halt
91640235e2SEnji Cooper	env RUMP_SERVER=$CLIENT rump.halt
92640235e2SEnji Cooper}
93640235e2SEnji Cooper
94640235e2SEnji Cooper
95640235e2SEnji Cooperwait_for_session_established()
96640235e2SEnji Cooper{
97640235e2SEnji Cooper	local dontfail=$1
98640235e2SEnji Cooper	local n=$WAITTIME
99640235e2SEnji Cooper
100640235e2SEnji Cooper	for i in $(seq $n); do
101640235e2SEnji Cooper		$HIJACKING pppoectl -d pppoe0 |grep -q "state = session"
102640235e2SEnji Cooper		[ $? = 0 ] && return
103640235e2SEnji Cooper		sleep 1
104640235e2SEnji Cooper	done
105640235e2SEnji Cooper
106*cdebaff8SEnji Cooper	if [ "$dontfail" != "dontfail" ]; then
107640235e2SEnji Cooper		atf_fail "Couldn't connect to the server for $n seconds."
108640235e2SEnji Cooper	fi
109640235e2SEnji Cooper}
110640235e2SEnji Cooper
111*cdebaff8SEnji Cooperwait_for_disconnected()
112640235e2SEnji Cooper{
113*cdebaff8SEnji Cooper	local dontfail=$1
114*cdebaff8SEnji Cooper	local n=$WAITTIME
115*cdebaff8SEnji Cooper
116*cdebaff8SEnji Cooper	for i in $(seq $n); do
117*cdebaff8SEnji Cooper		$HIJACKING pppoectl -d pppoe0 | grep -q "state = initial"
118*cdebaff8SEnji Cooper		[ $? = 0 ] && return
119*cdebaff8SEnji Cooper		# If PPPoE client is disconnected by PPPoE server and then
120*cdebaff8SEnji Cooper		# the client kicks callout of pppoe_timeout(), the client
121*cdebaff8SEnji Cooper		# state is changed to PPPOE_STATE_PADI_SENT while padi retrying.
122*cdebaff8SEnji Cooper		$HIJACKING pppoectl -d pppoe0 | grep -q "state = PADI sent"
123*cdebaff8SEnji Cooper		[ $? = 0 ] && return
124*cdebaff8SEnji Cooper
125*cdebaff8SEnji Cooper		sleep 1
126*cdebaff8SEnji Cooper	done
127*cdebaff8SEnji Cooper
128*cdebaff8SEnji Cooper	if [ "$dontfail" != "dontfail" ]; then
129*cdebaff8SEnji Cooper		atf_fail "Couldn't disconnect for $n seconds."
130*cdebaff8SEnji Cooper	fi
131*cdebaff8SEnji Cooper}
132*cdebaff8SEnji Cooper
133*cdebaff8SEnji Cooperrun_test()
134*cdebaff8SEnji Cooper{
135*cdebaff8SEnji Cooper	local auth=$1
136640235e2SEnji Cooper	setup
137640235e2SEnji Cooper
138*cdebaff8SEnji Cooper	# As pppoe client doesn't support rechallenge yet.
139*cdebaff8SEnji Cooper	local server_optparam=""
140*cdebaff8SEnji Cooper	if [ $auth = "chap" ]; then
141*cdebaff8SEnji Cooper		server_optparam="norechallenge"
142*cdebaff8SEnji Cooper	fi
143*cdebaff8SEnji Cooper
144640235e2SEnji Cooper	export RUMP_SERVER=$SERVER
145640235e2SEnji Cooper	local setup_serverparam="pppoectl pppoe0 hisauthproto=$auth \
146640235e2SEnji Cooper				    'hisauthname=$AUTHNAME' \
147640235e2SEnji Cooper				    'hisauthsecret=$SECRET' \
148*cdebaff8SEnji Cooper				    'myauthproto=none' \
149*cdebaff8SEnji Cooper				    $server_optparam"
150640235e2SEnji Cooper	atf_check -s exit:0 -x "$HIJACKING $setup_serverparam"
151640235e2SEnji Cooper	atf_check -s exit:0 rump.ifconfig pppoe0 up
152640235e2SEnji Cooper	unset RUMP_SERVER
153640235e2SEnji Cooper
154640235e2SEnji Cooper	export RUMP_SERVER=$CLIENT
155640235e2SEnji Cooper	local setup_clientparam="pppoectl pppoe0 myauthproto=$auth \
156640235e2SEnji Cooper				    'myauthname=$AUTHNAME' \
157640235e2SEnji Cooper				    'myauthsecret=$SECRET' \
158640235e2SEnji Cooper				    'hisauthproto=none'"
159640235e2SEnji Cooper	atf_check -s exit:0 -x "$HIJACKING $setup_clientparam"
160640235e2SEnji Cooper	atf_check -s exit:0 rump.ifconfig pppoe0 up
161640235e2SEnji Cooper	$DEBUG && rump.ifconfig
162640235e2SEnji Cooper	wait_for_session_established
163640235e2SEnji Cooper	atf_check -s exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT $SERVER_IP
164640235e2SEnji Cooper	unset RUMP_SERVER
165640235e2SEnji Cooper
166640235e2SEnji Cooper	# test for disconnection from server
167*cdebaff8SEnji Cooper	export RUMP_SERVER=$SERVER
168*cdebaff8SEnji Cooper	atf_check -s exit:0 rump.ifconfig pppoe0 down
169*cdebaff8SEnji Cooper	wait_for_disconnected
170640235e2SEnji Cooper	export RUMP_SERVER=$CLIENT
171*cdebaff8SEnji Cooper	wait_for_disconnected
172640235e2SEnji Cooper	atf_check -s not-exit:0 -o ignore -e ignore \
173640235e2SEnji Cooper	    rump.ping -c 1 -w $TIMEOUT $SERVER_IP
174640235e2SEnji Cooper	atf_check -s exit:0 -o match:'PADI sent' -x "$HIJACKING pppoectl -d pppoe0"
175640235e2SEnji Cooper	unset RUMP_SERVER
176640235e2SEnji Cooper
177640235e2SEnji Cooper	# test for recoonecting
178640235e2SEnji Cooper	atf_check -s exit:0 -x "env RUMP_SERVER=$SERVER rump.ifconfig pppoe0 up"
179640235e2SEnji Cooper	export RUMP_SERVER=$CLIENT
180640235e2SEnji Cooper	wait_for_session_established
181640235e2SEnji Cooper	atf_check -s exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT $SERVER_IP
182640235e2SEnji Cooper	unset RUMP_SERVER
183640235e2SEnji Cooper
184640235e2SEnji Cooper	# test for disconnection from client
185*cdebaff8SEnji Cooper	export RUMP_SERVER=$CLIENT
186*cdebaff8SEnji Cooper	atf_check -s exit:0 -x rump.ifconfig pppoe0 down
187*cdebaff8SEnji Cooper	wait_for_disconnected
188640235e2SEnji Cooper	export RUMP_SERVER=$SERVER
189*cdebaff8SEnji Cooper	wait_for_disconnected
190640235e2SEnji Cooper	$DEBUG && $HIJACKING pppoectl -d pppoe0
191640235e2SEnji Cooper	atf_check -s not-exit:0 -o ignore -e ignore \
192640235e2SEnji Cooper	    rump.ping -c 1 -w $TIMEOUT $CLIENT_IP
193640235e2SEnji Cooper	atf_check -s exit:0 -o match:'initial' -x "$HIJACKING pppoectl -d pppoe0"
194640235e2SEnji Cooper	unset RUMP_SERVER
195640235e2SEnji Cooper
196*cdebaff8SEnji Cooper	# test for reconnecting
197640235e2SEnji Cooper	export RUMP_SERVER=$CLIENT
198640235e2SEnji Cooper	atf_check -s exit:0 -x rump.ifconfig pppoe0 up
199640235e2SEnji Cooper	wait_for_session_established
200640235e2SEnji Cooper	$DEBUG && rump.ifconfig pppoe0
201640235e2SEnji Cooper	$DEBUG && $HIJACKING pppoectl -d pppoe0
202640235e2SEnji Cooper	unset RUMP_SERVER
203640235e2SEnji Cooper
204640235e2SEnji Cooper	export RUMP_SERVER=$SERVER
205*cdebaff8SEnji Cooper	atf_check -s exit:0 rump.ifconfig -w 10
206640235e2SEnji Cooper	atf_check -s exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT $CLIENT_IP
207640235e2SEnji Cooper	atf_check -s exit:0 -o match:'session' -x "$HIJACKING pppoectl -d pppoe0"
208640235e2SEnji Cooper	$DEBUG && HIJACKING pppoectl -d pppoe0
209640235e2SEnji Cooper	unset RUMP_SERVER
210640235e2SEnji Cooper
211640235e2SEnji Cooper	# test for invalid password
212640235e2SEnji Cooper	export RUMP_SERVER=$CLIENT
213640235e2SEnji Cooper	atf_check -s exit:0 rump.ifconfig pppoe0 down
214*cdebaff8SEnji Cooper	wait_for_disconnected
215640235e2SEnji Cooper	local setup_clientparam="pppoectl pppoe0 myauthproto=$auth \
216640235e2SEnji Cooper				    'myauthname=$AUTHNAME' \
217640235e2SEnji Cooper				    'myauthsecret=invalidsecret' \
218640235e2SEnji Cooper				    'hisauthproto=none'"
219640235e2SEnji Cooper	atf_check -s exit:0 -x "$HIJACKING $setup_clientparam"
220640235e2SEnji Cooper	atf_check -s exit:0 rump.ifconfig pppoe0 up
221640235e2SEnji Cooper	wait_for_session_established dontfail
222640235e2SEnji Cooper	atf_check -s not-exit:0 -o ignore -e ignore \
223640235e2SEnji Cooper	    rump.ping -c 1 -w $TIMEOUT $SERVER_IP
224*cdebaff8SEnji Cooper	atf_check -s exit:0 -o match:'DETACHED' rump.ifconfig pppoe0
225640235e2SEnji Cooper	unset RUMP_SERVER
226640235e2SEnji Cooper}
227640235e2SEnji Cooper
228*cdebaff8SEnji Cooperatf_test_case pppoe_pap cleanup
229*cdebaff8SEnji Cooper
230*cdebaff8SEnji Cooperpppoe_pap_head()
231*cdebaff8SEnji Cooper{
232*cdebaff8SEnji Cooper	atf_set "descr" "Does simple pap tests"
233*cdebaff8SEnji Cooper	atf_set "require.progs" "rump_server pppoectl"
234*cdebaff8SEnji Cooper}
235*cdebaff8SEnji Cooper
236*cdebaff8SEnji Cooperpppoe_pap_body()
237*cdebaff8SEnji Cooper{
238*cdebaff8SEnji Cooper	run_test pap
239*cdebaff8SEnji Cooper}
240*cdebaff8SEnji Cooper
241*cdebaff8SEnji Cooperpppoe_pap_cleanup()
242640235e2SEnji Cooper{
243640235e2SEnji Cooper	cleanup
244640235e2SEnji Cooper}
245*cdebaff8SEnji Cooper
246*cdebaff8SEnji Cooperatf_test_case pppoe_chap cleanup
247*cdebaff8SEnji Cooper
248*cdebaff8SEnji Cooperpppoe_chap_head()
249*cdebaff8SEnji Cooper{
250*cdebaff8SEnji Cooper	atf_set "descr" "Does simple chap tests"
251*cdebaff8SEnji Cooper	atf_set "require.progs" "rump_server pppoectl"
252*cdebaff8SEnji Cooper}
253*cdebaff8SEnji Cooper
254*cdebaff8SEnji Cooperpppoe_chap_body()
255*cdebaff8SEnji Cooper{
256*cdebaff8SEnji Cooper	run_test chap
257*cdebaff8SEnji Cooper}
258*cdebaff8SEnji Cooper
259*cdebaff8SEnji Cooperpppoe_chap_cleanup()
260*cdebaff8SEnji Cooper{
261*cdebaff8SEnji Cooper	cleanup
262*cdebaff8SEnji Cooper}
263*cdebaff8SEnji Cooper
264*cdebaff8SEnji Cooperrun_test6()
265*cdebaff8SEnji Cooper{
266*cdebaff8SEnji Cooper	local auth=$1
267*cdebaff8SEnji Cooper	setup "inet=false"
268*cdebaff8SEnji Cooper
269*cdebaff8SEnji Cooper	# As pppoe client doesn't support rechallenge yet.
270*cdebaff8SEnji Cooper	local server_optparam=""
271*cdebaff8SEnji Cooper	if [ $auth = "chap" ]; then
272*cdebaff8SEnji Cooper		server_optparam="norechallenge"
273*cdebaff8SEnji Cooper	fi
274*cdebaff8SEnji Cooper
275*cdebaff8SEnji Cooper	export RUMP_SERVER=$SERVER
276*cdebaff8SEnji Cooper	local setup_serverparam="pppoectl pppoe0 hisauthproto=$auth \
277*cdebaff8SEnji Cooper				    'hisauthname=$AUTHNAME' \
278*cdebaff8SEnji Cooper				    'hisauthsecret=$SECRET' \
279*cdebaff8SEnji Cooper				    'myauthproto=none' \
280*cdebaff8SEnji Cooper				    $server_optparam"
281*cdebaff8SEnji Cooper	atf_check -s exit:0 -x "$HIJACKING $setup_serverparam"
282*cdebaff8SEnji Cooper	atf_check -s exit:0 rump.ifconfig pppoe0 inet6 $SERVER_IP6/64 down
283*cdebaff8SEnji Cooper	atf_check -s exit:0 rump.ifconfig pppoe0 up
284*cdebaff8SEnji Cooper	unset RUMP_SERVER
285*cdebaff8SEnji Cooper
286*cdebaff8SEnji Cooper	export RUMP_SERVER=$CLIENT
287*cdebaff8SEnji Cooper	local setup_clientparam="pppoectl pppoe0 myauthproto=$auth \
288*cdebaff8SEnji Cooper				    'myauthname=$AUTHNAME' \
289*cdebaff8SEnji Cooper				    'myauthsecret=$SECRET' \
290*cdebaff8SEnji Cooper				    'hisauthproto=none'"
291*cdebaff8SEnji Cooper	atf_check -s exit:0 -x "$HIJACKING $setup_clientparam"
292*cdebaff8SEnji Cooper	atf_check -s exit:0 rump.ifconfig pppoe0 inet6 $CLIENT_IP6/64 down
293*cdebaff8SEnji Cooper	atf_check -s exit:0 rump.ifconfig pppoe0 up
294*cdebaff8SEnji Cooper	$DEBUG && rump.ifconfig
295*cdebaff8SEnji Cooper	wait_for_session_established
296*cdebaff8SEnji Cooper	atf_check -s exit:0 -o ignore rump.ifconfig -w 10
297*cdebaff8SEnji Cooper	export RUMP_SERVER=$SERVER
298*cdebaff8SEnji Cooper	atf_check -s exit:0 -o ignore rump.ifconfig -w 10
299*cdebaff8SEnji Cooper	export RUMP_SERVER=$CLIENT
300*cdebaff8SEnji Cooper	atf_check -s exit:0 -o ignore rump.ping6 -c 1 -X $TIMEOUT $SERVER_IP6
301*cdebaff8SEnji Cooper	unset RUMP_SERVER
302*cdebaff8SEnji Cooper
303*cdebaff8SEnji Cooper	# test for disconnection from server
304*cdebaff8SEnji Cooper	export RUMP_SERVER=$SERVER
305*cdebaff8SEnji Cooper	session_id=`$HIJACKING pppoectl -d pppoe0 | grep state`
306*cdebaff8SEnji Cooper	atf_check -s exit:0 rump.ifconfig pppoe0 down
307*cdebaff8SEnji Cooper	wait_for_disconnected
308*cdebaff8SEnji Cooper	export RUMP_SERVER=$CLIENT
309*cdebaff8SEnji Cooper	wait_for_disconnected
310*cdebaff8SEnji Cooper	atf_check -s not-exit:0 -o ignore -e ignore \
311*cdebaff8SEnji Cooper	    rump.ping6 -c 1 -X $TIMEOUT $SERVER_IP6
312*cdebaff8SEnji Cooper	atf_check -s exit:0 -o not-match:"$session_id" -x "$HIJACKING pppoectl -d pppoe0"
313*cdebaff8SEnji Cooper	unset RUMP_SERVER
314*cdebaff8SEnji Cooper
315*cdebaff8SEnji Cooper	# test for recoonecting
316*cdebaff8SEnji Cooper	export RUMP_SERVER=$SERVER
317*cdebaff8SEnji Cooper	atf_check -s exit:0 rump.ifconfig pppoe0 up
318*cdebaff8SEnji Cooper	wait_for_session_established
319*cdebaff8SEnji Cooper	atf_check -s exit:0 rump.ifconfig -w 10
320*cdebaff8SEnji Cooper	$DEBUG && $HIJACKING pppoectl -d pppoe0
321*cdebaff8SEnji Cooper	$DEBUG && rump.ifconfig pppoe0
322*cdebaff8SEnji Cooper	export RUMP_SERVER=$CLIENT
323*cdebaff8SEnji Cooper	atf_check -s exit:0 -o ignore rump.ifconfig -w 10
324*cdebaff8SEnji Cooper	atf_check -s exit:0 -o ignore rump.ping6 -c 1 -X $TIMEOUT $SERVER_IP6
325*cdebaff8SEnji Cooper	unset RUMP_SERVER
326*cdebaff8SEnji Cooper
327*cdebaff8SEnji Cooper	# test for disconnection from client
328*cdebaff8SEnji Cooper	export RUMP_SERVER=$CLIENT
329*cdebaff8SEnji Cooper	atf_check -s exit:0 rump.ifconfig pppoe0 down
330*cdebaff8SEnji Cooper	wait_for_disconnected
331*cdebaff8SEnji Cooper
332*cdebaff8SEnji Cooper	export RUMP_SERVER=$SERVER
333*cdebaff8SEnji Cooper	wait_for_disconnected
334*cdebaff8SEnji Cooper	$DEBUG && $HIJACKING pppoectl -d pppoe0
335*cdebaff8SEnji Cooper	atf_check -s not-exit:0 -o ignore -e ignore \
336*cdebaff8SEnji Cooper	    rump.ping6 -c 1 -X $TIMEOUT $CLIENT_IP6
337*cdebaff8SEnji Cooper	atf_check -s exit:0 -o match:'initial' -x "$HIJACKING pppoectl -d pppoe0"
338*cdebaff8SEnji Cooper	unset RUMP_SERVER
339*cdebaff8SEnji Cooper
340*cdebaff8SEnji Cooper	# test for reconnecting
341*cdebaff8SEnji Cooper	export RUMP_SERVER=$CLIENT
342*cdebaff8SEnji Cooper	atf_check -s exit:0 rump.ifconfig pppoe0 up
343*cdebaff8SEnji Cooper	wait_for_session_established
344*cdebaff8SEnji Cooper	atf_check -s exit:0 rump.ifconfig -w 10
345*cdebaff8SEnji Cooper
346*cdebaff8SEnji Cooper	$DEBUG && rump.ifconfig pppoe0
347*cdebaff8SEnji Cooper	$DEBUG && $HIJACKING pppoectl -d pppoe0
348*cdebaff8SEnji Cooper	unset RUMP_SERVER
349*cdebaff8SEnji Cooper
350*cdebaff8SEnji Cooper	export RUMP_SERVER=$SERVER
351*cdebaff8SEnji Cooper	atf_check -s exit:0 rump.ifconfig -w 10
352*cdebaff8SEnji Cooper	atf_check -s exit:0 -o ignore rump.ping6 -c 1 -X $TIMEOUT $CLIENT_IP6
353*cdebaff8SEnji Cooper	atf_check -s exit:0 -o match:'session' -x "$HIJACKING pppoectl -d pppoe0"
354*cdebaff8SEnji Cooper	$DEBUG && HIJACKING pppoectl -d pppoe0
355*cdebaff8SEnji Cooper	unset RUMP_SERVER
356*cdebaff8SEnji Cooper
357*cdebaff8SEnji Cooper	# test for invalid password
358*cdebaff8SEnji Cooper	export RUMP_SERVER=$CLIENT
359*cdebaff8SEnji Cooper	atf_check -s exit:0 rump.ifconfig pppoe0 down
360*cdebaff8SEnji Cooper	wait_for_disconnected
361*cdebaff8SEnji Cooper	local setup_clientparam="pppoectl pppoe0 myauthproto=$auth \
362*cdebaff8SEnji Cooper				    'myauthname=$AUTHNAME' \
363*cdebaff8SEnji Cooper				    'myauthsecret=invalidsecret' \
364*cdebaff8SEnji Cooper				    'hisauthproto=none'"
365*cdebaff8SEnji Cooper	atf_check -s exit:0 -x "$HIJACKING $setup_clientparam"
366*cdebaff8SEnji Cooper	atf_check -s exit:0 rump.ifconfig pppoe0 up
367*cdebaff8SEnji Cooper	wait_for_session_established dontfail
368*cdebaff8SEnji Cooper	atf_check -s not-exit:0 -o ignore -e ignore \
369*cdebaff8SEnji Cooper	    rump.ping6 -c 1 -X $TIMEOUT $SERVER_IP6
370*cdebaff8SEnji Cooper	atf_check -s exit:0 -o match:'DETACHED' rump.ifconfig pppoe0
371*cdebaff8SEnji Cooper	unset RUMP_SERVER
372*cdebaff8SEnji Cooper}
373*cdebaff8SEnji Cooper
374*cdebaff8SEnji Cooperatf_test_case pppoe6_pap cleanup
375*cdebaff8SEnji Cooper
376*cdebaff8SEnji Cooperpppoe6_pap_head()
377*cdebaff8SEnji Cooper{
378*cdebaff8SEnji Cooper	atf_set "descr" "Does simple pap using IPv6 tests"
379*cdebaff8SEnji Cooper	atf_set "require.progs" "rump_server pppoectl"
380*cdebaff8SEnji Cooper}
381*cdebaff8SEnji Cooper
382*cdebaff8SEnji Cooperpppoe6_pap_body()
383*cdebaff8SEnji Cooper{
384*cdebaff8SEnji Cooper	run_test6 pap
385*cdebaff8SEnji Cooper}
386*cdebaff8SEnji Cooper
387*cdebaff8SEnji Cooperpppoe6_pap_cleanup()
388*cdebaff8SEnji Cooper{
389*cdebaff8SEnji Cooper	cleanup
390*cdebaff8SEnji Cooper}
391*cdebaff8SEnji Cooper
392*cdebaff8SEnji Cooperatf_test_case pppoe6_chap cleanup
393*cdebaff8SEnji Cooper
394*cdebaff8SEnji Cooperpppoe6_chap_head()
395*cdebaff8SEnji Cooper{
396*cdebaff8SEnji Cooper	atf_set "descr" "Does simple chap using IPv6 tests"
397*cdebaff8SEnji Cooper	atf_set "require.progs" "rump_server pppoectl"
398*cdebaff8SEnji Cooper}
399*cdebaff8SEnji Cooper
400*cdebaff8SEnji Cooperpppoe6_chap_body()
401*cdebaff8SEnji Cooper{
402*cdebaff8SEnji Cooper	run_test6 chap
403*cdebaff8SEnji Cooper}
404*cdebaff8SEnji Cooper
405*cdebaff8SEnji Cooperpppoe6_chap_cleanup()
406*cdebaff8SEnji Cooper{
407*cdebaff8SEnji Cooper	cleanup
408*cdebaff8SEnji Cooper}
409*cdebaff8SEnji Cooper
410640235e2SEnji Cooperatf_init_test_cases()
411640235e2SEnji Cooper{
412*cdebaff8SEnji Cooper	atf_add_test_case pppoe_pap
413*cdebaff8SEnji Cooper	atf_add_test_case pppoe_chap
414*cdebaff8SEnji Cooper	atf_add_test_case pppoe6_pap
415*cdebaff8SEnji Cooper	atf_add_test_case pppoe6_chap
416640235e2SEnji Cooper}
417