Home | History | Annotate | Line # | Download | only in if_lagg
t_lagg.sh revision 1.5
      1 #	$NetBSD: t_lagg.sh,v 1.5 2021/11/02 01:57:16 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 	$DEBG && 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 
    232 	rump_server_start $SOCK_HOST0 lagg
    233 
    234 	export RUMP_SERVER=$SOCK_HOST0
    235 	$atf_ifconfig lagg0 create
    236 	rump_server_add_iface $SOCK_HOST0 shmif0 $BUS0
    237 	rump_server_add_iface $SOCK_HOST0 shmif1 $BUS1
    238 
    239 	maddr=$(get_macaddr $SOCK_HOST0 lagg0)
    240 	maddr0=$(get_macaddr $SOCK_HOST0 shmif0)
    241 	maddr1=$(get_macaddr $SOCK_HOST0 shmif1)
    242 
    243 	$atf_ifconfig lagg0 laggproto lacp
    244 
    245 	$atf_ifconfig lagg0 laggport shmif0
    246 	atf_check -s exit:0 -o match:$maddr0 rump.ifconfig lagg0
    247 
    248 	$atf_ifconfig lagg0 laggport shmif1
    249 	atf_check -s exit:0 -o match:$maddr0 rump.ifconfig lagg0
    250 	atf_check -s exit:0 -o match:$maddr0 rump.ifconfig shmif1
    251 
    252 	$atf_ifconfig lagg0 -laggport shmif0
    253 	atf_check -s exit:0 -o match:$maddr1 rump.ifconfig lagg0
    254 	atf_check -s exit:0 -o match:$maddr0 rump.ifconfig shmif0
    255 
    256 	$atf_ifconfig lagg0 laggport shmif0
    257 	atf_check -s exit:0 -o match:$maddr1 rump.ifconfig lagg0
    258 	atf_check -s exit:0 -o match:$maddr1 rump.ifconfig shmif0
    259 
    260 	$atf_ifconfig lagg0 -laggport shmif0
    261 	atf_check -s exit:0 -o match:$maddr0 rump.ifconfig shmif0
    262 
    263 	$atf_ifconfig lagg0 -laggport shmif1
    264 	atf_check -s exit:0 -o match:$maddr rump.ifconfig lagg0
    265 }
    266 
    267 lagg_macaddr_cleanup()
    268 {
    269 	$DEBUG && dump
    270 	cleanup
    271 }
    272 
    273 atf_test_case lagg_ipv6lla cleanup
    274 lagg_ipv6lla_head()
    275 {
    276 	atf_set "descr" "tests for a IPV6 LLA to assign to lagg(4)"
    277 	atf_set "require.progs" "rump_server"
    278 }
    279 
    280 lagg_ipv6lla_body()
    281 {
    282 	local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
    283 
    284 	rump_server_start $SOCK_HOST0 netinet6 lagg
    285 
    286 	export RUMP_SERVER=$SOCK_HOST0
    287 	$atf_ifconfig lagg0 create
    288 	rump_server_add_iface $SOCK_HOST0 shmif0 $BUS0
    289 	rump_server_add_iface $SOCK_HOST0 shmif1 $BUS1
    290 
    291 	$atf_ifconfig lagg0 laggproto lacp
    292 
    293 	$atf_ifconfig shmif0 up
    294 	atf_check -s exit:0 -o match:'inet6 fe80:' rump.ifconfig shmif0
    295 
    296 	$atf_ifconfig lagg0 laggproto lacp laggport shmif0
    297 	atf_check -s exit:0 -o not-match:'inet6 fe80:' rump.ifconfig shmif0
    298 
    299 	$atf_ifconfig lagg0 laggport shmif1
    300 	$atf_ifconfig shmif1 up
    301 	atf_check -s exit:0 -o not-match:'inet6 fe80:' rump.ifconfig shmif1
    302 
    303 	$atf_ifconfig lagg0 -laggport shmif0
    304 	atf_check -s exit:0 -o match:'inet6 fe80:' rump.ifconfig shmif0
    305 
    306 	$atf_ifconfig shmif1 down
    307 	$atf_ifconfig lagg0 -laggport shmif1
    308 	atf_check -s exit:0 -o not-match:'inet fe80:' rump.ifconfig shmif1
    309 }
    310 
    311 lagg_ipv6lla_cleanup()
    312 {
    313 	$DEBUG && dump
    314 	cleanup
    315 }
    316 
    317 atf_test_case lagg_lacp_basic cleanup
    318 lagg_lacp_basic_head()
    319 {
    320 
    321 	atf_set "descr" "tests for LACP basic functions"
    322 	atf_set "require.progs" "rump_server"
    323 }
    324 
    325 lagg_lacp_basic_body()
    326 {
    327 	local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
    328 
    329 	rump_server_start $SOCK_HOST0 lagg
    330 	rump_server_start $SOCK_HOST1 lagg
    331 	rump_server_start $SOCK_HOST2 lagg
    332 
    333 	export RUMP_SERVER=$SOCK_HOST0
    334 
    335 	# added running interface
    336 	$atf_ifconfig shmif0 create
    337 	$atf_ifconfig shmif0 linkstr $BUS0
    338 
    339 	$atf_ifconfig shmif1 create
    340 	$atf_ifconfig shmif1 linkstr $BUS1
    341 
    342 	$atf_ifconfig lagg0 create
    343 	$atf_ifconfig lagg0 laggproto lacp
    344 
    345 	$atf_ifconfig shmif0 up
    346 	$atf_ifconfig shmif1 up
    347 	$atf_ifconfig lagg0 up
    348 
    349 	$atf_ifconfig lagg0 laggport shmif0
    350 	$atf_ifconfig lagg0 laggport shmif1
    351 	$atf_ifconfig -w 10
    352 
    353 	$atf_ifconfig lagg0 -laggport shmif0
    354 	$atf_ifconfig lagg0 -laggport shmif1
    355 	$atf_ifconfig lagg0 down
    356 
    357 	# add the same interfaces again
    358 	$atf_ifconfig lagg0 up
    359 	$atf_ifconfig lagg0 laggport shmif0
    360 	$atf_ifconfig lagg0 laggport shmif1
    361 
    362 	# detach and re-attach protocol
    363 	$atf_ifconfig lagg0 laggproto none
    364 	$atf_ifconfig lagg0 laggproto lacp \
    365 	    laggport shmif0 laggport shmif1
    366 
    367 	$atf_ifconfig lagg0 -laggport shmif0 -laggport shmif1
    368 	$atf_ifconfig lagg0 destroy
    369 	$atf_ifconfig shmif0 destroy
    370 	$atf_ifconfig shmif1 destroy
    371 
    372 	# tests for a loopback condition
    373 	$atf_ifconfig shmif0 create
    374 	$atf_ifconfig shmif0 linkstr $BUS0
    375 	$atf_ifconfig shmif1 create
    376 	$atf_ifconfig shmif1 linkstr $BUS0
    377 	$atf_ifconfig lagg0 create
    378 	$atf_ifconfig lagg0 laggproto lacp \
    379 	    laggport shmif0 laggport shmif1
    380 	$atf_ifconfig shmif0 up
    381 	$atf_ifconfig shmif1 up
    382 	$atf_ifconfig lagg0 up
    383 
    384 	expected_inactive lagg0
    385 
    386 	$atf_ifconfig shmif0 down
    387 	$atf_ifconfig shmif0 destroy
    388 	$atf_ifconfig shmif1 down
    389 	$atf_ifconfig shmif1 destroy
    390 	$atf_ifconfig lagg0 down
    391 	$atf_ifconfig lagg0 destroy
    392 
    393 	export RUMP_SERVER=$SOCK_HOST0
    394 	$atf_ifconfig shmif0 create
    395 	$atf_ifconfig shmif0 linkstr $BUS0
    396 	$atf_ifconfig shmif0 up
    397 
    398 	$atf_ifconfig shmif1 create
    399 	$atf_ifconfig shmif1 linkstr $BUS1
    400 	$atf_ifconfig shmif1 up
    401 
    402 	$atf_ifconfig shmif2 create
    403 	$atf_ifconfig shmif2 linkstr $BUS2
    404 	$atf_ifconfig shmif2 up
    405 
    406 	$atf_ifconfig lagg0 create
    407 	$atf_ifconfig lagg0 laggproto lacp laggport shmif0 \
    408 	    laggport shmif1 laggport shmif2
    409 	$atf_ifconfig lagg0 up
    410 
    411 	export RUMP_SERVER=$SOCK_HOST1
    412 	$atf_ifconfig shmif0 create
    413 	$atf_ifconfig shmif0 linkstr $BUS0
    414 	$atf_ifconfig shmif0 up
    415 
    416 	$atf_ifconfig shmif1 create
    417 	$atf_ifconfig shmif1 linkstr $BUS1
    418 	$atf_ifconfig shmif1 up
    419 
    420 	$atf_ifconfig lagg0 create
    421 	$atf_ifconfig lagg0 laggproto lacp
    422 	$atf_ifconfig lagg1 create
    423 	$atf_ifconfig lagg1 laggproto lacp
    424 
    425 	$atf_ifconfig lagg0 laggport shmif0
    426 	$atf_ifconfig lagg0 up
    427 	wait_for_distributing lagg0 shmif0
    428 
    429 	$atf_ifconfig lagg1 laggport shmif1
    430 	$atf_ifconfig lagg1 up
    431 
    432 	export RUMP_SERVER=$SOCK_HOST2
    433 	$atf_ifconfig shmif0 create
    434 	$atf_ifconfig shmif0 linkstr $BUS2
    435 	$atf_ifconfig shmif0 up
    436 
    437 	$atf_ifconfig lagg0 create
    438 	$atf_ifconfig lagg0 laggproto lacp laggport shmif0
    439 	$atf_ifconfig lagg0 up
    440 
    441 	export RUMP_SERVER=$SOCK_HOST0
    442 	wait_for_distributing lagg0 shmif0
    443 	expected_inactive lagg0 shmif1
    444 	expected_inactive lagg0 shmif2
    445 }
    446 
    447 lagg_lacp_basic_cleanup()
    448 {
    449 
    450 	$DEBUG && dump
    451 	cleanup
    452 }
    453 
    454 lagg_lacp_ping()
    455 {
    456 	local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
    457 
    458 	local af=$1
    459 	local l2proto=$2
    460 	local atf_ping="atf_check -s exit:0 -o ignore rump.ping -c 1"
    461 	local ping=rump.ping
    462 	local rumplib=""
    463 	local pfx=24
    464 	local addr_host0=$IP4ADDR0
    465 	local addr_host1=$IP4ADDR1
    466 
    467 	case $af in
    468 	"inet")
    469 		# do nothing
    470 		;;
    471 	"inet6")
    472 		atf_ping="atf_check -s exit:0 -o ignore rump.ping6 -c 1"
    473 		rumplib="netinet6"
    474 		pfx=64
    475 		addr_host0=$IP6ADDR0
    476 		addr_host1=$IP6ADDR1
    477 		;;
    478 	esac
    479 
    480 	case $l2proto in
    481 	"ether")
    482 		iface0=shmif0
    483 		iface1=shmif1
    484 		iface2=shmif2
    485 		;;
    486 	"l2tp")
    487 		rumplib="$rumplib l2tp"
    488 		iface0=l2tp0
    489 		iface1=l2tp1
    490 		iface2=l2tp2
    491 		;;
    492 	esac
    493 
    494 	rump_server_start $SOCK_HOST0 lagg $rumplib
    495 	rump_server_start $SOCK_HOST1 lagg $rumplib
    496 
    497 	rump_server_add_iface $SOCK_HOST0 shmif0 $BUS0
    498 	rump_server_add_iface $SOCK_HOST0 shmif1 $BUS1
    499 	rump_server_add_iface $SOCK_HOST0 shmif2 $BUS2
    500 
    501 	rump_server_add_iface $SOCK_HOST1 shmif0 $BUS0
    502 	rump_server_add_iface $SOCK_HOST1 shmif1 $BUS1
    503 	rump_server_add_iface $SOCK_HOST1 shmif2 $BUS2
    504 
    505 	if [ x"$l2proto" = x"l2tp" ];then
    506 		setup_l2tp_ipv4tunnel
    507 	fi
    508 
    509 	export RUMP_SERVER=$SOCK_HOST0
    510 	$atf_ifconfig lagg0 create
    511 	$atf_ifconfig lagg0 laggproto lacp laggport $iface0
    512 	$atf_ifconfig lagg0 $af $addr_host0/$pfx
    513 	$atf_ifconfig $iface0 up
    514 	$atf_ifconfig lagg0 up
    515 
    516 	export RUMP_SERVER=$SOCK_HOST1
    517 	$atf_ifconfig lagg0 create
    518 	$atf_ifconfig lagg0 laggproto lacp laggport $iface0
    519 	$atf_ifconfig lagg0 $af $addr_host1/$pfx
    520 	$atf_ifconfig $iface0 up
    521 	$atf_ifconfig lagg0 up
    522 
    523 	export RUMP_SERVER=$SOCK_HOST0
    524 	wait_for_distributing lagg0
    525 	$atf_ifconfig -w 10
    526 
    527 	export RUMP_SERVER=$SOCK_HOST1
    528 	wait_for_distributing lagg0
    529 	$atf_ifconfig -w 10
    530 
    531 	$atf_ping $addr_host0
    532 
    533 	export RUMP_SERVER=$SOCK_HOST0
    534 	$atf_ifconfig $iface1 up
    535 	$atf_ifconfig lagg0 laggport $iface1 laggport $iface2
    536 	$atf_ifconfig $iface2 up
    537 
    538 	export RUMP_SERVER=$SOCK_HOST1
    539 	$atf_ifconfig $iface1 up
    540 	$atf_ifconfig lagg0 laggport $iface1 laggport $iface2
    541 	$atf_ifconfig $iface2 up
    542 
    543 	export RUMP_SERVER=$SOCK_HOST0
    544 	wait_for_distributing lagg0 $iface1
    545 	wait_for_distributing lagg0 $iface2
    546 
    547 	export RUMP_SERVER=$SOCK_HOST1
    548 	wait_for_distributing lagg0 $iface1
    549 	wait_for_distributing lagg0 $iface2
    550 
    551 	$atf_ping $addr_host0
    552 }
    553 
    554 atf_test_case lagg_lacp_ipv4 cleanup
    555 lagg_lacp_ipv4_head()
    556 {
    557 
    558 	atf_set "descr" "tests for IPv4 with LACP"
    559 	atf_set "require.progs" "rump_server"
    560 }
    561 
    562 lagg_lacp_ipv4_body()
    563 {
    564 
    565 	lagg_lacp_ping "inet" "ether"
    566 }
    567 
    568 lagg_lacp_ipv4_cleanup()
    569 {
    570 
    571 	$DEBUG && dump
    572 	cleanup
    573 }
    574 
    575 atf_test_case lagg_lacp_ipv6 cleanup
    576 lagg_lacp_ipv6_head()
    577 {
    578 
    579 	atf_set "descr" "tests for IPv6 with LACP"
    580 	atf_set "require.progs" "rump_server"
    581 }
    582 
    583 lagg_lacp_ipv6_body()
    584 {
    585 
    586 	lagg_lacp_ping "inet6" "ether"
    587 }
    588 
    589 lagg_lacp_ipv6_cleanup()
    590 {
    591 
    592 	$DEBUG && dump
    593 	cleanup
    594 }
    595 
    596 atf_test_case lagg_lacp_l2tp_ipv4 cleanup
    597 lagg_lacp_l2tp_ipv4_head()
    598 {
    599 
    600 	atf_set "descr" "tests for LACP over l2tp by using IPv4"
    601 	atf_set "require.progs" "rump_server"
    602 }
    603 
    604 lagg_lacp_l2tp_ipv4_body()
    605 {
    606 
    607 	lagg_lacp_ping "inet" "l2tp"
    608 }
    609 
    610 lagg_lacp_l2tp_ipv4_cleanup()
    611 {
    612 
    613 	$DEBUG && dump
    614 	cleanup
    615 }
    616 
    617 atf_test_case lagg_lacp_l2tp_ipv6 cleanup
    618 lagg_lacp_l2tp_ipv6_head()
    619 {
    620 
    621 	atf_set "descr" "tests for LACP over l2tp using IPv6"
    622 	atf_set "require.progs" "rump_server"
    623 }
    624 
    625 lagg_lacp_l2tp_ipv6_body()
    626 {
    627 
    628 	lagg_lacp_ping "inet6" "l2tp"
    629 }
    630 
    631 lagg_lacp_l2tp_ipv6_cleanup()
    632 {
    633 
    634 	$DEBUG && dump
    635 	cleanup
    636 }
    637 
    638 lagg_lacp_vlan()
    639 {
    640 	local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
    641 
    642 	local af=$1
    643 	local l2proto=$2
    644 	local atf_ping="atf_check -s exit:0 -o ignore rump.ping -c 1"
    645 	local rumplib="vlan"
    646 	local pfx=24
    647 	local vlan0_addr_host0=$IP4ADDR0
    648 	local host0addr0=$IP4ADDR0
    649 	local host1addr0=$IP4ADDR1
    650 	local host0addr1=$IP4ADDR2
    651 	local host1addr1=$IP4ADDR3
    652 
    653 	case $af in
    654 	"inet")
    655 		# do nothing
    656 		;;
    657 	"inet6")
    658 		atf_ping="atf_check -s exit:0 -o ignore rump.ping6 -c 1"
    659 		rumplib="$rumplib netinet6"
    660 		pfx=64
    661 		host0addr0=$IP6ADDR0
    662 		host1addr0=$IP6ADDR1
    663 		host0addr1=$IP6ADDR2
    664 		host1addr1=$IP6ADDR3
    665 		;;
    666 	esac
    667 
    668 	case $l2proto in
    669 	"ether")
    670 		iface0=shmif0
    671 		iface1=shmif1
    672 		iface2=shmif2
    673 		;;
    674 	"l2tp")
    675 		rumplib="$rumplib l2tp"
    676 		iface0=l2tp0
    677 		iface1=l2tp1
    678 		iface2=l2tp2
    679 	esac
    680 
    681 	rump_server_start $SOCK_HOST0 lagg $rumplib
    682 	rump_server_start $SOCK_HOST1 lagg $rumplib
    683 
    684 	rump_server_add_iface $SOCK_HOST0 shmif0 $BUS0
    685 	rump_server_add_iface $SOCK_HOST0 shmif1 $BUS1
    686 	rump_server_add_iface $SOCK_HOST0 shmif2 $BUS2
    687 
    688 	rump_server_add_iface $SOCK_HOST1 shmif0 $BUS0
    689 	rump_server_add_iface $SOCK_HOST1 shmif1 $BUS1
    690 	rump_server_add_iface $SOCK_HOST1 shmif2 $BUS2
    691 
    692 	if [ x"$l2proto" = x"l2tp" ]; then
    693 		setup_l2tp_ipv4tunnel
    694 	fi
    695 
    696 	export RUMP_SERVER=$SOCK_HOST0
    697 	$atf_ifconfig lagg0 create
    698 	$atf_ifconfig lagg0 laggproto lacp laggport $iface0
    699 	$atf_ifconfig $iface0 up
    700 	$atf_ifconfig lagg0 up
    701 
    702 	export RUMP_SERVER=$SOCK_HOST1
    703 	$atf_ifconfig lagg0 create
    704 	$atf_ifconfig lagg0 laggproto lacp laggport $iface0
    705 	$atf_ifconfig $iface0 up
    706 	$atf_ifconfig lagg0 up
    707 
    708 	export RUMP_SERVER=$SOCK_HOST0
    709 	wait_for_distributing lagg0
    710 
    711 	$atf_ifconfig vlan0 create
    712 	$atf_ifconfig vlan0 vlan 10 vlanif lagg0
    713 	$atf_ifconfig vlan0 $af $host0addr0/$pfx
    714 	$atf_ifconfig vlan0 up
    715 
    716 	$atf_ifconfig vlan1 create
    717 	$atf_ifconfig vlan1 vlan 11 vlanif lagg0
    718 	$atf_ifconfig vlan1 $af $host0addr1/$pfx
    719 	$atf_ifconfig vlan1 up
    720 
    721 	export RUMP_SERVER=$SOCK_HOST1
    722 	$atf_ifconfig vlan0 create
    723 	$atf_ifconfig vlan0 vlan 10 vlanif lagg0
    724 	$atf_ifconfig vlan0 $af $host1addr0/$pfx
    725 	$atf_ifconfig vlan0 up
    726 
    727 	$atf_ifconfig vlan1 create
    728 	$atf_ifconfig vlan1 vlan 11 vlanif lagg0
    729 	$atf_ifconfig vlan1 $af $host1addr1/$pfx
    730 	$atf_ifconfig vlan1 up
    731 
    732 	export RUMP_SERVER=$SOCK_HOST0
    733 	$atf_ifconfig -w 10
    734 	export RUMP_SERVER=$SOCK_HOST1
    735 	$atf_ifconfig -w 10
    736 
    737 	export RUMP_SERVER=$SOCK_HOST0
    738 	$atf_ping $host1addr0
    739 	$atf_ping $host1addr1
    740 
    741 	$atf_ifconfig lagg0 laggport $iface1
    742 	$atf_ifconfig $iface1 up
    743 
    744 	export RUMP_SERVER=$SOCK_HOST1
    745 	$atf_ifconfig lagg0 laggport $iface1
    746 	$atf_ifconfig $iface1 up
    747 
    748 	export RUMP_SERVER=$SOCK_HOST0
    749 	wait_for_distributing lagg0 $iface1
    750 
    751 	export RUMP_SERVER=$SOCK_HOST1
    752 	wait_for_distributing lagg0 $iface1
    753 
    754 	$atf_ping $host0addr0
    755 	$atf_ping $host0addr1
    756 }
    757 
    758 atf_test_case lagg_lacp_vlan_ipv4 cleanup
    759 lagg_lacp_vlan_ipv4_head()
    760 {
    761 
    762 	atf_set "descr" "tests for IPv4 VLAN frames over LACP LAG"
    763 	atf_set "require.progs" "rump_server"
    764 }
    765 
    766 lagg_lacp_vlan_ipv4_body()
    767 {
    768 
    769 	lagg_lacp_vlan "inet" "ether"
    770 }
    771 
    772 lagg_lacp_vlan_ipv4_cleanup()
    773 {
    774 	$DEBUG && dump
    775 	cleanup
    776 }
    777 
    778 atf_test_case lagg_lacp_vlan_ipv6 cleanup
    779 lagg_lacp_vlan_ipv6_head()
    780 {
    781 
    782 	atf_set "descr" "tests for IPv6 VLAN frames over LACP LAG"
    783 	atf_set "require.progs" "rump_server"
    784 }
    785 
    786 lagg_lacp_vlan_ipv6_body()
    787 {
    788 
    789 	lagg_lacp_vlan "inet6" "ether"
    790 }
    791 
    792 lagg_lacp_vlan_ipv6_cleanup()
    793 {
    794 	$DEBUG && dump
    795 	cleanup
    796 }
    797 
    798 atf_test_case lagg_lacp_vlanl2tp_ipv4 cleanup
    799 lagg_lacp_vlanl2tp_ipv4_head()
    800 {
    801 
    802 	atf_set "descr" "tests for IPv4 VLAN frames over LACP L2TP LAG"
    803 	atf_set "require.progs" "rump_server"
    804 }
    805 
    806 lagg_lacp_vlanl2tp_ipv4_body()
    807 {
    808 
    809 	lagg_lacp_vlan "inet" "l2tp"
    810 }
    811 
    812 lagg_lacp_vlanl2tp_ipv4_cleanup()
    813 {
    814 
    815 	$DEBUG && dump
    816 	cleanup
    817 }
    818 
    819 atf_test_case lagg_lacp_vlanl2tp_ipv6 cleanup
    820 lagg_lacp_vlanl2tp_ipv6_head()
    821 {
    822 
    823 	atf_set "descr" "tests for IPv6 VLAN frames over LACP L2TP LAG"
    824 	atf_set "require.progs" "rump_server"
    825 }
    826 
    827 lagg_lacp_vlanl2tp_ipv6_body()
    828 {
    829 
    830 	lagg_lacp_vlan "inet6" "l2tp"
    831 }
    832 
    833 lagg_lacp_vlanl2tp_ipv6_cleanup()
    834 {
    835 
    836 	$DEBUG && dump
    837 	cleanup
    838 }
    839 
    840 atf_test_case lagg_lacp_portpri cleanup
    841 lagg_lacp_portpri_head()
    842 {
    843 
    844 	atf_set "descr" "tests for LACP port priority"
    845 	atf_set "require.progs" "rump_server"
    846 }
    847 
    848 lagg_lacp_portpri_body()
    849 {
    850 	local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
    851 
    852 	rump_server_start $SOCK_HOST0 lagg
    853 	rump_server_start $SOCK_HOST1 lagg
    854 
    855 	rump_server_add_iface $SOCK_HOST0 shmif0 $BUS0
    856 	rump_server_add_iface $SOCK_HOST0 shmif1 $BUS1
    857 	rump_server_add_iface $SOCK_HOST0 shmif2 $BUS2
    858 
    859 	rump_server_add_iface $SOCK_HOST1 shmif0 $BUS0
    860 	rump_server_add_iface $SOCK_HOST1 shmif1 $BUS1
    861 	rump_server_add_iface $SOCK_HOST1 shmif2 $BUS2
    862 
    863 	export RUMP_SERVER=$SOCK_HOST0
    864 	$atf_ifconfig lagg0 create
    865 	$atf_ifconfig lagg0 laggproto lacp
    866 	$atf_ifconfig lagg0 lagglacp maxports 2
    867 
    868 	$atf_ifconfig shmif0 up
    869 	$atf_ifconfig shmif1 up
    870 	$atf_ifconfig shmif2 up
    871 
    872 	$atf_ifconfig lagg0 laggport shmif0 pri 1000
    873 	$atf_ifconfig lagg0 laggport shmif1 pri 2000
    874 	$atf_ifconfig lagg0 laggport shmif2 pri 3000
    875 	$atf_ifconfig lagg0 up
    876 
    877 	atf_check -s exit:0 -o match:'shmif0 pri=1000' rump.ifconfig lagg0
    878 	atf_check -s exit:0 -o match:'shmif1 pri=2000' rump.ifconfig lagg0
    879 	atf_check -s exit:0 -o match:'shmif2 pri=3000' rump.ifconfig lagg0
    880 
    881 	export RUMP_SERVER=$SOCK_HOST1
    882 	$atf_ifconfig lagg0 create
    883 	$atf_ifconfig lagg0 laggproto lacp
    884 
    885 	$atf_ifconfig shmif0 up
    886 	$atf_ifconfig shmif1 up
    887 	$atf_ifconfig shmif2 up
    888 
    889 	$atf_ifconfig lagg0 laggport shmif0 pri 300
    890 	$atf_ifconfig lagg0 laggport shmif1 pri 200
    891 	$atf_ifconfig lagg0 laggport shmif2 pri 100
    892 	$atf_ifconfig lagg0 up
    893 
    894 	atf_check -s exit:0 -o match:'shmif0 pri=300' rump.ifconfig lagg0
    895 	atf_check -s exit:0 -o match:'shmif1 pri=200' rump.ifconfig lagg0
    896 	atf_check -s exit:0 -o match:'shmif2 pri=100' rump.ifconfig lagg0
    897 
    898 	export RUMP_SERVER=$SOCK_HOST0
    899 	wait_for_distributing lagg0 shmif0
    900 	wait_for_distributing lagg0 shmif1
    901 	wait_state "STANDBY" lagg0 shmif2
    902 
    903 	$atf_ifconfig shmif0 down
    904 	wait_for_distributing lagg0 shmif2
    905 
    906 	$atf_ifconfig shmif0 up
    907 	wait_for_distributing lagg0 shmif0
    908 
    909 	$atf_ifconfig lagg0 laggportpri shmif0 5000
    910 	$atf_ifconfig lagg0 laggportpri shmif1 5000
    911 	$atf_ifconfig lagg0 laggportpri shmif2 5000
    912 
    913 	atf_check -s exit:0 -o match:'shmif0 pri=5000' rump.ifconfig lagg0
    914 	atf_check -s exit:0 -o match:'shmif1 pri=5000' rump.ifconfig lagg0
    915 	atf_check -s exit:0 -o match:'shmif2 pri=5000' rump.ifconfig lagg0
    916 
    917 	wait_state "STANDBY" lagg0 shmif0
    918 	wait_for_distributing lagg0 shmif1
    919 	wait_for_distributing lagg0 shmif2
    920 }
    921 
    922 lagg_lacp_portpri_cleanup()
    923 {
    924 
    925 	$DEBUG && dump
    926 	cleanup
    927 }
    928 
    929 lagg_failover()
    930 {
    931 	local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
    932 
    933 	local af=$1
    934 	local l2proto=$2
    935 	local ping="rump.ping -c 1"
    936 	local rumplib=""
    937 	local pfx=24
    938 	local addr_host0=$IP4ADDR0
    939 	local addr_host1=$IP4ADDR1
    940 
    941 	case $af in
    942 	"inet")
    943 		# do nothing
    944 		;;
    945 	"inet6")
    946 		ping="rump.ping6 -c 1"
    947 		rumplib="netinet6"
    948 		pfx=64
    949 		addr_host0=$IP6ADDR0
    950 		addr_host1=$IP6ADDR1
    951 		;;
    952 	esac
    953 
    954 	case $l2proto in
    955 	"ether")
    956 		iface0="shmif0"
    957 		iface1="shmif1"
    958 		iface2="shmif2"
    959 		;;
    960 	"l2tp")
    961 		rumplib="$rumplib l2tp"
    962 		iface0="l2tp0"
    963 		iface1="l2tp1"
    964 		iface2="l2tp2"
    965 		;;
    966 	esac
    967 
    968 	local atf_ping="atf_check -s exit:0 -o ignore ${ping}"
    969 
    970 	rump_server_start $SOCK_HOST0 lagg $rumplib
    971 	rump_server_start $SOCK_HOST1 lagg $rumplib
    972 
    973 	rump_server_add_iface $SOCK_HOST0 shmif0 $BUS0
    974 	rump_server_add_iface $SOCK_HOST0 shmif1 $BUS1
    975 	rump_server_add_iface $SOCK_HOST0 shmif2 $BUS2
    976 
    977 	rump_server_add_iface $SOCK_HOST1 shmif0 $BUS0
    978 	rump_server_add_iface $SOCK_HOST1 shmif1 $BUS1
    979 	rump_server_add_iface $SOCK_HOST1 shmif2 $BUS2
    980 
    981 	if [ x"$l2proto" = x"l2tp" ]; then
    982 		setup_l2tp_ipv4tunnel
    983 	fi
    984 
    985 	export RUMP_SERVER=$SOCK_HOST0
    986 	$atf_ifconfig lagg0 create
    987 	$atf_ifconfig lagg0 laggproto failover
    988 
    989 	$atf_ifconfig lagg0 laggport $iface0 pri 1000
    990 	$atf_ifconfig lagg0 laggport $iface1 pri 2000
    991 	$atf_ifconfig lagg0 laggport $iface2 pri 3000
    992 	$atf_ifconfig lagg0 $af $addr_host0/$pfx
    993 
    994 	export RUMP_SERVER=$SOCK_HOST1
    995 	$atf_ifconfig lagg0 create
    996 	$atf_ifconfig lagg0 laggproto failover
    997 
    998 	$atf_ifconfig lagg0 laggport $iface0 pri 1000
    999 	$atf_ifconfig lagg0 laggport $iface1 pri 3000
   1000 	$atf_ifconfig lagg0 laggport $iface2 pri 2000
   1001 	$atf_ifconfig lagg0 $af $addr_host1/$pfx
   1002 
   1003 	export RUMP_SERVER=$SOCK_HOST0
   1004 	$atf_ifconfig $iface0 up
   1005 	$atf_ifconfig $iface1 up
   1006 	$atf_ifconfig $iface2 up
   1007 	$atf_ifconfig lagg0 up
   1008 
   1009 	export RUMP_SERVER=$SOCK_HOST1
   1010 	$atf_ifconfig $iface0 up
   1011 	$atf_ifconfig $iface1 up
   1012 	$atf_ifconfig $iface2 up
   1013 	$atf_ifconfig lagg0 up
   1014 
   1015 	export RUMP_SERVER=$SOCK_HOST0
   1016 	$atf_ifconfig -w 10
   1017 	wait_for_distributing lagg0 $iface0
   1018 	wait_state "COLLECTING" lagg0 $iface0
   1019 	wait_state "COLLECTING" lagg0 $iface1
   1020 	wait_state "COLLECTING" lagg0 $iface2
   1021 
   1022 	export RUMP_SERVER=$SOCK_HOST1
   1023 	$atf_ifconfig -w 10
   1024 	wait_for_distributing lagg0 $iface0
   1025 	wait_state "COLLECTING" lagg0 $iface0
   1026 	wait_state "COLLECTING" lagg0 $iface1
   1027 	wait_state "COLLECTING" lagg0 $iface2
   1028 
   1029 	export RUMP_SERVER=$SOCK_HOST0
   1030 	$atf_ping $addr_host1
   1031 
   1032 	$atf_ifconfig $iface0 down
   1033 	wait_for_distributing lagg0 $iface1
   1034 	wait_state "COLLECTING" lagg0 $iface1
   1035 	wait_state "COLLECTING" lagg0 $iface2
   1036 
   1037 	export RUMP_SERVER=$SOCK_HOST1
   1038 	$atf_ifconfig $iface0 down
   1039 	wait_for_distributing lagg0 $iface2
   1040 	wait_state "COLLECTING" lagg0 $iface2
   1041 	wait_state "COLLECTING" lagg0 $iface1
   1042 
   1043 	export RUMP_SERVER=$SOCK_HOST0
   1044 	$atf_ping $addr_host1
   1045 
   1046 	$atf_ifconfig lagg0 laggfailover -rx-all
   1047 	atf_check -s exit:0 -o not-match:'$iface2.+COLLECTING' rump.ifconfig lagg0
   1048 
   1049 	export RUMP_SERVER=$SOCK_HOST1
   1050 	$atf_ifconfig lagg0 laggfailover -rx-all
   1051 	atf_check -s exit:0 -o not-match:'$iface1.+COLLECTING' rump.ifconfig lagg0
   1052 
   1053 	export RUMP_SERVER=$SOCK_HOST0
   1054 	atf_check -s not-exit:0 -o ignore -e ignore $ping -c 1 $addr_host1
   1055 }
   1056 
   1057 atf_test_case lagg_failover_ipv4 cleanup
   1058 lagg_failover_ipv4_head()
   1059 {
   1060 
   1061 	atf_set "descr" "tests for failover using IPv4"
   1062 	atf_set "require.progs" "rump_server"
   1063 }
   1064 
   1065 lagg_failover_ipv4_body()
   1066 {
   1067 
   1068 	lagg_failover "inet" "ether"
   1069 }
   1070 
   1071 lagg_failover_ipv4_cleanup()
   1072 {
   1073 
   1074 	$DEBUG && dump
   1075 	cleanup
   1076 }
   1077 
   1078 atf_test_case lagg_failover_ipv6 cleanup
   1079 lagg_failover_ipv6_head()
   1080 {
   1081 
   1082 	atf_set "descr" "tests for failover using IPv6"
   1083 	atf_set "require.progs" "rump_server"
   1084 }
   1085 
   1086 lagg_failover_ipv6_body()
   1087 {
   1088 
   1089 	lagg_failover "inet6" "ether"
   1090 }
   1091 
   1092 lagg_failover_ipv6_cleanup()
   1093 {
   1094 
   1095 	$DEBUG && dump
   1096 	cleanup
   1097 }
   1098 
   1099 atf_test_case lagg_failover_l2tp_ipv4 cleanup
   1100 lagg_failover_l2tp_ipv4_head()
   1101 {
   1102 
   1103 	atf_set "descr" "tests for failover over l2tp using IPv4"
   1104 	atf_set "require.progs" "rump_server"
   1105 }
   1106 
   1107 lagg_failover_l2tp_ipv4_body()
   1108 {
   1109 
   1110 	lagg_failover "inet" "l2tp"
   1111 }
   1112 
   1113 lagg_failover_l2tp_ipv4_cleanup()
   1114 {
   1115 	$DEBUG && dump
   1116 	cleanup
   1117 }
   1118 
   1119 atf_test_case lagg_failover_l2tp_ipv6 cleanup
   1120 lagg_failover_l2tp_ipv6_head()
   1121 {
   1122 
   1123 	atf_set "descr" "tests for failover over l2tp using IPv6"
   1124 	atf_set "require.progs" "rump_server"
   1125 }
   1126 
   1127 lagg_failover_l2tp_ipv6_body()
   1128 {
   1129 
   1130 	lagg_failover "inet6" "l2tp"
   1131 }
   1132 
   1133 lagg_failover_l2tp_ipv6_cleanup()
   1134 {
   1135 	$DEBUG && dump
   1136 	cleanup
   1137 }
   1138 
   1139 lagg_loadbalance()
   1140 {
   1141 	local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
   1142 
   1143 	local af=$1
   1144 	local l2proto=$2
   1145 	local ping="rump.ping -c 1"
   1146 	local rumplib=""
   1147 	local pfx=24
   1148 	local addr_host0=$IP4ADDR0
   1149 	local addr_host1=$IP4ADDR1
   1150 
   1151 	case $af in
   1152 	"inet")
   1153 		# do nothing
   1154 		;;
   1155 	"inet6")
   1156 		ping="rump.ping6 -c 1"
   1157 		rumplib="netinet6"
   1158 		pfx=64
   1159 		addr_host0=$IP6ADDR0
   1160 		addr_host1=$IP6ADDR1
   1161 		;;
   1162 	esac
   1163 
   1164 	case $l2proto in
   1165 	"ether")
   1166 		iface0=shmif0
   1167 		iface1=shmif1
   1168 		iface2=shmif2
   1169 		;;
   1170 	"l2tp")
   1171 		rumplib="$rumplib l2tp"
   1172 		iface0=l2tp0
   1173 		iface1=l2tp1
   1174 		iface2=l2tp2
   1175 		;;
   1176 	esac
   1177 
   1178 	local atf_ping="atf_check -s exit:0 -o ignore ${ping}"
   1179 
   1180 	rump_server_start $SOCK_HOST0 lagg $rumplib
   1181 	rump_server_start $SOCK_HOST1 lagg $rumplib
   1182 
   1183 	rump_server_add_iface $SOCK_HOST0 shmif0 $BUS0
   1184 	rump_server_add_iface $SOCK_HOST0 shmif1 $BUS1
   1185 	rump_server_add_iface $SOCK_HOST0 shmif2 $BUS2
   1186 
   1187 	rump_server_add_iface $SOCK_HOST1 shmif0 $BUS0
   1188 	rump_server_add_iface $SOCK_HOST1 shmif1 $BUS1
   1189 	rump_server_add_iface $SOCK_HOST1 shmif2 $BUS2
   1190 
   1191 	if [ x"$l2proto" = x"l2tp" ]; then
   1192 		setup_l2tp_ipv4tunnel
   1193 	fi
   1194 
   1195 	export RUMP_SERVER=$SOCK_HOST0
   1196 	$atf_ifconfig lagg0 create
   1197 	$atf_ifconfig lagg0 laggproto loadbalance
   1198 
   1199 	$atf_ifconfig lagg0 laggport $iface0 pri 1000
   1200 	$atf_ifconfig lagg0 laggport $iface1 pri 2000
   1201 	$atf_ifconfig lagg0 laggport $iface2 pri 3000
   1202 	$atf_ifconfig lagg0 $af $addr_host0/$pfx
   1203 
   1204 	export RUMP_SERVER=$SOCK_HOST1
   1205 	$atf_ifconfig lagg0 create
   1206 	$atf_ifconfig lagg0 laggproto loadbalance
   1207 
   1208 	$atf_ifconfig lagg0 laggport $iface0 pri 1000
   1209 	$atf_ifconfig lagg0 laggport $iface1 pri 3000
   1210 	$atf_ifconfig lagg0 laggport $iface2 pri 2000
   1211 	$atf_ifconfig lagg0 $af $addr_host1/$pfx
   1212 
   1213 	export RUMP_SERVER=$SOCK_HOST0
   1214 	$atf_ifconfig $iface0 up
   1215 	$atf_ifconfig $iface1 up
   1216 	$atf_ifconfig $iface2 up
   1217 	$atf_ifconfig lagg0 up
   1218 
   1219 	export RUMP_SERVER=$SOCK_HOST1
   1220 	$atf_ifconfig $iface0 up
   1221 	$atf_ifconfig $iface1 up
   1222 	$atf_ifconfig $iface2 up
   1223 	$atf_ifconfig lagg0 up
   1224 
   1225 	export RUMP_SERVER=$SOCK_HOST0
   1226 	$atf_ifconfig -w 10
   1227 	wait_for_distributing lagg0 $iface0
   1228 	wait_state "COLLECTING" lagg0 $iface0
   1229 	wait_state "COLLECTING" lagg0 $iface1
   1230 	wait_state "COLLECTING" lagg0 $iface2
   1231 
   1232 	export RUMP_SERVER=$SOCK_HOST1
   1233 	$atf_ifconfig -w 10
   1234 	wait_state "COLLECTING,DISTRIBUTING" lagg0 $iface0
   1235 	wait_state "COLLECTING,DISTRIBUTING" lagg0 $iface1
   1236 	wait_state "COLLECTING,DISTRIBUTING" lagg0 $iface2
   1237 
   1238 	export RUMP_SERVER=$SOCK_HOST0
   1239 	$atf_ping $addr_host1
   1240 
   1241 	$atf_ifconfig $iface0 down
   1242 	wait_state "COLLECTING,DISTRIBUTING" lagg0 $iface1
   1243 	wait_state "COLLECTING,DISTRIBUTING" lagg0 $iface2
   1244 
   1245 	export RUMP_SERVER=$SOCK_HOST1
   1246 	$atf_ifconfig $iface0 down
   1247 	wait_state "COLLECTING,DISTRIBUTING" lagg0 $iface1
   1248 	wait_state "COLLECTING,DISTRIBUTING" lagg0 $iface2
   1249 
   1250 	export RUMP_SERVER=$SOCK_HOST0
   1251 	$atf_ping $addr_host1
   1252 }
   1253 
   1254 atf_test_case lagg_loadbalance_ipv4 cleanup
   1255 lagg_loadbalance_ipv4_head()
   1256 {
   1257 
   1258 	atf_set "descr" "tests for loadbalance using IPv4"
   1259 	atf_set "require.progs" "rump_server"
   1260 }
   1261 
   1262 lagg_loadbalance_ipv4_body()
   1263 {
   1264 
   1265 	lagg_loadbalance "inet" "ether"
   1266 }
   1267 
   1268 lagg_loadbalance_ipv4_cleanup()
   1269 {
   1270 
   1271 	$DEBUG && dump
   1272 	cleanup
   1273 }
   1274 
   1275 atf_test_case lagg_loadbalance_ipv6 cleanup
   1276 lagg_loadbalance_ipv6_head()
   1277 {
   1278 
   1279 	atf_set "descr" "tests for loadbalance using IPv6"
   1280 	atf_set "require.progs" "rump_server"
   1281 }
   1282 
   1283 lagg_loadbalance_ipv6_body()
   1284 {
   1285 
   1286 	lagg_loadbalance "inet6" "ether"
   1287 }
   1288 
   1289 lagg_loadbalance_ipv6_cleanup()
   1290 {
   1291 
   1292 	$DEBUG && dump
   1293 	cleanup
   1294 }
   1295 
   1296 atf_test_case lagg_loadbalance_l2tp_ipv4 cleanup
   1297 lagg_loadbalance_l2tp_ipv4_head()
   1298 {
   1299 
   1300 	atf_set "descr" "tests for loadbalance over l2tp using IPv4"
   1301 	atf_set "require.progs" "rump_server"
   1302 }
   1303 
   1304 lagg_loadbalance_l2tp_ipv4_body()
   1305 {
   1306 
   1307 	lagg_loadbalance "inet" "l2tp"
   1308 }
   1309 
   1310 lagg_loadbalance_l2tp_ipv4_cleanup()
   1311 {
   1312 
   1313 	$DEBUG && dump
   1314 	cleanup
   1315 }
   1316 
   1317 atf_test_case lagg_loadbalance_l2tp_ipv6 cleanup
   1318 lagg_loadbalance_l2tp_ipv4_head()
   1319 {
   1320 
   1321 	atf_set "descr" "tests for loadbalance over l2tp using IPv6"
   1322 	atf_set "require.progs" "rump_server"
   1323 }
   1324 
   1325 lagg_loadbalance_l2tp_ipv6_body()
   1326 {
   1327 
   1328 	lagg_loadbalance "inet6" "l2tp"
   1329 }
   1330 
   1331 lagg_loadbalance_l2tp_ipv6_cleanup()
   1332 {
   1333 
   1334 	$DEBUG && dump
   1335 	cleanup
   1336 }
   1337 
   1338 atf_init_test_cases()
   1339 {
   1340 
   1341 	atf_add_test_case lagg_ifconfig
   1342 	atf_add_test_case lagg_macaddr
   1343 	atf_add_test_case lagg_ipv6lla
   1344 	atf_add_test_case lagg_lacp_basic
   1345 	atf_add_test_case lagg_lacp_ipv4
   1346 	atf_add_test_case lagg_lacp_ipv6
   1347 	atf_add_test_case lagg_lacp_l2tp_ipv4
   1348 	atf_add_test_case lagg_lacp_l2tp_ipv6
   1349 	atf_add_test_case lagg_lacp_vlan_ipv4
   1350 	atf_add_test_case lagg_lacp_vlan_ipv6
   1351 	atf_add_test_case lagg_lacp_vlanl2tp_ipv4
   1352 	atf_add_test_case lagg_lacp_vlanl2tp_ipv6
   1353 	atf_add_test_case lagg_lacp_portpri
   1354 	atf_add_test_case lagg_failover_ipv4
   1355 	atf_add_test_case lagg_failover_ipv6
   1356 	atf_add_test_case lagg_failover_l2tp_ipv4
   1357 	atf_add_test_case lagg_failover_l2tp_ipv6
   1358 	atf_add_test_case lagg_loadbalance_ipv4
   1359 	atf_add_test_case lagg_loadbalance_ipv6
   1360 	atf_add_test_case lagg_loadbalance_l2tp_ipv4
   1361 	atf_add_test_case lagg_loadbalance_l2tp_ipv6
   1362 }
   1363