t_lagg.sh revision 1.3 1 # $NetBSD: t_lagg.sh,v 1.3 2021/10/19 07:57:15 yamaguchi Exp $
2 #
3 # Copyright (c) 2021 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 SOCK_HOST0=unix://commsock0
29 SOCK_HOST1=unix://commsock1
30 SOCK_HOST2=unix://commsock2
31 BUS0=bus0
32 BUS1=bus1
33 BUS2=bus2
34 IP4ADDR0=192.168.0.1
35 IP4ADDR1=192.168.0.2
36 IP4ADDR2=192.168.1.1
37 IP4ADDR3=192.168.1.2
38 IP6ADDR0=fc00::1
39 IP6ADDR1=fc00::2
40 IP6ADDR2=fc00:1::1
41 IP6ADDR3=fc00:1::2
42 WAITTIME=20
43
44 DEBUG=${DEBUG:-false}
45
46 wait_state()
47 {
48 local state=$1
49 local if_lagg=$2
50 local if_port=$3
51
52 local n=$WAITTIME
53 local cmd_grep="grep -q ${state}"
54
55 if [ x"$if_port" != x"" ]; then
56 cmd_grep="grep $if_port | $cmd_grep"
57 fi
58
59 for i in $(seq $n); do
60 rump.ifconfig $if_lagg | eval $cmd_grep
61 if [ $? = 0 ] ; then
62 $DEBUG && echo "wait for $i seconds."
63 return 0
64 fi
65
66 sleep 1
67 done
68
69 $DEBUG && rump.ifconfig -v $if_lagg
70 atf_fail "Couldn't be ${state} for $n seconds."
71 }
72 wait_for_distributing()
73 {
74
75 wait_state "DISTRIBUTING" $*
76 }
77
78 expected_inactive()
79 {
80 local if_lagg=$1
81 local if_port=$2
82
83 sleep 3 # wait a little
84 atf_check -s exit:0 -o not-match:"${if_port}.*ACTIVE" \
85 rump.ifconfig ${if_lagg}
86 }
87
88 setup_l2tp_ipv4tunnel()
89 {
90 local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
91
92 local a_addr0=10.0.0.1
93 local a_addr1=10.0.0.2
94 local b_addr0=10.0.1.1
95 local b_addr1=10.0.1.2
96 local c_addr0=10.0.2.1
97 local c_addr1=10.0.2.2
98
99 local a_session0=1001
100 local a_session1=1002
101 local b_session0=1011
102 local b_session1=1012
103 local c_session0=1021
104 local c_session1=1022
105
106 rump_server_add_iface $SOCK_HOST0 l2tp0
107 rump_server_add_iface $SOCK_HOST0 l2tp1
108 rump_server_add_iface $SOCK_HOST0 l2tp2
109 rump_server_add_iface $SOCK_HOST1 l2tp0
110 rump_server_add_iface $SOCK_HOST1 l2tp1
111 rump_server_add_iface $SOCK_HOST1 l2tp2
112
113
114 export RUMP_SERVER=$SOCK_HOST0
115 $atf_ifconfig shmif0 $a_addr0/24
116 $atf_ifconfig l2tp0 tunnel $a_addr0 $a_addr1
117 $atf_ifconfig l2tp0 session $a_session0 $a_session1
118
119 $atf_ifconfig shmif1 $b_addr0/24
120 $atf_ifconfig l2tp1 tunnel $b_addr0 $b_addr1
121 $atf_ifconfig l2tp1 session $b_session0 $b_session1
122
123 $atf_ifconfig shmif2 $c_addr0/24
124 $atf_ifconfig l2tp2 tunnel $c_addr0 $c_addr1
125 $atf_ifconfig l2tp2 session $c_session0 $c_session1
126
127 export RUMP_SERVER=$SOCK_HOST1
128 $atf_ifconfig shmif0 $a_addr1/24
129 $atf_ifconfig l2tp0 tunnel $a_addr1 $a_addr0
130 $atf_ifconfig l2tp0 session $a_session1 $a_session0
131
132 $atf_ifconfig shmif1 $b_addr1/24
133 $atf_ifconfig l2tp1 tunnel $b_addr1 $b_addr0
134 $atf_ifconfig l2tp1 session $b_session1 $b_session0
135
136 $atf_ifconfig shmif2 $c_addr1/24
137 $atf_ifconfig l2tp2 tunnel $c_addr1 $c_addr0
138 $atf_ifconfig l2tp2 session $c_session1 $c_session0
139 }
140
141 atf_test_case lagg_ifconfig cleanup
142 lagg_ifconfig_head()
143 {
144
145 atf_set "descr" "tests for create, destroy, and ioctl of lagg(4)"
146 atf_set "require.progs" "rump_server"
147 }
148
149 lagg_ifconfig_body()
150 {
151 local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
152
153 rump_server_start $SOCK_HOST0 lagg
154
155 export RUMP_SERVER=$SOCK_HOST0
156 $atf_ifconfig lagg0 create
157 $atf_ifconfig lagg0 destroy
158
159 $atf_ifconfig lagg0 create
160 $atf_ifconfig shmif0 create
161
162 $atf_ifconfig lagg0 laggproto none
163 atf_check -s exit:0 -o match:'laggproto none' \
164 rump.ifconfig lagg0
165
166 # cannot add a port while protocol is none
167 atf_check -s not-exit:0 -e ignore \
168 rump.ifconfig lagg0 laggport shmif0
169
170 $atf_ifconfig lagg0 laggproto lacp
171 atf_check -s exit:0 -o match:'laggproto lacp' \
172 rump.ifconfig lagg0
173
174 # add a port and an added port
175 $atf_ifconfig lagg0 laggport shmif0
176 atf_check -s not-exit:0 -e ignore \
177 rump.ifconfig lagg0 laggport shmif0
178
179 # remove an added port and a removed port
180 $atf_ifconfig lagg0 -laggport shmif0
181 atf_check -s not-exit:0 -e ignore \
182 rump.ifconfig lagg0 -laggport shmif0
183
184 # re-add a removed port
185 $atf_ifconfig lagg0 laggport shmif0
186
187 # detach protocol even if the I/F has ports
188 $atf_ifconfig lagg0 laggproto none
189
190 # destroy the interface while grouping ports
191 $atf_ifconfig lagg0 destroy
192
193 $atf_ifconfig lagg0 create
194 $atf_ifconfig shmif1 create
195
196 $atf_ifconfig lagg0 laggproto lacp
197 $atf_ifconfig lagg0 laggport shmif0
198 $atf_ifconfig lagg0 laggport shmif1
199
200 $atf_ifconfig lagg0 -laggport shmif0
201 $atf_ifconfig lagg0 laggport shmif0
202 $atf_ifconfig lagg0 -laggport shmif1
203 $atf_ifconfig lagg0 laggport shmif1
204
205 # destroy a LAGed port
206 atf_check -s exit:0 -o match:shmif0 rump.ifconfig lagg0
207 atf_check -s exit:0 -o match:shmif1 rump.ifconfig lagg0
208 $atf_ifconfig shmif0 destroy
209 $atf_ifconfig shmif1 destroy
210
211 $atf_ifconfig lagg0 laggproto none
212 atf_check -s exit:0 -o ignore rump.ifconfig lagg0
213 }
214
215 lagg_ifconfig_cleanup()
216 {
217 $DEBG && dump
218 cleanup
219 }
220
221 atf_test_case lagg_macaddr cleanup
222 lagg_macaddr_head()
223 {
224 atf_set "descr" "tests for a MAC address to assign to lagg(4)"
225 atf_set "require.progs" "rump_server"
226 }
227
228 lagg_macaddr_body()
229 {
230 local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
231
232 rump_server_start $SOCK_HOST0 lagg
233
234 export RUMP_SERVER=$SOCK_HOST0
235 $atf_ifconfig lagg0 create
236 rump_server_add_iface $SOCK_HOST0 shmif0 $BUS0
237 rump_server_add_iface $SOCK_HOST0 shmif1 $BUS1
238
239 maddr=$(get_macaddr $SOCK_HOST0 lagg0)
240 maddr0=$(get_macaddr $SOCK_HOST0 shmif0)
241 maddr1=$(get_macaddr $SOCK_HOST0 shmif1)
242
243 $atf_ifconfig lagg0 laggproto lacp
244
245 $atf_ifconfig lagg0 laggport shmif0
246 atf_check -s exit:0 -o match:$maddr0 rump.ifconfig lagg0
247
248 $atf_ifconfig lagg0 laggport shmif1
249 atf_check -s exit:0 -o match:$maddr0 rump.ifconfig lagg0
250 atf_check -s exit:0 -o match:$maddr0 rump.ifconfig shmif1
251
252 $atf_ifconfig lagg0 -laggport shmif0
253 atf_check -s exit:0 -o match:$maddr1 rump.ifconfig lagg0
254 atf_check -s exit:0 -o match:$maddr0 rump.ifconfig shmif0
255
256 $atf_ifconfig lagg0 laggport shmif0
257 atf_check -s exit:0 -o match:$maddr1 rump.ifconfig lagg0
258 atf_check -s exit:0 -o match:$maddr1 rump.ifconfig shmif0
259
260 $atf_ifconfig lagg0 -laggport shmif0
261 atf_check -s exit:0 -o match:$maddr0 rump.ifconfig shmif0
262
263 $atf_ifconfig lagg0 -laggport shmif1
264 atf_check -s exit:0 -o match:$maddr rump.ifconfig lagg0
265 }
266
267 lagg_macaddr_cleanup()
268 {
269 $DEBUG && dump
270 cleanup
271 }
272
273 atf_test_case lagg_ipv6lla cleanup
274 lagg_ipv6lla_head()
275 {
276 atf_set "descr" "tests for a IPV6 LLA to assign to lagg(4)"
277 atf_set "require.progs" "rump_server"
278 }
279
280 lagg_ipv6lla_body()
281 {
282 local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
283
284 rump_server_start $SOCK_HOST0 netinet6 lagg
285
286 export RUMP_SERVER=$SOCK_HOST0
287 $atf_ifconfig lagg0 create
288 rump_server_add_iface $SOCK_HOST0 shmif0 $BUS0
289 rump_server_add_iface $SOCK_HOST0 shmif1 $BUS1
290
291 $atf_ifconfig lagg0 laggproto lacp
292
293 $atf_ifconfig shmif0 up
294 atf_check -s exit:0 -o match:'inet6 fe80:' rump.ifconfig shmif0
295
296 $atf_ifconfig lagg0 laggproto lacp laggport shmif0
297 atf_check -s exit:0 -o not-match:'inet6 fe80:' rump.ifconfig shmif0
298
299 $atf_ifconfig lagg0 laggport shmif1
300 $atf_ifconfig shmif1 up
301 atf_check -s exit:0 -o not-match:'inet6 fe80:' rump.ifconfig shmif1
302
303 $atf_ifconfig lagg0 -laggport shmif0
304 atf_check -s exit:0 -o match:'inet6 fe80:' rump.ifconfig shmif0
305
306 $atf_ifconfig shmif1 down
307 $atf_ifconfig lagg0 -laggport shmif1
308 atf_check -s exit:0 -o not-match:'inet fe80:' rump.ifconfig shmif1
309 }
310
311 lagg_ipv6lla_cleanup()
312 {
313 $DEBUG && dump
314 cleanup
315 }
316
317 atf_test_case lagg_lacp_basic cleanup
318 lagg_lacp_basic_head()
319 {
320
321 atf_set "descr" "tests for LACP basic functions"
322 atf_set "require.progs" "rump_server"
323 }
324
325 lagg_lacp_basic_body()
326 {
327 local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
328
329 rump_server_start $SOCK_HOST0 lagg
330 rump_server_start $SOCK_HOST1 lagg
331 rump_server_start $SOCK_HOST2 lagg
332
333 export RUMP_SERVER=$SOCK_HOST0
334
335 # added running interface
336 $atf_ifconfig shmif0 create
337 $atf_ifconfig shmif0 linkstr $BUS0
338
339 $atf_ifconfig shmif1 create
340 $atf_ifconfig shmif1 linkstr $BUS1
341
342 $atf_ifconfig lagg0 create
343 $atf_ifconfig lagg0 laggproto lacp
344
345 $atf_ifconfig shmif0 up
346 $atf_ifconfig shmif1 up
347 $atf_ifconfig lagg0 up
348
349 $atf_ifconfig lagg0 laggport shmif0
350 $atf_ifconfig lagg0 laggport shmif1
351 $atf_ifconfig -w 10
352
353 $atf_ifconfig lagg0 -laggport shmif0
354 $atf_ifconfig lagg0 -laggport shmif1
355 $atf_ifconfig lagg0 down
356
357 # add the same interfaces again
358 $atf_ifconfig lagg0 up
359 $atf_ifconfig lagg0 laggport shmif0
360 $atf_ifconfig lagg0 laggport shmif1
361
362 # detach and re-attach protocol
363 $atf_ifconfig lagg0 laggproto none
364 $atf_ifconfig lagg0 laggproto lacp \
365 laggport shmif0 laggport shmif1
366
367 $atf_ifconfig lagg0 -laggport shmif0 -laggport shmif1
368 $atf_ifconfig lagg0 destroy
369 $atf_ifconfig shmif0 destroy
370 $atf_ifconfig shmif1 destroy
371
372 # tests for a loopback condition
373 $atf_ifconfig shmif0 create
374 $atf_ifconfig shmif0 linkstr $BUS0
375 $atf_ifconfig shmif1 create
376 $atf_ifconfig shmif1 linkstr $BUS0
377 $atf_ifconfig lagg0 create
378 $atf_ifconfig lagg0 laggproto lacp \
379 laggport shmif0 laggport shmif1
380 $atf_ifconfig shmif0 up
381 $atf_ifconfig shmif1 up
382 $atf_ifconfig lagg0 up
383
384 expected_inactive lagg0
385
386 $atf_ifconfig shmif0 down
387 $atf_ifconfig shmif0 destroy
388 $atf_ifconfig shmif1 down
389 $atf_ifconfig shmif1 destroy
390 $atf_ifconfig lagg0 down
391 $atf_ifconfig lagg0 destroy
392
393 export RUMP_SERVER=$SOCK_HOST0
394 $atf_ifconfig shmif0 create
395 $atf_ifconfig shmif0 linkstr $BUS0
396 $atf_ifconfig shmif0 up
397
398 $atf_ifconfig shmif1 create
399 $atf_ifconfig shmif1 linkstr $BUS1
400 $atf_ifconfig shmif1 up
401
402 $atf_ifconfig shmif2 create
403 $atf_ifconfig shmif2 linkstr $BUS2
404 $atf_ifconfig shmif2 up
405
406 $atf_ifconfig lagg0 create
407 $atf_ifconfig lagg0 laggproto lacp laggport shmif0 \
408 laggport shmif1 laggport shmif2
409 $atf_ifconfig lagg0 up
410
411 export RUMP_SERVER=$SOCK_HOST1
412 $atf_ifconfig shmif0 create
413 $atf_ifconfig shmif0 linkstr $BUS0
414 $atf_ifconfig shmif0 up
415
416 $atf_ifconfig shmif1 create
417 $atf_ifconfig shmif1 linkstr $BUS1
418 $atf_ifconfig shmif1 up
419
420 $atf_ifconfig lagg0 create
421 $atf_ifconfig lagg0 laggproto lacp
422 $atf_ifconfig lagg1 create
423 $atf_ifconfig lagg1 laggproto lacp
424
425 $atf_ifconfig lagg0 laggport shmif0
426 $atf_ifconfig lagg0 up
427 wait_for_distributing lagg0 shmif0
428
429 $atf_ifconfig lagg1 laggport shmif1
430 $atf_ifconfig lagg1 up
431
432 export RUMP_SERVER=$SOCK_HOST2
433 $atf_ifconfig shmif0 create
434 $atf_ifconfig shmif0 linkstr $BUS2
435 $atf_ifconfig shmif0 up
436
437 $atf_ifconfig lagg0 create
438 $atf_ifconfig lagg0 laggproto lacp laggport shmif0
439 $atf_ifconfig lagg0 up
440
441 export RUMP_SERVER=$SOCK_HOST0
442 wait_for_distributing lagg0 shmif0
443 expected_inactive lagg0 shmif1
444 expected_inactive lagg0 shmif2
445 }
446
447 lagg_lacp_basic_cleanup()
448 {
449
450 $DEBUG && dump
451 cleanup
452 }
453
454 lagg_lacp_ping()
455 {
456 local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
457
458 local af=$1
459 local l2proto=$2
460 local atf_ping="atf_check -s exit:0 -o ignore rump.ping -c 1"
461 local ping=rump.ping
462 local rumplib=""
463 local pfx=24
464 local addr_host0=$IP4ADDR0
465 local addr_host1=$IP4ADDR1
466
467 case $af in
468 "inet")
469 # do nothing
470 ;;
471 "inet6")
472 atf_ping="atf_check -s exit:0 -o ignore rump.ping6 -c 1"
473 rumplib="netinet6"
474 pfx=64
475 addr_host0=$IP6ADDR0
476 addr_host1=$IP6ADDR1
477 ;;
478 esac
479
480 case $l2proto in
481 "ether")
482 iface0=shmif0
483 iface1=shmif1
484 iface2=shmif2
485 ;;
486 "l2tp")
487 rumplib="$rumplib l2tp"
488 iface0=l2tp0
489 iface1=l2tp1
490 iface2=l2tp2
491 ;;
492 esac
493
494 rump_server_start $SOCK_HOST0 lagg $rumplib
495 rump_server_start $SOCK_HOST1 lagg $rumplib
496
497 rump_server_add_iface $SOCK_HOST0 shmif0 $BUS0
498 rump_server_add_iface $SOCK_HOST0 shmif1 $BUS1
499 rump_server_add_iface $SOCK_HOST0 shmif2 $BUS2
500
501 rump_server_add_iface $SOCK_HOST1 shmif0 $BUS0
502 rump_server_add_iface $SOCK_HOST1 shmif1 $BUS1
503 rump_server_add_iface $SOCK_HOST1 shmif2 $BUS2
504
505 if [ x"$l2proto" = x"l2tp" ];then
506 setup_l2tp_ipv4tunnel
507 fi
508
509 export RUMP_SERVER=$SOCK_HOST0
510 $atf_ifconfig lagg0 create
511 $atf_ifconfig lagg0 laggproto lacp laggport $iface0
512 $atf_ifconfig lagg0 $af $addr_host0/$pfx
513 $atf_ifconfig $iface0 up
514 $atf_ifconfig lagg0 up
515
516 export RUMP_SERVER=$SOCK_HOST1
517 $atf_ifconfig lagg0 create
518 $atf_ifconfig lagg0 laggproto lacp laggport $iface0
519 $atf_ifconfig lagg0 $af $addr_host1/$pfx
520 $atf_ifconfig $iface0 up
521 $atf_ifconfig lagg0 up
522
523 export RUMP_SERVER=$SOCK_HOST0
524 wait_for_distributing lagg0
525 $atf_ifconfig -w 10
526
527 export RUMP_SERVER=$SOCK_HOST1
528 wait_for_distributing lagg0
529 $atf_ifconfig -w 10
530
531 $atf_ping $addr_host0
532
533 export RUMP_SERVER=$SOCK_HOST0
534 $atf_ifconfig $iface1 up
535 $atf_ifconfig lagg0 laggport $iface1 laggport $iface2
536 $atf_ifconfig $iface2 up
537
538 export RUMP_SERVER=$SOCK_HOST1
539 $atf_ifconfig $iface1 up
540 $atf_ifconfig lagg0 laggport $iface1 laggport $iface2
541 $atf_ifconfig $iface2 up
542
543 export RUMP_SERVER=$SOCK_HOST0
544 wait_for_distributing lagg0 $iface1
545 wait_for_distributing lagg0 $iface2
546
547 export RUMP_SERVER=$SOCK_HOST1
548 wait_for_distributing lagg0 $iface1
549 wait_for_distributing lagg0 $iface2
550
551 $atf_ping $addr_host0
552 }
553
554 atf_test_case lagg_lacp_ipv4 cleanup
555 lagg_lacp_ipv4_head()
556 {
557
558 atf_set "descr" "tests for IPv4 with LACP"
559 atf_set "require.progs" "rump_server"
560 }
561
562 lagg_lacp_ipv4_body()
563 {
564
565 lagg_lacp_ping "inet" "ether"
566 }
567
568 lagg_lacp_ipv4_cleanup()
569 {
570
571 $DEBUG && dump
572 cleanup
573 }
574
575 atf_test_case lagg_lacp_ipv6 cleanup
576 lagg_lacp_ipv6_head()
577 {
578
579 atf_set "descr" "tests for IPv6 with LACP"
580 atf_set "require.progs" "rump_server"
581 }
582
583 lagg_lacp_ipv6_body()
584 {
585
586 lagg_lacp_ping "inet6" "ether"
587 }
588
589 lagg_lacp_ipv6_cleanup()
590 {
591
592 $DEBUG && dump
593 cleanup
594 }
595
596 atf_test_case lagg_lacp_l2tp_ipv4 cleanup
597 lagg_lacp_l2tp_ipv4_head()
598 {
599
600 atf_set "descr" "tests for LACP over l2tp by using IPv4"
601 atf_set "require.progs" "rump_server"
602 }
603
604 lagg_lacp_l2tp_ipv4_body()
605 {
606
607 lagg_lacp_ping "inet" "l2tp"
608 }
609
610 lagg_lacp_l2tp_ipv4_cleanup()
611 {
612
613 $DEBUG && dump
614 cleanup
615 }
616
617 atf_test_case lagg_lacp_l2tp_ipv6 cleanup
618 lagg_lacp_l2tp_ipv6_head()
619 {
620
621 atf_set "descr" "tests for LACP over l2tp using IPv6"
622 atf_set "require.progs" "rump_server"
623 }
624
625 lagg_lacp_l2tp_ipv6_body()
626 {
627
628 lagg_lacp_ping "inet6" "l2tp"
629 }
630
631 lagg_lacp_l2tp_ipv6_cleanup()
632 {
633
634 $DEBUG && dump
635 cleanup
636 }
637
638 lagg_lacp_vlan()
639 {
640 local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
641
642 local af=$1
643 local atf_ping="atf_check -s exit:0 -o ignore rump.ping -c 1"
644 local rumplib="vlan"
645 local pfx=24
646 local vlan0_addr_host0=$IP4ADDR0
647 local host0addr0=$IP4ADDR0
648 local host1addr0=$IP4ADDR1
649 local host0addr1=$IP4ADDR2
650 local host1addr1=$IP4ADDR3
651
652 case $af in
653 "inet")
654 # do nothing
655 ;;
656 "inet6")
657 atf_ping="atf_check -s exit:0 -o ignore rump.ping6 -c 1"
658 rumplib="netinet6"
659 pfx=64
660 host0addr0=$IP6ADDR0
661 host1addr0=$IP6ADDR1
662 host0addr1=$IP6ADDR2
663 host1addr1=$IP6ADDR3
664 ;;
665 esac
666
667 rump_server_start $SOCK_HOST0 lagg $rumplib
668 rump_server_start $SOCK_HOST1 lagg $rumplib
669
670 rump_server_add_iface $SOCK_HOST0 shmif0 $BUS0
671 rump_server_add_iface $SOCK_HOST0 shmif1 $BUS1
672 rump_server_add_iface $SOCK_HOST0 shmif2 $BUS2
673
674 rump_server_add_iface $SOCK_HOST1 shmif0 $BUS0
675 rump_server_add_iface $SOCK_HOST1 shmif1 $BUS1
676 rump_server_add_iface $SOCK_HOST1 shmif2 $BUS2
677
678 export RUMP_SERVER=$SOCK_HOST0
679 $atf_ifconfig lagg0 create
680 $atf_ifconfig lagg0 laggproto lacp laggport shmif0
681 $atf_ifconfig shmif0 up
682 $atf_ifconfig lagg0 up
683
684 export RUMP_SERVER=$SOCK_HOST1
685 $atf_ifconfig lagg0 create
686 $atf_ifconfig lagg0 laggproto lacp laggport shmif0
687 $atf_ifconfig shmif0 up
688 $atf_ifconfig lagg0 up
689
690 export RUMP_SERVER=$SOCK_HOST0
691 wait_for_distributing lagg0
692
693 $atf_ifconfig vlan0 create
694 $atf_ifconfig vlan0 vlan 10 vlanif lagg0
695 $atf_ifconfig vlan0 $af $host0addr0/$pfx
696 $atf_ifconfig vlan0 up
697
698 $atf_ifconfig vlan1 create
699 $atf_ifconfig vlan1 vlan 11 vlanif lagg0
700 $atf_ifconfig vlan1 $af $host0addr1/$pfx
701 $atf_ifconfig vlan1 up
702
703 export RUMP_SERVER=$SOCK_HOST1
704 $atf_ifconfig vlan0 create
705 $atf_ifconfig vlan0 vlan 10 vlanif lagg0
706 $atf_ifconfig vlan0 $af $host1addr0/$pfx
707 $atf_ifconfig vlan0 up
708
709 $atf_ifconfig vlan1 create
710 $atf_ifconfig vlan1 vlan 11 vlanif lagg0
711 $atf_ifconfig vlan1 $af $host1addr1/$pfx
712 $atf_ifconfig vlan1 up
713
714 export RUMP_SERVER=$SOCK_HOST0
715 $atf_ifconfig -w 10
716 export RUMP_SERVER=$SOCK_HOST1
717 $atf_ifconfig -w 10
718
719 export RUMP_SERVER=$SOCK_HOST0
720 $atf_ping $host1addr0
721 $atf_ping $host1addr1
722
723 $atf_ifconfig lagg0 laggport shmif1
724 $atf_ifconfig shmif1 up
725
726 export RUMP_SERVER=$SOCK_HOST1
727 $atf_ifconfig lagg0 laggport shmif1
728 $atf_ifconfig shmif1 up
729
730 export RUMP_SERVER=$SOCK_HOST0
731 wait_for_distributing lagg0 shmif1
732
733 export RUMP_SERVER=$SOCK_HOST1
734 wait_for_distributing lagg0 shmif1
735
736 $atf_ping $host0addr0
737 $atf_ping $host0addr1
738 }
739
740 atf_test_case lagg_lacp_vlan_ipv4 cleanup
741 lagg_lacp_vlan_ipv4_head()
742 {
743
744 atf_set "descr" "tests for IPv4 VLAN frames over LACP LAG"
745 atf_set "require.progs" "rump_server"
746 }
747
748 lagg_lacp_vlan_ipv4_body()
749 {
750
751 lagg_lacp_vlan "inet"
752 }
753
754 lagg_lacp_vlan_ipv4_cleanup()
755 {
756 $DEBUG && dump
757 cleanup
758 }
759
760 atf_test_case lagg_lacp_vlan_ipv6 cleanup
761 lagg_lacp_vlan_ipv6_head()
762 {
763
764 atf_set "descr" "tests for IPv6 VLAN frames over LACP LAG"
765 atf_set "require.progs" "rump_server"
766 }
767
768 lagg_lacp_vlan_ipv6_body()
769 {
770
771 lagg_lacp_vlan "inet"
772 }
773
774 lagg_lacp_vlan_ipv6_cleanup()
775 {
776 $DEBUG && dump
777 cleanup
778 }
779
780 atf_test_case lagg_lacp_portpri cleanup
781 lagg_lacp_portpri_head()
782 {
783
784 atf_set "descr" "tests for LACP port priority"
785 atf_set "require.progs" "rump_server"
786 }
787
788 lagg_lacp_portpri_body()
789 {
790 local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
791
792 rump_server_start $SOCK_HOST0 lagg
793 rump_server_start $SOCK_HOST1 lagg
794
795 rump_server_add_iface $SOCK_HOST0 shmif0 $BUS0
796 rump_server_add_iface $SOCK_HOST0 shmif1 $BUS1
797 rump_server_add_iface $SOCK_HOST0 shmif2 $BUS2
798
799 rump_server_add_iface $SOCK_HOST1 shmif0 $BUS0
800 rump_server_add_iface $SOCK_HOST1 shmif1 $BUS1
801 rump_server_add_iface $SOCK_HOST1 shmif2 $BUS2
802
803 export RUMP_SERVER=$SOCK_HOST0
804 $atf_ifconfig lagg0 create
805 $atf_ifconfig lagg0 laggproto lacp
806 $atf_ifconfig lagg0 lagglacp maxports 2
807
808 $atf_ifconfig shmif0 up
809 $atf_ifconfig shmif1 up
810 $atf_ifconfig shmif2 up
811
812 $atf_ifconfig lagg0 laggport shmif0 pri 1000
813 $atf_ifconfig lagg0 laggport shmif1 pri 2000
814 $atf_ifconfig lagg0 laggport shmif2 pri 3000
815 $atf_ifconfig lagg0 up
816
817 atf_check -s exit:0 -o match:'shmif0 pri=1000' rump.ifconfig lagg0
818 atf_check -s exit:0 -o match:'shmif1 pri=2000' rump.ifconfig lagg0
819 atf_check -s exit:0 -o match:'shmif2 pri=3000' rump.ifconfig lagg0
820
821 export RUMP_SERVER=$SOCK_HOST1
822 $atf_ifconfig lagg0 create
823 $atf_ifconfig lagg0 laggproto lacp
824
825 $atf_ifconfig shmif0 up
826 $atf_ifconfig shmif1 up
827 $atf_ifconfig shmif2 up
828
829 $atf_ifconfig lagg0 laggport shmif0 pri 300
830 $atf_ifconfig lagg0 laggport shmif1 pri 200
831 $atf_ifconfig lagg0 laggport shmif2 pri 100
832 $atf_ifconfig lagg0 up
833
834 atf_check -s exit:0 -o match:'shmif0 pri=300' rump.ifconfig lagg0
835 atf_check -s exit:0 -o match:'shmif1 pri=200' rump.ifconfig lagg0
836 atf_check -s exit:0 -o match:'shmif2 pri=100' rump.ifconfig lagg0
837
838 export RUMP_SERVER=$SOCK_HOST0
839 wait_for_distributing lagg0 shmif0
840 wait_for_distributing lagg0 shmif1
841 wait_state "STANDBY" lagg0 shmif2
842
843 $atf_ifconfig shmif0 down
844 wait_for_distributing lagg0 shmif2
845
846 $atf_ifconfig shmif0 up
847 wait_for_distributing lagg0 shmif0
848
849 $atf_ifconfig lagg0 laggportpri shmif0 5000
850 $atf_ifconfig lagg0 laggportpri shmif1 5000
851 $atf_ifconfig lagg0 laggportpri shmif2 5000
852
853 atf_check -s exit:0 -o match:'shmif0 pri=5000' rump.ifconfig lagg0
854 atf_check -s exit:0 -o match:'shmif1 pri=5000' rump.ifconfig lagg0
855 atf_check -s exit:0 -o match:'shmif2 pri=5000' rump.ifconfig lagg0
856
857 wait_state "STANDBY" lagg0 shmif0
858 wait_for_distributing lagg0 shmif1
859 wait_for_distributing lagg0 shmif2
860 }
861
862 lagg_lacp_portpri_cleanup()
863 {
864
865 $DEBUG && dump
866 cleanup
867 }
868
869 lagg_failover()
870 {
871 local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
872
873 local af=$1
874 local l2proto=$2
875 local ping="rump.ping -c 1"
876 local rumplib=""
877 local pfx=24
878 local addr_host0=$IP4ADDR0
879 local addr_host1=$IP4ADDR1
880
881 case $af in
882 "inet")
883 # do nothing
884 ;;
885 "inet6")
886 ping="rump.ping6 -c 1"
887 rumplib="netinet6"
888 pfx=64
889 addr_host0=$IP6ADDR0
890 addr_host1=$IP6ADDR1
891 ;;
892 esac
893
894 case $l2proto in
895 "ether")
896 iface0="shmif0"
897 iface1="shmif1"
898 iface2="shmif2"
899 ;;
900 "l2tp")
901 rumplib="$rumplib l2tp"
902 iface0="l2tp0"
903 iface1="l2tp1"
904 iface2="l2tp2"
905 ;;
906 esac
907
908 local atf_ping="atf_check -s exit:0 -o ignore ${ping}"
909
910 rump_server_start $SOCK_HOST0 lagg $rumplib
911 rump_server_start $SOCK_HOST1 lagg $rumplib
912
913 rump_server_add_iface $SOCK_HOST0 shmif0 $BUS0
914 rump_server_add_iface $SOCK_HOST0 shmif1 $BUS1
915 rump_server_add_iface $SOCK_HOST0 shmif2 $BUS2
916
917 rump_server_add_iface $SOCK_HOST1 shmif0 $BUS0
918 rump_server_add_iface $SOCK_HOST1 shmif1 $BUS1
919 rump_server_add_iface $SOCK_HOST1 shmif2 $BUS2
920
921 if [ x"$l2proto" = x"l2tp" ]; then
922 setup_l2tp_ipv4tunnel
923 fi
924
925 export RUMP_SERVER=$SOCK_HOST0
926 $atf_ifconfig lagg0 create
927 $atf_ifconfig lagg0 laggproto failover
928
929 $atf_ifconfig lagg0 laggport $iface0 pri 1000
930 $atf_ifconfig lagg0 laggport $iface1 pri 2000
931 $atf_ifconfig lagg0 laggport $iface2 pri 3000
932 $atf_ifconfig lagg0 $af $addr_host0/$pfx
933
934 export RUMP_SERVER=$SOCK_HOST1
935 $atf_ifconfig lagg0 create
936 $atf_ifconfig lagg0 laggproto failover
937
938 $atf_ifconfig lagg0 laggport $iface0 pri 1000
939 $atf_ifconfig lagg0 laggport $iface1 pri 3000
940 $atf_ifconfig lagg0 laggport $iface2 pri 2000
941 $atf_ifconfig lagg0 $af $addr_host1/$pfx
942
943 export RUMP_SERVER=$SOCK_HOST0
944 $atf_ifconfig $iface0 up
945 $atf_ifconfig $iface1 up
946 $atf_ifconfig $iface2 up
947 $atf_ifconfig lagg0 up
948
949 export RUMP_SERVER=$SOCK_HOST1
950 $atf_ifconfig $iface0 up
951 $atf_ifconfig $iface1 up
952 $atf_ifconfig $iface2 up
953 $atf_ifconfig lagg0 up
954
955 export RUMP_SERVER=$SOCK_HOST0
956 $atf_ifconfig -w 10
957 wait_for_distributing lagg0 $iface0
958 wait_state "COLLECTING" lagg0 $iface0
959 wait_state "COLLECTING" lagg0 $iface1
960 wait_state "COLLECTING" lagg0 $iface2
961
962 export RUMP_SERVER=$SOCK_HOST1
963 $atf_ifconfig -w 10
964 wait_for_distributing lagg0 $iface0
965 wait_state "COLLECTING" lagg0 $iface0
966 wait_state "COLLECTING" lagg0 $iface1
967 wait_state "COLLECTING" lagg0 $iface2
968
969 export RUMP_SERVER=$SOCK_HOST0
970 $atf_ping $addr_host1
971
972 $atf_ifconfig $iface0 down
973 wait_for_distributing lagg0 $iface1
974 wait_state "COLLECTING" lagg0 $iface1
975 wait_state "COLLECTING" lagg0 $iface2
976
977 export RUMP_SERVER=$SOCK_HOST1
978 $atf_ifconfig $iface0 down
979 wait_for_distributing lagg0 $iface2
980 wait_state "COLLECTING" lagg0 $iface2
981 wait_state "COLLECTING" lagg0 $iface1
982
983 export RUMP_SERVER=$SOCK_HOST0
984 $atf_ping $addr_host1
985
986 $atf_ifconfig lagg0 laggfailover -rx-all
987 atf_check -s exit:0 -o not-match:'$iface2.+COLLECTING' rump.ifconfig lagg0
988
989 export RUMP_SERVER=$SOCK_HOST1
990 $atf_ifconfig lagg0 laggfailover -rx-all
991 atf_check -s exit:0 -o not-match:'$iface1.+COLLECTING' rump.ifconfig lagg0
992
993 export RUMP_SERVER=$SOCK_HOST0
994 atf_check -s not-exit:0 -o ignore -e ignore $ping -c 1 $addr_host1
995 }
996
997 atf_test_case lagg_failover_ipv4 cleanup
998 lagg_failover_ipv4_head()
999 {
1000
1001 atf_set "descr" "tests for failover using IPv4"
1002 atf_set "require.progs" "rump_server"
1003 }
1004
1005 lagg_failover_ipv4_body()
1006 {
1007
1008 lagg_failover "inet" "ether"
1009 }
1010
1011 lagg_failover_ipv4_cleanup()
1012 {
1013
1014 $DEBUG && dump
1015 cleanup
1016 }
1017
1018 atf_test_case lagg_failover_ipv6 cleanup
1019 lagg_failover_ipv6_head()
1020 {
1021
1022 atf_set "descr" "tests for failover using IPv6"
1023 atf_set "require.progs" "rump_server"
1024 }
1025
1026 lagg_failover_ipv6_body()
1027 {
1028
1029 lagg_failover "inet6" "ether"
1030 }
1031
1032 lagg_failover_ipv6_cleanup()
1033 {
1034
1035 $DEBUG && dump
1036 cleanup
1037 }
1038
1039 atf_test_case lagg_failover_l2tp_ipv4 cleanup
1040 lagg_failover_l2tp_ipv4_head()
1041 {
1042
1043 atf_set "descr" "tests for failover over l2tp using IPv4"
1044 atf_set "require.progs" "rump_server"
1045 }
1046
1047 lagg_failover_l2tp_ipv4_body()
1048 {
1049
1050 lagg_failover "inet" "l2tp"
1051 }
1052
1053 lagg_failover_l2tp_ipv4_cleanup()
1054 {
1055 $DEBUG && dump
1056 cleanup
1057 }
1058
1059 atf_test_case lagg_failover_l2tp_ipv6 cleanup
1060 lagg_failover_l2tp_ipv6_head()
1061 {
1062
1063 atf_set "descr" "tests for failover over l2tp using IPv6"
1064 atf_set "require.progs" "rump_server"
1065 }
1066
1067 lagg_failover_l2tp_ipv6_body()
1068 {
1069
1070 lagg_failover "inet6" "l2tp"
1071 }
1072
1073 lagg_failover_l2tp_ipv6_cleanup()
1074 {
1075 $DEBUG && dump
1076 cleanup
1077 }
1078
1079 lagg_loadbalance()
1080 {
1081 local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
1082
1083 local af=$1
1084 local l2proto=$2
1085 local ping="rump.ping -c 1"
1086 local rumplib=""
1087 local pfx=24
1088 local addr_host0=$IP4ADDR0
1089 local addr_host1=$IP4ADDR1
1090
1091 case $af in
1092 "inet")
1093 # do nothing
1094 ;;
1095 "inet6")
1096 ping="rump.ping6 -c 1"
1097 rumplib="netinet6"
1098 pfx=64
1099 addr_host0=$IP6ADDR0
1100 addr_host1=$IP6ADDR1
1101 ;;
1102 esac
1103
1104 case $l2proto in
1105 "ether")
1106 iface0=shmif0
1107 iface1=shmif1
1108 iface2=shmif2
1109 ;;
1110 "l2tp")
1111 rumplib="$rumplib l2tp"
1112 iface0=l2tp0
1113 iface1=l2tp1
1114 iface2=l2tp2
1115 ;;
1116 esac
1117
1118 local atf_ping="atf_check -s exit:0 -o ignore ${ping}"
1119
1120 rump_server_start $SOCK_HOST0 lagg $rumplib
1121 rump_server_start $SOCK_HOST1 lagg $rumplib
1122
1123 rump_server_add_iface $SOCK_HOST0 shmif0 $BUS0
1124 rump_server_add_iface $SOCK_HOST0 shmif1 $BUS1
1125 rump_server_add_iface $SOCK_HOST0 shmif2 $BUS2
1126
1127 rump_server_add_iface $SOCK_HOST1 shmif0 $BUS0
1128 rump_server_add_iface $SOCK_HOST1 shmif1 $BUS1
1129 rump_server_add_iface $SOCK_HOST1 shmif2 $BUS2
1130
1131 if [ x"$l2proto" = x"l2tp" ]; then
1132 setup_l2tp_ipv4tunnel
1133 fi
1134
1135 export RUMP_SERVER=$SOCK_HOST0
1136 $atf_ifconfig lagg0 create
1137 $atf_ifconfig lagg0 laggproto loadbalance
1138
1139 $atf_ifconfig lagg0 laggport $iface0 pri 1000
1140 $atf_ifconfig lagg0 laggport $iface1 pri 2000
1141 $atf_ifconfig lagg0 laggport $iface2 pri 3000
1142 $atf_ifconfig lagg0 $af $addr_host0/$pfx
1143
1144 export RUMP_SERVER=$SOCK_HOST1
1145 $atf_ifconfig lagg0 create
1146 $atf_ifconfig lagg0 laggproto loadbalance
1147
1148 $atf_ifconfig lagg0 laggport $iface0 pri 1000
1149 $atf_ifconfig lagg0 laggport $iface1 pri 3000
1150 $atf_ifconfig lagg0 laggport $iface2 pri 2000
1151 $atf_ifconfig lagg0 $af $addr_host1/$pfx
1152
1153 export RUMP_SERVER=$SOCK_HOST0
1154 $atf_ifconfig $iface0 up
1155 $atf_ifconfig $iface1 up
1156 $atf_ifconfig $iface2 up
1157 $atf_ifconfig lagg0 up
1158
1159 export RUMP_SERVER=$SOCK_HOST1
1160 $atf_ifconfig $iface0 up
1161 $atf_ifconfig $iface1 up
1162 $atf_ifconfig $iface2 up
1163 $atf_ifconfig lagg0 up
1164
1165 export RUMP_SERVER=$SOCK_HOST0
1166 $atf_ifconfig -w 10
1167 wait_for_distributing lagg0 $iface0
1168 wait_state "COLLECTING" lagg0 $iface0
1169 wait_state "COLLECTING" lagg0 $iface1
1170 wait_state "COLLECTING" lagg0 $iface2
1171
1172 export RUMP_SERVER=$SOCK_HOST1
1173 $atf_ifconfig -w 10
1174 wait_state "COLLECTING,DISTRIBUTING" lagg0 $iface0
1175 wait_state "COLLECTING,DISTRIBUTING" lagg0 $iface1
1176 wait_state "COLLECTING,DISTRIBUTING" lagg0 $iface2
1177
1178 export RUMP_SERVER=$SOCK_HOST0
1179 $atf_ping $addr_host1
1180
1181 $atf_ifconfig $iface0 down
1182 wait_state "COLLECTING,DISTRIBUTING" lagg0 $iface1
1183 wait_state "COLLECTING,DISTRIBUTING" lagg0 $iface2
1184
1185 export RUMP_SERVER=$SOCK_HOST1
1186 $atf_ifconfig $iface0 down
1187 wait_state "COLLECTING,DISTRIBUTING" lagg0 $iface1
1188 wait_state "COLLECTING,DISTRIBUTING" lagg0 $iface2
1189
1190 export RUMP_SERVER=$SOCK_HOST0
1191 $atf_ping $addr_host1
1192 }
1193
1194 atf_test_case lagg_loadbalance_ipv4 cleanup
1195 lagg_loadbalance_ipv4_head()
1196 {
1197
1198 atf_set "descr" "tests for loadbalance using IPv4"
1199 atf_set "require.progs" "rump_server"
1200 }
1201
1202 lagg_loadbalance_ipv4_body()
1203 {
1204
1205 lagg_loadbalance "inet" "ether"
1206 }
1207
1208 lagg_loadbalance_ipv4_cleanup()
1209 {
1210
1211 $DEBUG && dump
1212 cleanup
1213 }
1214
1215 atf_test_case lagg_loadbalance_ipv6 cleanup
1216 lagg_loadbalance_ipv6_head()
1217 {
1218
1219 atf_set "descr" "tests for loadbalance using IPv6"
1220 atf_set "require.progs" "rump_server"
1221 }
1222
1223 lagg_loadbalance_ipv6_body()
1224 {
1225
1226 lagg_loadbalance "inet6" "ether"
1227 }
1228
1229 lagg_loadbalance_ipv6_cleanup()
1230 {
1231
1232 $DEBUG && dump
1233 cleanup
1234 }
1235
1236 atf_test_case lagg_loadbalance_l2tp_ipv4 cleanup
1237 lagg_loadbalance_l2tp_ipv4_head()
1238 {
1239
1240 atf_set "descr" "tests for loadbalance over l2tp using IPv4"
1241 atf_set "require.progs" "rump_server"
1242 }
1243
1244 lagg_loadbalance_l2tp_ipv4_body()
1245 {
1246
1247 lagg_loadbalance "inet" "l2tp"
1248 }
1249
1250 lagg_loadbalance_l2tp_ipv4_cleanup()
1251 {
1252
1253 $DEBUG && dump
1254 cleanup
1255 }
1256
1257 atf_test_case lagg_loadbalance_l2tp_ipv6 cleanup
1258 lagg_loadbalance_l2tp_ipv4_head()
1259 {
1260
1261 atf_set "descr" "tests for loadbalance over l2tp using IPv6"
1262 atf_set "require.progs" "rump_server"
1263 }
1264
1265 lagg_loadbalance_l2tp_ipv6_body()
1266 {
1267
1268 lagg_loadbalance "inet6" "l2tp"
1269 }
1270
1271 lagg_loadbalance_l2tp_ipv6_cleanup()
1272 {
1273
1274 $DEBUG && dump
1275 cleanup
1276 }
1277
1278 atf_init_test_cases()
1279 {
1280
1281 atf_add_test_case lagg_ifconfig
1282 atf_add_test_case lagg_macaddr
1283 atf_add_test_case lagg_ipv6lla
1284 atf_add_test_case lagg_lacp_basic
1285 atf_add_test_case lagg_lacp_ipv4
1286 atf_add_test_case lagg_lacp_ipv6
1287 atf_add_test_case lagg_lacp_l2tp_ipv4
1288 atf_add_test_case lagg_lacp_l2tp_ipv6
1289 atf_add_test_case lagg_lacp_vlan_ipv4
1290 atf_add_test_case lagg_lacp_vlan_ipv6
1291 atf_add_test_case lagg_lacp_portpri
1292 atf_add_test_case lagg_failover_ipv4
1293 atf_add_test_case lagg_failover_ipv6
1294 atf_add_test_case lagg_failover_l2tp_ipv4
1295 atf_add_test_case lagg_failover_l2tp_ipv6
1296 atf_add_test_case lagg_loadbalance_ipv4
1297 atf_add_test_case lagg_loadbalance_ipv6
1298 atf_add_test_case lagg_loadbalance_l2tp_ipv4
1299 atf_add_test_case lagg_loadbalance_l2tp_ipv6
1300 }
1301