1#!/usr/bin/env atf-sh 2#- 3# SPDX-License-Identifier: BSD-2-Clause 4# 5# Copyright (c) 2020 Alexander V. Chernikov 6# 7# Redistribution and use in source and binary forms, with or without 8# modification, are permitted provided that the following conditions 9# are met: 10# 1. Redistributions of source code must retain the above copyright 11# notice, this list of conditions and the following disclaimer. 12# 2. Redistributions in binary form must reproduce the above copyright 13# notice, this list of conditions and the following disclaimer in the 14# documentation and/or other materials provided with the distribution. 15# 16# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26# SUCH DAMAGE. 27# 28# $FreeBSD$ 29# 30 31. $(atf_get_srcdir)/../common/vnet.subr 32 33atf_test_case "output6_tcp_setup_success" "cleanup" 34output6_tcp_setup_success_head() 35{ 36 37 atf_set descr 'Test valid IPv6 TCP output' 38 atf_set require.user root 39} 40 41output6_tcp_setup_success_body() 42{ 43 44 vnet_init 45 46 net_src="2001:db8:0:0:1::" 47 net_dst="2001:db8:0:0:1::" 48 ip_src="${net_src}1" 49 ip_dst=${net_dst}4242 50 plen=64 51 text="testtesttst" 52 port=4242 53 54 script_name=`dirname $0`/../common/net_receiver.py 55 script_name=`realpath ${script_name}` 56 jname="v6t-output6_tcp_setup_success" 57 58 epair=$(vnet_mkepair) 59 60 vnet_mkjail ${jname}a ${epair}a 61 jexec ${jname}a ifconfig ${epair}a up 62 jexec ${jname}a ifconfig ${epair}a inet6 ${ip_src}/${plen} 63 64 vnet_mkjail ${jname}b ${epair}b 65 jexec ${jname}b ifconfig ${epair}b up 66 67 jexec ${jname}b ifconfig ${epair}b inet6 ${ip_dst}/${plen} 68 69 # wait for DAD to complete 70 while [ `jexec ${jname}b ifconfig ${epair}b inet6 | grep -c tentative` != "0" ]; do 71 sleep 0.1 72 done 73 while [ `jexec ${jname}a ifconfig ${epair}a inet6 | grep -c tentative` != "0" ]; do 74 sleep 0.1 75 done 76 77 # run listener 78 args="--family inet6 --ports ${port} --match_str ${text}" 79 echo jexec ${jname}b ${script_name} ${args} 80 jexec ${jname}b ${script_name} --test_name "test_listen_tcp" ${args} & 81 cmd_pid=$! 82 83 # wait for the script init 84 counter=0 85 while [ `jexec ${jname}b sockstat -6qlp ${port} | wc -l` != "1" ]; do 86 sleep 0.01 87 counter=$((counter+1)) 88 if [ ${counter} -ge 50 ]; then break; fi 89 done 90 if [ `jexec ${jname}b sockstat -6qlp ${port} | wc -l` != "1" ]; then 91 echo "App setup failed" 92 exit 1 93 fi 94 95 # run sender 96 echo -n "${text}" | jexec ${jname}a nc -N ${ip_dst} ${port} 97 exit_code=$? 98 if [ $exit_code -ne 0 ]; then atf_fail "sender exit code $exit_code" ; fi 99 100 wait ${cmd_pid} 101 exit_code=$? 102 if [ $exit_code -ne 0 ]; then atf_fail "receiver exit code $exit_code" ; fi 103} 104 105output6_tcp_setup_success_cleanup() 106{ 107 vnet_cleanup 108} 109 110 111atf_test_case "output6_udp_setup_success" "cleanup" 112output6_udp_setup_success_head() 113{ 114 115 atf_set descr 'Test valid IPv6 UDP output' 116 atf_set require.user root 117} 118 119output6_udp_setup_success_body() 120{ 121 122 vnet_init 123 124 net_src="2001:db8:0:0:1::" 125 net_dst="2001:db8:0:0:1::" 126 ip_src="${net_src}1" 127 ip_dst=${net_dst}4242 128 plen=64 129 text="testtesttst" 130 port=4242 131 132 script_name=`dirname $0`/../common/net_receiver.py 133 script_name=`realpath ${script_name}` 134 jname="v6t-output6_udp_setup_success" 135 136 epair=$(vnet_mkepair) 137 138 vnet_mkjail ${jname}a ${epair}a 139 jexec ${jname}a ifconfig ${epair}a up 140 jexec ${jname}a ifconfig ${epair}a inet6 ${ip_src}/${plen} 141 142 vnet_mkjail ${jname}b ${epair}b 143 jexec ${jname}b ifconfig ${epair}b up 144 jexec ${jname}b ifconfig ${epair}b inet6 ${ip_dst}/${plen} 145 146 # wait for DAD to complete 147 while [ `jexec ${jname}b ifconfig ${epair}b inet6 | grep -c tentative` != "0" ]; do 148 sleep 0.1 149 done 150 while [ `jexec ${jname}a ifconfig ${epair}a inet6 | grep -c tentative` != "0" ]; do 151 sleep 0.1 152 done 153 154 # run listener 155 args="--family inet6 --ports ${port} --match_str ${text}" 156 echo jexec ${jname}b ${script_name} ${args} 157 jexec ${jname}b ${script_name} --test_name "test_listen_udp" ${args} & 158 cmd_pid=$! 159 160 # wait for the script init 161 counter=0 162 while [ `jexec ${jname}b sockstat -6qlp ${port} | wc -l` != "1" ]; do 163 sleep 0.1 164 counterc=$((counter+1)) 165 if [ ${counter} -ge 50 ]; then break; fi 166 done 167 if [ `jexec ${jname}b sockstat -6qlp ${port} | wc -l` != "1" ]; then 168 echo "App setup failed" 169 exit 1 170 fi 171 172 # run sender 173 # TODO: switch from nc to some alternative to avoid 1-second delay 174 echo -n "${text}" | jexec ${jname}a nc -uNw1 ${ip_dst} ${port} 175 exit_code=$? 176 if [ $exit_code -ne 0 ]; then atf_fail "sender exit code $exit_code" ; fi 177 178 wait ${cmd_pid} 179 exit_code=$? 180 if [ $exit_code -ne 0 ]; then atf_fail "receiver exit code $exit_code" ; fi 181} 182 183output6_udp_setup_success_cleanup() 184{ 185 vnet_cleanup 186} 187 188atf_test_case "output6_raw_success" "cleanup" 189output6_raw_success_head() 190{ 191 192 atf_set descr 'Test valid IPv6 raw output' 193 atf_set require.user root 194} 195 196output6_raw_success_body() 197{ 198 199 vnet_init 200 201 net_src="2001:db8:0:0:1::" 202 net_dst="2001:db8:0:0:1::" 203 ip_src="${net_src}1" 204 ip_dst=${net_dst}4242 205 plen=64 206 207 script_name=`dirname $0`/../common/net_receiver.py 208 script_name=`realpath ${script_name}` 209 jname="v6t-output6_raw_success" 210 211 epair=$(vnet_mkepair) 212 213 vnet_mkjail ${jname}a ${epair}a 214 jexec ${jname}a ifconfig ${epair}a up 215 jexec ${jname}a ifconfig ${epair}a inet6 ${ip_src}/${plen} 216 217 vnet_mkjail ${jname}b ${epair}b 218 jexec ${jname}b ifconfig ${epair}b up 219 220 jexec ${jname}b ifconfig ${epair}b inet6 ${ip_dst}/${plen} 221 222 # wait for DAD to complete 223 while [ `jexec ${jname}b ifconfig ${epair}b inet6 | grep -c tentative` != "0" ]; do 224 sleep 0.1 225 done 226 while [ `jexec ${jname}a ifconfig ${epair}a inet6 | grep -c tentative` != "0" ]; do 227 sleep 0.1 228 done 229 230 atf_check -o match:'1 packets transmitted, 1 packets received' jexec ${jname}a ping6 -nc1 ${ip_dst} 231} 232 233output6_raw_success_cleanup() 234{ 235 vnet_cleanup 236} 237 238# Multipath tests are done the following way: 239# epair0/LL 240# jailA lo/GU < > lo/GU jailB 241# epair1/LL 242# jailA has 2 routes towards /64 prefix on jailB loopback, via 2 epairs 243# jailB has 1 route towards /64 prefix on jailA loopback, via epair0 244# 245# jailA initiates connections/sends packets towards IPs on jailB loopback. 246# Script then compares amount of packets sent via epair0 and epair1 247 248mpath_check() 249{ 250 if [ "`sysctl -i -n net.route.multipath`" != 1 ]; then 251 atf_skip "This test requires ROUTE_MPATH enabled" 252 fi 253} 254 255atf_test_case "output6_tcp_flowid_mpath_success" "cleanup" 256output6_tcp_flowid_mpath_success_head() 257{ 258 259 atf_set descr 'Test valid IPv6 TCP output flowid generation' 260 atf_set require.user root 261} 262 263output6_tcp_flowid_mpath_success_body() 264{ 265 vnet_init 266 mpath_check 267 268 net_src="2001:db8:0:1" 269 net_dst="2001:db8:0:2" 270 ip_src="${net_src}::1" 271 ip_dst="${net_dst}::1" 272 plen=64 273 text="testtesttst" 274 275 script_name=`dirname $0`/../common/net_receiver.py 276 script_name=`realpath ${script_name}` 277 jname="v6t-output6_tcp_flowid_mpath_success" 278 279 epair0=$(vnet_mkepair) 280 epair1=$(vnet_mkepair) 281 lo_src=$(vnet_mkloopback) 282 lo_dst=$(vnet_mkloopback) 283 284 vnet_mkjail ${jname}a ${epair0}a ${epair1}a ${lo_src} 285 jls -N 286 # enable link-local IPv6 287 jexec ${jname}a ndp -i ${epair0}a -- -disabled 288 jexec ${jname}a ifconfig ${epair0}a up 289 jexec ${jname}a ndp -i ${epair1}a -- -disabled 290 jexec ${jname}a ifconfig ${epair1}a up 291 jexec ${jname}a ifconfig ${lo_src} up 292 293 vnet_mkjail ${jname}b ${epair0}b ${epair1}b ${lo_dst} 294 jls -N 295 jexec ${jname}b ndp -i ${epair0}b -- -disabled 296 jexec ${jname}b ifconfig ${epair0}b up 297 jexec ${jname}b ndp -i ${epair1}b -- -disabled 298 jexec ${jname}b ifconfig ${epair1}b up 299 jexec ${jname}b ifconfig ${lo_dst} up 300 301 # DST ips/ports to test 302 ips="d3:c4:eb:40 2b:ff:dd:52 b1:d4:44:0e 41:2c:4d:43 66:4a:b4:be 8b:da:ac:f7 ca:d1:c4:f0 b1:31:da:d7 0c:ac:45:7a 44:9c:ce:71" 303 ports="53540 49743 43067 9131 16734 5150 14379 40292 20634 51302 3387 24387 9282 14275 42103 26881 42461 29520 45714 11096" 304 305 jexec ${jname}a ifconfig ${lo_src} inet6 ${ip_src}/128 306 307 jexec ${jname}b ifconfig ${lo_dst} inet6 ${ip_dst}/128 308 for i in ${ips}; do 309 jexec ${jname}b ifconfig ${lo_dst} inet6 ${net_dst}:${i}/128 310 done 311 312 # wait for DAD to complete 313 while [ `jexec ${jname}b ifconfig | grep inet6 | grep -c tentative` != "0" ]; do 314 sleep 0.1 315 done 316 while [ `jexec ${jname}a ifconfig | grep inet6 | grep -c tentative` != "0" ]; do 317 sleep 0.1 318 done 319 320 # Add routes 321 # A -> towards B via epair0a LL 322 ll=`jexec ${jname}b ifconfig ${epair0}b inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'` 323 jexec ${jname}a route add -6 -net ${net_dst}::/${plen} ${ll}%${epair0}a 324 # A -> towards B via epair1a LL 325 ll=`jexec ${jname}b ifconfig ${epair1}b inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'` 326 jexec ${jname}a route add -6 -net ${net_dst}::/${plen} ${ll}%${epair1}a 327 328 # B towards A via epair0b LL 329 ll=`jexec ${jname}a ifconfig ${epair1}a inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'` 330 jexec ${jname}b route add -6 -net ${net_src}::/${plen} ${ll}%${epair1}b 331 332 # Base setup verification 333 atf_check -o match:'1 packets transmitted, 1 packets received' jexec ${jname}a ping6 -c1 ${ip_dst} 334 335 # run listener 336 num_ports=`echo ${ports} | wc -w` 337 num_ips=`echo ${ips} | wc -w` 338 count_examples=$((num_ports*num_ips)) 339 listener_ports=`echo ${ports} | tr ' ' '\n' | sort -n | tr '\n' ',' | sed -e 's?,$??'` 340 args="--family inet6 --ports ${listener_ports} --count ${count_examples} --match_str ${text}" 341 echo jexec ${jname}b ${script_name} ${args} 342 jexec ${jname}b ${script_name} --test_name "test_listen_tcp" ${args} & 343 cmd_pid=$! 344 345 # wait for the app init 346 counter=0 347 init=0 348 while [ ${counter} -le 50 ]; do 349 _ports=`jexec ${jname}b sockstat -6ql | awk "\\\$3 == ${cmd_pid} {print \\\$6}"|awk -F: "{print \\\$2}" | sort -n | tr '\n' ','` 350 if [ "${_ports}" = "${listener_ports}," ]; then 351 init=1 352 break; 353 fi 354 done 355 if [ ${init} -eq 0 ]; then 356 jexec ${jname}b sockstat -6ql | awk "\$3 == ${cmd_pid}" 357 echo "App setup failed" 358 exit 1 359 fi 360 echo "App setup done" 361 362 # run sender 363 for _ip in ${ips}; do 364 ip="${net_dst}:${_ip}" 365 for port in ${ports}; do 366 echo -n "${text}" | jexec ${jname}a nc -nN ${ip} ${port} 367 exit_code=$? 368 if [ $exit_code -ne 0 ]; then atf_fail "sender exit code $exit_code" ; fi 369 done 370 done 371 372 wait ${cmd_pid} 373 exit_code=$? 374 if [ $exit_code -ne 0 ]; then atf_fail "receiver exit code $exit_code" ; fi 375 376 pkt_0=`jexec ${jname}a netstat -Wf link -I ${epair0}a | head | awk '$1!~/^Name/{print$8}'` 377 pkt_1=`jexec ${jname}a netstat -Wf link -I ${epair1}a | head | awk '$1!~/^Name/{print$8}'` 378 if [ ${pkt_0} -le 10 ]; then 379 atf_fail "Balancing failure: 1: ${pkt_0} 2: ${pkt_1}" 380 fi 381 if [ ${pkt_1} -le 10 ]; then 382 atf_fail "Balancing failure: 1: ${pkt_0} 2: ${pkt_1}" 383 fi 384 echo "TCP Balancing: 1: ${pkt_0} 2: ${pkt_1}" 385} 386 387output6_tcp_flowid_mpath_success_cleanup() 388{ 389 vnet_cleanup 390} 391 392atf_test_case "output6_udp_flowid_mpath_success" "cleanup" 393output6_udp_flowid_mpath_success_head() 394{ 395 396 atf_set descr 'Test valid IPv6 UDP output flowid generation' 397 atf_set require.user root 398} 399 400output6_udp_flowid_mpath_success_body() 401{ 402 403 vnet_init 404 mpath_check 405 406 # Note this test will spawn around ~100 nc processes 407 408 net_src="2001:db8:0:1" 409 net_dst="2001:db8:0:2" 410 ip_src="${net_src}::1" 411 ip_dst="${net_dst}::1" 412 plen=64 413 text="testtesttst" 414 415 script_name=`dirname $0`/../common/net_receiver.py 416 script_name=`realpath ${script_name}` 417 jname="v6t-output6_udp_flowid_mpath_success" 418 419 epair0=$(vnet_mkepair) 420 epair1=$(vnet_mkepair) 421 lo_src=$(vnet_mkloopback) 422 lo_dst=$(vnet_mkloopback) 423 424 vnet_mkjail ${jname}a ${epair0}a ${epair1}a ${lo_src} 425 jls -N 426 # enable link-local IPv6 427 jexec ${jname}a ndp -i ${epair0}a -- -disabled 428 jexec ${jname}a ifconfig ${epair0}a up 429 jexec ${jname}a ndp -i ${epair1}a -- -disabled 430 jexec ${jname}a ifconfig ${epair1}a up 431 jexec ${jname}a ifconfig ${lo_src} up 432 433 vnet_mkjail ${jname}b ${epair0}b ${epair1}b ${lo_dst} 434 jls -N 435 jexec ${jname}b ndp -i ${epair0}b -- -disabled 436 jexec ${jname}b ifconfig ${epair0}b up 437 jexec ${jname}b ndp -i ${epair1}b -- -disabled 438 jexec ${jname}b ifconfig ${epair1}b up 439 jexec ${jname}b ifconfig ${lo_dst} up 440 441 # DST ips/ports to test 442 ips="d3:c4:eb:40 2b:ff:dd:52 b1:d4:44:0e 41:2c:4d:43 66:4a:b4:be 8b:da:ac:f7 ca:d1:c4:f0 b1:31:da:d7 0c:ac:45:7a 44:9c:ce:71" 443 ports="53540 49743 43067 9131 16734 5150 14379 40292 20634 51302 3387 24387 9282 14275 42103 26881 42461 29520 45714 11096" 444 445 jexec ${jname}a ifconfig ${lo_src} inet6 ${ip_src}/128 446 447 jexec ${jname}b ifconfig ${lo_dst} inet6 ${ip_dst}/128 448 for i in ${ips}; do 449 jexec ${jname}b ifconfig ${lo_dst} inet6 ${net_dst}:${i}/128 450 done 451 452 453 # wait for DAD to complete 454 while [ `jexec ${jname}b ifconfig | grep inet6 | grep -c tentative` != "0" ]; do 455 sleep 0.1 456 done 457 while [ `jexec ${jname}a ifconfig | grep inet6 | grep -c tentative` != "0" ]; do 458 sleep 0.1 459 done 460 461 # Add routes 462 # A -> towards B via epair0a LL 463 ll=`jexec ${jname}b ifconfig ${epair0}b inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'` 464 jexec ${jname}a route add -6 -net ${net_dst}::/${plen} ${ll}%${epair0}a 465 # A -> towards B via epair1a LL 466 ll=`jexec ${jname}b ifconfig ${epair1}b inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'` 467 jexec ${jname}a route add -6 -net ${net_dst}::/${plen} ${ll}%${epair1}a 468 469 # B towards A via epair0b LL 470 ll=`jexec ${jname}a ifconfig ${epair1}a inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'` 471 jexec ${jname}b route add -6 -net ${net_src}::/${plen} ${ll}%${epair1}b 472 473 # Base setup verification 474 atf_check -o match:'1 packets transmitted, 1 packets received' jexec ${jname}a ping6 -c1 ${ip_dst} 475 476 # run listener 477 num_ports=`echo ${ports} | wc -w` 478 num_ips=`echo ${ips} | wc -w` 479 count_examples=$((num_ports*num_ips)) 480 listener_ports=`echo ${ports} | tr ' ' '\n' | sort -n | tr '\n' ',' | sed -e 's?,$??'` 481 args="--family inet6 --ports ${listener_ports} --count ${count_examples} --match_str ${text}" 482 echo jexec ${jname}b ${script_name} ${args} 483 jexec ${jname}b ${script_name} --test_name "test_listen_udp" ${args} & 484 cmd_pid=$! 485 486 # wait for the app init 487 counter=0 488 init=0 489 while [ ${counter} -le 50 ]; do 490 _ports=`jexec ${jname}b sockstat -6ql | awk "\\\$3 == ${cmd_pid} {print \\\$6}"|awk -F: "{print \\\$2}" | sort -n | tr '\n' ','` 491 if [ "${_ports}" = "${listener_ports}," ]; then 492 init=1 493 break; 494 fi 495 done 496 if [ ${init} -eq 0 ]; then 497 jexec ${jname}b sockstat -6ql | awk "\$3 == ${cmd_pid}" 498 echo "App setup failed" 499 exit 1 500 fi 501 echo "App setup done" 502 503 # run sender 504 for _ip in ${ips}; do 505 ip="${net_dst}:${_ip}" 506 for port in ${ports}; do 507 # XXX: switch to something that allows immediate exit 508 echo -n "${text}" | jexec ${jname}a nc -nuNw1 ${ip} ${port} & 509 sleep 0.01 510 done 511 done 512 513 wait ${cmd_pid} 514 exit_code=$? 515 if [ $exit_code -ne 0 ]; then atf_fail "receiver exit code $exit_code" ; fi 516 517 pkt_0=`jexec ${jname}a netstat -Wf link -I ${epair0}a | head | awk '$1!~/^Name/{print$8}'` 518 pkt_1=`jexec ${jname}a netstat -Wf link -I ${epair1}a | head | awk '$1!~/^Name/{print$8}'` 519 if [ ${pkt_0} -le 10 ]; then 520 atf_fail "Balancing failure: 1: ${pkt_0} 2: ${pkt_1}" 521 fi 522 if [ ${pkt_1} -le 10 ]; then 523 atf_fail "Balancing failure: 1: ${pkt_0} 2: ${pkt_1}" 524 fi 525 echo "UDP BALANCING: 1: ${pkt_0} 2: ${pkt_1}" 526} 527 528output6_udp_flowid_mpath_success_cleanup() 529{ 530 vnet_cleanup 531} 532 533atf_test_case "output6_raw_flowid_mpath_success" "cleanup" 534output6_raw_flowid_mpath_success_head() 535{ 536 537 atf_set descr 'Test valid IPv6 raw output flowid generation' 538 atf_set require.user root 539} 540 541output6_raw_flowid_mpath_success_body() 542{ 543 544 vnet_init 545 mpath_check 546 547 net_src="2001:db8:0:1" 548 net_dst="2001:db8:0:2" 549 ip_src="${net_src}::1" 550 ip_dst="${net_dst}::1" 551 plen=64 552 text="testtesttst" 553 554 jname="v6t-output6_raw_flowid_mpath_success" 555 556 epair0=$(vnet_mkepair) 557 epair1=$(vnet_mkepair) 558 lo_src=$(vnet_mkloopback) 559 lo_dst=$(vnet_mkloopback) 560 561 vnet_mkjail ${jname}a ${epair0}a ${epair1}a ${lo_src} 562 jls -N 563 # enable link-local IPv6 564 jexec ${jname}a ndp -i ${epair0}a -- -disabled 565 jexec ${jname}a ifconfig ${epair0}a up 566 jexec ${jname}a ndp -i ${epair1}a -- -disabled 567 jexec ${jname}a ifconfig ${epair1}a up 568 jexec ${jname}a ifconfig ${lo_src} up 569 570 vnet_mkjail ${jname}b ${epair0}b ${epair1}b ${lo_dst} 571 jls -N 572 jexec ${jname}b ndp -i ${epair0}b -- -disabled 573 jexec ${jname}b ifconfig ${epair0}b up 574 jexec ${jname}b ndp -i ${epair1}b -- -disabled 575 jexec ${jname}b ifconfig ${epair1}b up 576 jexec ${jname}b ifconfig ${lo_dst} up 577 578 # DST ips to test 579 ips="9d:33:f2:7f 48:06:9a:0b cf:96:d5:78 76:da:8e:28 d4:66:38:1e ec:43:da:7c bb:f8:93:2f d3:c4:eb:40" 580 ips="${ips} c7:31:0e:ae 8d:ed:35:2e c0:e0:22:31 82:1c:4e:28 c1:00:60:3e 6a:4f:3b:6c 8e:a7:e9:57 2b:ff:dd:52" 581 ips="${ips} 88:44:79:5d 80:62:83:11 c8:e4:17:a6 e7:2a:45:d7 5a:92:0e:04 70:fc:6a:ee ce:24:4c:68 41:2c:4d:43" 582 ips="${ips} 57:2b:5e:a7 f9:e0:69:c6 cb:b9:e6:ed 28:88:5d:fa d6:19:ac:1d dc:de:37:d8 fe:39:55:c7 b1:31:da:d7" 583 584 jexec ${jname}a ifconfig ${lo_src} inet6 ${ip_src}/128 585 586 jexec ${jname}b ifconfig ${lo_dst} inet6 ${ip_dst}/128 587 for i in ${ips}; do 588 jexec ${jname}b ifconfig ${lo_dst} inet6 ${net_dst}:${i}/128 589 done 590 591 # wait for DAD to complete 592 while [ `jexec ${jname}b ifconfig | grep inet6 | grep -c tentative` != "0" ]; do 593 sleep 0.1 594 done 595 while [ `jexec ${jname}a ifconfig | grep inet6 | grep -c tentative` != "0" ]; do 596 sleep 0.1 597 done 598 599 # Add routes 600 # A -> towards B via epair0a LL 601 ll=`jexec ${jname}b ifconfig ${epair0}b inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'` 602 jexec ${jname}a route add -6 -net ${net_dst}::/${plen} ${ll}%${epair0}a 603 # A -> towards B via epair1a LL 604 ll=`jexec ${jname}b ifconfig ${epair1}b inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'` 605 jexec ${jname}a route add -6 -net ${net_dst}::/${plen} ${ll}%${epair1}a 606 607 # B towards A via epair0b LL 608 ll=`jexec ${jname}a ifconfig ${epair1}a inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'` 609 jexec ${jname}b route add -6 -net ${net_src}::/${plen} ${ll}%${epair1}b 610 611 # Base setup verification 612 atf_check -o match:'1 packets transmitted, 1 packets received' jexec ${jname}a ping6 -nc1 ${ip_dst} 613 614 # run sender 615 valid_message='1 packets transmitted, 1 packets received' 616 for _ip in ${ips}; do 617 ip="${net_dst}:${_ip}" 618 atf_check -o match:"${valid_message}" jexec ${jname}a ping6 -nc1 ${ip} 619 done 620 621 pkt_0=`jexec ${jname}a netstat -Wf link -I ${epair0}a | head | awk '$1!~/^Name/{print$8}'` 622 pkt_1=`jexec ${jname}a netstat -Wf link -I ${epair1}a | head | awk '$1!~/^Name/{print$8}'` 623 624 jexec ${jname}a netstat -bWf link -I ${epair0}a 625 jexec ${jname}a netstat -bWf link -I ${epair1}a 626 if [ ${pkt_0} -le 10 ]; then 627 atf_fail "Balancing failure: 1: ${pkt_0} 2: ${pkt_1}" 628 fi 629 if [ ${pkt_1} -le 10 ]; then 630 atf_fail "Balancing failure: 1: ${pkt_0} 2: ${pkt_1}" 631 fi 632 echo "RAW BALANCING: 1: ${pkt_0} 2: ${pkt_1}" 633} 634 635output6_raw_flowid_mpath_success_cleanup() 636{ 637 vnet_cleanup 638} 639 640atf_init_test_cases() 641{ 642 atf_add_test_case "output6_tcp_setup_success" 643 atf_add_test_case "output6_udp_setup_success" 644 atf_add_test_case "output6_raw_success" 645 atf_add_test_case "output6_tcp_flowid_mpath_success" 646 atf_add_test_case "output6_udp_flowid_mpath_success" 647 atf_add_test_case "output6_raw_flowid_mpath_success" 648} 649 650# end 651 652 653