t_pppoe.sh revision 1.29 1 # $NetBSD: t_pppoe.sh,v 1.29 2021/05/06 01:09:43 yamaguchi Exp $
2 #
3 # Copyright (c) 2016 Internet Initiative Japan Inc.
4 # All rights reserved.
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
14 #
15 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 # POSSIBILITY OF SUCH DAMAGE.
26 #
27
28 SERVER=unix://pppoe_server
29 CLIENT=unix://pppoe_client
30
31 SERVER_IP=10.3.3.1
32 CLIENT_IP=10.3.3.3
33 SERVER_IP6=fc00::1
34 CLIENT_IP6=fc00::3
35 AUTHNAME=foobar@baz.com
36 SECRET=oink
37 BUS=bus0
38 TIMEOUT=3
39 WAITTIME=10
40 DEBUG=${DEBUG:-false}
41
42 atf_ifconfig()
43 {
44
45 atf_check -s exit:0 rump.ifconfig $*
46 }
47
48 atf_pppoectl()
49 {
50
51 atf_check -s exit:0 -x "$HIJACKING pppoectl $*"
52 }
53
54 atf_test_case pppoe_create_destroy cleanup
55 pppoe_create_destroy_head()
56 {
57
58 atf_set "descr" "Test creating/destroying pppoe interfaces"
59 atf_set "require.progs" "rump_server"
60 }
61
62 pppoe_create_destroy_body()
63 {
64
65 rump_server_start $CLIENT netinet6 pppoe
66
67 test_create_destroy_common $CLIENT pppoe0 true
68 }
69
70 pppoe_create_destroy_cleanup()
71 {
72
73 $DEBUG && dump
74 cleanup
75 }
76
77 setup_ifaces()
78 {
79
80 rump_server_add_iface $SERVER shmif0 $BUS
81 rump_server_add_iface $CLIENT shmif0 $BUS
82 rump_server_add_iface $SERVER pppoe0
83 rump_server_add_iface $CLIENT pppoe0
84
85 export RUMP_SERVER=$SERVER
86 atf_ifconfig shmif0 up
87 $inet && atf_ifconfig pppoe0 \
88 inet $SERVER_IP $CLIENT_IP down
89 atf_ifconfig pppoe0 link0
90
91 $DEBUG && rump.ifconfig pppoe0 debug
92 $DEBUG && rump.ifconfig
93 $DEBUG && $HIJACKING pppoectl -d pppoe0
94 unset RUMP_SERVER
95
96 export RUMP_SERVER=$CLIENT
97 atf_ifconfig shmif0 up
98
99 $inet && atf_ifconfig pppoe0 \
100 inet 0.0.0.0 0.0.0.1 down
101
102 $DEBUG && rump.ifconfig pppoe0 debug
103 $DEBUG && rump.ifconfig
104 $DEBUG && $HIJACKING pppoectl -d pppoe0
105 unset RUMP_SERVER
106 }
107
108 setup()
109 {
110 inet=true
111
112 if [ $# -ne 0 ]; then
113 eval $@
114 fi
115
116 rump_server_start $SERVER netinet6 pppoe
117 rump_server_start $CLIENT netinet6 pppoe
118
119 setup_ifaces
120
121 export RUMP_SERVER=$SERVER
122 atf_pppoectl -e shmif0 pppoe0
123 unset RUMP_SERVER
124
125 export RUMP_SERVER=$CLIENT
126 atf_pppoectl -e shmif0 pppoe0
127 unset RUMP_SERVER
128 }
129
130 wait_for_opened()
131 {
132 local cp=$1
133 local dontfail=$2
134 local n=$WAITTIME
135
136 for i in $(seq $n); do
137 $HIJACKING pppoectl -dd pppoe0 | grep -q "$cp state: opened"
138 if [ $? = 0 ]; then
139 rump.ifconfig -w 10
140 return
141 fi
142 sleep 1
143 done
144
145 if [ "$dontfail" != "dontfail" ]; then
146 atf_fail "Couldn't connect to the server for $n seconds."
147 fi
148 }
149
150 wait_for_disconnected()
151 {
152 local dontfail=$1
153 local n=$WAITTIME
154
155 for i in $(seq $n); do
156 # If PPPoE client is disconnected by PPPoE server, then
157 # the LCP state will of the client is in a starting to send PADI.
158 $HIJACKING pppoectl -dd pppoe0 | grep -q \
159 -e "LCP state: initial" -e "LCP state: starting"
160 [ $? = 0 ] && return
161
162 sleep 1
163 done
164
165 if [ "$dontfail" != "dontfail" ]; then
166 atf_fail "Couldn't disconnect for $n seconds."
167 fi
168 }
169
170 run_test()
171 {
172 local auth=$1
173 local cp="IPCP"
174 setup
175
176 # As pppoe client doesn't support rechallenge yet.
177 local server_optparam=""
178 if [ $auth = "chap" ]; then
179 server_optparam="norechallenge"
180 fi
181
182 export RUMP_SERVER=$SERVER
183 atf_pppoectl pppoe0 "hisauthproto=$auth" \
184 "hisauthname=$AUTHNAME" "hisauthsecret=$SECRET" \
185 "myauthproto=none" $server_optparam
186 atf_ifconfig pppoe0 up
187 unset RUMP_SERVER
188
189 export RUMP_SERVER=$CLIENT
190 atf_pppoectl pppoe0 \
191 "myauthname=$AUTHNAME" "myauthsecret=$SECRET" \
192 "myauthproto=$auth" "hisauthproto=none"
193 atf_ifconfig pppoe0 up
194 $DEBUG && rump.ifconfig
195 wait_for_opened $cp
196 atf_check -s exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT $SERVER_IP
197 unset RUMP_SERVER
198
199 # test for disconnection from server
200 export RUMP_SERVER=$SERVER
201 atf_ifconfig pppoe0 down
202 wait_for_disconnected
203 export RUMP_SERVER=$CLIENT
204 wait_for_disconnected
205 atf_check -s not-exit:0 -o ignore -e ignore \
206 rump.ping -c 1 -w $TIMEOUT $SERVER_IP
207 atf_check -s exit:0 -o match:'PADI sent' -x "$HIJACKING pppoectl -d pppoe0"
208 unset RUMP_SERVER
209
210 # test for reconnecting
211 atf_check -s exit:0 -x "env RUMP_SERVER=$SERVER rump.ifconfig pppoe0 up"
212 export RUMP_SERVER=$CLIENT
213 wait_for_opened $cp
214 atf_check -s exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT $SERVER_IP
215 unset RUMP_SERVER
216
217 # test for disconnection from client
218 export RUMP_SERVER=$CLIENT
219 atf_ifconfig pppoe0 down
220 wait_for_disconnected
221 export RUMP_SERVER=$SERVER
222 wait_for_disconnected
223 $DEBUG && $HIJACKING pppoectl -d pppoe0
224 atf_check -s not-exit:0 -o ignore -e ignore \
225 rump.ping -c 1 -w $TIMEOUT $CLIENT_IP
226 atf_check -s exit:0 -o match:'initial' -x "$HIJACKING pppoectl -d pppoe0"
227 unset RUMP_SERVER
228
229 # test for reconnecting
230 export RUMP_SERVER=$CLIENT
231 atf_ifconfig pppoe0 up
232 wait_for_opened $cp
233 $DEBUG && rump.ifconfig pppoe0
234 $DEBUG && $HIJACKING pppoectl -d pppoe0
235 unset RUMP_SERVER
236
237 export RUMP_SERVER=$SERVER
238 atf_ifconfig -w 10
239 atf_check -s exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT $CLIENT_IP
240 atf_check -s exit:0 -o match:'session' -x "$HIJACKING pppoectl -d pppoe0"
241 $DEBUG && HIJACKING pppoectl -d pppoe0
242 unset RUMP_SERVER
243
244 # test for invalid password
245 export RUMP_SERVER=$CLIENT
246 atf_ifconfig pppoe0 down
247 wait_for_disconnected
248 atf_pppoectl pppoe0 "myauthproto=$auth" \
249 "myauthname=$AUTHNAME" \
250 "myauthsecret=invalidsecret" \
251 "hisauthproto=none" \
252 "max-auth-failure=1"
253 atf_ifconfig pppoe0 up
254 wait_for_opened $cp dontfail
255 atf_check -s not-exit:0 -o ignore -e ignore \
256 rump.ping -c 1 -w $TIMEOUT $SERVER_IP
257 atf_check -s exit:0 -o match:'DETACHED' rump.ifconfig pppoe0
258 unset RUMP_SERVER
259 }
260
261 atf_test_case pppoe_pap cleanup
262
263 pppoe_pap_head()
264 {
265 atf_set "descr" "Does simple pap tests"
266 atf_set "require.progs" "rump_server pppoectl"
267 }
268
269 pppoe_pap_body()
270 {
271 run_test pap
272 }
273
274 pppoe_pap_cleanup()
275 {
276
277 $DEBUG && dump
278 cleanup
279 }
280
281 atf_test_case pppoe_chap cleanup
282
283 pppoe_chap_head()
284 {
285 atf_set "descr" "Does simple chap tests"
286 atf_set "require.progs" "rump_server pppoectl"
287 }
288
289 pppoe_chap_body()
290 {
291 run_test chap
292 }
293
294 pppoe_chap_cleanup()
295 {
296
297 $DEBUG && dump
298 cleanup
299 }
300
301 run_test6()
302 {
303 local auth=$1
304 local cp="IPv6CP"
305 setup "inet=false"
306
307 # As pppoe client doesn't support rechallenge yet.
308 local server_optparam=""
309 if [ $auth = "chap" ]; then
310 server_optparam="norechallenge"
311 fi
312
313 export RUMP_SERVER=$SERVER
314 atf_pppoectl pppoe0 \
315 "hisauthname=$AUTHNAME" "hisauthsecret=$SECRET" \
316 "hisauthproto=$auth" "myauthproto=none" \
317 $server_optparam
318 atf_ifconfig pppoe0 inet6 $SERVER_IP6/64 down
319 atf_ifconfig pppoe0 up
320 unset RUMP_SERVER
321
322 export RUMP_SERVER=$CLIENT
323 atf_pppoectl pppoe0 \
324 "myauthname=$AUTHNAME" "myauthsecret=$SECRET" \
325 "myauthproto=$auth" "hisauthproto=none"
326 atf_ifconfig pppoe0 inet6 $CLIENT_IP6/64 down
327 atf_ifconfig pppoe0 up
328 $DEBUG && rump.ifconfig
329 wait_for_opened $cp
330 atf_ifconfig -w 10
331 export RUMP_SERVER=$SERVER
332 rump.ifconfig -w 10
333 export RUMP_SERVER=$CLIENT
334 atf_check -s exit:0 -o ignore rump.ping6 -c 1 -X $TIMEOUT $SERVER_IP6
335 unset RUMP_SERVER
336
337 # test for disconnection from server
338 export RUMP_SERVER=$SERVER
339 session_id=`$HIJACKING pppoectl -d pppoe0 | grep state`
340 atf_ifconfig pppoe0 down
341 wait_for_disconnected
342 export RUMP_SERVER=$CLIENT
343 wait_for_disconnected
344 atf_check -s not-exit:0 -o ignore -e ignore \
345 rump.ping6 -c 1 -X $TIMEOUT $SERVER_IP6
346 atf_check -s exit:0 -o not-match:"$session_id" -x "$HIJACKING pppoectl -d pppoe0"
347 unset RUMP_SERVER
348
349 # test for reconnecting
350 export RUMP_SERVER=$SERVER
351 atf_ifconfig pppoe0 up
352 wait_for_opened $cp
353 atf_ifconfig -w 10
354 $DEBUG && $HIJACKING pppoectl -d pppoe0
355 $DEBUG && rump.ifconfig pppoe0
356 export RUMP_SERVER=$CLIENT
357 atf_ifconfig -w 10
358 atf_check -s exit:0 -o ignore rump.ping6 -c 1 -X $TIMEOUT $SERVER_IP6
359 unset RUMP_SERVER
360
361 # test for disconnection from client
362 export RUMP_SERVER=$CLIENT
363 atf_ifconfig pppoe0 down
364 wait_for_disconnected
365
366 export RUMP_SERVER=$SERVER
367 wait_for_disconnected
368 $DEBUG && $HIJACKING pppoectl -d pppoe0
369 atf_check -s not-exit:0 -o ignore -e ignore \
370 rump.ping6 -c 1 -X $TIMEOUT $CLIENT_IP6
371 atf_check -s exit:0 -o match:'initial' -x "$HIJACKING pppoectl -d pppoe0"
372 unset RUMP_SERVER
373
374 # test for reconnecting
375 export RUMP_SERVER=$CLIENT
376 atf_ifconfig pppoe0 up
377 wait_for_opened $cp
378 atf_ifconfig -w 10
379
380 $DEBUG && rump.ifconfig pppoe0
381 $DEBUG && $HIJACKING pppoectl -d pppoe0
382 unset RUMP_SERVER
383
384 export RUMP_SERVER=$SERVER
385 atf_ifconfig -w 10
386 atf_check -s exit:0 -o ignore rump.ping6 -c 1 -X $TIMEOUT $CLIENT_IP6
387 atf_check -s exit:0 -o match:'session' -x "$HIJACKING pppoectl -d pppoe0"
388 $DEBUG && HIJACKING pppoectl -d pppoe0
389 unset RUMP_SERVER
390
391 # test for invalid password
392 export RUMP_SERVER=$CLIENT
393 atf_ifconfig pppoe0 down
394 wait_for_disconnected
395 atf_pppoectl pppoe0 \
396 "myauthname=$AUTHNAME" "myauthsecret=invalidsecret" \
397 "myauthproto=$auth" "hisauthproto=none" \
398 "max-auth-failure=1"
399 atf_ifconfig pppoe0 up
400 wait_for_opened $cp dontfail
401 atf_check -s not-exit:0 -o ignore -e ignore \
402 rump.ping6 -c 1 -X $TIMEOUT $SERVER_IP6
403 atf_check -s exit:0 -o match:'DETACHED' rump.ifconfig pppoe0
404 unset RUMP_SERVER
405 }
406
407 atf_test_case pppoe6_pap cleanup
408
409 pppoe6_pap_head()
410 {
411 atf_set "descr" "Does simple pap using IPv6 tests"
412 atf_set "require.progs" "rump_server pppoectl"
413 }
414
415 pppoe6_pap_body()
416 {
417 run_test6 pap
418 }
419
420 pppoe6_pap_cleanup()
421 {
422
423 $DEBUG && dump
424 cleanup
425 }
426
427 atf_test_case pppoe6_chap cleanup
428
429 pppoe6_chap_head()
430 {
431 atf_set "descr" "Does simple chap using IPv6 tests"
432 atf_set "require.progs" "rump_server pppoectl"
433 }
434
435 pppoe6_chap_body()
436 {
437 run_test6 chap
438 }
439
440 pppoe6_chap_cleanup()
441 {
442
443 $DEBUG && dump
444 cleanup
445 }
446
447 atf_test_case pppoe_params cleanup
448
449 dump_bus()
450 {
451
452 shmif_dumpbus -p - ${BUS} | tcpdump -n -e -r -
453 }
454
455 setup_auth_conf()
456 {
457 local auth=chap
458 local server_optparam="norechallenge"
459
460 export RUMP_SERVER=$SERVER
461 atf_ifconfig pppoe0 link0
462 atf_pppoectl pppoe0 \
463 "hisauthname=$AUTHNAME" "hisauthsecret=$SECRET" \
464 "hisauthproto=$auth" "myauthproto=none" \
465 $server_optparam
466 unset RUMP_SERVER
467
468 export RUMP_SERVER=$CLIENT
469 $inet && atf_ifconfig pppoe0 \
470 inet 0.0.0.0 0.0.0.1 down
471 atf_pppoectl pppoe0 \
472 "myauthname=$AUTHNAME" "myauthsecret=$SECRET" \
473 "myauthproto=$auth" "hisauthproto=none"
474
475 $DEBUG && rump.ifconfig
476 unset RUMP_SERVER
477 }
478
479 pppoe_params_head()
480 {
481 atf_set "descr" "Set and clear access concentrator name and service name"
482 atf_set "require.progs" "rump_server pppoectl"
483 }
484
485 pppoe_params_body()
486 {
487 local dumpcmd
488 local cp="LCP"
489
490 dumpcmd="shmif_dumpbus -p - ${BUS}"
491 dumpcmd="${dumpcmd} | tcpdump -n -e -r -"
492
493 rump_server_start $SERVER netinet6 pppoe
494 rump_server_start $CLIENT netinet6 pppoe
495
496 setup_ifaces
497 setup_auth_conf
498
499 export RUMP_SERVER=$SERVER
500 atf_pppoectl -e shmif0 pppoe0
501 atf_ifconfig pppoe0 up
502 unset RUMP_SERVER
503
504 export RUMP_SERVER=$CLIENT
505 atf_pppoectl -e shmif0 pppoe0
506 atf_ifconfig pppoe0 up
507 $DEBUG && rump.ifconfig
508 wait_for_opened $cp
509 unset RUMP_SERVER
510
511 $DEBUG && dump_bus
512 atf_check -s exit:0 -o match:'\[Service-Name\]' -e ignore \
513 -x "${dumpcmd} | grep PADI"
514 atf_check -s exit:0 -o match:'\[Service-Name\]' -e ignore \
515 -x "${dumpcmd} | grep PADR"
516 atf_check -s exit:0 -o not-match:'AC-Name' -e ignore \
517 -x "${dumpcmd} | grep PADI"
518
519 # set Remote access concentrator name (AC-NAME, -a option)
520 export RUMP_SERVER=$CLIENT
521 atf_ifconfig pppoe0 down
522 wait_for_disconnected
523 atf_pppoectl -e shmif0 -a ACNAME-TEST0 pppoe0
524 atf_ifconfig pppoe0 up
525 $DEBUG && rump.ifconfig
526 wait_for_opened $cp
527 unset RUMP_SERVER
528
529 $DEBUG && dump_bus
530 atf_check -s exit:0 -o match:'\[AC-Name "ACNAME-TEST0"\]' -e ignore \
531 -x "${dumpcmd} | grep PADI"
532
533 # change AC-NAME
534 export RUMP_SERVER=$CLIENT
535 atf_ifconfig pppoe0 down
536 wait_for_disconnected
537 atf_pppoectl -e shmif0 -a ACNAME-TEST1 pppoe0
538 atf_ifconfig pppoe0 up
539 $DEBUG && rump.ifconfig
540 wait_for_opened $cp
541 unset RUMP_SERVER
542
543 $DEBUG && dump_bus
544 atf_check -s exit:0 -o match:'\[AC-Name "ACNAME-TEST1"\]' -e ignore \
545 -x "${dumpcmd} | grep PADI"
546
547 # clear AC-NAME
548 rump_server_destroy_ifaces
549 rm ${BUS} 2> /dev/null
550 setup_ifaces
551 setup_auth_conf
552
553 export RUMP_SERVER=$SERVER
554 atf_pppoectl -e shmif0 pppoe0
555 atf_ifconfig pppoe0 up
556 unset RUMP_SERVER
557
558 export RUMP_SERVER=$CLIENT
559 atf_ifconfig pppoe0 down
560 wait_for_disconnected
561 atf_pppoectl -a ACNAME-TEST2 -e shmif0 pppoe0
562 atf_pppoectl -e shmif0 pppoe0
563 atf_ifconfig pppoe0 up
564 $DEBUG && rump.ifconfig
565 wait_for_opened $cp
566 unset RUMP_SERVER
567
568 $DEBUG && dump_bus
569 atf_check -s exit:0 -o match:'\[Service-Name\]' -e ignore \
570 -x "${dumpcmd} | grep PADI"
571 atf_check -s exit:0 -o match:'\[Service-Name\]' -e ignore \
572 -x "${dumpcmd} | grep PADR"
573 atf_check -s exit:0 -o not-match:'AC-Name' -e ignore \
574 -x "${dumpcmd} | grep PADI"
575
576 # store 0 length string in AC-NAME
577 export RUMP_SERVER=$CLIENT
578 atf_ifconfig pppoe0 down
579 wait_for_disconnected
580 atf_pppoectl -a \"\" -e shmif0 pppoe0
581 atf_ifconfig pppoe0 up
582 $DEBUG && rump.ifconfig
583 wait_for_opened $cp
584 unset RUMP_SERVER
585
586 atf_check -s exit:0 -o match:'\[AC-Name\]' -e ignore \
587 -x "${dumpcmd} | grep PADI"
588
589 # set Service Name (Service-Name, -s option)
590 rump_server_destroy_ifaces
591 rm ${BUS} 2> /dev/null
592 setup_ifaces
593 setup_auth_conf
594
595 export RUMP_SERVER=$SERVER
596 atf_pppoectl -e shmif0 pppoe0
597 atf_ifconfig pppoe0 up
598 unset RUMP_SERVER
599
600 export RUMP_SERVER=$CLIENT
601 atf_ifconfig pppoe0 down
602 wait_for_disconnected
603 atf_pppoectl -e shmif0 -s SNAME-TEST0 pppoe0
604 atf_ifconfig pppoe0 up
605 $DEBUG && rump.ifconfig
606 wait_for_opened $cp
607 unset RUMP_SERVER
608
609 $DEBUG && dump_bus
610 atf_check -s exit:0 -o match:'\[Service-Name "SNAME-TEST0"\]' -e ignore \
611 -x "${dumpcmd} | grep PADI"
612 atf_check -s exit:0 -o match:'\[Service-Name "SNAME-TEST0"\]' -e ignore \
613 -x "${dumpcmd} | grep PADR"
614 atf_check -s exit:0 -o not-match:'AC-Name' -e ignore \
615 -x "${dumpcmd} | grep PADI"
616
617 # change Service-Name
618 export RUMP_SERVER=$CLIENT
619 atf_ifconfig pppoe0 down
620 wait_for_disconnected
621 atf_pppoectl -e shmif0 -s SNAME-TEST1 pppoe0
622 atf_ifconfig pppoe0 up
623 $DEBUG && rump.ifconfig
624 wait_for_opened $cp
625 unset RUMP_SERVER
626
627 $DEBUG && dump_bus
628 atf_check -s exit:0 -o match:'\[Service-Name "SNAME-TEST1"\]' -e ignore \
629 -x "${dumpcmd} | grep PADI"
630 atf_check -s exit:0 -o match:'\[Service-Name "SNAME-TEST1"\]' -e ignore \
631 -x "${dumpcmd} | grep PADR"
632
633 # clear Service-Name
634 rump_server_destroy_ifaces
635 rm ${BUS} 2> /dev/null
636 setup_ifaces
637 setup_auth_conf
638
639 export RUMP_SERVER=$SERVER
640 atf_pppoectl -e shmif0 pppoe0
641 atf_ifconfig pppoe0 up
642 unset RUMP_SERVER
643
644 export RUMP_SERVER=$CLIENT
645 atf_ifconfig pppoe0 down
646 wait_for_disconnected
647 atf_pppoectl -s SNAME-TEST2 -e shmif0 pppoe0
648 atf_pppoectl -e shmif0 pppoe0
649 atf_ifconfig pppoe0 up
650 $DEBUG && rump.ifconfig
651 wait_for_opened $cp
652 unset RUMP_SERVER
653
654 $DEBUG && dump_bus
655 atf_check -s exit:0 -o match:'\[Service-Name\]' -e ignore \
656 -x "${dumpcmd} | grep PADI"
657 atf_check -s exit:0 -o match:'\[Service-Name\]' -e ignore \
658 -x "${dumpcmd} | grep PADR"
659 atf_check -s exit:0 -o not-match:'AC-Name' -e ignore \
660 -x "${dumpcmd} | grep PADI"
661
662 # set AC-NAME and Service-Name
663 rump_server_destroy_ifaces
664 rm ${BUS} 2> /dev/null
665 setup_ifaces
666 setup_auth_conf
667
668 export RUMP_SERVER=$SERVER
669 atf_pppoectl -e shmif0 pppoe0
670 atf_ifconfig pppoe0 up
671 unset RUMP_SERVER
672
673 export RUMP_SERVER=$CLIENT
674 atf_ifconfig pppoe0 down
675 wait_for_disconnected
676 atf_pppoectl -e shmif0 -a ACNAME-TEST3 -s SNAME-TEST3 pppoe0
677 atf_ifconfig pppoe0 up
678 $DEBUG && rump.ifconfig
679 wait_for_opened $cp
680 unset RUMP_SERVER
681
682 $DEBUG && dump_bus
683 atf_check -s exit:0 \
684 -o match:'\[Service-Name "SNAME-TEST3"\] \[AC-Name "ACNAME-TEST3"\]' \
685 -e ignore \
686 -x "${dumpcmd} | grep PADI"
687 atf_check -s exit:0 -o match:'\[Service-Name "SNAME-TEST3"\]' -e ignore \
688 -x "${dumpcmd} | grep PADR"
689
690 # change AC-NAME
691 export RUMP_SERVER=$CLIENT
692 atf_ifconfig pppoe0 down
693 wait_for_disconnected
694 atf_pppoectl -e shmif0 -a ACNAME-TEST4 pppoe0
695 atf_ifconfig pppoe0 up
696 $DEBUG && rump.ifconfig
697 wait_for_opened $cp
698 unset RUMP_SERVER
699
700 $DEBUG && dump_bus
701 atf_check -s exit:0 \
702 -o match:'\[Service-Name\] \[AC-Name "ACNAME-TEST4"\]' \
703 -e ignore \
704 -x "${dumpcmd} | grep PADI"
705 atf_check -s exit:0 -o match:'\[Service-Name\]' -e ignore \
706 -x "${dumpcmd} | grep PADR"
707
708 # change Service-Name
709 export RUMP_SERVER=$CLIENT
710 atf_ifconfig pppoe0 down
711 wait_for_disconnected
712 atf_pppoectl -e shmif0 -a ACNAME-TEST5 -s SNAME-TEST5 pppoe0
713 atf_pppoectl -e shmif0 -s SNAME-TEST6 pppoe0
714 atf_ifconfig pppoe0 up
715 $DEBUG && rump.ifconfig
716 wait_for_opened $cp
717 unset RUMP_SERVER
718
719 $DEBUG && dump_bus
720 atf_check -s exit:0 \
721 -o match:'\[Service-Name "SNAME-TEST6"\]' \
722 -e ignore \
723 -x "${dumpcmd} | grep PADI"
724 atf_check -s exit:0 -o match:'\[Service-Name "SNAME-TEST6"\]' -e ignore \
725 -x "${dumpcmd} | grep PADR"
726 atf_check -s exit:0 -o not-match:'\[AC-Name "ACNAME-TEST5\]"' -e ignore \
727 -x "${dumpcmd} | grep PADI"
728 }
729
730 pppoe_params_cleanup()
731 {
732
733 $DEBUG && dump
734 cleanup
735 }
736
737 pppoe_passiveauthproto()
738 {
739 local auth=$1
740 local cp="IPCP"
741 setup
742
743 local server_optparam=""
744 if [ $auth = "chap" ]; then
745 server_optparam="norechallenge"
746 fi
747
748 export RUMP_SERVER=$SERVER
749 atf_pppoectl pppoe0 \
750 "hisauthname=$AUTHNAME" "hisauthsecret=$SECRET" \
751 "hisauthproto=$auth" "myauthproto=none" \
752 $server_optparam
753 atf_ifconfig pppoe0 up
754
755 export RUMP_SERVER=$CLIENT
756 atf_pppoectl pppoe0 \
757 "myauthname=$AUTHNAME" "myauthsecret=$SECRET" \
758 "myauthproto=none" "hisauthproto=none" \
759 "passiveauthproto"
760 atf_ifconfig pppoe0 up
761 $DEBUG && rump.ifconfig
762 wait_for_opened $cp
763 atf_ifconfig -w 10
764 atf_check -s exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT $SERVER_IP
765 }
766
767 atf_test_case pppoe_passiveauthproto_pap cleanup
768 pppoe_passiveauthproto_pap_head()
769 {
770
771 atf_set "descr" "Test for passiveauthproto option on PAP"
772 atf_set "require.progs" "rump_server"
773 }
774
775 pppoe_passiveauthproto_pap_body()
776 {
777
778 pppoe_passiveauthproto "pap"
779 }
780
781 pppoe_passiveauthproto_pap_cleanup()
782 {
783
784 $DEBUG && dump
785 cleanup
786 }
787
788 atf_test_case pppoe_passiveauthproto_chap cleanup
789 pppoe_passiveauthproto_chap_head()
790 {
791
792 atf_set "descr" "Test for passiveauthproto option on chap"
793 atf_set "require.progs" "rump_server"
794 }
795
796 pppoe_passiveauthproto_chap_body()
797 {
798
799 pppoe_passiveauthproto "chap"
800 }
801
802 pppoe_passiveauthproto_chap_cleanup()
803 {
804
805 $DEBUG && dump
806 cleanup
807 }
808
809 atf_test_case pppoe_mtu cleanup
810 pppoe_mtu_head()
811 {
812
813 atf_set "descr" "Test for mtu"
814 atf_set "require.progs" "rump_server"
815 }
816
817 pppoe_mtu_body()
818 {
819 local auth=chap
820 local cp="IPCP"
821 setup
822
823 export RUMP_SERVER=$SERVER
824 atf_pppoectl pppoe0 \
825 "hisauthname=$AUTHNAME" "hisauthsecret=$SECRET" \
826 "hisauthproto=$auth" "myauthproto=none" \
827 norechallenge
828 atf_ifconfig pppoe0 mtu 1400
829 atf_ifconfig pppoe0 up
830
831 export RUMP_SERVER=$CLIENT
832 atf_pppoectl pppoe0 \
833 "myauthname=$AUTHNAME" "myauthsecret=$SECRET" \
834 "myauthproto=$auth" "hisauthproto=none"
835 atf_ifconfig pppoe0 mtu 1450
836 atf_ifconfig pppoe0 up
837
838 wait_for_opened $cp
839 atf_ifconfig -w 10
840
841 export RUMP_SERVER=$SERVER
842 atf_check -s exit:0 -o match:'mtu 1400' rump.ifconfig pppoe0
843
844 export RUMP_SERVER=$CLIENT
845 atf_check -s exit:0 -o match:'mtu 1400' rump.ifconfig pppoe0
846
847 # mtu can set to 1460 but it is not applied.
848 atf_ifconfig pppoe0 mtu 1460
849 atf_check -s exit:0 -o match:'mtu 1400' rump.ifconfig pppoe0
850
851 export RUMP_SERVER=$SERVER
852 atf_ifconfig pppoe0 mtu 1470
853 atf_ifconfig pppoe0 down
854 atf_ifconfig pppoe0 up
855 wait_for_opened $cp
856 atf_ifconfig -w 10
857
858 # mtu 1460 is applied after LCP negotiation
859 atf_check -s exit:0 -o match:'mtu 1460' rump.ifconfig pppoe0
860
861 export RUMP_SERVER=$CLIENT
862 atf_check -s exit:0 -o match:'mtu 1460' rump.ifconfig pppoe0
863
864 rump.ifconfig pppoe0 mtu 1500
865 atf_check -s exit:0 -o ignore \
866 -e match:'SIOCSIFMTU: Invalid argument' \
867 rump.ifconfig pppoe0 mtu 1501
868 }
869
870 pppoe_mtu_cleanup()
871 {
872
873 $DEBUG && dump
874 cleanup
875 }
876
877 atf_init_test_cases()
878 {
879
880 atf_add_test_case pppoe_create_destroy
881 atf_add_test_case pppoe_params
882 atf_add_test_case pppoe_pap
883 atf_add_test_case pppoe_chap
884 atf_add_test_case pppoe6_pap
885 atf_add_test_case pppoe6_chap
886 atf_add_test_case pppoe_passiveauthproto_pap
887 atf_add_test_case pppoe_passiveauthproto_chap
888 atf_add_test_case pppoe_mtu
889 }
890