1*6cecaa57Sozaki-r# $NetBSD: t_cbq.sh,v 1.3 2021/07/16 02:33:32 ozaki-r Exp $ 283b6f2d1Sozaki-r# 383b6f2d1Sozaki-r# Copyright (c) 2021 Internet Initiative Japan Inc. 483b6f2d1Sozaki-r# All rights reserved. 583b6f2d1Sozaki-r# 683b6f2d1Sozaki-r# Redistribution and use in source and binary forms, with or without 783b6f2d1Sozaki-r# modification, are permitted provided that the following conditions 883b6f2d1Sozaki-r# are met: 983b6f2d1Sozaki-r# 1. Redistributions of source code must retain the above copyright 1083b6f2d1Sozaki-r# notice, this list of conditions and the following disclaimer. 1183b6f2d1Sozaki-r# 2. Redistributions in binary form must reproduce the above copyright 1283b6f2d1Sozaki-r# notice, this list of conditions and the following disclaimer in the 1383b6f2d1Sozaki-r# documentation and/or other materials provided with the distribution. 1483b6f2d1Sozaki-r# 1583b6f2d1Sozaki-r# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 1683b6f2d1Sozaki-r# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 1783b6f2d1Sozaki-r# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 1883b6f2d1Sozaki-r# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 1983b6f2d1Sozaki-r# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2083b6f2d1Sozaki-r# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2183b6f2d1Sozaki-r# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2283b6f2d1Sozaki-r# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2383b6f2d1Sozaki-r# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2483b6f2d1Sozaki-r# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2583b6f2d1Sozaki-r# POSSIBILITY OF SUCH DAMAGE. 2683b6f2d1Sozaki-r# 2783b6f2d1Sozaki-r 2883b6f2d1Sozaki-rSOCK_LOCAL=unix://altq_local 2983b6f2d1Sozaki-rSOCK_REMOTE=unix://altq_remote 3083b6f2d1Sozaki-rBUS=bus_altq 3183b6f2d1Sozaki-rTIMEOUT=3 3283b6f2d1Sozaki-r 3383b6f2d1Sozaki-r# rumphijack can't handle AF_LOCAL socket (/var/run/altq_quip) correctly, 3483b6f2d1Sozaki-r# so use the socket via the host. 3583b6f2d1Sozaki-rHIJACKING_ALTQ="$HIJACKING,blanket=/dev/altq/altq:/dev/altq/cbq:/etc/altq.conf:/var/run/altqd.pid" 3683b6f2d1Sozaki-r 3783b6f2d1Sozaki-rDEBUG=${DEBUG:-false} 3883b6f2d1Sozaki-r 3983b6f2d1Sozaki-rIP_LOCAL1=10.0.0.1 4083b6f2d1Sozaki-rIP_LOCAL2=10.0.1.1 4183b6f2d1Sozaki-rIP_REMOTE11=10.0.0.2 4283b6f2d1Sozaki-rIP_REMOTE12=10.0.0.22 4356d8905eSozaki-rIP_REMOTE13=10.0.0.23 4483b6f2d1Sozaki-rIP_REMOTE21=10.0.1.2 4583b6f2d1Sozaki-rIP_REMOTE22=10.0.1.22 4683b6f2d1Sozaki-rALTQD_PIDFILE=./pid 4783b6f2d1Sozaki-r 48*6cecaa57Sozaki-rstart_altqd() 49*6cecaa57Sozaki-r{ 50*6cecaa57Sozaki-r 51*6cecaa57Sozaki-r $HIJACKING_ALTQ altqd 52*6cecaa57Sozaki-r 53*6cecaa57Sozaki-r sleep 0.1 54*6cecaa57Sozaki-r if $HIJACKING_ALTQ test ! -f /var/run/altqd.pid; then 55*6cecaa57Sozaki-r sleep 1 56*6cecaa57Sozaki-r fi 57*6cecaa57Sozaki-r 58*6cecaa57Sozaki-r $HIJACKING_ALTQ test -f /var/run/altqd.pid 59*6cecaa57Sozaki-r if [ $? != 0 ]; then 60*6cecaa57Sozaki-r atf_fail "starting altqd failed" 61*6cecaa57Sozaki-r fi 62*6cecaa57Sozaki-r 63*6cecaa57Sozaki-r $HIJACKING_ALTQ cat /var/run/altqd.pid > $ALTQD_PIDFILE 64*6cecaa57Sozaki-r} 6583b6f2d1Sozaki-r 6683b6f2d1Sozaki-rstart_altqd_basic() 6783b6f2d1Sozaki-r{ 6883b6f2d1Sozaki-r 6983b6f2d1Sozaki-r export RUMP_SERVER=$SOCK_LOCAL 7083b6f2d1Sozaki-r 7183b6f2d1Sozaki-r $HIJACKING_ALTQ mkdir -p /rump/etc 7283b6f2d1Sozaki-r $HIJACKING_ALTQ mkdir -p /rump/var/run 7383b6f2d1Sozaki-r 7483b6f2d1Sozaki-r cat > ./altq.conf <<-EOF 7583b6f2d1Sozaki-r interface shmif0 cbq 7683b6f2d1Sozaki-r class cbq shmif0 root_class NULL pbandwidth 100 7783b6f2d1Sozaki-r class cbq shmif0 normal_class root_class pbandwidth 50 default 7883b6f2d1Sozaki-r filter shmif0 normal_class $IP_REMOTE11 0 0 0 0 7983b6f2d1Sozaki-r class cbq shmif0 drop_class root_class pbandwidth 0 8083b6f2d1Sozaki-r filter shmif0 drop_class $IP_REMOTE12 0 0 0 0 8183b6f2d1Sozaki-r EOF 8283b6f2d1Sozaki-r $DEBUG && cat ./altq.conf 8383b6f2d1Sozaki-r atf_check -s exit:0 $HIJACKING_ALTQ cp ./altq.conf /rump/etc/altq.conf 84*6cecaa57Sozaki-r atf_check -s exit:0 $HIJACKING_ALTQ test -f /rump/etc/altq.conf 8583b6f2d1Sozaki-r 86*6cecaa57Sozaki-r start_altqd 8783b6f2d1Sozaki-r 8883b6f2d1Sozaki-r $DEBUG && $HIJACKING_ALTQ altqstat -s 8983b6f2d1Sozaki-r $HIJACKING_ALTQ altqstat -c 1 >./out 9083b6f2d1Sozaki-r $DEBUG && cat ./out 9183b6f2d1Sozaki-r atf_check -s exit:0 \ 9283b6f2d1Sozaki-r -o match:"altqstat: cbq on interface shmif0" \ 9383b6f2d1Sozaki-r -o match:'Class 1 on Interface shmif0: root_class' \ 9483b6f2d1Sozaki-r -o match:'Class 2 on Interface shmif0: normal_class' \ 9583b6f2d1Sozaki-r -o match:'Class 3 on Interface shmif0: ctl_class' \ 9683b6f2d1Sozaki-r -o match:'Class 4 on Interface shmif0: drop_class' \ 9783b6f2d1Sozaki-r cat ./out 9883b6f2d1Sozaki-r rm -f ./out 9983b6f2d1Sozaki-r} 10083b6f2d1Sozaki-r 10183b6f2d1Sozaki-rshutdown_altqd() 10283b6f2d1Sozaki-r{ 10383b6f2d1Sozaki-r local pid="$(cat $ALTQD_PIDFILE)" 10483b6f2d1Sozaki-r 10583b6f2d1Sozaki-r if [ -n "$pid" ]; then 10683b6f2d1Sozaki-r pgrep -x altqd | grep -q $pid 10783b6f2d1Sozaki-r if [ $? = 0 ]; then 10883b6f2d1Sozaki-r kill $(cat $ALTQD_PIDFILE) 10983b6f2d1Sozaki-r sleep 1 11083b6f2d1Sozaki-r fi 11183b6f2d1Sozaki-r $DEBUG && pgrep -x altqd 11283b6f2d1Sozaki-r fi 11383b6f2d1Sozaki-r} 11483b6f2d1Sozaki-r 11583b6f2d1Sozaki-rcheck_counter() 11683b6f2d1Sozaki-r{ 11783b6f2d1Sozaki-r local file=$1 11883b6f2d1Sozaki-r local name=$2 11983b6f2d1Sozaki-r local match="$3" 12083b6f2d1Sozaki-r 12183b6f2d1Sozaki-r grep -A 8 ${name}_class $file > $file.$name 12283b6f2d1Sozaki-r atf_check -s exit:0 -o match:"$match" cat $file.$name 12383b6f2d1Sozaki-r rm -f $file.$name 12483b6f2d1Sozaki-r} 12583b6f2d1Sozaki-r 12683b6f2d1Sozaki-rtest_altq_cbq_basic_ipv4() 12783b6f2d1Sozaki-r{ 12883b6f2d1Sozaki-r local ifconfig="atf_check -s exit:0 rump.ifconfig" 12983b6f2d1Sozaki-r local ping="atf_check -s exit:0 -o ignore rump.ping" 13083b6f2d1Sozaki-r local opts="-q -c 1 -w 1" 13183b6f2d1Sozaki-r 13283b6f2d1Sozaki-r rump_server_fs_start $SOCK_LOCAL local altq 13383b6f2d1Sozaki-r rump_server_start $SOCK_REMOTE 13483b6f2d1Sozaki-r 13583b6f2d1Sozaki-r rump_server_add_iface $SOCK_LOCAL shmif0 $BUS 13683b6f2d1Sozaki-r rump_server_add_iface $SOCK_REMOTE shmif0 $BUS 13783b6f2d1Sozaki-r 13883b6f2d1Sozaki-r export RUMP_SERVER=$SOCK_LOCAL 13983b6f2d1Sozaki-r $ifconfig shmif0 inet $IP_LOCAL1/24 14083b6f2d1Sozaki-r export RUMP_SERVER=$SOCK_REMOTE 14183b6f2d1Sozaki-r $ifconfig shmif0 inet $IP_REMOTE11/24 14283b6f2d1Sozaki-r $ifconfig shmif0 inet $IP_REMOTE12/24 alias 14383b6f2d1Sozaki-r $ifconfig -w 10 14483b6f2d1Sozaki-r 14583b6f2d1Sozaki-r export RUMP_SERVER=$SOCK_LOCAL 14683b6f2d1Sozaki-r # Invoke ARP 14783b6f2d1Sozaki-r $ping $opts $IP_REMOTE11 14883b6f2d1Sozaki-r $ping $opts $IP_REMOTE12 14983b6f2d1Sozaki-r 15083b6f2d1Sozaki-r start_altqd_basic 15183b6f2d1Sozaki-r 15283b6f2d1Sozaki-r export RUMP_SERVER=$SOCK_LOCAL 15383b6f2d1Sozaki-r $ping $opts $IP_REMOTE11 15483b6f2d1Sozaki-r 15583b6f2d1Sozaki-r $HIJACKING_ALTQ altqstat -c 1 >./out 15683b6f2d1Sozaki-r $DEBUG && cat ./out 15783b6f2d1Sozaki-r 15883b6f2d1Sozaki-r check_counter ./out normal 'pkts: 1' 15983b6f2d1Sozaki-r check_counter ./out root 'pkts: 1' 16083b6f2d1Sozaki-r check_counter ./out drop 'pkts: 0' 16183b6f2d1Sozaki-r 16283b6f2d1Sozaki-r export RUMP_SERVER=$SOCK_LOCAL 16383b6f2d1Sozaki-r atf_check -s not-exit:0 -o ignore -e match:"No buffer space available" \ 16483b6f2d1Sozaki-r rump.ping $opts $IP_REMOTE12 16583b6f2d1Sozaki-r 16683b6f2d1Sozaki-r $HIJACKING_ALTQ altqstat -c 1 >./out 16783b6f2d1Sozaki-r $DEBUG && cat ./out 16883b6f2d1Sozaki-r 16983b6f2d1Sozaki-r check_counter ./out drop 'drops: 1' 17083b6f2d1Sozaki-r check_counter ./out drop 'pkts: 0' 17183b6f2d1Sozaki-r check_counter ./out normal 'pkts: 1' 17283b6f2d1Sozaki-r check_counter ./out root 'pkts: 1' 17383b6f2d1Sozaki-r 17483b6f2d1Sozaki-r rm -f ./out 17583b6f2d1Sozaki-r 17683b6f2d1Sozaki-r shutdown_altqd 17783b6f2d1Sozaki-r 17883b6f2d1Sozaki-r rump_server_destroy_ifaces 17983b6f2d1Sozaki-r} 18083b6f2d1Sozaki-r 18183b6f2d1Sozaki-rstart_altqd_multi_ifaces() 18283b6f2d1Sozaki-r{ 18383b6f2d1Sozaki-r 18483b6f2d1Sozaki-r export RUMP_SERVER=$SOCK_LOCAL 18583b6f2d1Sozaki-r 18683b6f2d1Sozaki-r $HIJACKING_ALTQ mkdir -p /rump/etc 18783b6f2d1Sozaki-r $HIJACKING_ALTQ mkdir -p /rump/var/run 18883b6f2d1Sozaki-r 18983b6f2d1Sozaki-r cat > ./altq.conf <<-EOF 19083b6f2d1Sozaki-r interface shmif0 cbq 19183b6f2d1Sozaki-r class cbq shmif0 root_class NULL pbandwidth 100 19283b6f2d1Sozaki-r class cbq shmif0 normal_class root_class pbandwidth 50 default 19383b6f2d1Sozaki-r filter shmif0 normal_class $IP_REMOTE11 0 0 0 0 19483b6f2d1Sozaki-r class cbq shmif0 drop_class root_class pbandwidth 0 19583b6f2d1Sozaki-r filter shmif0 drop_class $IP_REMOTE12 0 0 0 0 19683b6f2d1Sozaki-r interface shmif1 cbq 19783b6f2d1Sozaki-r class cbq shmif1 root_class NULL pbandwidth 100 19883b6f2d1Sozaki-r class cbq shmif1 normal_class root_class pbandwidth 50 default 19983b6f2d1Sozaki-r filter shmif1 normal_class $IP_REMOTE21 0 0 0 0 20083b6f2d1Sozaki-r class cbq shmif1 drop_class root_class pbandwidth 0 20183b6f2d1Sozaki-r filter shmif1 drop_class $IP_REMOTE22 0 0 0 0 20283b6f2d1Sozaki-r EOF 20383b6f2d1Sozaki-r $DEBUG && cat ./altq.conf 20483b6f2d1Sozaki-r atf_check -s exit:0 $HIJACKING_ALTQ cp ./altq.conf /rump/etc/altq.conf 20583b6f2d1Sozaki-r $HIJACKING_ALTQ test -f /rump/etc/altq.conf 20683b6f2d1Sozaki-r 207*6cecaa57Sozaki-r start_altqd 20883b6f2d1Sozaki-r 20983b6f2d1Sozaki-r $DEBUG && $HIJACKING_ALTQ altqstat -s 21083b6f2d1Sozaki-r 21183b6f2d1Sozaki-r $HIJACKING_ALTQ altqstat -c 1 -i shmif0 >./out 21283b6f2d1Sozaki-r $DEBUG && cat ./out 21383b6f2d1Sozaki-r atf_check -s exit:0 \ 21483b6f2d1Sozaki-r -o match:"altqstat: cbq on interface shmif0" \ 21583b6f2d1Sozaki-r -o match:'Class 1 on Interface shmif0: root_class' \ 21683b6f2d1Sozaki-r -o match:'Class 2 on Interface shmif0: normal_class' \ 21783b6f2d1Sozaki-r -o match:'Class 3 on Interface shmif0: ctl_class' \ 21883b6f2d1Sozaki-r -o match:'Class 4 on Interface shmif0: drop_class' \ 21983b6f2d1Sozaki-r cat ./out 22083b6f2d1Sozaki-r 22183b6f2d1Sozaki-r $HIJACKING_ALTQ altqstat -c 1 -i shmif1 >./out 22283b6f2d1Sozaki-r $DEBUG && cat ./out 22383b6f2d1Sozaki-r atf_check -s exit:0 \ 22483b6f2d1Sozaki-r -o match:"altqstat: cbq on interface shmif1" \ 22583b6f2d1Sozaki-r -o match:'Class 1 on Interface shmif1: root_class' \ 22683b6f2d1Sozaki-r -o match:'Class 2 on Interface shmif1: normal_class' \ 22783b6f2d1Sozaki-r -o match:'Class 3 on Interface shmif1: ctl_class' \ 22883b6f2d1Sozaki-r -o match:'Class 4 on Interface shmif1: drop_class' \ 22983b6f2d1Sozaki-r cat ./out 23083b6f2d1Sozaki-r 23183b6f2d1Sozaki-r rm -f ./out 23283b6f2d1Sozaki-r} 23383b6f2d1Sozaki-r 23483b6f2d1Sozaki-rtest_altq_cbq_multi_ifaces_ipv4() 23583b6f2d1Sozaki-r{ 23683b6f2d1Sozaki-r local ifconfig="atf_check -s exit:0 rump.ifconfig" 23783b6f2d1Sozaki-r local ping="atf_check -s exit:0 -o ignore rump.ping" 23883b6f2d1Sozaki-r local opts="-q -c 1 -w 1" 23983b6f2d1Sozaki-r 24083b6f2d1Sozaki-r rump_server_fs_start $SOCK_LOCAL local altq 24183b6f2d1Sozaki-r rump_server_start $SOCK_REMOTE 24283b6f2d1Sozaki-r 24383b6f2d1Sozaki-r rump_server_add_iface $SOCK_LOCAL shmif0 $BUS 24483b6f2d1Sozaki-r rump_server_add_iface $SOCK_LOCAL shmif1 $BUS 24583b6f2d1Sozaki-r rump_server_add_iface $SOCK_REMOTE shmif0 $BUS 24683b6f2d1Sozaki-r 24783b6f2d1Sozaki-r export RUMP_SERVER=$SOCK_LOCAL 24883b6f2d1Sozaki-r $ifconfig shmif0 inet $IP_LOCAL1/24 24983b6f2d1Sozaki-r $ifconfig shmif1 inet $IP_LOCAL2/24 25083b6f2d1Sozaki-r export RUMP_SERVER=$SOCK_REMOTE 25183b6f2d1Sozaki-r $ifconfig shmif0 inet $IP_REMOTE11/24 25283b6f2d1Sozaki-r $ifconfig shmif0 inet $IP_REMOTE12/24 alias 25383b6f2d1Sozaki-r $ifconfig shmif0 inet $IP_REMOTE21/24 alias 25483b6f2d1Sozaki-r $ifconfig shmif0 inet $IP_REMOTE22/24 alias 25583b6f2d1Sozaki-r $ifconfig -w 10 25683b6f2d1Sozaki-r 25783b6f2d1Sozaki-r export RUMP_SERVER=$SOCK_LOCAL 25883b6f2d1Sozaki-r # Invoke ARP 25983b6f2d1Sozaki-r $ping $opts $IP_REMOTE11 26083b6f2d1Sozaki-r $ping $opts $IP_REMOTE12 26183b6f2d1Sozaki-r $ping $opts $IP_REMOTE21 26283b6f2d1Sozaki-r $ping $opts $IP_REMOTE22 26383b6f2d1Sozaki-r 26483b6f2d1Sozaki-r start_altqd_multi_ifaces 26583b6f2d1Sozaki-r 26683b6f2d1Sozaki-r export RUMP_SERVER=$SOCK_LOCAL 26783b6f2d1Sozaki-r $ping $opts $IP_REMOTE11 26883b6f2d1Sozaki-r 26983b6f2d1Sozaki-r $HIJACKING_ALTQ altqstat -c 1 -i shmif0 >./out 27083b6f2d1Sozaki-r $DEBUG && cat ./out 27183b6f2d1Sozaki-r 27283b6f2d1Sozaki-r check_counter ./out normal 'pkts: 1' 27383b6f2d1Sozaki-r check_counter ./out root 'pkts: 1' 27483b6f2d1Sozaki-r check_counter ./out drop 'pkts: 0' 27583b6f2d1Sozaki-r 27683b6f2d1Sozaki-r $ping $opts $IP_REMOTE21 27783b6f2d1Sozaki-r 27883b6f2d1Sozaki-r $HIJACKING_ALTQ altqstat -c 1 -i shmif1 >./out 27983b6f2d1Sozaki-r $DEBUG && cat ./out 28083b6f2d1Sozaki-r 28183b6f2d1Sozaki-r check_counter ./out normal 'pkts: 1' 28283b6f2d1Sozaki-r check_counter ./out root 'pkts: 1' 28383b6f2d1Sozaki-r check_counter ./out drop 'pkts: 0' 28483b6f2d1Sozaki-r 28583b6f2d1Sozaki-r export RUMP_SERVER=$SOCK_LOCAL 28683b6f2d1Sozaki-r atf_check -s not-exit:0 -o ignore -e match:"No buffer space available" \ 28783b6f2d1Sozaki-r rump.ping $opts $IP_REMOTE12 28883b6f2d1Sozaki-r 28983b6f2d1Sozaki-r $HIJACKING_ALTQ altqstat -c 1 -i shmif0 >./out 29083b6f2d1Sozaki-r $DEBUG && cat ./out 29183b6f2d1Sozaki-r 29283b6f2d1Sozaki-r check_counter ./out drop 'drops: 1' 29383b6f2d1Sozaki-r check_counter ./out drop 'pkts: 0' 29483b6f2d1Sozaki-r check_counter ./out normal 'pkts: 1' 29583b6f2d1Sozaki-r check_counter ./out root 'pkts: 1' 29683b6f2d1Sozaki-r 29783b6f2d1Sozaki-r atf_check -s not-exit:0 -o ignore -e match:"No buffer space available" \ 29883b6f2d1Sozaki-r rump.ping $opts $IP_REMOTE22 29983b6f2d1Sozaki-r 30083b6f2d1Sozaki-r $HIJACKING_ALTQ altqstat -c 1 -i shmif1 >./out 30183b6f2d1Sozaki-r $DEBUG && cat ./out 30283b6f2d1Sozaki-r 30383b6f2d1Sozaki-r check_counter ./out drop 'drops: 1' 30483b6f2d1Sozaki-r check_counter ./out drop 'pkts: 0' 30583b6f2d1Sozaki-r check_counter ./out normal 'pkts: 1' 30683b6f2d1Sozaki-r check_counter ./out root 'pkts: 1' 30783b6f2d1Sozaki-r 30883b6f2d1Sozaki-r rm -f ./out 30983b6f2d1Sozaki-r 31083b6f2d1Sozaki-r shutdown_altqd 31183b6f2d1Sozaki-r 31283b6f2d1Sozaki-r rump_server_destroy_ifaces 31383b6f2d1Sozaki-r} 31483b6f2d1Sozaki-r 31556d8905eSozaki-rstart_altqd_options() 31656d8905eSozaki-r{ 31756d8905eSozaki-r 31856d8905eSozaki-r export RUMP_SERVER=$SOCK_LOCAL 31956d8905eSozaki-r 32056d8905eSozaki-r $HIJACKING_ALTQ mkdir -p /rump/etc 32156d8905eSozaki-r $HIJACKING_ALTQ mkdir -p /rump/var/run 32256d8905eSozaki-r 32356d8905eSozaki-r # - no-tbr and no-control are specified 32456d8905eSozaki-r # - root_class is the default class 32556d8905eSozaki-r cat > ./altq.conf <<-EOF 32656d8905eSozaki-r interface shmif0 cbq no-tbr no-control 32756d8905eSozaki-r class cbq shmif0 root_class NULL pbandwidth 100 default 32856d8905eSozaki-r class cbq shmif0 normal_class root_class pbandwidth 50 32956d8905eSozaki-r filter shmif0 normal_class $IP_REMOTE11 0 0 0 0 33056d8905eSozaki-r class cbq shmif0 drop_class root_class pbandwidth 0 33156d8905eSozaki-r filter shmif0 drop_class $IP_REMOTE12 0 0 0 0 33256d8905eSozaki-r EOF 33356d8905eSozaki-r $DEBUG && cat ./altq.conf 33456d8905eSozaki-r atf_check -s exit:0 $HIJACKING_ALTQ cp ./altq.conf /rump/etc/altq.conf 33556d8905eSozaki-r $HIJACKING_ALTQ test -f /rump/etc/altq.conf 33656d8905eSozaki-r 337*6cecaa57Sozaki-r start_altqd 33856d8905eSozaki-r 33956d8905eSozaki-r $DEBUG && $HIJACKING_ALTQ altqstat -s 34056d8905eSozaki-r $HIJACKING_ALTQ altqstat -c 1 >./out 34156d8905eSozaki-r $DEBUG && cat ./out 34256d8905eSozaki-r atf_check -s exit:0 \ 34356d8905eSozaki-r -o match:"altqstat: cbq on interface shmif0" \ 34456d8905eSozaki-r -o match:'Class 1 on Interface shmif0: root_class' \ 34556d8905eSozaki-r -o match:'Class 2 on Interface shmif0: normal_class' \ 34656d8905eSozaki-r -o match:'Class 3 on Interface shmif0: drop_class' \ 34756d8905eSozaki-r cat ./out 34856d8905eSozaki-r atf_check -s exit:0 -o not-match:'shmif0: ctl_class' cat ./out 34956d8905eSozaki-r 35056d8905eSozaki-r rm -f ./out 35156d8905eSozaki-r} 35256d8905eSozaki-r 35356d8905eSozaki-rtest_altq_cbq_options_ipv4() 35456d8905eSozaki-r{ 35556d8905eSozaki-r local ifconfig="atf_check -s exit:0 rump.ifconfig" 35656d8905eSozaki-r local ping="atf_check -s exit:0 -o ignore rump.ping" 35756d8905eSozaki-r local opts="-q -c 1 -w 1" 35856d8905eSozaki-r 35956d8905eSozaki-r rump_server_fs_start $SOCK_LOCAL local altq 36056d8905eSozaki-r rump_server_start $SOCK_REMOTE 36156d8905eSozaki-r 36256d8905eSozaki-r rump_server_add_iface $SOCK_LOCAL shmif0 $BUS 36356d8905eSozaki-r rump_server_add_iface $SOCK_REMOTE shmif0 $BUS 36456d8905eSozaki-r 36556d8905eSozaki-r export RUMP_SERVER=$SOCK_LOCAL 36656d8905eSozaki-r $ifconfig shmif0 inet $IP_LOCAL1/24 36756d8905eSozaki-r export RUMP_SERVER=$SOCK_REMOTE 36856d8905eSozaki-r $ifconfig shmif0 inet $IP_REMOTE11/24 36956d8905eSozaki-r $ifconfig shmif0 inet $IP_REMOTE12/24 alias 37056d8905eSozaki-r $ifconfig shmif0 inet $IP_REMOTE13/24 alias 37156d8905eSozaki-r $ifconfig -w 10 37256d8905eSozaki-r 37356d8905eSozaki-r export RUMP_SERVER=$SOCK_LOCAL 37456d8905eSozaki-r # Invoke ARP 37556d8905eSozaki-r $ping $opts $IP_REMOTE11 37656d8905eSozaki-r $ping $opts $IP_REMOTE12 37756d8905eSozaki-r $ping $opts $IP_REMOTE13 37856d8905eSozaki-r 37956d8905eSozaki-r start_altqd_options 38056d8905eSozaki-r 38156d8905eSozaki-r export RUMP_SERVER=$SOCK_LOCAL 38256d8905eSozaki-r $ping $opts $IP_REMOTE11 38356d8905eSozaki-r 38456d8905eSozaki-r $HIJACKING_ALTQ altqstat -c 1 >./out 38556d8905eSozaki-r $DEBUG && cat ./out 38656d8905eSozaki-r 38756d8905eSozaki-r check_counter ./out normal 'pkts: 1' 38856d8905eSozaki-r check_counter ./out root 'pkts: 1' 38956d8905eSozaki-r check_counter ./out drop 'pkts: 0' 39056d8905eSozaki-r 39156d8905eSozaki-r atf_check -s not-exit:0 -o ignore -e match:"No buffer space available" \ 39256d8905eSozaki-r rump.ping $opts $IP_REMOTE12 39356d8905eSozaki-r 39456d8905eSozaki-r $HIJACKING_ALTQ altqstat -c 1 >./out 39556d8905eSozaki-r $DEBUG && cat ./out 39656d8905eSozaki-r 39756d8905eSozaki-r check_counter ./out drop 'drops: 1' 39856d8905eSozaki-r check_counter ./out drop 'pkts: 0' 39956d8905eSozaki-r check_counter ./out normal 'pkts: 1' 40056d8905eSozaki-r check_counter ./out root 'pkts: 1' 40156d8905eSozaki-r 40256d8905eSozaki-r # The packet goes to the default class 40356d8905eSozaki-r $ping $opts $IP_REMOTE13 40456d8905eSozaki-r 40556d8905eSozaki-r $HIJACKING_ALTQ altqstat -c 1 >./out 40656d8905eSozaki-r $DEBUG && cat ./out 40756d8905eSozaki-r 40856d8905eSozaki-r check_counter ./out drop 'pkts: 0' 40956d8905eSozaki-r check_counter ./out normal 'pkts: 1' 41056d8905eSozaki-r check_counter ./out root 'pkts: 2' 41156d8905eSozaki-r 41256d8905eSozaki-r rm -f ./out 41356d8905eSozaki-r 41456d8905eSozaki-r shutdown_altqd 41556d8905eSozaki-r 41656d8905eSozaki-r rump_server_destroy_ifaces 41756d8905eSozaki-r} 41856d8905eSozaki-r 41983b6f2d1Sozaki-radd_test_case() 42083b6f2d1Sozaki-r{ 42183b6f2d1Sozaki-r local algo=$1 42283b6f2d1Sozaki-r local type=$2 42383b6f2d1Sozaki-r local ipproto=$3 42483b6f2d1Sozaki-r 42583b6f2d1Sozaki-r name="altq_${algo}_${type}_${ipproto}" 42683b6f2d1Sozaki-r desc="Tests for ALTQ $algo (${type}) on ${ipproto}" 42783b6f2d1Sozaki-r 42883b6f2d1Sozaki-r atf_test_case ${name} cleanup 42983b6f2d1Sozaki-r eval " 43083b6f2d1Sozaki-r ${name}_head() { 43183b6f2d1Sozaki-r atf_set descr \"$desc\" 43283b6f2d1Sozaki-r atf_set require.progs rump_server altqd altqstat 43383b6f2d1Sozaki-r } 43483b6f2d1Sozaki-r ${name}_body() { 43583b6f2d1Sozaki-r test_altq_${algo}_${type}_${ipproto} 43683b6f2d1Sozaki-r } 43783b6f2d1Sozaki-r ${name}_cleanup() { 43883b6f2d1Sozaki-r shutdown_altqd 43983b6f2d1Sozaki-r \$DEBUG && dump 44083b6f2d1Sozaki-r cleanup 44183b6f2d1Sozaki-r } 44283b6f2d1Sozaki-r " 44383b6f2d1Sozaki-r atf_add_test_case ${name} 44483b6f2d1Sozaki-r} 44583b6f2d1Sozaki-r 44683b6f2d1Sozaki-ratf_init_test_cases() 44783b6f2d1Sozaki-r{ 44883b6f2d1Sozaki-r 44983b6f2d1Sozaki-r add_test_case cbq basic ipv4 45083b6f2d1Sozaki-r add_test_case cbq multi_ifaces ipv4 45156d8905eSozaki-r add_test_case cbq options ipv4 45283b6f2d1Sozaki-r} 453