t_vlan.sh revision 1.12 1 # $NetBSD: t_vlan.sh,v 1.12 2018/11/14 05:07:48 knakahara 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 BUS=bus
29 SOCK_LOCAL=unix://commsock1
30 SOCK_REMOTE=unix://commsock2
31 IP_LOCAL0=10.0.0.1
32 IP_LOCAL1=10.0.1.1
33 IP_REMOTE0=10.0.0.2
34 IP_REMOTE1=10.0.1.2
35 IP_MCADDR0=224.0.0.10
36 IP6_LOCAL0=fc00:0::1
37 IP6_LOCAL1=fc00:1::1
38 IP6_REMOTE0=fc00:0::2
39 IP6_REMOTE1=fc00:1::2
40 IP6_MCADDR0=ff11::10
41 ETH_IP_MCADDR0=01:00:5e:00:00:0a
42 ETH_IP6_MCADDR0=33:33:00:00:00:10
43
44 DEBUG=${DEBUG:-false}
45
46 vlan_create_destroy_body_common()
47 {
48 export RUMP_SERVER=${SOCK_LOCAL}
49
50 atf_check -s exit:0 rump.ifconfig vlan0 create
51 atf_check -s exit:0 rump.ifconfig vlan0 destroy
52
53 atf_check -s exit:0 rump.ifconfig vlan0 create
54 atf_check -s exit:0 rump.ifconfig vlan0 up
55 atf_check -s exit:0 rump.ifconfig vlan0 down
56 atf_check -s exit:0 rump.ifconfig vlan0 destroy
57
58 atf_check -s exit:0 rump.ifconfig shmif0 create
59 atf_check -s exit:0 rump.ifconfig vlan0 create
60 atf_check -s exit:0 rump.ifconfig vlan0 vlan 1 vlanif shmif0
61 atf_check -s exit:0 rump.ifconfig vlan0 up
62 atf_check -s exit:0 rump.ifconfig vlan0 destroy
63
64 # more than one vlan interface with a same parent interface
65 atf_check -s exit:0 rump.ifconfig shmif1 create
66 atf_check -s exit:0 rump.ifconfig vlan0 create
67 atf_check -s exit:0 rump.ifconfig vlan0 vlan 10 vlanif shmif0
68 atf_check -s exit:0 rump.ifconfig vlan1 create
69 atf_check -s exit:0 rump.ifconfig vlan1 vlan 11 vlanif shmif0
70
71 # more than one interface with another parent interface
72 atf_check -s exit:0 rump.ifconfig vlan2 create
73 atf_check -s exit:0 rump.ifconfig vlan2 vlan 12 vlanif shmif1
74 atf_check -s exit:0 rump.ifconfig vlan3 create
75 atf_check -s exit:0 rump.ifconfig vlan3 vlan 13 vlanif shmif1
76 atf_check -s exit:0 rump.ifconfig shmif0 destroy
77 atf_check -s exit:0 -o not-match:'shmif0' rump.ifconfig vlan0
78 atf_check -s exit:0 -o not-match:'shmif0' rump.ifconfig vlan1
79 atf_check -s exit:0 -o match:'shmif1' rump.ifconfig vlan2
80 atf_check -s exit:0 -o match:'shmif1' rump.ifconfig vlan3
81 atf_check -s exit:0 rump.ifconfig vlan0 destroy
82 atf_check -s exit:0 rump.ifconfig vlan1 destroy
83 atf_check -s exit:0 rump.ifconfig vlan2 destroy
84 atf_check -s exit:0 rump.ifconfig vlan3 destroy
85
86 }
87
88 atf_test_case vlan_create_destroy cleanup
89 vlan_create_destroy_head()
90 {
91
92 atf_set "descr" "tests of creation and deletion of vlan interface"
93 atf_set "require.progs" "rump_server"
94 }
95
96 vlan_create_destroy_body()
97 {
98 rump_server_start $SOCK_LOCAL vlan
99
100 vlan_create_destroy_body_common
101 }
102
103
104 vlan_create_destroy_cleanup()
105 {
106
107 $DEBUG && dump
108 cleanup
109 }
110
111 atf_test_case vlan_create_destroy6 cleanup
112 vlan_create_destroy6_head()
113 {
114
115 atf_set "descr" "tests of creation and deletion of vlan interface with IPv6"
116 atf_set "require.progs" "rump_server"
117 }
118
119 vlan_create_destroy6_body()
120 {
121
122 rump_server_start $SOCK_LOCAL vlan netinet6
123
124 vlan_create_destroy_body_common
125 }
126
127 vlan_create_destroy6_cleanup()
128 {
129
130 $DEBUG && dump
131 cleanup
132 }
133
134 vlan_basic_body_common()
135 {
136 local outfile=./out
137 local af=inet
138 local prefix=24
139 local local0=$IP_LOCAL0
140 local remote0=$IP_REMOTE0
141 local ping_cmd="rump.ping -n -w 1 -c 1"
142
143 if [ x"$1" = x"inet6" ]; then
144 af="inet6"
145 prefix=64
146 local0=$IP6_LOCAL0
147 remote0=$IP6_REMOTE0
148 ping_cmd="rump.ping6 -n -c 1"
149 fi
150
151 rump_server_add_iface $SOCK_LOCAL shmif0 $BUS
152 rump_server_add_iface $SOCK_REMOTE shmif0 $BUS
153
154 export RUMP_SERVER=$SOCK_LOCAL
155 atf_check -s exit:0 rump.ifconfig shmif0 up
156 export RUMP_SERVER=$SOCK_REMOTE
157 atf_check -s exit:0 rump.ifconfig shmif0 up
158
159 export RUMP_SERVER=$SOCK_LOCAL
160 atf_check -s exit:0 rump.ifconfig vlan0 create
161 atf_check -s exit:0 rump.ifconfig vlan0 vlan 10 vlanif shmif0
162 atf_check -s exit:0 rump.ifconfig vlan0 $af $local0/$prefix
163 atf_check -s exit:0 rump.ifconfig vlan0 up
164 atf_check -s exit:0 rump.ifconfig -w 10
165
166 export RUMP_SERVER=$SOCK_REMOTE
167 atf_check -s exit:0 rump.ifconfig vlan0 create
168 atf_check -s exit:0 rump.ifconfig vlan0 vlan 10 vlanif shmif0
169 atf_check -s exit:0 rump.ifconfig vlan0 $af $remote0/$prefix
170 atf_check -s exit:0 rump.ifconfig vlan0 up
171 atf_check -s exit:0 rump.ifconfig -w 10
172
173 extract_new_packets $BUS > $outfile
174
175 export RUMP_SERVER=$SOCK_LOCAL
176 atf_check -s exit:0 -o ignore $ping_cmd $remote0
177
178 extract_new_packets $BUS > $outfile
179 atf_check -s exit:0 -o match:'vlan 10' cat $outfile
180
181 atf_check -s exit:0 rump.ifconfig vlan0 -vlanif
182 atf_check -s exit:0 rump.ifconfig vlan0 vlan 20 vlanif shmif0
183 atf_check -s exit:0 rump.ifconfig vlan0 $af $local0/$prefix
184 atf_check -s exit:0 rump.ifconfig vlan0 up
185 atf_check -s exit:0 rump.ifconfig -w 10
186
187 extract_new_packets $BUS > $outfile
188 atf_check -s not-exit:0 -o ignore $ping_cmd $remote0
189
190 extract_new_packets $BUS > $outfile
191 atf_check -s exit:0 -o match:'vlan 20' cat $outfile
192
193 export RUMP_SERVER=$SOCK_LOCAL
194 atf_check -s exit:0 rump.ifconfig vlan0 -vlanif
195 atf_check -s exit:0 rump.ifconfig vlan0 vlan 10 vlanif shmif0
196 atf_check -s exit:0 rump.ifconfig vlan0 $af $local0/$prefix
197 atf_check -s exit:0 rump.ifconfig vlan0 up
198 atf_check -s exit:0 rump.ifconfig -w 10
199
200 atf_check -s exit:0 -o ignore rump.ifconfig -z vlan0
201 atf_check -s exit:0 -o ignore $ping_cmd $remote0
202 rump.ifconfig -v vlan0 > $outfile
203
204 atf_check -s exit:0 -o not-match:' 0 packets' cat $outfile
205 atf_check -s exit:0 -o not-match:' 0 bytes' cat $outfile
206 }
207
208 atf_test_case vlan_basic cleanup
209 vlan_basic_head()
210 {
211
212 atf_set "descr" "tests of communications over vlan interfaces"
213 atf_set "require.progs" "rump_server"
214 }
215
216 vlan_basic_body()
217 {
218 rump_server_start $SOCK_LOCAL vlan
219 rump_server_start $SOCK_REMOTE vlan
220
221 vlan_basic_body_common inet
222
223 }
224
225 vlan_basic_cleanup()
226 {
227
228 $DEBUG && dump
229 cleanup
230 }
231
232 atf_test_case vlan_basic6 cleanup
233 vlan_basic6_head()
234 {
235
236 atf_set "descr" "tests of communications over vlan interfaces using IPv6"
237 atf_set "require.progs" "rump_server"
238 }
239
240 vlan_basic6_body()
241 {
242 rump_server_start $SOCK_LOCAL vlan netinet6
243 rump_server_start $SOCK_REMOTE vlan netinet6
244
245 vlan_basic_body_common inet6
246 }
247
248 vlan_basic6_cleanup()
249 {
250
251 $DEBUG && dump
252 cleanup
253 }
254
255 vlanid_config_and_ping()
256 {
257 local vlanid=$1
258 shift
259
260 export RUMP_SERVER=$SOCK_LOCAL
261 atf_check -s exit:0 rump.ifconfig vlan0 vlan $vlanid vlanif shmif0
262 atf_check -s exit:0 rump.ifconfig vlan0 $IP_LOCAL0/24
263 atf_check -s exit:0 rump.ifconfig vlan0 up
264
265 export RUMP_SERVER=$SOCK_REMOTE
266 atf_check -s exit:0 rump.ifconfig vlan0 vlan $vlanid vlanif shmif0
267 atf_check -s exit:0 rump.ifconfig vlan0 $IP_REMOTE0/24
268 atf_check -s exit:0 rump.ifconfig vlan0 up
269
270 export RUMP_SERVER=$SOCK_LOCAL
271 atf_check -s exit:0 -o ignore rump.ping -n -w 1 -c 1 $IP_REMOTE0
272 atf_check -s exit:0 rump.ifconfig vlan0 -vlanif
273
274 export RUMP_SERVER=$SOCK_REMOTE
275 atf_check -s exit:0 rump.ifconfig vlan0 -vlanif
276 }
277
278 vlanid_config_and_ping6()
279 {
280 local vlanid=$1
281 shift
282
283 export RUMP_SERVER=$SOCK_LOCAL
284 atf_check -s exit:0 rump.ifconfig vlan0 vlan $vlanid vlanif shmif0
285 atf_check -s exit:0 rump.ifconfig vlan0 inet6 $IP6_LOCAL0/64
286 atf_check -s exit:0 rump.ifconfig vlan0 up
287
288 export RUMP_SERVER=$SOCK_REMOTE
289 atf_check -s exit:0 rump.ifconfig vlan0 vlan $vlanid vlanif shmif0
290 atf_check -s exit:0 rump.ifconfig vlan0 inet6 $IP6_REMOTE0/64
291 atf_check -s exit:0 rump.ifconfig vlan0 up
292
293 export RUMP_SERVER=$SOCK_LOCAL
294 atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 $IP6_REMOTE0
295 atf_check -s exit:0 rump.ifconfig vlan0 -vlanif
296
297 export RUMP_SERVER=$SOCK_REMOTE
298 atf_check -s exit:0 rump.ifconfig vlan0 -vlanif
299 }
300
301 vlan_vlanid_body_common()
302 {
303 local af=inet
304 local prefix=24
305 local sysctl_param="net.inet.ip.dad_count=0"
306 local ping_cmd="rump.ping -n -w 1 -c 1"
307 local config_and_ping=vlanid_config_and_ping
308 local local0=$IP_LOCAL0
309 local local1=$IP_LOCAL1
310 local remote0=$IP_REMOTE0
311 local remote1=$IP_REMOTE1
312
313 if [ x"$1" = x"inet6" ]; then
314 af=inet6
315 prefix=64
316 sysctl_param="net.inet6.ip6.dad_count=0"
317 ping_cmd="rump.ping6 -n -c 1"
318 config_and_ping=vlanid_config_and_ping6
319 local0=$IP6_LOCAL0
320 local1=$IP6_LOCAL1
321 remote0=$IP6_REMOTE0
322 remote1=$IP6_REMOTE1
323 fi
324
325 rump_server_add_iface $SOCK_LOCAL shmif0 $BUS
326 rump_server_add_iface $SOCK_REMOTE shmif0 $BUS
327
328 export RUMP_SERVER=$SOCK_LOCAL
329 atf_check -s exit:0 -o ignore rump.sysctl -w $sysctl_param
330 atf_check -s exit:0 rump.ifconfig shmif0 up
331 atf_check -s exit:0 rump.ifconfig vlan0 create
332
333 export RUMP_SERVER=$SOCK_REMOTE
334 atf_check -s exit:0 -o ignore rump.sysctl -w $sysctl_param
335 atf_check -s exit:0 rump.ifconfig shmif0 up
336 atf_check -s exit:0 rump.ifconfig vlan0 create
337
338 export RUMP_SERVER=$SOCK_LOCAL
339 atf_check -s not-exit:0 -e ignore\
340 rump.ifconfig vlan0 vlan -1 vlanif shmif0
341
342 # $config_and_ping 0 # reserved vlan id
343 $config_and_ping 1
344 $config_and_ping 4094
345 # $config_and_ping 4095 #reserved vlan id
346
347 if [ "${RANDOM:-0}" != "${RANDOM:-0}" ]
348 then
349 for TAG in $(( ${RANDOM:-0} % 4092 + 2 )) \
350 $(( ${RANDOM:-0} % 4092 + 2 )) \
351 $(( ${RANDOM:-0} % 4092 + 2 ))
352 do
353 $config_and_ping "${TAG}"
354 done
355 fi
356
357 export RUMP_SERVER=$SOCK_LOCAL
358 for TAG in 0 4095 4096 $((4096*4 + 1)) 65536 65537 $((65536 + 4095))
359 do
360 atf_check -s not-exit:0 -e not-empty \
361 rump.ifconfig vlan0 vlan "${TAG}" vlanif shmif0
362 done
363
364 atf_check -s exit:0 rump.ifconfig vlan0 vlan 1 vlanif shmif0
365 atf_check -s not-exit:0 -e ignore \
366 rump.ifconfig vlan0 vlan 2 vlanif shmif0
367
368 atf_check -s not-exit:0 -e ignore \
369 rump.ifconfig vlan0 vlan 1 vlanif shmif1
370
371 atf_check -s exit:0 rump.ifconfig vlan0 -vlanif
372 atf_check -s not-exit:0 -e ignore \
373 rump.ifconfig vlan0 $local0/$prefix
374
375 export RUMP_SERVER=$SOCK_LOCAL
376 atf_check -s exit:0 rump.ifconfig vlan0 vlan 10 vlanif shmif0
377 atf_check -s exit:0 rump.ifconfig vlan0 $af $local0/$prefix
378 atf_check -s exit:0 rump.ifconfig vlan0 up
379 atf_check -s exit:0 rump.ifconfig vlan1 create
380 atf_check -s exit:0 rump.ifconfig vlan1 vlan 11 vlanif shmif0
381 atf_check -s exit:0 rump.ifconfig vlan1 $af $local1/$prefix
382 atf_check -s exit:0 rump.ifconfig vlan1 up
383
384 export RUMP_SERVER=$SOCK_REMOTE
385 atf_check -s exit:0 rump.ifconfig vlan0 -vlanif
386 atf_check -s exit:0 rump.ifconfig vlan0 vlan 10 vlanif shmif0
387 atf_check -s exit:0 rump.ifconfig vlan0 $af $remote0/$prefix
388 atf_check -s exit:0 rump.ifconfig vlan0 up
389 atf_check -s exit:0 rump.ifconfig vlan1 create
390 atf_check -s exit:0 rump.ifconfig vlan1 vlan 11 vlanif shmif0
391 atf_check -s exit:0 rump.ifconfig vlan1 $af $remote1/$prefix
392 atf_check -s exit:0 rump.ifconfig vlan1 up
393
394 export RUMP_SERVER=$SOCK_LOCAL
395 atf_check -s exit:0 -o ignore $ping_cmd $remote0
396 atf_check -s exit:0 -o ignore $ping_cmd $remote1
397 }
398
399 atf_test_case vlan_vlanid cleanup
400 vlan_vlanid_head()
401 {
402
403 atf_set "descr" "tests of configuration for vlan id"
404 atf_set "require.progs" "rump_server"
405 }
406
407 vlan_vlanid_body()
408 {
409 rump_server_start $SOCK_LOCAL vlan
410 rump_server_start $SOCK_REMOTE vlan
411
412 vlan_vlanid_body_common inet
413 }
414
415 vlan_vlanid_cleanup()
416 {
417
418 $DEBUG && dump
419 cleanup
420 }
421
422 atf_test_case vlan_vlanid6 cleanup
423 vlan_vlanid6_head()
424 {
425
426 atf_set "descr" "tests of configuration for vlan id using IPv6"
427 atf_set "require.progs" "rump_server"
428 }
429
430
431 vlan_vlanid6_body()
432 {
433 rump_server_start $SOCK_LOCAL vlan netinet6
434 rump_server_start $SOCK_REMOTE vlan netinet6
435
436 vlan_vlanid_body_common inet6
437 }
438
439 vlan_vlanid6_cleanup()
440 {
441
442 $DEBUG && dump
443 cleanup
444 }
445
446 vlan_configs_body_common()
447 {
448 export RUMP_SERVER=${SOCK_LOCAL}
449
450 atf_check -s exit:0 rump.ifconfig shmif0 create
451 atf_check -s exit:0 rump.ifconfig shmif1 create
452 # unset U/L bit to detect a bug fixed by if_vlan.c:r1.132
453 atf_check -s exit:0 rump.ifconfig shmif0 link b0:a0:75:00:01:00 active
454 atf_check -s exit:0 rump.ifconfig shmif1 link b0:a0:75:00:01:01 active
455 atf_check -s exit:0 rump.ifconfig vlan0 create
456
457 atf_check -s exit:0 rump.ifconfig vlan0 vlan 10 vlanif shmif0
458 atf_check -s exit:0 rump.ifconfig vlan0 -vlanif
459
460 atf_check -s exit:0 rump.ifconfig vlan0 vlan 10 vlanif shmif0
461 atf_check -s exit:0 rump.ifconfig vlan0 -vlanif shmif0
462
463 atf_check -s exit:0 rump.ifconfig vlan0 vlan 10 vlanif shmif0
464 atf_check -s exit:0 -e ignore rump.ifconfig vlan0 -vlanif shmif1
465 atf_check -s exit:0 -e ignore rump.ifconfig vlan0 -vlanif shmif2
466
467 atf_check -s exit:0 rump.ifconfig vlan0 -vlanif
468
469 atf_check -s exit:0 rump.ifconfig vlan0 vlan 10 vlanif shmif0
470 atf_check -s exit:0 -e match:'Invalid argument' \
471 rump.ifconfig vlan0 mtu 1497
472 atf_check -s exit:0 rump.ifconfig vlan0 mtu 1496
473 atf_check -s exit:0 rump.ifconfig vlan0 mtu 42
474 atf_check -s exit:0 -e match:'Invalid argument' \
475 rump.ifconfig vlan0 mtu 41
476 atf_check -s exit:0 rump.ifconfig vlan0 -vlanif
477
478 atf_check -s exit:0 rump.ifconfig vlan1 create
479 atf_check -s exit:0 rump.ifconfig vlan0 vlan 10 vlanif shmif0
480 atf_check -s not-exit:0 -e match:'File exists' \
481 rump.ifconfig vlan1 vlan 10 vlanif shmif0
482 atf_check -s exit:0 rump.ifconfig vlan1 vlan 10 vlanif shmif1
483
484 atf_check -s exit:0 rump.ifconfig vlan1 -vlanif shmif1
485 atf_check -s exit:0 rump.ifconfig vlan1 vlan 10 vlanif shmif1
486
487 atf_check -s exit:0 rump.ifconfig vlan0 -vlanif shmif0
488 atf_check -s exit:0 rump.ifconfig vlan0 vlan 10 vlanif shmif0
489 }
490
491 atf_test_case vlan_configs cleanup
492 vlan_configs_head()
493 {
494 atf_set "descr" "tests of configuration except vlan id"
495 atf_set "require.progs" "rump_server"
496 }
497
498 vlan_configs_body()
499 {
500
501 rump_server_start $SOCK_LOCAL vlan
502
503 vlan_configs_body_common
504
505 }
506
507 vlan_configs_cleanup()
508 {
509
510 $DEBUG && dump
511 cleanup
512 }
513
514 atf_test_case vlan_configs6 cleanup
515 vlan_configs6_head()
516 {
517 atf_set "descr" "tests of configuration except vlan id using IPv6"
518 atf_set "require.progs" "rump_server"
519 }
520
521 vlan_configs6_body()
522 {
523 rump_server_start $SOCK_LOCAL vlan netinet6
524
525 vlan_configs_body_common
526 }
527
528 vlan_configs6_cleanup()
529 {
530 $DEBUG && dump
531 cleanup
532 }
533
534 vlan_bridge_body_common()
535 {
536
537 rump_server_add_iface $SOCK_LOCAL shmif0 $BUS
538
539 export RUMP_SERVER=$SOCK_LOCAL
540 atf_check -s exit:0 rump.ifconfig shmif0 up
541
542 atf_check -s exit:0 rump.ifconfig vlan0 create
543 atf_check -s exit:0 rump.ifconfig vlan0 vlan 10 vlanif shmif0
544 atf_check -s exit:0 rump.ifconfig vlan0 up
545 $DEBUG && rump.ifconfig vlan0
546
547 atf_check -s exit:0 rump.ifconfig bridge0 create
548 # Adjust to the MTU of a vlan on a shmif
549 atf_check -s exit:0 rump.ifconfig bridge0 mtu 1496
550 atf_check -s exit:0 rump.ifconfig bridge0 up
551 # Test brconfig add
552 atf_check -s exit:0 $HIJACKING brconfig bridge0 add vlan0
553 $DEBUG && brconfig bridge0
554 # Test brconfig delete
555 atf_check -s exit:0 $HIJACKING brconfig bridge0 delete vlan0
556
557 atf_check -s exit:0 $HIJACKING brconfig bridge0 add vlan0
558 # Test vlan destruction with bridge
559 atf_check -s exit:0 rump.ifconfig vlan0 destroy
560
561 rump_server_destroy_ifaces
562 }
563
564 atf_test_case vlan_bridge cleanup
565 vlan_bridge_head()
566 {
567
568 atf_set "descr" "tests of vlan interfaces with bridges (IPv4)"
569 atf_set "require.progs" "rump_server"
570 }
571
572 vlan_bridge_body()
573 {
574
575 rump_server_start $SOCK_LOCAL vlan bridge
576 vlan_bridge_body_common
577 }
578
579 vlan_bridge_cleanup()
580 {
581
582 $DEBUG && dump
583 cleanup
584 }
585
586 atf_test_case vlan_bridge6 cleanup
587 vlan_bridge6_head()
588 {
589
590 atf_set "descr" "tests of vlan interfaces with bridges (IPv6)"
591 atf_set "require.progs" "rump_server"
592 }
593
594 vlan_bridge6_body()
595 {
596
597 rump_server_start $SOCK_LOCAL vlan netinet6 bridge
598 vlan_bridge_body_common
599 }
600
601 vlan_bridge6_cleanup()
602 {
603
604 $DEBUG && dump
605 cleanup
606 }
607
608 vlan_multicast_body_common()
609 {
610
611 local af="inet"
612 local local0=$IP_LOCAL0
613 local local1=$IP_LOCAL1
614 local mcaddr=$IP_MCADDR0
615 local eth_mcaddr=$ETH_IP_MCADDR0
616 local prefix=24
617 local siocXmulti="$(atf_get_srcdir)/siocXmulti"
618
619 if [ x"$1" = x"inet6" ]; then
620 af="inet6"
621 prefix=64
622 local0=$IP6_LOCAL0
623 local1=$IP6_LOCAL1
624 mcaddr=$IP6_MCADDR0
625 eth_mcaddr=$ETH_IP6_MCADDR0
626 fi
627
628 export RUMP_SERVER=$SOCK_LOCAL
629
630 atf_check -s exit:0 rump.ifconfig shmif0 create
631 atf_check -s exit:0 rump.ifconfig shmif0 linkstr net0 up
632 atf_check -s exit:0 rump.ifconfig vlan0 create
633 atf_check -s exit:0 rump.ifconfig vlan0 vlan 10 vlanif shmif0
634 atf_check -s exit:0 rump.ifconfig vlan0 $af $local0/$prefix up
635 atf_check -s exit:0 rump.ifconfig vlan1 create
636 atf_check -s exit:0 rump.ifconfig vlan1 vlan 11 vlanif shmif0
637 atf_check -s exit:0 rump.ifconfig vlan1 $af $local1/$prefix up
638 atf_check -s exit:0 rump.ifconfig -w 10
639
640 # check the initial state
641 atf_check -s exit:0 -o not-match:"$eth_mcaddr" $HIJACKING ifmcstat
642
643 # add a multicast address
644 atf_check -s exit:0 $HIJACKING $siocXmulti add vlan0 $mcaddr
645 atf_check -s exit:0 -o match:"$eth_mcaddr" $HIJACKING ifmcstat
646
647 # delete the address
648 atf_check -s exit:0 $HIJACKING $siocXmulti del vlan0 $mcaddr
649 atf_check -s exit:0 -o not-match:"$eth_mcaddr" $HIJACKING ifmcstat
650
651 # delete a non-existing address
652 atf_check -s not-exit:0 -e ignore $HIJACKING $siocXmulti del vlan0 $mcaddr
653
654 # add an address to different interfaces
655 atf_check -s exit:0 $HIJACKING $siocXmulti add vlan0 $mcaddr
656 atf_check -s exit:0 $HIJACKING $siocXmulti add vlan1 $mcaddr
657 atf_check -s exit:0 -o match:"${eth_mcaddr}: 2" $HIJACKING ifmcstat
658 atf_check -s exit:0 $HIJACKING $siocXmulti del vlan0 $mcaddr
659
660 # delete the address with invalid interface
661 atf_check -s not-exit:0 -e match:"Invalid argument" \
662 $HIJACKING $siocXmulti del vlan0 $mcaddr
663
664 atf_check -s exit:0 $HIJACKING $siocXmulti del vlan1 $mcaddr
665
666 # add and delete a same address more than once
667 atf_check -s exit:0 $HIJACKING $siocXmulti add vlan0 $mcaddr
668 atf_check -s exit:0 $HIJACKING $siocXmulti add vlan0 $mcaddr
669 atf_check -s exit:0 $HIJACKING $siocXmulti add vlan0 $mcaddr
670 atf_check -s exit:0 -o match:"${eth_mcaddr}: 3" $HIJACKING ifmcstat
671 atf_check -s exit:0 $HIJACKING $siocXmulti del vlan0 $mcaddr
672 atf_check -s exit:0 $HIJACKING $siocXmulti del vlan0 $mcaddr
673 atf_check -s exit:0 $HIJACKING $siocXmulti del vlan0 $mcaddr
674 atf_check -s exit:0 -o not-match:"$eth_mcaddr" $HIJACKING ifmcstat
675
676 # delete all address added to parent device when remove
677 # the config of parent interface
678 atf_check -s exit:0 $HIJACKING $siocXmulti add vlan0 $mcaddr
679 atf_check -s exit:0 $HIJACKING $siocXmulti add vlan0 $mcaddr
680 atf_check -s exit:0 $HIJACKING $siocXmulti add vlan0 $mcaddr
681 atf_check -s exit:0 rump.ifconfig vlan0 -vlanif shmif0
682 atf_check -s exit:0 -o not-match:"$eth_mcaddr" $HIJACKING ifmcstat
683 }
684
685 atf_test_case vlan_multicast cleanup
686 vlan_multicast_head()
687 {
688 atf_set "descr" "tests of multicast address adding and deleting"
689 atf_set "require.progs" "rump_server"
690 }
691
692 vlan_multicast_body()
693 {
694 rump_server_start $SOCK_LOCAL vlan
695
696 vlan_multicast_body_common inet
697 }
698
699 vlan_multicast_cleanup()
700 {
701 $DEBUG && dump
702 cleanup
703 }
704
705 atf_test_case vlan_multicast6 cleanup
706 vlan_multicast6_head()
707 {
708 atf_set "descr" "tests of multicast address adding and deleting with IPv6"
709 atf_set "require.progs" "rump_server"
710 }
711
712 vlan_multicast6_body()
713 {
714 rump_server_start $SOCK_LOCAL vlan netinet6
715
716 vlan_multicast_body_common inet6
717 }
718
719 vlan_multicast6_cleanup()
720 {
721 $DEBUG && dump
722 cleanup
723 }
724
725 atf_init_test_cases()
726 {
727
728 atf_add_test_case vlan_create_destroy
729 atf_add_test_case vlan_basic
730 atf_add_test_case vlan_vlanid
731 atf_add_test_case vlan_configs
732 atf_add_test_case vlan_bridge
733 atf_add_test_case vlan_multicast
734
735 atf_add_test_case vlan_create_destroy6
736 atf_add_test_case vlan_basic6
737 atf_add_test_case vlan_vlanid6
738 atf_add_test_case vlan_configs6
739 atf_add_test_case vlan_bridge6
740 atf_add_test_case vlan_multicast6
741 }
742