1. $(atf_get_srcdir)/utils.subr 2 3atf_test_case "hfsc" "cleanup" 4hfsc_head() 5{ 6 atf_set descr 'Basic HFSC test' 7 atf_set require.user root 8} 9 10hfsc_body() 11{ 12 altq_init 13 is_altq_supported hfsc 14 15 epair=$(vnet_mkepair) 16 vnet_mkjail altq_hfsc ${epair}b 17 18 ifconfig ${epair}a 192.0.2.1/24 up 19 jexec altq_hfsc ifconfig ${epair}b 192.0.2.2/24 up 20 21 # Sanity check 22 atf_check -s exit:0 -o ignore ping -i .1 -c 3 -s 1200 192.0.2.2 23 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)" \ 28 "pass proto icmp " 29 30 # single ping succeeds just fine 31 atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2 32 33 # "Saturate the link" 34 ping -i .1 -c 5 -s 1200 192.0.2.2 35 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 38} 39 40hfsc_cleanup() 41{ 42 altq_cleanup 43} 44 45atf_test_case "match" "cleanup" 46match_head() 47{ 48 atf_set descr 'Basic match keyword test' 49 atf_set require.user root 50} 51 52match_body() 53{ 54 altq_init 55 is_altq_supported hfsc 56 57 epair=$(vnet_mkepair) 58 vnet_mkjail altq_match ${epair}b 59 60 ifconfig ${epair}a 192.0.2.1/24 up 61 jexec altq_match ifconfig ${epair}b 192.0.2.2/24 up 62 63 # Sanity check 64 atf_check -s exit:0 -o ignore ping -i .1 -c 3 -s 1200 192.0.2.2 65 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" \ 72 "pass" 73 74 # single ping succeeds just fine 75 atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2 76 77 # "Saturate the link" 78 ping -i .1 -c 5 -s 1200 192.0.2.2 79 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 82} 83 84match_cleanup() 85{ 86 altq_cleanup 87} 88 89atf_init_test_cases() 90{ 91 atf_add_test_case "hfsc" 92 atf_add_test_case "match" 93} 94 95