Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 31 Jul 2021 13:03:53 GMT
From:      Kristof Provost <kp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 2400173b9377 - stable/13 - altq tests: Basic ALTQ test
Message-ID:  <202107311303.16VD3rhq066460@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=2400173b937739966d2bf0cc305c564243074cc9

commit 2400173b937739966d2bf0cc305c564243074cc9
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2021-01-23 09:37:03 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2021-07-31 08:12:02 +0000

    altq tests: Basic ALTQ test
    
    Activate ALTQ_HFSC, crudely check if it really limits bandwidth as we'd expect.
    
    Reviewed by:            donner@
    Differential Revision:  https://reviews.freebsd.org/D28303
    
    (cherry picked from commit 16b3833344ad04194f10b567bc6fae829a52a850)
---
 tests/sys/netpfil/pf/Makefile   |  3 ++-
 tests/sys/netpfil/pf/altq.sh    | 49 +++++++++++++++++++++++++++++++++++++++++
 tests/sys/netpfil/pf/utils.subr | 24 ++++++++++++++++++++
 3 files changed, 75 insertions(+), 1 deletion(-)

diff --git a/tests/sys/netpfil/pf/Makefile b/tests/sys/netpfil/pf/Makefile
index cfa5f5c7c912..2f9ce73f381b 100644
--- a/tests/sys/netpfil/pf/Makefile
+++ b/tests/sys/netpfil/pf/Makefile
@@ -5,7 +5,8 @@ PACKAGE=	tests
 TESTSDIR=       ${TESTSBASE}/sys/netpfil/pf
 TESTS_SUBDIRS+=	ioctl
 
-ATF_TESTS_SH+=	anchor \
+ATF_TESTS_SH+=	altq \
+		anchor \
 		checksum \
 		dup \
 		forward \
diff --git a/tests/sys/netpfil/pf/altq.sh b/tests/sys/netpfil/pf/altq.sh
new file mode 100644
index 000000000000..89da4c0deb6f
--- /dev/null
+++ b/tests/sys/netpfil/pf/altq.sh
@@ -0,0 +1,49 @@
+. $(atf_get_srcdir)/utils.subr
+
+atf_test_case "hfsc" "cleanup"
+hfsc_head()
+{
+	atf_set descr 'Basic HFSC test'
+	atf_set require.user root
+}
+
+hfsc_body()
+{
+	altq_init
+	is_altq_supported hfsc
+
+	epair=$(vnet_mkepair)
+	vnet_mkjail altq_hfsc ${epair}b
+
+	ifconfig ${epair}a 192.0.2.1/24 up
+	jexec altq_hfsc ifconfig ${epair}b 192.0.2.2/24 up
+
+	# Sanity check
+	atf_check -s exit:0 -o ignore ping -i .1 -c 3 -s 1200 192.0.2.2
+
+	jexec altq_hfsc pfctl -e
+	pft_set_rules altq_hfsc \
+	    "altq on ${epair}b bandwidth 100b hfsc queue { default }" \
+	    "queue default hfsc(default linkshare 80b)" \
+	    "pass proto icmp "
+
+	# single ping succeeds just fine
+	atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2
+
+	# "Saturate the link"
+	ping -i .1 -c 5 -s 1200 192.0.2.2
+
+	# We should now be hitting the limits and get this packet dropped.
+	atf_check -s exit:2 -o ignore ping -c 1 -s 1200 192.0.2.2
+}
+
+hfsc_cleanup()
+{
+	altq_cleanup
+}
+
+atf_init_test_cases()
+{
+	atf_add_test_case "hfsc"
+}
+
diff --git a/tests/sys/netpfil/pf/utils.subr b/tests/sys/netpfil/pf/utils.subr
index 62e85d5cc463..d7df2a6747da 100644
--- a/tests/sys/netpfil/pf/utils.subr
+++ b/tests/sys/netpfil/pf/utils.subr
@@ -79,3 +79,27 @@ pfsynct_cleanup()
 {
 	pft_cleanup
 }
+
+is_altq_supported()
+{
+	sysctl -q kern.features.altq >/dev/null || \
+	    atf_skip "Test requires ALTQ"
+
+	while [ -n "$1" ]
+	do
+		sysctl -q kern.features.altq.${1} >/dev/null || \
+		    atf_skip "Test required ALTQ_${1}"
+		shift
+	done
+}
+
+altq_init()
+{
+	pft_init
+	is_altq_supported
+}
+
+altq_cleanup()
+{
+	pft_cleanup
+}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202107311303.16VD3rhq066460>