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