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