t_pppoe.sh revision 1.29.2.1 1 # $NetBSD: t_pppoe.sh,v 1.29.2.1 2021/05/31 22:15:23 cjep 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)|(initial)' \
208 -x "$HIJACKING pppoectl -d pppoe0"
209 unset RUMP_SERVER
210
211 # test for reconnecting
212 atf_check -s exit:0 -x "env RUMP_SERVER=$SERVER rump.ifconfig pppoe0 up"
213 export RUMP_SERVER=$CLIENT
214 wait_for_opened $cp
215 atf_check -s exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT $SERVER_IP
216 unset RUMP_SERVER
217
218 # test for disconnection from client
219 export RUMP_SERVER=$CLIENT
220 atf_ifconfig pppoe0 down
221 wait_for_disconnected
222 export RUMP_SERVER=$SERVER
223 wait_for_disconnected
224 $DEBUG && $HIJACKING pppoectl -d pppoe0
225 atf_check -s not-exit:0 -o ignore -e ignore \
226 rump.ping -c 1 -w $TIMEOUT $CLIENT_IP
227 atf_check -s exit:0 -o match:'initial' -x "$HIJACKING pppoectl -d pppoe0"
228 unset RUMP_SERVER
229
230 # test for reconnecting
231 export RUMP_SERVER=$CLIENT
232 atf_ifconfig pppoe0 up
233 wait_for_opened $cp
234 $DEBUG && rump.ifconfig pppoe0
235 $DEBUG && $HIJACKING pppoectl -d pppoe0
236 unset RUMP_SERVER
237
238 export RUMP_SERVER=$SERVER
239 atf_ifconfig -w 10
240 atf_check -s exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT $CLIENT_IP
241 atf_check -s exit:0 -o match:'session' -x "$HIJACKING pppoectl -d pppoe0"
242 $DEBUG && $HIJACKING pppoectl -d pppoe0
243 unset RUMP_SERVER
244
245 # test for invalid password
246 export RUMP_SERVER=$CLIENT
247 atf_ifconfig pppoe0 down
248 wait_for_disconnected
249 atf_pppoectl pppoe0 "myauthproto=$auth" \
250 "myauthname=$AUTHNAME" \
251 "myauthsecret=invalidsecret" \
252 "hisauthproto=none" \
253 "max-auth-failure=1"
254 atf_ifconfig pppoe0 up
255 wait_for_opened $cp dontfail
256 atf_check -s not-exit:0 -o ignore -e ignore \
257 rump.ping -c 1 -w $TIMEOUT $SERVER_IP
258 atf_check -s exit:0 -o match:'DETACHED' rump.ifconfig pppoe0
259 unset RUMP_SERVER
260 }
261
262 atf_test_case pppoe_pap cleanup
263
264 pppoe_pap_head()
265 {
266 atf_set "descr" "Does simple pap tests"
267 atf_set "require.progs" "rump_server pppoectl"
268 }
269
270 pppoe_pap_body()
271 {
272 run_test pap
273 }
274
275 pppoe_pap_cleanup()
276 {
277
278 $DEBUG && dump
279 cleanup
280 }
281
282 atf_test_case pppoe_chap cleanup
283
284 pppoe_chap_head()
285 {
286 atf_set "descr" "Does simple chap tests"
287 atf_set "require.progs" "rump_server pppoectl"
288 }
289
290 pppoe_chap_body()
291 {
292 run_test chap
293 }
294
295 pppoe_chap_cleanup()
296 {
297
298 $DEBUG && dump
299 cleanup
300 }
301
302 run_test6()
303 {
304 local auth=$1
305 local cp="IPv6CP"
306 setup "inet=false"
307
308 # As pppoe client doesn't support rechallenge yet.
309 local server_optparam=""
310 if [ $auth = "chap" ]; then
311 server_optparam="norechallenge"
312 fi
313
314 export RUMP_SERVER=$SERVER
315 atf_pppoectl pppoe0 \
316 "hisauthname=$AUTHNAME" "hisauthsecret=$SECRET" \
317 "hisauthproto=$auth" "myauthproto=none" \
318 $server_optparam
319 atf_ifconfig pppoe0 inet6 $SERVER_IP6/64 down
320 atf_ifconfig pppoe0 up
321 unset RUMP_SERVER
322
323 export RUMP_SERVER=$CLIENT
324 atf_pppoectl pppoe0 \
325 "myauthname=$AUTHNAME" "myauthsecret=$SECRET" \
326 "myauthproto=$auth" "hisauthproto=none"
327 atf_ifconfig pppoe0 inet6 $CLIENT_IP6/64 down
328 atf_ifconfig pppoe0 up
329 $DEBUG && rump.ifconfig
330 wait_for_opened $cp
331 atf_ifconfig -w 10
332 export RUMP_SERVER=$SERVER
333 rump.ifconfig -w 10
334 export RUMP_SERVER=$CLIENT
335 atf_check -s exit:0 -o ignore rump.ping6 -c 1 -X $TIMEOUT $SERVER_IP6
336 unset RUMP_SERVER
337
338 # test for disconnection from server
339 export RUMP_SERVER=$SERVER
340 session_id=`$HIJACKING pppoectl -d pppoe0 | grep state`
341 atf_ifconfig pppoe0 down
342 wait_for_disconnected
343 export RUMP_SERVER=$CLIENT
344 wait_for_disconnected
345 atf_check -s not-exit:0 -o ignore -e ignore \
346 rump.ping6 -c 1 -X $TIMEOUT $SERVER_IP6
347 atf_check -s exit:0 -o not-match:"$session_id" -x "$HIJACKING pppoectl -d pppoe0"
348 unset RUMP_SERVER
349
350 # test for reconnecting
351 export RUMP_SERVER=$SERVER
352 atf_ifconfig pppoe0 up
353 wait_for_opened $cp
354 atf_ifconfig -w 10
355 $DEBUG && $HIJACKING pppoectl -d pppoe0
356 $DEBUG && rump.ifconfig pppoe0
357 export RUMP_SERVER=$CLIENT
358 atf_ifconfig -w 10
359 atf_check -s exit:0 -o ignore rump.ping6 -c 1 -X $TIMEOUT $SERVER_IP6
360 unset RUMP_SERVER
361
362 # test for disconnection from client
363 export RUMP_SERVER=$CLIENT
364 atf_ifconfig pppoe0 down
365 wait_for_disconnected
366
367 export RUMP_SERVER=$SERVER
368 wait_for_disconnected
369 $DEBUG && $HIJACKING pppoectl -d pppoe0
370 atf_check -s not-exit:0 -o ignore -e ignore \
371 rump.ping6 -c 1 -X $TIMEOUT $CLIENT_IP6
372 atf_check -s exit:0 -o match:'initial' -x "$HIJACKING pppoectl -d pppoe0"
373 unset RUMP_SERVER
374
375 # test for reconnecting
376 export RUMP_SERVER=$CLIENT
377 atf_ifconfig pppoe0 up
378 wait_for_opened $cp
379 atf_ifconfig -w 10
380
381 $DEBUG && rump.ifconfig pppoe0
382 $DEBUG && $HIJACKING pppoectl -d pppoe0
383 unset RUMP_SERVER
384
385 export RUMP_SERVER=$SERVER
386 atf_ifconfig -w 10
387 atf_check -s exit:0 -o ignore rump.ping6 -c 1 -X $TIMEOUT $CLIENT_IP6
388 atf_check -s exit:0 -o match:'session' -x "$HIJACKING pppoectl -d pppoe0"
389 $DEBUG && HIJACKING pppoectl -d pppoe0
390 unset RUMP_SERVER
391
392 # test for invalid password
393 export RUMP_SERVER=$CLIENT
394 atf_ifconfig pppoe0 down
395 wait_for_disconnected
396 atf_pppoectl pppoe0 \
397 "myauthname=$AUTHNAME" "myauthsecret=invalidsecret" \
398 "myauthproto=$auth" "hisauthproto=none" \
399 "max-auth-failure=1"
400 atf_ifconfig pppoe0 up
401 wait_for_opened $cp dontfail
402 atf_check -s not-exit:0 -o ignore -e ignore \
403 rump.ping6 -c 1 -X $TIMEOUT $SERVER_IP6
404 atf_check -s exit:0 -o match:'DETACHED' rump.ifconfig pppoe0
405 unset RUMP_SERVER
406 }
407
408 atf_test_case pppoe6_pap cleanup
409
410 pppoe6_pap_head()
411 {
412 atf_set "descr" "Does simple pap using IPv6 tests"
413 atf_set "require.progs" "rump_server pppoectl"
414 }
415
416 pppoe6_pap_body()
417 {
418 run_test6 pap
419 }
420
421 pppoe6_pap_cleanup()
422 {
423
424 $DEBUG && dump
425 cleanup
426 }
427
428 atf_test_case pppoe6_chap cleanup
429
430 pppoe6_chap_head()
431 {
432 atf_set "descr" "Does simple chap using IPv6 tests"
433 atf_set "require.progs" "rump_server pppoectl"
434 }
435
436 pppoe6_chap_body()
437 {
438 run_test6 chap
439 }
440
441 pppoe6_chap_cleanup()
442 {
443
444 $DEBUG && dump
445 cleanup
446 }
447
448 atf_test_case pppoe_params cleanup
449
450 dump_bus()
451 {
452
453 shmif_dumpbus -p - ${BUS} | tcpdump -n -e -r -
454 }
455
456 setup_auth_conf()
457 {
458 local auth=chap
459 local server_optparam="norechallenge"
460
461 export RUMP_SERVER=$SERVER
462 atf_ifconfig pppoe0 link0
463 atf_pppoectl pppoe0 \
464 "hisauthname=$AUTHNAME" "hisauthsecret=$SECRET" \
465 "hisauthproto=$auth" "myauthproto=none" \
466 $server_optparam
467 unset RUMP_SERVER
468
469 export RUMP_SERVER=$CLIENT
470 $inet && atf_ifconfig pppoe0 \
471 inet 0.0.0.0 0.0.0.1 down
472 atf_pppoectl pppoe0 \
473 "myauthname=$AUTHNAME" "myauthsecret=$SECRET" \
474 "myauthproto=$auth" "hisauthproto=none"
475
476 $DEBUG && rump.ifconfig
477 unset RUMP_SERVER
478 }
479
480 pppoe_params_head()
481 {
482 atf_set "descr" "Set and clear access concentrator name and service name"
483 atf_set "require.progs" "rump_server pppoectl"
484 }
485
486 pppoe_params_body()
487 {
488 local dumpcmd
489 local cp="LCP"
490
491 dumpcmd="shmif_dumpbus -p - ${BUS}"
492 dumpcmd="${dumpcmd} | tcpdump -n -e -r -"
493
494 rump_server_start $SERVER netinet6 pppoe
495 rump_server_start $CLIENT netinet6 pppoe
496
497 setup_ifaces
498 setup_auth_conf
499
500 export RUMP_SERVER=$SERVER
501 atf_pppoectl -e shmif0 pppoe0
502 atf_ifconfig pppoe0 up
503 unset RUMP_SERVER
504
505 export RUMP_SERVER=$CLIENT
506 atf_pppoectl -e shmif0 pppoe0
507 atf_ifconfig pppoe0 up
508 $DEBUG && rump.ifconfig
509 wait_for_opened $cp
510 unset RUMP_SERVER
511
512 $DEBUG && dump_bus
513 atf_check -s exit:0 -o match:'\[Service-Name\]' -e ignore \
514 -x "${dumpcmd} | grep PADI"
515 atf_check -s exit:0 -o match:'\[Service-Name\]' -e ignore \
516 -x "${dumpcmd} | grep PADR"
517 atf_check -s exit:0 -o not-match:'AC-Name' -e ignore \
518 -x "${dumpcmd} | grep PADI"
519
520 # set Remote access concentrator name (AC-NAME, -a option)
521 export RUMP_SERVER=$CLIENT
522 atf_ifconfig pppoe0 down
523 wait_for_disconnected
524 atf_pppoectl -e shmif0 -a ACNAME-TEST0 pppoe0
525 atf_ifconfig pppoe0 up
526 $DEBUG && rump.ifconfig
527 wait_for_opened $cp
528 unset RUMP_SERVER
529
530 $DEBUG && dump_bus
531 atf_check -s exit:0 -o match:'\[AC-Name "ACNAME-TEST0"\]' -e ignore \
532 -x "${dumpcmd} | grep PADI"
533
534 # change AC-NAME
535 export RUMP_SERVER=$CLIENT
536 atf_ifconfig pppoe0 down
537 wait_for_disconnected
538 atf_pppoectl -e shmif0 -a ACNAME-TEST1 pppoe0
539 atf_ifconfig pppoe0 up
540 $DEBUG && rump.ifconfig
541 wait_for_opened $cp
542 unset RUMP_SERVER
543
544 $DEBUG && dump_bus
545 atf_check -s exit:0 -o match:'\[AC-Name "ACNAME-TEST1"\]' -e ignore \
546 -x "${dumpcmd} | grep PADI"
547
548 # clear AC-NAME
549 rump_server_destroy_ifaces
550 rm ${BUS} 2> /dev/null
551 setup_ifaces
552 setup_auth_conf
553
554 export RUMP_SERVER=$SERVER
555 atf_pppoectl -e shmif0 pppoe0
556 atf_ifconfig pppoe0 up
557 unset RUMP_SERVER
558
559 export RUMP_SERVER=$CLIENT
560 atf_ifconfig pppoe0 down
561 wait_for_disconnected
562 atf_pppoectl -a ACNAME-TEST2 -e shmif0 pppoe0
563 atf_pppoectl -e shmif0 pppoe0
564 atf_ifconfig pppoe0 up
565 $DEBUG && rump.ifconfig
566 wait_for_opened $cp
567 unset RUMP_SERVER
568
569 $DEBUG && dump_bus
570 atf_check -s exit:0 -o match:'\[Service-Name\]' -e ignore \
571 -x "${dumpcmd} | grep PADI"
572 atf_check -s exit:0 -o match:'\[Service-Name\]' -e ignore \
573 -x "${dumpcmd} | grep PADR"
574 atf_check -s exit:0 -o not-match:'AC-Name' -e ignore \
575 -x "${dumpcmd} | grep PADI"
576
577 # store 0 length string in AC-NAME
578 export RUMP_SERVER=$CLIENT
579 atf_ifconfig pppoe0 down
580 wait_for_disconnected
581 atf_pppoectl -a \"\" -e shmif0 pppoe0
582 atf_ifconfig pppoe0 up
583 $DEBUG && rump.ifconfig
584 wait_for_opened $cp
585 unset RUMP_SERVER
586
587 atf_check -s exit:0 -o match:'\[AC-Name\]' -e ignore \
588 -x "${dumpcmd} | grep PADI"
589
590 # set Service Name (Service-Name, -s option)
591 rump_server_destroy_ifaces
592 rm ${BUS} 2> /dev/null
593 setup_ifaces
594 setup_auth_conf
595
596 export RUMP_SERVER=$SERVER
597 atf_pppoectl -e shmif0 pppoe0
598 atf_ifconfig pppoe0 up
599 unset RUMP_SERVER
600
601 export RUMP_SERVER=$CLIENT
602 atf_ifconfig pppoe0 down
603 wait_for_disconnected
604 atf_pppoectl -e shmif0 -s SNAME-TEST0 pppoe0
605 atf_ifconfig pppoe0 up
606 $DEBUG && rump.ifconfig
607 wait_for_opened $cp
608 unset RUMP_SERVER
609
610 $DEBUG && dump_bus
611 atf_check -s exit:0 -o match:'\[Service-Name "SNAME-TEST0"\]' -e ignore \
612 -x "${dumpcmd} | grep PADI"
613 atf_check -s exit:0 -o match:'\[Service-Name "SNAME-TEST0"\]' -e ignore \
614 -x "${dumpcmd} | grep PADR"
615 atf_check -s exit:0 -o not-match:'AC-Name' -e ignore \
616 -x "${dumpcmd} | grep PADI"
617
618 # change Service-Name
619 export RUMP_SERVER=$CLIENT
620 atf_ifconfig pppoe0 down
621 wait_for_disconnected
622 atf_pppoectl -e shmif0 -s SNAME-TEST1 pppoe0
623 atf_ifconfig pppoe0 up
624 $DEBUG && rump.ifconfig
625 wait_for_opened $cp
626 unset RUMP_SERVER
627
628 $DEBUG && dump_bus
629 atf_check -s exit:0 -o match:'\[Service-Name "SNAME-TEST1"\]' -e ignore \
630 -x "${dumpcmd} | grep PADI"
631 atf_check -s exit:0 -o match:'\[Service-Name "SNAME-TEST1"\]' -e ignore \
632 -x "${dumpcmd} | grep PADR"
633
634 # clear Service-Name
635 rump_server_destroy_ifaces
636 rm ${BUS} 2> /dev/null
637 setup_ifaces
638 setup_auth_conf
639
640 export RUMP_SERVER=$SERVER
641 atf_pppoectl -e shmif0 pppoe0
642 atf_ifconfig pppoe0 up
643 unset RUMP_SERVER
644
645 export RUMP_SERVER=$CLIENT
646 atf_ifconfig pppoe0 down
647 wait_for_disconnected
648 atf_pppoectl -s SNAME-TEST2 -e shmif0 pppoe0
649 atf_pppoectl -e shmif0 pppoe0
650 atf_ifconfig pppoe0 up
651 $DEBUG && rump.ifconfig
652 wait_for_opened $cp
653 unset RUMP_SERVER
654
655 $DEBUG && dump_bus
656 atf_check -s exit:0 -o match:'\[Service-Name\]' -e ignore \
657 -x "${dumpcmd} | grep PADI"
658 atf_check -s exit:0 -o match:'\[Service-Name\]' -e ignore \
659 -x "${dumpcmd} | grep PADR"
660 atf_check -s exit:0 -o not-match:'AC-Name' -e ignore \
661 -x "${dumpcmd} | grep PADI"
662
663 # set AC-NAME and Service-Name
664 rump_server_destroy_ifaces
665 rm ${BUS} 2> /dev/null
666 setup_ifaces
667 setup_auth_conf
668
669 export RUMP_SERVER=$SERVER
670 atf_pppoectl -e shmif0 pppoe0
671 atf_ifconfig pppoe0 up
672 unset RUMP_SERVER
673
674 export RUMP_SERVER=$CLIENT
675 atf_ifconfig pppoe0 down
676 wait_for_disconnected
677 atf_pppoectl -e shmif0 -a ACNAME-TEST3 -s SNAME-TEST3 pppoe0
678 atf_ifconfig pppoe0 up
679 $DEBUG && rump.ifconfig
680 wait_for_opened $cp
681 unset RUMP_SERVER
682
683 $DEBUG && dump_bus
684 atf_check -s exit:0 \
685 -o match:'\[Service-Name "SNAME-TEST3"\] \[AC-Name "ACNAME-TEST3"\]' \
686 -e ignore \
687 -x "${dumpcmd} | grep PADI"
688 atf_check -s exit:0 -o match:'\[Service-Name "SNAME-TEST3"\]' -e ignore \
689 -x "${dumpcmd} | grep PADR"
690
691 # change AC-NAME
692 export RUMP_SERVER=$CLIENT
693 atf_ifconfig pppoe0 down
694 wait_for_disconnected
695 atf_pppoectl -e shmif0 -a ACNAME-TEST4 pppoe0
696 atf_ifconfig pppoe0 up
697 $DEBUG && rump.ifconfig
698 wait_for_opened $cp
699 unset RUMP_SERVER
700
701 $DEBUG && dump_bus
702 atf_check -s exit:0 \
703 -o match:'\[Service-Name\] \[AC-Name "ACNAME-TEST4"\]' \
704 -e ignore \
705 -x "${dumpcmd} | grep PADI"
706 atf_check -s exit:0 -o match:'\[Service-Name\]' -e ignore \
707 -x "${dumpcmd} | grep PADR"
708
709 # change Service-Name
710 export RUMP_SERVER=$CLIENT
711 atf_ifconfig pppoe0 down
712 wait_for_disconnected
713 atf_pppoectl -e shmif0 -a ACNAME-TEST5 -s SNAME-TEST5 pppoe0
714 atf_pppoectl -e shmif0 -s SNAME-TEST6 pppoe0
715 atf_ifconfig pppoe0 up
716 $DEBUG && rump.ifconfig
717 wait_for_opened $cp
718 unset RUMP_SERVER
719
720 $DEBUG && dump_bus
721 atf_check -s exit:0 \
722 -o match:'\[Service-Name "SNAME-TEST6"\]' \
723 -e ignore \
724 -x "${dumpcmd} | grep PADI"
725 atf_check -s exit:0 -o match:'\[Service-Name "SNAME-TEST6"\]' -e ignore \
726 -x "${dumpcmd} | grep PADR"
727 atf_check -s exit:0 -o not-match:'\[AC-Name "ACNAME-TEST5\]"' -e ignore \
728 -x "${dumpcmd} | grep PADI"
729
730 export RUMP_SERVER=$CLIENT
731 atf_ifconfig pppoe0 down
732 export RUMP_SERVER=$SERVER
733 wait_for_disconnected
734
735 # ipcp & ipv6cp are enabled by default
736 export RUMP_SERVER=$CLIENT
737 atf_check -s exit:0 -o match:'ipcp: enable' \
738 -x "$HIJACKING pppoectl pppoe0"
739 atf_check -s exit:0 -o match:'ipv6cp: enable' \
740 -x "$HIJACKING pppoectl pppoe0"
741
742 # ipcp enable & ipv6cp disable
743 atf_pppoectl pppoe0 noipv6cp
744 atf_ifconfig pppoe0 up
745 wait_for_opened "IPCP"
746 atf_check -s exit:0 -o match:'IPv6CP state: initial' \
747 -x "$HIJACKING pppoectl -dd pppoe0"
748
749 atf_ifconfig pppoe0 down
750 export RUMP_SERVER=$SERVER
751 wait_for_disconnected
752
753 # ipcp disable & ipv6cp enable
754 export RUMP_SERVER=$CLIENT
755 atf_pppoectl pppoe0 noipcp ipv6cp
756 atf_ifconfig pppoe0 up
757 wait_for_opened "IPv6CP"
758 atf_check -s exit:0 -o match:'IPCP state: initial' \
759 -x "$HIJACKING pppoectl -dd pppoe0"
760 }
761
762 pppoe_params_cleanup()
763 {
764
765 $DEBUG && dump
766 cleanup
767 }
768
769 pppoe_passiveauthproto()
770 {
771 local auth=$1
772 local cp="IPCP"
773 setup
774
775 local server_optparam=""
776 if [ $auth = "chap" ]; then
777 server_optparam="norechallenge"
778 fi
779
780 export RUMP_SERVER=$SERVER
781 atf_pppoectl pppoe0 \
782 "hisauthname=$AUTHNAME" "hisauthsecret=$SECRET" \
783 "hisauthproto=$auth" "myauthproto=none" \
784 $server_optparam
785 atf_ifconfig pppoe0 up
786
787 export RUMP_SERVER=$CLIENT
788 atf_pppoectl pppoe0 \
789 "myauthname=$AUTHNAME" "myauthsecret=$SECRET" \
790 "myauthproto=none" "hisauthproto=none" \
791 "passiveauthproto"
792 atf_ifconfig pppoe0 up
793 $DEBUG && rump.ifconfig
794 wait_for_opened $cp
795 atf_ifconfig -w 10
796 atf_check -s exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT $SERVER_IP
797 }
798
799 atf_test_case pppoe_passiveauthproto_pap cleanup
800 pppoe_passiveauthproto_pap_head()
801 {
802
803 atf_set "descr" "Test for passiveauthproto option on PAP"
804 atf_set "require.progs" "rump_server"
805 }
806
807 pppoe_passiveauthproto_pap_body()
808 {
809
810 pppoe_passiveauthproto "pap"
811 }
812
813 pppoe_passiveauthproto_pap_cleanup()
814 {
815
816 $DEBUG && dump
817 cleanup
818 }
819
820 atf_test_case pppoe_passiveauthproto_chap cleanup
821 pppoe_passiveauthproto_chap_head()
822 {
823
824 atf_set "descr" "Test for passiveauthproto option on chap"
825 atf_set "require.progs" "rump_server"
826 }
827
828 pppoe_passiveauthproto_chap_body()
829 {
830
831 pppoe_passiveauthproto "chap"
832 }
833
834 pppoe_passiveauthproto_chap_cleanup()
835 {
836
837 $DEBUG && dump
838 cleanup
839 }
840
841 atf_test_case pppoe_mtu cleanup
842 pppoe_mtu_head()
843 {
844
845 atf_set "descr" "Test for mtu"
846 atf_set "require.progs" "rump_server"
847 }
848
849 pppoe_mtu_body()
850 {
851 local auth=chap
852 local cp="IPCP"
853 setup
854
855 export RUMP_SERVER=$SERVER
856 atf_pppoectl pppoe0 \
857 "hisauthname=$AUTHNAME" "hisauthsecret=$SECRET" \
858 "hisauthproto=$auth" "myauthproto=none" \
859 norechallenge
860 atf_ifconfig pppoe0 mtu 1400
861 atf_ifconfig pppoe0 up
862
863 export RUMP_SERVER=$CLIENT
864 atf_pppoectl pppoe0 \
865 "myauthname=$AUTHNAME" "myauthsecret=$SECRET" \
866 "myauthproto=$auth" "hisauthproto=none"
867 atf_ifconfig pppoe0 mtu 1450
868 atf_ifconfig pppoe0 up
869
870 wait_for_opened $cp
871 atf_ifconfig -w 10
872
873 export RUMP_SERVER=$SERVER
874 atf_check -s exit:0 -o match:'mtu 1400' rump.ifconfig pppoe0
875
876 export RUMP_SERVER=$CLIENT
877 atf_check -s exit:0 -o match:'mtu 1400' rump.ifconfig pppoe0
878
879 # mtu can set to 1460 but it is not applied.
880 atf_ifconfig pppoe0 mtu 1460
881 atf_check -s exit:0 -o match:'mtu 1400' rump.ifconfig pppoe0
882
883 export RUMP_SERVER=$SERVER
884 atf_ifconfig pppoe0 mtu 1470
885 atf_ifconfig pppoe0 down
886 atf_ifconfig pppoe0 up
887 wait_for_opened $cp
888 atf_ifconfig -w 10
889
890 # mtu 1460 is applied after LCP negotiation
891 atf_check -s exit:0 -o match:'mtu 1460' rump.ifconfig pppoe0
892
893 export RUMP_SERVER=$CLIENT
894 atf_check -s exit:0 -o match:'mtu 1460' rump.ifconfig pppoe0
895
896 rump.ifconfig pppoe0 mtu 1500
897 atf_check -s exit:0 -o ignore \
898 -e match:'SIOCSIFMTU: Invalid argument' \
899 rump.ifconfig pppoe0 mtu 1501
900 }
901
902 pppoe_mtu_cleanup()
903 {
904
905 $DEBUG && dump
906 cleanup
907 }
908
909 atf_init_test_cases()
910 {
911
912 atf_add_test_case pppoe_create_destroy
913 atf_add_test_case pppoe_params
914 atf_add_test_case pppoe_pap
915 atf_add_test_case pppoe_chap
916 atf_add_test_case pppoe6_pap
917 atf_add_test_case pppoe6_chap
918 atf_add_test_case pppoe_passiveauthproto_pap
919 atf_add_test_case pppoe_passiveauthproto_chap
920 atf_add_test_case pppoe_mtu
921 }
922