1# $NetBSD: t_vlan.sh,v 1.17 2020/03/08 09:05:33 nisimura 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::1 37IP6_LOCAL1=fc00:1::1 38IP6_REMOTE0=fc00::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 258vlan_auto_follow_mtu_body_common() 259{ 260 local atf_ifconfig="atf_check -s exit:0 rump.ifconfig" 261 local outfile=./out 262 local af=inet 263 local prefix=24 264 local local0=$IP_LOCAL0 265 local remote0=$IP_REMOTE0 266 local ping_cmd="rump.ping -D -n -w 1 -c 1" 267 local mtu=1500 268 local vlan_mtu=`expr $mtu - 4` 269 # ipv4 header=20bytes, icmp header=8bytes 270 local padding=`expr $vlan_mtu - 20 - 8` 271 local over_padding=`expr $vlan_mtu - 20 - 8 + 1` 272 local nonfrag_msg="$local0 > $remote0: ICMP echo request" 273 # unused for ipv4 274 local frag_msg="" 275 276 if [ x"$1" = x"inet6" ]; then 277 af="inet6" 278 prefix=64 279 local0=$IP6_LOCAL0 280 remote0=$IP6_REMOTE0 281 # ipv6 header=40bytes, icmpv6 header=8bytes 282 padding=`expr $vlan_mtu - 40 - 8` 283 over_padding=`expr $vlan_mtu - 40 - 8 + 1` 284 ping_cmd="rump.ping6 -mm -n -c 1 -i 1" 285 nonfrag_msg="$local0 > $remote0: ICMP6, echo request" 286 frag_msg="$local0 > $remote0: frag .* ICMP6, echo request" 287 fi 288 289 rump_server_add_iface $SOCK_LOCAL shmif0 $BUS 290 rump_server_add_iface $SOCK_REMOTE shmif0 $BUS 291 292 export RUMP_SERVER=$SOCK_LOCAL 293 $atf_ifconfig shmif0 up 294 export RUMP_SERVER=$SOCK_REMOTE 295 $atf_ifconfig shmif0 up 296 297 export RUMP_SERVER=$SOCK_LOCAL 298 $atf_ifconfig vlan0 create 299 300 # since upper bound of shmif's mtu is 1500, 301 # so we lower vlan's mtu instead of raising shmif's. 302 # to do this, we change the interface's parameter 303 # such as ND_IFINFO(ifp)->maxmtu that is changed by SIOCSIFMTU. 304 305 # $atf_config shmif0 mtu 1600 306 $atf_ifconfig vlan0 vlan 10 vlanif shmif0 307 $atf_ifconfig vlan0 mtu 1400 308 $atf_ifconfig vlan0 -vlanif shmif0 309 310 $atf_ifconfig vlan0 vlan 10 vlanif shmif0 311 $atf_ifconfig vlan0 $af $local0/$prefix 312 $atf_ifconfig vlan0 up 313 $atf_ifconfig -w 10 314 315 export RUMP_SERVER=$SOCK_REMOTE 316 $atf_ifconfig vlan0 create 317 $atf_ifconfig vlan0 vlan 10 vlanif shmif0 318 $atf_ifconfig vlan0 $af $remote0/$prefix 319 $atf_ifconfig vlan0 up 320 $atf_ifconfig -w 10 321 322 extract_new_packets $BUS > $outfile 323 export RUMP_SERVER=$SOCK_LOCAL 324 325 atf_check -s exit:0 -o ignore $ping_cmd -s $padding $remote0 326 extract_new_packets $BUS > $outfile 327 atf_check -s exit:0 -o match:"$nonfrag_msg" cat $outfile 328 329 if [ x"$1" = x"inet6" ]; then 330 atf_check -s exit:0 -o ignore $ping_cmd -s $over_padding $remote0 331 extract_new_packets $BUS > $outfile 332 atf_check -s exit:0 -o match:"$frag_msg" cat $outfile 333 else 334 atf_check -s not-exit:0 -o ignore -e match:"Message too long" \ 335 $ping_cmd -s $over_padding $remote0 336 fi 337} 338 339atf_test_case vlan_auto_follow_mtu cleanup 340vlan_auto_follow_mtu_head() 341{ 342 343 atf_set "descr" "tests of setting vlan mtu using IPv4" 344 atf_set "require.progs" "rump_server" 345} 346 347vlan_auto_follow_mtu_body() 348{ 349 rump_server_start $SOCK_LOCAL vlan 350 rump_server_start $SOCK_REMOTE vlan 351 352 vlan_auto_follow_mtu_body_common inet 353} 354 355vlan_auto_follow_mtu_cleanup() 356{ 357 358 $DEBUG && dump 359 cleanup 360} 361 362atf_test_case vlan_auto_follow_mtu6 cleanup 363vlan_auto_follow_mtu6_head() 364{ 365 366 atf_set "descr" "tests of setting vlan mtu using IPv6" 367 atf_set "require.progs" "rump_server" 368} 369 370vlan_auto_follow_mtu6_body() 371{ 372 rump_server_start $SOCK_LOCAL vlan netinet6 373 rump_server_start $SOCK_REMOTE vlan netinet6 374 375 vlan_auto_follow_mtu_body_common inet6 376} 377 378vlan_auto_follow_mtu6_cleanup() 379{ 380 381 $DEBUG && dump 382 cleanup 383} 384 385vlanid_config_and_ping() 386{ 387 local atf_ifconfig="atf_check -s exit:0 rump.ifconfig" 388 local vlanid=$1 389 shift 390 391 export RUMP_SERVER=$SOCK_LOCAL 392 $atf_ifconfig vlan0 vlan $vlanid vlanif shmif0 393 $atf_ifconfig vlan0 $IP_LOCAL0/24 394 $atf_ifconfig vlan0 up 395 396 export RUMP_SERVER=$SOCK_REMOTE 397 $atf_ifconfig vlan0 vlan $vlanid vlanif shmif0 398 $atf_ifconfig vlan0 $IP_REMOTE0/24 399 $atf_ifconfig vlan0 up 400 401 export RUMP_SERVER=$SOCK_LOCAL 402 atf_check -s exit:0 -o ignore rump.ping -n -w 1 -c 1 $IP_REMOTE0 403 $atf_ifconfig vlan0 -vlanif 404 405 export RUMP_SERVER=$SOCK_REMOTE 406 $atf_ifconfig vlan0 -vlanif 407} 408 409vlanid_config_and_ping6() 410{ 411 local atf_ifconfig="atf_check -s exit:0 rump.ifconfig" 412 local vlanid=$1 413 shift 414 415 export RUMP_SERVER=$SOCK_LOCAL 416 $atf_ifconfig vlan0 vlan $vlanid vlanif shmif0 417 $atf_ifconfig vlan0 inet6 $IP6_LOCAL0/64 418 $atf_ifconfig vlan0 up 419 420 export RUMP_SERVER=$SOCK_REMOTE 421 $atf_ifconfig vlan0 vlan $vlanid vlanif shmif0 422 $atf_ifconfig vlan0 inet6 $IP6_REMOTE0/64 423 $atf_ifconfig vlan0 up 424 425 export RUMP_SERVER=$SOCK_LOCAL 426 atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 $IP6_REMOTE0 427 $atf_ifconfig vlan0 -vlanif 428 429 export RUMP_SERVER=$SOCK_REMOTE 430 $atf_ifconfig vlan0 -vlanif 431} 432 433vlan_vlanid_body_common() 434{ 435 local atf_ifconfig="atf_check -s exit:0 rump.ifconfig" 436 local af=inet 437 local prefix=24 438 local sysctl_param="net.inet.ip.dad_count=0" 439 local ping_cmd="rump.ping -n -w 1 -c 1" 440 local config_and_ping=vlanid_config_and_ping 441 local local0=$IP_LOCAL0 442 local local1=$IP_LOCAL1 443 local remote0=$IP_REMOTE0 444 local remote1=$IP_REMOTE1 445 446 if [ x"$1" = x"inet6" ]; then 447 af=inet6 448 prefix=64 449 sysctl_param="net.inet6.ip6.dad_count=0" 450 ping_cmd="rump.ping6 -n -c 1" 451 config_and_ping=vlanid_config_and_ping6 452 local0=$IP6_LOCAL0 453 local1=$IP6_LOCAL1 454 remote0=$IP6_REMOTE0 455 remote1=$IP6_REMOTE1 456 fi 457 458 rump_server_add_iface $SOCK_LOCAL shmif0 $BUS 459 rump_server_add_iface $SOCK_REMOTE shmif0 $BUS 460 461 export RUMP_SERVER=$SOCK_LOCAL 462 atf_check -s exit:0 -o ignore rump.sysctl -w $sysctl_param 463 $atf_ifconfig shmif0 up 464 $atf_ifconfig vlan0 create 465 466 export RUMP_SERVER=$SOCK_REMOTE 467 atf_check -s exit:0 -o ignore rump.sysctl -w $sysctl_param 468 $atf_ifconfig shmif0 up 469 $atf_ifconfig vlan0 create 470 471 export RUMP_SERVER=$SOCK_LOCAL 472 atf_check -s not-exit:0 -e match:"^usage: rump.ifconfig" \ 473 rump.ifconfig vlan0 vlan -1 vlanif shmif0 474 475 # $config_and_ping 0 # reserved vlan id 476 $config_and_ping 1 477 $config_and_ping 4094 478 # $config_and_ping 4095 #reserved vlan id 479 480 if [ "${RANDOM:-0}" != "${RANDOM:-0}" ] 481 then 482 for TAG in $(( ${RANDOM:-0} % 4092 + 2 )) \ 483 $(( ${RANDOM:-0} % 4092 + 2 )) \ 484 $(( ${RANDOM:-0} % 4092 + 2 )) 485 do 486 $config_and_ping "${TAG}" 487 done 488 fi 489 490 export RUMP_SERVER=$SOCK_LOCAL 491 for TAG in 0 4095 4096 $((4096*4 + 1)) 65536 65537 $((65536 + 4095)) 492 do 493 atf_check -s not-exit:0 -e not-empty \ 494 rump.ifconfig vlan0 vlan "${TAG}" vlanif shmif0 495 done 496 497 $atf_ifconfig vlan0 vlan 1 vlanif shmif0 498 atf_check -s not-exit:0 -e match:"SIOCSETVLAN: Device busy" \ 499 rump.ifconfig vlan0 vlan 2 vlanif shmif0 500 501 atf_check -s not-exit:0 -e match:"SIOCSETVLAN: Device busy" \ 502 rump.ifconfig vlan0 vlan 1 vlanif shmif1 503 504 $atf_ifconfig vlan0 -vlanif 505 atf_check -s not-exit:0 -e match:"Invalid argument" \ 506 rump.ifconfig vlan0 $af $local0/$prefix 507 508 export RUMP_SERVER=$SOCK_LOCAL 509 $atf_ifconfig vlan0 vlan 10 vlanif shmif0 510 $atf_ifconfig vlan0 $af $local0/$prefix 511 $atf_ifconfig vlan0 up 512 $atf_ifconfig vlan1 create 513 $atf_ifconfig vlan1 vlan 11 vlanif shmif0 514 $atf_ifconfig vlan1 $af $local1/$prefix 515 $atf_ifconfig vlan1 up 516 517 export RUMP_SERVER=$SOCK_REMOTE 518 $atf_ifconfig vlan0 -vlanif 519 $atf_ifconfig vlan0 vlan 10 vlanif shmif0 520 $atf_ifconfig vlan0 $af $remote0/$prefix 521 $atf_ifconfig vlan0 up 522 $atf_ifconfig vlan1 create 523 $atf_ifconfig vlan1 vlan 11 vlanif shmif0 524 $atf_ifconfig vlan1 $af $remote1/$prefix 525 $atf_ifconfig vlan1 up 526 527 export RUMP_SERVER=$SOCK_LOCAL 528 atf_check -s exit:0 -o ignore $ping_cmd $remote0 529 atf_check -s exit:0 -o ignore $ping_cmd $remote1 530} 531 532atf_test_case vlan_vlanid cleanup 533vlan_vlanid_head() 534{ 535 536 atf_set "descr" "tests of configuration for vlan id" 537 atf_set "require.progs" "rump_server" 538} 539 540vlan_vlanid_body() 541{ 542 rump_server_start $SOCK_LOCAL vlan 543 rump_server_start $SOCK_REMOTE vlan 544 545 vlan_vlanid_body_common inet 546} 547 548vlan_vlanid_cleanup() 549{ 550 551 $DEBUG && dump 552 cleanup 553} 554 555atf_test_case vlan_vlanid6 cleanup 556vlan_vlanid6_head() 557{ 558 559 atf_set "descr" "tests of configuration for vlan id using IPv6" 560 atf_set "require.progs" "rump_server" 561} 562 563 564vlan_vlanid6_body() 565{ 566 rump_server_start $SOCK_LOCAL vlan netinet6 567 rump_server_start $SOCK_REMOTE vlan netinet6 568 569 vlan_vlanid_body_common inet6 570} 571 572vlan_vlanid6_cleanup() 573{ 574 575 $DEBUG && dump 576 cleanup 577} 578 579vlan_configs_body_common() 580{ 581 local atf_ifconfig="atf_check -s exit:0 rump.ifconfig" 582 583 export RUMP_SERVER=${SOCK_LOCAL} 584 585 $atf_ifconfig shmif0 create 586 $atf_ifconfig shmif1 create 587 # unset U/L bit to detect a bug fixed by if_vlan.c:r1.132 588 $atf_ifconfig shmif0 link b0:a0:75:00:01:00 active 589 $atf_ifconfig shmif1 link b0:a0:75:00:01:01 active 590 $atf_ifconfig vlan0 create 591 592 $atf_ifconfig vlan0 vlan 10 vlanif shmif0 593 $atf_ifconfig vlan0 -vlanif 594 595 $atf_ifconfig vlan0 vlan 10 vlanif shmif0 596 $atf_ifconfig vlan0 -vlanif shmif0 597 598 $atf_ifconfig vlan0 vlan 10 vlanif shmif0 599 atf_check -s exit:0 rump.ifconfig vlan0 -vlanif shmif1 600 atf_check -s exit:0 rump.ifconfig vlan0 -vlanif shmif2 601 602 $atf_ifconfig vlan0 -vlanif 603 604 $atf_ifconfig vlan0 vlan 10 vlanif shmif0 605 atf_check -s exit:0 -e match:'Invalid argument' \ 606 rump.ifconfig vlan0 mtu 1497 607 $atf_ifconfig vlan0 mtu 1496 608 $atf_ifconfig vlan0 mtu 42 609 atf_check -s exit:0 -e match:'Invalid argument' \ 610 rump.ifconfig vlan0 mtu 41 611 $atf_ifconfig vlan0 -vlanif 612 613 $atf_ifconfig vlan1 create 614 $atf_ifconfig vlan0 vlan 10 vlanif shmif0 615 atf_check -s not-exit:0 -e match:'File exists' \ 616 rump.ifconfig vlan1 vlan 10 vlanif shmif0 617 $atf_ifconfig vlan1 vlan 10 vlanif shmif1 618 619 $atf_ifconfig vlan1 -vlanif shmif1 620 $atf_ifconfig vlan1 vlan 10 vlanif shmif1 621 622 $atf_ifconfig vlan0 -vlanif shmif0 623 $atf_ifconfig vlan0 vlan 10 vlanif shmif0 624} 625 626atf_test_case vlan_configs cleanup 627vlan_configs_head() 628{ 629 atf_set "descr" "tests of configuration except vlan id" 630 atf_set "require.progs" "rump_server" 631} 632 633vlan_configs_body() 634{ 635 636 rump_server_start $SOCK_LOCAL vlan 637 638 vlan_configs_body_common 639 640} 641 642vlan_configs_cleanup() 643{ 644 645 $DEBUG && dump 646 cleanup 647} 648 649atf_test_case vlan_configs6 cleanup 650vlan_configs6_head() 651{ 652 atf_set "descr" "tests of configuration except vlan id using IPv6" 653 atf_set "require.progs" "rump_server" 654} 655 656vlan_configs6_body() 657{ 658 rump_server_start $SOCK_LOCAL vlan netinet6 659 660 vlan_configs_body_common 661} 662 663vlan_configs6_cleanup() 664{ 665 $DEBUG && dump 666 cleanup 667} 668 669vlan_bridge_body_common() 670{ 671 local atf_ifconfig="atf_check -s exit:0 rump.ifconfig" 672 673 rump_server_add_iface $SOCK_LOCAL shmif0 $BUS 674 675 export RUMP_SERVER=$SOCK_LOCAL 676 $atf_ifconfig shmif0 up 677 678 $atf_ifconfig vlan0 create 679 $atf_ifconfig vlan0 vlan 10 vlanif shmif0 680 $atf_ifconfig vlan0 up 681 $DEBUG && rump.ifconfig vlan0 682 683 $atf_ifconfig bridge0 create 684 # Adjust to the MTU of a vlan on a shmif 685 $atf_ifconfig bridge0 mtu 1496 686 $atf_ifconfig bridge0 up 687 # Test brconfig add 688 atf_check -s exit:0 $HIJACKING brconfig bridge0 add vlan0 689 $DEBUG && brconfig bridge0 690 # Test brconfig delete 691 atf_check -s exit:0 $HIJACKING brconfig bridge0 delete vlan0 692 693 atf_check -s exit:0 $HIJACKING brconfig bridge0 add vlan0 694 # Test vlan destruction with bridge 695 $atf_ifconfig vlan0 destroy 696 697 rump_server_destroy_ifaces 698} 699 700atf_test_case vlan_bridge cleanup 701vlan_bridge_head() 702{ 703 704 atf_set "descr" "tests of vlan interfaces with bridges (IPv4)" 705 atf_set "require.progs" "rump_server" 706} 707 708vlan_bridge_body() 709{ 710 711 rump_server_start $SOCK_LOCAL vlan bridge 712 vlan_bridge_body_common 713} 714 715vlan_bridge_cleanup() 716{ 717 718 $DEBUG && dump 719 cleanup 720} 721 722atf_test_case vlan_bridge6 cleanup 723vlan_bridge6_head() 724{ 725 726 atf_set "descr" "tests of vlan interfaces with bridges (IPv6)" 727 atf_set "require.progs" "rump_server" 728} 729 730vlan_bridge6_body() 731{ 732 733 rump_server_start $SOCK_LOCAL vlan netinet6 bridge 734 vlan_bridge_body_common 735} 736 737vlan_bridge6_cleanup() 738{ 739 740 $DEBUG && dump 741 cleanup 742} 743 744vlan_multicast_body_common() 745{ 746 local atf_ifconfig="atf_check -s exit:0 rump.ifconfig" 747 local af="inet" 748 local local0=$IP_LOCAL0 749 local local1=$IP_LOCAL1 750 local mcaddr=$IP_MCADDR0 751 local eth_mcaddr=$ETH_IP_MCADDR0 752 local prefix=24 753 local siocXmulti="$(atf_get_srcdir)/siocXmulti" 754 local atf_siocXmulti="atf_check -s exit:0 $HIJACKING $siocXmulti" 755 756 if [ x"$1" = x"inet6" ]; then 757 af="inet6" 758 prefix=64 759 local0=$IP6_LOCAL0 760 local1=$IP6_LOCAL1 761 mcaddr=$IP6_MCADDR0 762 eth_mcaddr=$ETH_IP6_MCADDR0 763 fi 764 765 export RUMP_SERVER=$SOCK_LOCAL 766 767 $atf_ifconfig shmif0 create 768 $atf_ifconfig shmif0 linkstr net0 up 769 $atf_ifconfig vlan0 create 770 $atf_ifconfig vlan0 vlan 10 vlanif shmif0 771 $atf_ifconfig vlan0 $af $local0/$prefix up 772 $atf_ifconfig vlan1 create 773 $atf_ifconfig vlan1 vlan 11 vlanif shmif0 774 $atf_ifconfig vlan1 $af $local1/$prefix up 775 $atf_ifconfig -w 10 776 777 # check the initial state 778 atf_check -s exit:0 -o not-match:"$eth_mcaddr" $HIJACKING ifmcstat 779 780 # add a multicast address 781 $atf_siocXmulti add vlan0 $mcaddr 782 atf_check -s exit:0 -o match:"$eth_mcaddr" $HIJACKING ifmcstat 783 784 # delete the address 785 $atf_siocXmulti del vlan0 $mcaddr 786 atf_check -s exit:0 -o not-match:"$eth_mcaddr" $HIJACKING ifmcstat 787 788 # delete a non-existing address 789 atf_check -s not-exit:0 -e match:"Invalid argument" \ 790 $HIJACKING $siocXmulti del vlan0 $mcaddr 791 792 # add an address to different interfaces 793 $atf_siocXmulti add vlan0 $mcaddr 794 $atf_siocXmulti add vlan1 $mcaddr 795 atf_check -s exit:0 -o match:"${eth_mcaddr} refcount 2" $HIJACKING ifmcstat 796 $atf_siocXmulti del vlan0 $mcaddr 797 798 # delete the address with invalid interface 799 atf_check -s not-exit:0 -e match:"Invalid argument" \ 800 $HIJACKING $siocXmulti del vlan0 $mcaddr 801 802 $atf_siocXmulti del vlan1 $mcaddr 803 804 # add and delete a same address more than once 805 $atf_siocXmulti add vlan0 $mcaddr 806 $atf_siocXmulti add vlan0 $mcaddr 807 $atf_siocXmulti add vlan0 $mcaddr 808 atf_check -s exit:0 -o match:"${eth_mcaddr} refcount 3" $HIJACKING ifmcstat 809 $atf_siocXmulti del vlan0 $mcaddr 810 $atf_siocXmulti del vlan0 $mcaddr 811 $atf_siocXmulti del vlan0 $mcaddr 812 atf_check -s exit:0 -o not-match:"$eth_mcaddr" $HIJACKING ifmcstat 813 814 # delete all address added to parent device when remove 815 # the config of parent interface 816 $atf_siocXmulti add vlan0 $mcaddr 817 $atf_siocXmulti add vlan0 $mcaddr 818 $atf_siocXmulti add vlan0 $mcaddr 819 $atf_ifconfig vlan0 -vlanif shmif0 820 atf_check -s exit:0 -o not-match:"$eth_mcaddr" $HIJACKING ifmcstat 821} 822 823atf_test_case vlan_multicast cleanup 824vlan_multicast_head() 825{ 826 atf_set "descr" "tests of multicast address adding and deleting" 827 atf_set "require.progs" "rump_server" 828} 829 830vlan_multicast_body() 831{ 832 rump_server_start $SOCK_LOCAL vlan 833 834 vlan_multicast_body_common inet 835} 836 837vlan_multicast_cleanup() 838{ 839 $DEBUG && dump 840 cleanup 841} 842 843atf_test_case vlan_multicast6 cleanup 844vlan_multicast6_head() 845{ 846 atf_set "descr" "tests of multicast address adding and deleting with IPv6" 847 atf_set "require.progs" "rump_server" 848} 849 850vlan_multicast6_body() 851{ 852 rump_server_start $SOCK_LOCAL vlan netinet6 853 854 vlan_multicast_body_common inet6 855} 856 857vlan_multicast6_cleanup() 858{ 859 $DEBUG && dump 860 cleanup 861} 862 863atf_init_test_cases() 864{ 865 866 atf_add_test_case vlan_create_destroy 867 atf_add_test_case vlan_basic 868 atf_add_test_case vlan_auto_follow_mtu 869 atf_add_test_case vlan_vlanid 870 atf_add_test_case vlan_configs 871 atf_add_test_case vlan_bridge 872 atf_add_test_case vlan_multicast 873 874 atf_add_test_case vlan_create_destroy6 875 atf_add_test_case vlan_basic6 876 atf_add_test_case vlan_auto_follow_mtu6 877 atf_add_test_case vlan_vlanid6 878 atf_add_test_case vlan_configs6 879 atf_add_test_case vlan_bridge6 880 atf_add_test_case vlan_multicast6 881} 882