From owner-dev-commits-src-branches@freebsd.org Wed Sep 1 13:28:33 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 68BA366A6F0; Wed, 1 Sep 2021 13:28:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4H04dD5zkzz3QmQ; Wed, 1 Sep 2021 13:28:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A1D562584F; Wed, 1 Sep 2021 13:28:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 181DSWTs047690; Wed, 1 Sep 2021 13:28:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 181DSW02047689; Wed, 1 Sep 2021 13:28:32 GMT (envelope-from git) Date: Wed, 1 Sep 2021 13:28:32 GMT Message-Id: <202109011328.181DSW02047689@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 4defcd907832 - stable/13 - pf tests: ALTQ priority test MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 4defcd9078323b0b01536d1cfe628ad484c1aeb0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Sep 2021 13:28:34 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=4defcd9078323b0b01536d1cfe628ad484c1aeb0 commit 4defcd9078323b0b01536d1cfe628ad484c1aeb0 Author: Kristof Provost AuthorDate: 2021-08-26 08:25:57 +0000 Commit: Kristof Provost CommitDate: 2021-09-01 13:27:01 +0000 pf tests: ALTQ priority test Test that ALTQ can prioritise one type of traffic over another. Do this by establishing a slow link and saturating it with ICMP echos. When prioritised TCP connections reliably go through. When not prioritised TCP connections reliably fail. MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit cd46399b9ccf04f6ec00a532e52c8b1edb007af7) --- tests/sys/netpfil/pf/altq.sh | 94 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 93 insertions(+), 1 deletion(-) diff --git a/tests/sys/netpfil/pf/altq.sh b/tests/sys/netpfil/pf/altq.sh index 53cf10e47565..ebb28f34c22e 100644 --- a/tests/sys/netpfil/pf/altq.sh +++ b/tests/sys/netpfil/pf/altq.sh @@ -145,10 +145,102 @@ cbq_vlan_cleanup() altq_cleanup } +atf_test_case "prioritise" "cleanup" +prioritise_head() +{ + atf_set descr "Test prioritising one type of traffic over the other" + atf_set require.user root +} + +prioritise_body() +{ + altq_init + is_altq_supported cbq + + epair=$(vnet_mkepair) + vnet_mkjail altq_prioritise ${epair}b + + ifconfig ${epair}a 192.0.2.1/24 up + jexec altq_prioritise ifconfig ${epair}b 192.0.2.2/24 up + + jexec altq_prioritise /usr/sbin/inetd -p inetd-altq.pid \ + $(atf_get_srcdir)/../pf/echo_inetd.conf + + # Sanity check + atf_check -s exit:0 -o ignore ping -i .1 -c 3 -s 1200 192.0.2.2 + + jexec altq_prioritise pfctl -e + pft_set_rules altq_prioritise \ + "altq on ${epair}b bandwidth 6000b cbq queue { default, slow }" \ + "queue default priority 7 cbq(default)" \ + "queue slow priority 1 cbq" \ + "match proto icmp queue slow" \ + "match proto tcp queue default" \ + "pass" + + # single ping succeeds just fine + atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2 + + # Unsaturated TCP succeeds + reply=$(echo "foo" | nc -w 5 -N 192.0.2.2 7) + if [ "$reply" != "foo" ]; + then + atf_fail "Unsaturated echo failed" + fi + + # "Saturate the link" + ping -i .01 -c 50 -s 1200 192.0.2.2 + + # We should now be hitting the limits and get these packet dropped. + rcv=$(ping -i .1 -c 5 -s 1200 192.0.2.2 | tr "," "\n" | awk '/packets received/ { print $1; }') + echo "Received $rcv packets" + if [ ${rcv} -gt 1 ] + then + atf_fail "Received ${rcv} packets in a saturated link" + fi + + # TCP should still pass + for i in `seq 1 10` + do + reply=$(echo "foo_${i}" | nc -w 5 -N 192.0.2.2 7) + if [ "$reply" != "foo_${i}" ]; + then + atf_fail "Prioritised echo failed ${i}" + fi + + done + + # Now reverse priority + pft_set_rules altq_prioritise \ + "altq on ${epair}b bandwidth 6000b cbq queue { default, slow }" \ + "queue default priority 7 cbq(default)" \ + "queue slow priority 1 cbq" \ + "match proto tcp queue slow" \ + "match proto icmp queue default" \ + "pass" + + atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2 + ping -i .01 -c 50 -s 1200 192.0.2.2 + for i in `seq 1 10` + do + reply=$(echo "foo_${i}" | nc -w 5 -N 192.0.2.2 7) + if [ "$reply" == "foo_${i}" ]; + then + atf_fail "Unexpected echo success" + fi + + done +} + +prioritise_cleanup() +{ + altq_cleanup +} + atf_init_test_cases() { atf_add_test_case "hfsc" atf_add_test_case "match" atf_add_test_case "cbq_vlan" + atf_add_test_case "prioritise" } -