t_lagg.sh revision 1.2.2.2 1 # $NetBSD: t_lagg.sh,v 1.2.2.2 2021/05/31 22:15:23 cjep 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 atf_test_case lagg_ifconfig cleanup
89 lagg_ifconfig_head()
90 {
91
92 atf_set "descr" "tests for create, destroy, and ioctl of lagg(4)"
93 atf_set "require.progs" "rump_server"
94 }
95
96 lagg_ifconfig_body()
97 {
98 local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
99
100 rump_server_start $SOCK_HOST0 lagg
101
102 export RUMP_SERVER=$SOCK_HOST0
103 $atf_ifconfig lagg0 create
104 $atf_ifconfig lagg0 destroy
105
106 $atf_ifconfig lagg0 create
107 $atf_ifconfig shmif0 create
108
109 $atf_ifconfig lagg0 laggproto none
110 atf_check -s exit:0 -o match:'laggproto none' \
111 rump.ifconfig lagg0
112
113 # cannot add a port while protocol is none
114 atf_check -s not-exit:0 -e ignore \
115 rump.ifconfig lagg0 laggport shmif0
116
117 $atf_ifconfig lagg0 laggproto lacp
118 atf_check -s exit:0 -o match:'laggproto lacp' \
119 rump.ifconfig lagg0
120
121 # add a port and an added port
122 $atf_ifconfig lagg0 laggport shmif0
123 atf_check -s not-exit:0 -e ignore \
124 rump.ifconfig lagg0 laggport shmif0
125
126 # remove an added port and a removed port
127 $atf_ifconfig lagg0 -laggport shmif0
128 atf_check -s not-exit:0 -e ignore \
129 rump.ifconfig lagg0 -laggport shmif0
130
131 # re-add a removed port
132 $atf_ifconfig lagg0 laggport shmif0
133
134 # detach protocol even if the I/F has ports
135 $atf_ifconfig lagg0 laggproto none
136
137 # destroy the interface while grouping ports
138 $atf_ifconfig lagg0 destroy
139
140 $atf_ifconfig lagg0 create
141 $atf_ifconfig shmif1 create
142
143 $atf_ifconfig lagg0 laggproto lacp
144 $atf_ifconfig lagg0 laggport shmif0
145 $atf_ifconfig lagg0 laggport shmif1
146
147 $atf_ifconfig lagg0 -laggport shmif0
148 $atf_ifconfig lagg0 laggport shmif0
149 $atf_ifconfig lagg0 -laggport shmif1
150 $atf_ifconfig lagg0 laggport shmif1
151
152 # destroy a LAGed port
153 atf_check -s exit:0 -o match:shmif0 rump.ifconfig lagg0
154 atf_check -s exit:0 -o match:shmif1 rump.ifconfig lagg0
155 $atf_ifconfig shmif0 destroy
156 $atf_ifconfig shmif1 destroy
157
158 $atf_ifconfig lagg0 laggproto none
159 atf_check -s exit:0 -o ignore rump.ifconfig lagg0
160 }
161
162 lagg_ifconfig_cleanup()
163 {
164 $DEBG && dump
165 cleanup
166 }
167
168 atf_test_case lagg_macaddr cleanup
169 lagg_macaddr_head()
170 {
171 atf_set "descr" "tests for a MAC address to assign to lagg(4)"
172 atf_set "require.progs" "rump_server"
173 }
174
175 lagg_macaddr_body()
176 {
177 local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
178
179 rump_server_start $SOCK_HOST0 lagg
180
181 export RUMP_SERVER=$SOCK_HOST0
182 $atf_ifconfig lagg0 create
183 rump_server_add_iface $SOCK_HOST0 shmif0 $BUS0
184 rump_server_add_iface $SOCK_HOST0 shmif1 $BUS1
185
186 maddr=$(get_macaddr $SOCK_HOST0 lagg0)
187 maddr0=$(get_macaddr $SOCK_HOST0 shmif0)
188 maddr1=$(get_macaddr $SOCK_HOST0 shmif1)
189
190 $atf_ifconfig lagg0 laggproto lacp
191
192 $atf_ifconfig lagg0 laggport shmif0
193 atf_check -s exit:0 -o match:$maddr0 rump.ifconfig lagg0
194
195 $atf_ifconfig lagg0 laggport shmif1
196 atf_check -s exit:0 -o match:$maddr0 rump.ifconfig lagg0
197 atf_check -s exit:0 -o match:$maddr0 rump.ifconfig shmif1
198
199 $atf_ifconfig lagg0 -laggport shmif0
200 atf_check -s exit:0 -o match:$maddr1 rump.ifconfig lagg0
201 atf_check -s exit:0 -o match:$maddr0 rump.ifconfig shmif0
202
203 $atf_ifconfig lagg0 laggport shmif0
204 atf_check -s exit:0 -o match:$maddr1 rump.ifconfig lagg0
205 atf_check -s exit:0 -o match:$maddr1 rump.ifconfig shmif0
206
207 $atf_ifconfig lagg0 -laggport shmif0
208 atf_check -s exit:0 -o match:$maddr0 rump.ifconfig shmif0
209
210 $atf_ifconfig lagg0 -laggport shmif1
211 atf_check -s exit:0 -o match:$maddr rump.ifconfig lagg0
212 }
213
214 lagg_macaddr_cleanup()
215 {
216 $DEBUG && dump
217 cleanup
218 }
219
220 atf_test_case lagg_ipv6lla cleanup
221 lagg_ipv6lla_head()
222 {
223 atf_set "descr" "tests for a IPV6 LLA to assign to lagg(4)"
224 atf_set "require.progs" "rump_server"
225 }
226
227 lagg_ipv6lla_body()
228 {
229 local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
230
231 rump_server_start $SOCK_HOST0 netinet6 lagg
232
233 export RUMP_SERVER=$SOCK_HOST0
234 $atf_ifconfig lagg0 create
235 rump_server_add_iface $SOCK_HOST0 shmif0 $BUS0
236 rump_server_add_iface $SOCK_HOST0 shmif1 $BUS1
237
238 $atf_ifconfig lagg0 laggproto lacp
239
240 $atf_ifconfig shmif0 up
241 atf_check -s exit:0 -o match:'inet6 fe80:' rump.ifconfig shmif0
242
243 $atf_ifconfig lagg0 laggproto lacp laggport shmif0
244 atf_check -s exit:0 -o not-match:'inet6 fe80:' rump.ifconfig shmif0
245
246 $atf_ifconfig lagg0 laggport shmif1
247 $atf_ifconfig shmif1 up
248 atf_check -s exit:0 -o not-match:'inet6 fe80:' rump.ifconfig shmif1
249
250 $atf_ifconfig lagg0 -laggport shmif0
251 atf_check -s exit:0 -o match:'inet6 fe80:' rump.ifconfig shmif0
252
253 $atf_ifconfig shmif1 down
254 $atf_ifconfig lagg0 -laggport shmif1
255 atf_check -s exit:0 -o not-match:'inet fe80:' rump.ifconfig shmif1
256 }
257
258 lagg_ipv6lla_cleanup()
259 {
260 $DEBUG && dump
261 cleanup
262 }
263
264 atf_test_case lagg_lacp_basic cleanup
265 lagg_lacp_basic_head()
266 {
267
268 atf_set "descr" "tests for LACP basic functions"
269 atf_set "require.progs" "rump_server"
270 }
271
272 lagg_lacp_basic_body()
273 {
274 local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
275
276 rump_server_start $SOCK_HOST0 lagg
277 rump_server_start $SOCK_HOST1 lagg
278 rump_server_start $SOCK_HOST2 lagg
279
280 export RUMP_SERVER=$SOCK_HOST0
281
282 # added running interface
283 $atf_ifconfig shmif0 create
284 $atf_ifconfig shmif0 linkstr $BUS0
285
286 $atf_ifconfig shmif1 create
287 $atf_ifconfig shmif1 linkstr $BUS1
288
289 $atf_ifconfig lagg0 create
290 $atf_ifconfig lagg0 laggproto lacp
291
292 $atf_ifconfig shmif0 up
293 $atf_ifconfig shmif1 up
294 $atf_ifconfig lagg0 up
295
296 $atf_ifconfig lagg0 laggport shmif0
297 $atf_ifconfig lagg0 laggport shmif1
298 $atf_ifconfig -w 10
299
300 $atf_ifconfig lagg0 -laggport shmif0
301 $atf_ifconfig lagg0 -laggport shmif1
302 $atf_ifconfig lagg0 down
303
304 # add the same interfaces again
305 $atf_ifconfig lagg0 up
306 $atf_ifconfig lagg0 laggport shmif0
307 $atf_ifconfig lagg0 laggport shmif1
308
309 # detach and re-attach protocol
310 $atf_ifconfig lagg0 laggproto none
311 $atf_ifconfig lagg0 laggproto lacp \
312 laggport shmif0 laggport shmif1
313
314 $atf_ifconfig lagg0 -laggport shmif0 -laggport shmif1
315 $atf_ifconfig lagg0 destroy
316 $atf_ifconfig shmif0 destroy
317 $atf_ifconfig shmif1 destroy
318
319 # tests for a loopback condition
320 $atf_ifconfig shmif0 create
321 $atf_ifconfig shmif0 linkstr $BUS0
322 $atf_ifconfig shmif1 create
323 $atf_ifconfig shmif1 linkstr $BUS0
324 $atf_ifconfig lagg0 create
325 $atf_ifconfig lagg0 laggproto lacp \
326 laggport shmif0 laggport shmif1
327 $atf_ifconfig shmif0 up
328 $atf_ifconfig shmif1 up
329 $atf_ifconfig lagg0 up
330
331 expected_inactive lagg0
332
333 $atf_ifconfig shmif0 down
334 $atf_ifconfig shmif0 destroy
335 $atf_ifconfig shmif1 down
336 $atf_ifconfig shmif1 destroy
337 $atf_ifconfig lagg0 down
338 $atf_ifconfig lagg0 destroy
339
340 export RUMP_SERVER=$SOCK_HOST0
341 $atf_ifconfig shmif0 create
342 $atf_ifconfig shmif0 linkstr $BUS0
343 $atf_ifconfig shmif0 up
344
345 $atf_ifconfig shmif1 create
346 $atf_ifconfig shmif1 linkstr $BUS1
347 $atf_ifconfig shmif1 up
348
349 $atf_ifconfig shmif2 create
350 $atf_ifconfig shmif2 linkstr $BUS2
351 $atf_ifconfig shmif2 up
352
353 $atf_ifconfig lagg0 create
354 $atf_ifconfig lagg0 laggproto lacp laggport shmif0 \
355 laggport shmif1 laggport shmif2
356 $atf_ifconfig lagg0 up
357
358 export RUMP_SERVER=$SOCK_HOST1
359 $atf_ifconfig shmif0 create
360 $atf_ifconfig shmif0 linkstr $BUS0
361 $atf_ifconfig shmif0 up
362
363 $atf_ifconfig shmif1 create
364 $atf_ifconfig shmif1 linkstr $BUS1
365 $atf_ifconfig shmif1 up
366
367 $atf_ifconfig lagg0 create
368 $atf_ifconfig lagg0 laggproto lacp
369 $atf_ifconfig lagg1 create
370 $atf_ifconfig lagg1 laggproto lacp
371
372 $atf_ifconfig lagg0 laggport shmif0
373 $atf_ifconfig lagg0 up
374 wait_for_distributing lagg0 shmif0
375
376 $atf_ifconfig lagg1 laggport shmif1
377 $atf_ifconfig lagg1 up
378
379 export RUMP_SERVER=$SOCK_HOST2
380 $atf_ifconfig shmif0 create
381 $atf_ifconfig shmif0 linkstr $BUS2
382 $atf_ifconfig shmif0 up
383
384 $atf_ifconfig lagg0 create
385 $atf_ifconfig lagg0 laggproto lacp laggport shmif0
386 $atf_ifconfig lagg0 up
387
388 export RUMP_SERVER=$SOCK_HOST0
389 wait_for_distributing lagg0 shmif0
390 expected_inactive lagg0 shmif1
391 expected_inactive lagg0 shmif2
392 }
393
394 lagg_lacp_basic_cleanup()
395 {
396
397 $DEBUG && dump
398 cleanup
399 }
400
401 lagg_lacp_ping()
402 {
403 local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
404
405 local af=$1
406 local atf_ping="atf_check -s exit:0 -o ignore rump.ping -c 1"
407 local ping=rump.ping
408 local rumplib=""
409 local pfx=24
410 local addr_host0=$IP4ADDR0
411 local addr_host1=$IP4ADDR1
412
413 case $af in
414 "inet")
415 # do nothing
416 ;;
417 "inet6")
418 atf_ping="atf_check -s exit:0 -o ignore rump.ping6 -c 1"
419 rumplib="netinet6"
420 pfx=64
421 addr_host0=$IP6ADDR0
422 addr_host1=$IP6ADDR1
423 ;;
424 esac
425
426 rump_server_start $SOCK_HOST0 lagg $rumplib
427 rump_server_start $SOCK_HOST1 lagg $rumplib
428
429 rump_server_add_iface $SOCK_HOST0 shmif0 $BUS0
430 rump_server_add_iface $SOCK_HOST0 shmif1 $BUS1
431 rump_server_add_iface $SOCK_HOST0 shmif2 $BUS2
432
433 rump_server_add_iface $SOCK_HOST1 shmif0 $BUS0
434 rump_server_add_iface $SOCK_HOST1 shmif1 $BUS1
435 rump_server_add_iface $SOCK_HOST1 shmif2 $BUS2
436
437 export RUMP_SERVER=$SOCK_HOST0
438 $atf_ifconfig lagg0 create
439 $atf_ifconfig lagg0 laggproto lacp laggport shmif0
440 $atf_ifconfig lagg0 $af $addr_host0/$pfx
441 $atf_ifconfig shmif0 up
442 $atf_ifconfig lagg0 up
443
444 export RUMP_SERVER=$SOCK_HOST1
445 $atf_ifconfig lagg0 create
446 $atf_ifconfig lagg0 laggproto lacp laggport shmif0
447 $atf_ifconfig lagg0 $af $addr_host1/$pfx
448 $atf_ifconfig shmif0 up
449 $atf_ifconfig lagg0 up
450
451 export RUMP_SERVER=$SOCK_HOST0
452 wait_for_distributing lagg0
453 $atf_ifconfig -w 10
454
455 export RUMP_SERVER=$SOCK_HOST1
456 wait_for_distributing lagg0
457 $atf_ifconfig -w 10
458
459 $atf_ping $addr_host0
460
461 export RUMP_SERVER=$SOCK_HOST0
462 $atf_ifconfig shmif1 up
463 $atf_ifconfig lagg0 laggport shmif1 laggport shmif2
464 $atf_ifconfig shmif2 up
465
466 export RUMP_SERVER=$SOCK_HOST1
467 $atf_ifconfig shmif1 up
468 $atf_ifconfig lagg0 laggport shmif1 laggport shmif2
469 $atf_ifconfig shmif2 up
470
471 export RUMP_SERVER=$SOCK_HOST0
472 wait_for_distributing lagg0 shmif1
473 wait_for_distributing lagg0 shmif2
474
475 export RUMP_SERVER=$SOCK_HOST1
476 wait_for_distributing lagg0 shmif1
477 wait_for_distributing lagg0 shmif2
478
479 $atf_ping $addr_host0
480 }
481
482 atf_test_case lagg_lacp_ipv4 cleanup
483 lagg_lacp_ipv4_head()
484 {
485
486 atf_set "descr" "tests for IPv4 with LACP"
487 atf_set "require.progs" "rump_server"
488 }
489
490 lagg_lacp_ipv4_body()
491 {
492
493 lagg_lacp_ping "inet"
494 }
495
496 lagg_lacp_ipv4_cleanup()
497 {
498
499 $DEBUG && dump
500 cleanup
501 }
502
503 atf_test_case lagg_lacp_ipv6 cleanup
504 lagg_lacp_ipv6_head()
505 {
506
507 atf_set "descr" "tests for IPv6 with LACP"
508 atf_set "require.progs" "rump_server"
509 }
510
511 lagg_lacp_ipv6_body()
512 {
513
514 lagg_lacp_ping "inet6"
515 }
516
517 lagg_lacp_ipv6_cleanup()
518 {
519
520 $DEBUG && dump
521 cleanup
522 }
523
524 lagg_lacp_vlan()
525 {
526 local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
527
528 local af=$1
529 local atf_ping="atf_check -s exit:0 -o ignore rump.ping -c 1"
530 local rumplib="vlan"
531 local pfx=24
532 local vlan0_addr_host0=$IP4ADDR0
533 local host0addr0=$IP4ADDR0
534 local host1addr0=$IP4ADDR1
535 local host0addr1=$IP4ADDR2
536 local host1addr1=$IP4ADDR3
537
538 case $af in
539 "inet")
540 # do nothing
541 ;;
542 "inet6")
543 atf_ping="atf_check -s exit:0 -o ignore rump.ping6 -c 1"
544 rumplib="netinet6"
545 pfx=64
546 host0addr0=$IP6ADDR0
547 host1addr0=$IP6ADDR1
548 host0addr1=$IP6ADDR2
549 host1addr1=$IP6ADDR3
550 ;;
551 esac
552
553 rump_server_start $SOCK_HOST0 lagg $rumplib
554 rump_server_start $SOCK_HOST1 lagg $rumplib
555
556 rump_server_add_iface $SOCK_HOST0 shmif0 $BUS0
557 rump_server_add_iface $SOCK_HOST0 shmif1 $BUS1
558 rump_server_add_iface $SOCK_HOST0 shmif2 $BUS2
559
560 rump_server_add_iface $SOCK_HOST1 shmif0 $BUS0
561 rump_server_add_iface $SOCK_HOST1 shmif1 $BUS1
562 rump_server_add_iface $SOCK_HOST1 shmif2 $BUS2
563
564 export RUMP_SERVER=$SOCK_HOST0
565 $atf_ifconfig lagg0 create
566 $atf_ifconfig lagg0 laggproto lacp laggport shmif0
567 $atf_ifconfig shmif0 up
568 $atf_ifconfig lagg0 up
569
570 export RUMP_SERVER=$SOCK_HOST1
571 $atf_ifconfig lagg0 create
572 $atf_ifconfig lagg0 laggproto lacp laggport shmif0
573 $atf_ifconfig shmif0 up
574 $atf_ifconfig lagg0 up
575
576 export RUMP_SERVER=$SOCK_HOST0
577 wait_for_distributing lagg0
578
579 $atf_ifconfig vlan0 create
580 $atf_ifconfig vlan0 vlan 10 vlanif lagg0
581 $atf_ifconfig vlan0 $af $host0addr0/$pfx
582 $atf_ifconfig vlan0 up
583
584 $atf_ifconfig vlan1 create
585 $atf_ifconfig vlan1 vlan 11 vlanif lagg0
586 $atf_ifconfig vlan1 $af $host0addr1/$pfx
587 $atf_ifconfig vlan1 up
588
589 export RUMP_SERVER=$SOCK_HOST1
590 $atf_ifconfig vlan0 create
591 $atf_ifconfig vlan0 vlan 10 vlanif lagg0
592 $atf_ifconfig vlan0 $af $host1addr0/$pfx
593 $atf_ifconfig vlan0 up
594
595 $atf_ifconfig vlan1 create
596 $atf_ifconfig vlan1 vlan 11 vlanif lagg0
597 $atf_ifconfig vlan1 $af $host1addr1/$pfx
598 $atf_ifconfig vlan1 up
599
600 export RUMP_SERVER=$SOCK_HOST0
601 $atf_ifconfig -w 10
602 export RUMP_SERVER=$SOCK_HOST1
603 $atf_ifconfig -w 10
604
605 export RUMP_SERVER=$SOCK_HOST0
606 $atf_ping $host1addr0
607 $atf_ping $host1addr1
608
609 $atf_ifconfig lagg0 laggport shmif1
610 $atf_ifconfig shmif1 up
611
612 export RUMP_SERVER=$SOCK_HOST1
613 $atf_ifconfig lagg0 laggport shmif1
614 $atf_ifconfig shmif1 up
615
616 export RUMP_SERVER=$SOCK_HOST0
617 wait_for_distributing lagg0 shmif1
618
619 export RUMP_SERVER=$SOCK_HOST1
620 wait_for_distributing lagg0 shmif1
621
622 $atf_ping $host0addr0
623 $atf_ping $host0addr1
624 }
625
626 atf_test_case lagg_lacp_vlan_ipv4 cleanup
627 lagg_lacp_vlan_ipv4_head()
628 {
629
630 atf_set "descr" "tests for IPv4 VLAN frames over LACP LAG"
631 atf_set "require.progs" "rump_server"
632 }
633
634 lagg_lacp_vlan_ipv4_body()
635 {
636
637 lagg_lacp_vlan "inet"
638 }
639
640 lagg_lacp_vlan_ipv4_cleanup()
641 {
642 $DEBUG && dump
643 cleanup
644 }
645
646 atf_test_case lagg_lacp_vlan_ipv6 cleanup
647 lagg_lacp_vlan_ipv6_head()
648 {
649
650 atf_set "descr" "tests for IPv6 VLAN frames over LACP LAG"
651 atf_set "require.progs" "rump_server"
652 }
653
654 lagg_lacp_vlan_ipv6_body()
655 {
656
657 lagg_lacp_vlan "inet"
658 }
659
660 lagg_lacp_vlan_ipv6_cleanup()
661 {
662 $DEBUG && dump
663 cleanup
664 }
665
666 atf_test_case lagg_lacp_portpri cleanup
667 lagg_lacp_portpri_head()
668 {
669
670 atf_set "descr" "tests for LACP port priority"
671 atf_set "require.progs" "rump_server"
672 }
673
674 lagg_lacp_portpri_body()
675 {
676 local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
677
678 rump_server_start $SOCK_HOST0 lagg
679 rump_server_start $SOCK_HOST1 lagg
680
681 rump_server_add_iface $SOCK_HOST0 shmif0 $BUS0
682 rump_server_add_iface $SOCK_HOST0 shmif1 $BUS1
683 rump_server_add_iface $SOCK_HOST0 shmif2 $BUS2
684
685 rump_server_add_iface $SOCK_HOST1 shmif0 $BUS0
686 rump_server_add_iface $SOCK_HOST1 shmif1 $BUS1
687 rump_server_add_iface $SOCK_HOST1 shmif2 $BUS2
688
689 export RUMP_SERVER=$SOCK_HOST0
690 $atf_ifconfig lagg0 create
691 $atf_ifconfig lagg0 laggproto lacp
692 $atf_ifconfig lagg0 lagglacp maxports 2
693
694 $atf_ifconfig shmif0 up
695 $atf_ifconfig shmif1 up
696 $atf_ifconfig shmif2 up
697
698 $atf_ifconfig lagg0 laggport shmif0 pri 1000
699 $atf_ifconfig lagg0 laggport shmif1 pri 2000
700 $atf_ifconfig lagg0 laggport shmif2 pri 3000
701 $atf_ifconfig lagg0 up
702
703 atf_check -s exit:0 -o match:'shmif0 pri=1000' rump.ifconfig lagg0
704 atf_check -s exit:0 -o match:'shmif1 pri=2000' rump.ifconfig lagg0
705 atf_check -s exit:0 -o match:'shmif2 pri=3000' rump.ifconfig lagg0
706
707 export RUMP_SERVER=$SOCK_HOST1
708 $atf_ifconfig lagg0 create
709 $atf_ifconfig lagg0 laggproto lacp
710
711 $atf_ifconfig shmif0 up
712 $atf_ifconfig shmif1 up
713 $atf_ifconfig shmif2 up
714
715 $atf_ifconfig lagg0 laggport shmif0 pri 300
716 $atf_ifconfig lagg0 laggport shmif1 pri 200
717 $atf_ifconfig lagg0 laggport shmif2 pri 100
718 $atf_ifconfig lagg0 up
719
720 atf_check -s exit:0 -o match:'shmif0 pri=300' rump.ifconfig lagg0
721 atf_check -s exit:0 -o match:'shmif1 pri=200' rump.ifconfig lagg0
722 atf_check -s exit:0 -o match:'shmif2 pri=100' rump.ifconfig lagg0
723
724 export RUMP_SERVER=$SOCK_HOST0
725 wait_for_distributing lagg0 shmif0
726 wait_for_distributing lagg0 shmif1
727 wait_state "STANDBY" lagg0 shmif2
728
729 $atf_ifconfig shmif0 down
730 wait_for_distributing lagg0 shmif2
731
732 $atf_ifconfig shmif0 up
733 wait_for_distributing lagg0 shmif0
734
735 $atf_ifconfig lagg0 laggportpri shmif0 5000
736 $atf_ifconfig lagg0 laggportpri shmif1 5000
737 $atf_ifconfig lagg0 laggportpri shmif2 5000
738
739 atf_check -s exit:0 -o match:'shmif0 pri=5000' rump.ifconfig lagg0
740 atf_check -s exit:0 -o match:'shmif1 pri=5000' rump.ifconfig lagg0
741 atf_check -s exit:0 -o match:'shmif2 pri=5000' rump.ifconfig lagg0
742
743 wait_state "STANDBY" lagg0 shmif0
744 wait_for_distributing lagg0 shmif1
745 wait_for_distributing lagg0 shmif2
746 }
747
748 lagg_lacp_portpri_cleanup()
749 {
750
751 $DEBUG && dump
752 cleanup
753 }
754
755 lagg_failover()
756 {
757 local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
758
759 local af=$1
760 local ping="rump.ping -c 1"
761 local rumplib=""
762 local pfx=24
763 local addr_host0=$IP4ADDR0
764 local addr_host1=$IP4ADDR1
765
766 case $af in
767 "inet")
768 # do nothing
769 ;;
770 "inet6")
771 ping="rump.ping6 -c 1"
772 rumplib="netinet6"
773 pfx=64
774 addr_host0=$IP6ADDR0
775 addr_host1=$IP6ADDR1
776 ;;
777 esac
778
779 local atf_ping="atf_check -s exit:0 -o ignore ${ping}"
780
781 rump_server_start $SOCK_HOST0 lagg $rumplib
782 rump_server_start $SOCK_HOST1 lagg $rumplib
783
784 rump_server_add_iface $SOCK_HOST0 shmif0 $BUS0
785 rump_server_add_iface $SOCK_HOST0 shmif1 $BUS1
786 rump_server_add_iface $SOCK_HOST0 shmif2 $BUS2
787
788 rump_server_add_iface $SOCK_HOST1 shmif0 $BUS0
789 rump_server_add_iface $SOCK_HOST1 shmif1 $BUS1
790 rump_server_add_iface $SOCK_HOST1 shmif2 $BUS2
791
792 export RUMP_SERVER=$SOCK_HOST0
793 $atf_ifconfig lagg0 create
794 $atf_ifconfig lagg0 laggproto failover
795
796 $atf_ifconfig lagg0 laggport shmif0 pri 1000
797 $atf_ifconfig lagg0 laggport shmif1 pri 2000
798 $atf_ifconfig lagg0 laggport shmif2 pri 3000
799 $atf_ifconfig lagg0 $af $addr_host0/$pfx
800
801 export RUMP_SERVER=$SOCK_HOST1
802 $atf_ifconfig lagg0 create
803 $atf_ifconfig lagg0 laggproto failover
804
805 $atf_ifconfig lagg0 laggport shmif0 pri 1000
806 $atf_ifconfig lagg0 laggport shmif1 pri 3000
807 $atf_ifconfig lagg0 laggport shmif2 pri 2000
808 $atf_ifconfig lagg0 $af $addr_host1/$pfx
809
810 export RUMP_SERVER=$SOCK_HOST0
811 $atf_ifconfig shmif0 up
812 $atf_ifconfig shmif1 up
813 $atf_ifconfig shmif2 up
814 $atf_ifconfig lagg0 up
815
816 export RUMP_SERVER=$SOCK_HOST1
817 $atf_ifconfig shmif0 up
818 $atf_ifconfig shmif1 up
819 $atf_ifconfig shmif2 up
820 $atf_ifconfig lagg0 up
821
822 export RUMP_SERVER=$SOCK_HOST0
823 $atf_ifconfig -w 10
824 wait_for_distributing lagg0 shmif0
825 wait_state "COLLECTING" lagg0 shmif0
826 wait_state "COLLECTING" lagg0 shmif1
827 wait_state "COLLECTING" lagg0 shmif2
828
829 export RUMP_SERVER=$SOCK_HOST1
830 $atf_ifconfig -w 10
831 wait_for_distributing lagg0 shmif0
832 wait_state "COLLECTING" lagg0 shmif0
833 wait_state "COLLECTING" lagg0 shmif1
834 wait_state "COLLECTING" lagg0 shmif2
835
836 export RUMP_SERVER=$SOCK_HOST0
837 $atf_ping $addr_host1
838
839 $atf_ifconfig shmif0 down
840 wait_for_distributing lagg0 shmif1
841 wait_state "COLLECTING" lagg0 shmif1
842 wait_state "COLLECTING" lagg0 shmif2
843
844 export RUMP_SERVER=$SOCK_HOST1
845 $atf_ifconfig shmif0 down
846 wait_for_distributing lagg0 shmif2
847 wait_state "COLLECTING" lagg0 shmif2
848 wait_state "COLLECTING" lagg0 shmif1
849
850 export RUMP_SERVER=$SOCK_HOST0
851 $atf_ping $addr_host1
852
853 $atf_ifconfig lagg0 laggfailover -rx-all
854 atf_check -s exit:0 -o not-match:'shmif2.+COLLECTING' rump.ifconfig lagg0
855
856 export RUMP_SERVER=$SOCK_HOST1
857 $atf_ifconfig lagg0 laggfailover -rx-all
858 atf_check -s exit:0 -o not-match:'shmif1.+COLLECTING' rump.ifconfig lagg0
859
860 export RUMP_SERVER=$SOCK_HOST0
861 atf_check -s not-exit:0 -o ignore -e ignore $ping -c 1 $addr_host1
862 }
863
864 atf_test_case lagg_failover_ipv4 cleanup
865 lagg_failover_ipv4_head()
866 {
867
868 atf_set "descr" "tests for failover using IPv4"
869 atf_set "require.progs" "rump_server"
870 }
871
872 lagg_failover_ipv4_body()
873 {
874
875 lagg_failover "inet"
876 }
877
878 lagg_failover_ipv4_cleanup()
879 {
880
881 $DEBUG && dump
882 cleanup
883 }
884
885 atf_test_case lagg_failover_ipv6 cleanup
886 lagg_failover_ipv6_head()
887 {
888
889 atf_set "descr" "tests for failover using IPv6"
890 atf_set "require.progs" "rump_server"
891 }
892
893 lagg_failover_ipv6_body()
894 {
895
896 lagg_failover "inet6"
897 }
898
899 lagg_failover_ipv6_cleanup()
900 {
901
902 $DEBUG && dump
903 cleanup
904 }
905
906 lagg_loadbalance()
907 {
908 local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
909
910 local af=$1
911 local ping="rump.ping -c 1"
912 local rumplib=""
913 local pfx=24
914 local addr_host0=$IP4ADDR0
915 local addr_host1=$IP4ADDR1
916
917 case $af in
918 "inet")
919 # do nothing
920 ;;
921 "inet6")
922 ping="rump.ping6 -c 1"
923 rumplib="netinet6"
924 pfx=64
925 addr_host0=$IP6ADDR0
926 addr_host1=$IP6ADDR1
927 ;;
928 esac
929
930 local atf_ping="atf_check -s exit:0 -o ignore ${ping}"
931
932 rump_server_start $SOCK_HOST0 lagg $rumplib
933 rump_server_start $SOCK_HOST1 lagg $rumplib
934
935 rump_server_add_iface $SOCK_HOST0 shmif0 $BUS0
936 rump_server_add_iface $SOCK_HOST0 shmif1 $BUS1
937 rump_server_add_iface $SOCK_HOST0 shmif2 $BUS2
938
939 rump_server_add_iface $SOCK_HOST1 shmif0 $BUS0
940 rump_server_add_iface $SOCK_HOST1 shmif1 $BUS1
941 rump_server_add_iface $SOCK_HOST1 shmif2 $BUS2
942
943 export RUMP_SERVER=$SOCK_HOST0
944 $atf_ifconfig lagg0 create
945 $atf_ifconfig lagg0 laggproto loadbalance
946
947 $atf_ifconfig lagg0 laggport shmif0 pri 1000
948 $atf_ifconfig lagg0 laggport shmif1 pri 2000
949 $atf_ifconfig lagg0 laggport shmif2 pri 3000
950 $atf_ifconfig lagg0 $af $addr_host0/$pfx
951
952 export RUMP_SERVER=$SOCK_HOST1
953 $atf_ifconfig lagg0 create
954 $atf_ifconfig lagg0 laggproto loadbalance
955
956 $atf_ifconfig lagg0 laggport shmif0 pri 1000
957 $atf_ifconfig lagg0 laggport shmif1 pri 3000
958 $atf_ifconfig lagg0 laggport shmif2 pri 2000
959 $atf_ifconfig lagg0 $af $addr_host1/$pfx
960
961 export RUMP_SERVER=$SOCK_HOST0
962 $atf_ifconfig shmif0 up
963 $atf_ifconfig shmif1 up
964 $atf_ifconfig shmif2 up
965 $atf_ifconfig lagg0 up
966
967 export RUMP_SERVER=$SOCK_HOST1
968 $atf_ifconfig shmif0 up
969 $atf_ifconfig shmif1 up
970 $atf_ifconfig shmif2 up
971 $atf_ifconfig lagg0 up
972
973 export RUMP_SERVER=$SOCK_HOST0
974 $atf_ifconfig -w 10
975 wait_for_distributing lagg0 shmif0
976 wait_state "COLLECTING" lagg0 shmif0
977 wait_state "COLLECTING" lagg0 shmif1
978 wait_state "COLLECTING" lagg0 shmif2
979
980 export RUMP_SERVER=$SOCK_HOST1
981 $atf_ifconfig -w 10
982 wait_state "COLLECTING,DISTRIBUTING" lagg0 shmif0
983 wait_state "COLLECTING,DISTRIBUTING" lagg0 shmif1
984 wait_state "COLLECTING,DISTRIBUTING" lagg0 shmif2
985
986 export RUMP_SERVER=$SOCK_HOST0
987 $atf_ping $addr_host1
988
989 $atf_ifconfig shmif0 down
990 wait_state "COLLECTING,DISTRIBUTING" lagg0 shmif1
991 wait_state "COLLECTING,DISTRIBUTING" lagg0 shmif2
992
993 export RUMP_SERVER=$SOCK_HOST1
994 $atf_ifconfig shmif0 down
995 wait_state "COLLECTING,DISTRIBUTING" lagg0 shmif1
996 wait_state "COLLECTING,DISTRIBUTING" lagg0 shmif2
997
998 export RUMP_SERVER=$SOCK_HOST0
999 $atf_ping $addr_host1
1000 }
1001
1002 atf_test_case lagg_loadbalance_ipv4 cleanup
1003 lagg_loadbalance_ipv4_head()
1004 {
1005
1006 atf_set "descr" "tests for loadbalance using IPv4"
1007 atf_set "require.progs" "rump_server"
1008 }
1009
1010 lagg_loadbalance_ipv4_body()
1011 {
1012
1013 lagg_loadbalance "inet"
1014 }
1015
1016 lagg_loadbalance_ipv4_cleanup()
1017 {
1018
1019 $DEBUG && dump
1020 cleanup
1021 }
1022
1023 atf_test_case lagg_loadbalance_ipv6 cleanup
1024 lagg_loadbalance_ipv6_head()
1025 {
1026
1027 atf_set "descr" "tests for loadbalance using IPv6"
1028 atf_set "require.progs" "rump_server"
1029 }
1030
1031 lagg_loadbalance_ipv6_body()
1032 {
1033
1034 lagg_loadbalance "inet6"
1035 }
1036
1037 lagg_loadbalance_ipv6_cleanup()
1038 {
1039
1040 $DEBUG && dump
1041 cleanup
1042 }
1043
1044 atf_init_test_cases()
1045 {
1046
1047 atf_add_test_case lagg_ifconfig
1048 atf_add_test_case lagg_macaddr
1049 atf_add_test_case lagg_ipv6lla
1050 atf_add_test_case lagg_lacp_basic
1051 atf_add_test_case lagg_lacp_ipv4
1052 atf_add_test_case lagg_lacp_ipv6
1053 atf_add_test_case lagg_lacp_vlan_ipv4
1054 atf_add_test_case lagg_lacp_vlan_ipv6
1055 atf_add_test_case lagg_lacp_portpri
1056 atf_add_test_case lagg_failover_ipv4
1057 atf_add_test_case lagg_failover_ipv6
1058 atf_add_test_case lagg_loadbalance_ipv4
1059 atf_add_test_case lagg_loadbalance_ipv6
1060 }
1061