1 . $(atf_get_srcdir)/utils.subr
3 atf_test_case "hfsc" "cleanup"
6 atf_set descr 'Basic HFSC test'
7 atf_set require.user root
13 is_altq_supported hfsc
16 vnet_mkjail altq_hfsc ${epair}b
18 ifconfig ${epair}a 192.0.2.1/24 up
19 jexec altq_hfsc ifconfig ${epair}b 192.0.2.2/24 up
22 atf_check -s exit:0 -o ignore ping -i .1 -c 3 -s 1200 192.0.2.2
24 jexec altq_hfsc pfctl -e
25 pft_set_rules altq_hfsc \
26 "altq on ${epair}b bandwidth 100b hfsc queue { default }" \
27 "queue default hfsc(default linkshare 80b)" \
30 # single ping succeeds just fine
31 atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2
34 ping -i .1 -c 5 -s 1200 192.0.2.2
36 # We should now be hitting the limits and get this packet dropped.
37 atf_check -s exit:2 -o ignore ping -c 1 -s 1200 192.0.2.2
45 atf_test_case "match" "cleanup"
48 atf_set descr 'Basic match keyword test'
49 atf_set require.user root
55 is_altq_supported hfsc
58 vnet_mkjail altq_match ${epair}b
60 ifconfig ${epair}a 192.0.2.1/24 up
61 jexec altq_match ifconfig ${epair}b 192.0.2.2/24 up
64 atf_check -s exit:0 -o ignore ping -i .1 -c 3 -s 1200 192.0.2.2
66 jexec altq_match pfctl -e
67 pft_set_rules altq_match \
68 "altq on ${epair}b bandwidth 100000000b hfsc queue { default, slow }" \
69 "queue default hfsc(default linkshare 80000000b)" \
70 "queue slow hfsc(linkshare 80b upperlimit 80b)" \
71 "match proto icmp queue slow" \
74 # single ping succeeds just fine
75 atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2
78 ping -i .1 -c 5 -s 1200 192.0.2.2
80 # We should now be hitting the limits and get this packet dropped.
81 atf_check -s exit:2 -o ignore ping -c 1 -s 1200 192.0.2.2
89 atf_test_case "cbq_vlan" "cleanup"
92 atf_set descr 'CBQ over VLAN test'
93 atf_set require.user root
101 epair=$(vnet_mkepair)
102 vnet_mkjail altq_cbq_vlan ${epair}b
105 ifconfig ${vlan} vlan 42 vlandev ${epair}a
106 ifconfig ${vlan} 192.0.2.1/24 up
107 ifconfig ${epair}a up
109 vlanj=$(jexec altq_cbq_vlan ifconfig vlan create)
110 echo ${vlanj} >> created_interfaces.lst
112 jexec altq_cbq_vlan ifconfig ${epair}b up
113 jexec altq_cbq_vlan ifconfig ${vlanj} vlan 42 vlandev ${epair}b
114 jexec altq_cbq_vlan ifconfig ${vlanj} 192.0.2.2/24 up
117 atf_check -s exit:0 -o ignore ping -i .1 -c 3 -s 1200 192.0.2.2
119 jexec altq_cbq_vlan pfctl -e
120 pft_set_rules altq_cbq_vlan \
121 "altq on ${vlanj} bandwidth 14000b cbq queue { default }" \
122 "queue default bandwidth 14000b cbq(default) { slow } " \
123 "queue slow bandwidth 6000b cbq(borrow)" \
124 "match proto icmp queue slow" \
125 "match proto tcp queue default" \
128 # single ping succeeds just fine
129 atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2
131 # "Saturate the link"
132 ping -i .01 -c 50 -s 1200 192.0.2.2
134 # We should now be hitting the limits and get these packet dropped.
135 rcv=$(ping -i .1 -c 5 -s 1200 192.0.2.2 | tr "," "\n" | awk '/packets received/ { print $1; }')
136 echo "Received $rcv packets"
139 atf_fail "Received ${rcv} packets in a saturated link"
148 atf_test_case "codel_bridge" "cleanup"
151 atf_set descr 'codel over if_bridge test'
152 atf_set require.user root
158 is_altq_supported codel
159 if ! kldstat -q -m if_bridge; then
160 atf_skip "This test requires if_bridge"
163 epair=$(vnet_mkepair)
164 ifconfig ${epair}a 192.0.2.1/24 up
166 vnet_mkjail altq_codel_bridge ${epair}b
168 bridge=$(jexec altq_codel_bridge ifconfig bridge create)
169 jexec altq_codel_bridge ifconfig ${bridge} addm ${epair}b
170 jexec altq_codel_bridge ifconfig ${epair}b up
171 jexec altq_codel_bridge ifconfig ${bridge} 192.0.2.2/24 up
174 atf_check -s exit:0 -o ignore ping -i .1 -c 3 -s 1200 192.0.2.2
176 jexec altq_codel_bridge pfctl -e
177 pft_set_rules altq_codel_bridge \
178 "altq on ${bridge} bandwidth 1000b codelq queue { slow }" \
182 # "Saturate the link"
183 ping -i .1 -c 5 -s 1200 192.0.2.2
185 # We should now be hitting the limits and get these packet dropped.
186 rcv=$(ping -i .1 -c 5 -s 1200 192.0.2.2 | tr "," "\n" | awk '/packets received/ { print $1; }')
187 echo "Received $rcv packets"
190 atf_fail "Received ${rcv} packets in a saturated link"
194 codel_bridge_cleanup()
199 atf_test_case "prioritise" "cleanup"
202 atf_set descr "Test prioritising one type of traffic over the other"
203 atf_set require.user root
209 is_altq_supported cbq
211 epair=$(vnet_mkepair)
212 vnet_mkjail altq_prioritise ${epair}b
214 ifconfig ${epair}a 192.0.2.1/24 up
215 jexec altq_prioritise ifconfig ${epair}b 192.0.2.2/24 up
217 jexec altq_prioritise /usr/sbin/inetd -p inetd-altq.pid \
218 $(atf_get_srcdir)/../pf/echo_inetd.conf
221 atf_check -s exit:0 -o ignore ping -i .1 -c 3 -s 1200 192.0.2.2
223 jexec altq_prioritise pfctl -e
224 pft_set_rules altq_prioritise \
225 "altq on ${epair}b bandwidth 6000b cbq queue { default, slow }" \
226 "queue default priority 7 cbq(default)" \
227 "queue slow priority 1 cbq" \
228 "match proto icmp queue slow" \
229 "match proto tcp queue default" \
232 # single ping succeeds just fine
233 atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2
235 # Unsaturated TCP succeeds
236 reply=$(echo "foo" | nc -w 5 -N 192.0.2.2 7)
237 if [ "$reply" != "foo" ];
239 atf_fail "Unsaturated echo failed"
242 # "Saturate the link"
243 ping -i .01 -c 50 -s 1200 192.0.2.2
245 # We should now be hitting the limits and get these packet dropped.
246 rcv=$(ping -i .1 -c 5 -s 1200 192.0.2.2 | tr "," "\n" | awk '/packets received/ { print $1; }')
247 echo "Received $rcv packets"
250 atf_fail "Received ${rcv} packets in a saturated link"
253 # TCP should still pass
256 reply=$(echo "foo_${i}" | nc -w 5 -N 192.0.2.2 7)
257 if [ "$reply" != "foo_${i}" ];
259 atf_fail "Prioritised echo failed ${i}"
264 # Now reverse priority
265 pft_set_rules altq_prioritise \
266 "altq on ${epair}b bandwidth 6000b cbq queue { default, slow }" \
267 "queue default priority 7 cbq(default)" \
268 "queue slow priority 1 cbq" \
269 "match proto tcp queue slow" \
270 "match proto icmp queue default" \
273 atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2
274 ping -i .01 -c 50 -s 1200 192.0.2.2
277 reply=$(echo "foo_${i}" | nc -w 5 -N 192.0.2.2 7)
278 if [ "$reply" == "foo_${i}" ];
280 atf_fail "Unexpected echo success"
291 atf_test_case "codel_vlan" "cleanup"
294 atf_set descr 'Test double-pass through ALTQ with codel'
295 atf_set require.user root
301 is_altq_supported priq
302 is_altq_supported codel
305 epair=$(vnet_mkepair)
307 vnet_mkjail ${j}a ${epair}a
308 va=$(jexec ${j}a ifconfig vlan create)
309 jexec ${j}a ifconfig ${epair}a up
310 jexec ${j}a ifconfig ${va} vlan 42 vlandev ${epair}a up
311 jexec ${j}a ifconfig ${va} inet 192.0.2.1/24
313 vnet_mkjail ${j}b ${epair}b
314 vb=$(jexec ${j}b ifconfig vlan create)
315 jexec ${j}b ifconfig ${epair}b up
316 jexec ${j}b ifconfig ${vb} vlan 42 vlandev ${epair}b up
317 jexec ${j}b ifconfig ${vb} inet 192.0.2.2/24
320 atf_check -s exit:0 -o ignore \
321 jexec ${j}a ping -c 1 192.0.2.2
324 pft_set_rules ${j}a \
325 "altq on ${epair}a priq bandwidth 10Mb queue { slow }" \
326 "queue slow priority 6 qlimit 50 priq ( default codel )" \
327 "altq on ${va} priq bandwidth 10Mb queue { vslow }" \
328 "queue vslow priority 6 qlimit 50 priq ( default codel )" \
331 atf_check -s exit:0 -o ignore \
332 jexec ${j}a ping -c 1 192.0.2.2
340 atf_init_test_cases()
342 atf_add_test_case "hfsc"
343 atf_add_test_case "match"
344 atf_add_test_case "cbq_vlan"
345 atf_add_test_case "codel_bridge"
346 atf_add_test_case "prioritise"
347 atf_add_test_case "codel_vlan"