Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 31 Jul 2021 13:03:55 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: c1bb4edaa06d - stable/13 - pf tests: Test the match keyword
Message-ID:  <202107311303.16VD3tSj066558@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=c1bb4edaa06dd1d8d81fadc9b6aa6d87693976b9

commit c1bb4edaa06dd1d8d81fadc9b6aa6d87693976b9
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2021-03-02 15:57:27 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2021-07-31 08:12:02 +0000

    pf tests: Test the match keyword
    
    The new match keyword can currently only assign queues, so we can only
    test it with ALTQ.
    Set up a basic scenario where we use 'match' to assign ICMP traffic to a
    slow queue, and confirm that it's really getting slowed down.
    
    MFC after:      2 weeks
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D31116
    
    (cherry picked from commit d363ebc78cbb50bc334d74fb5bb755af53c69ff0)
---
 tests/sys/netpfil/pf/altq.sh | 45 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/tests/sys/netpfil/pf/altq.sh b/tests/sys/netpfil/pf/altq.sh
index 89da4c0deb6f..294c01e9f8bd 100644
--- a/tests/sys/netpfil/pf/altq.sh
+++ b/tests/sys/netpfil/pf/altq.sh
@@ -42,8 +42,53 @@ hfsc_cleanup()
 	altq_cleanup
 }
 
+atf_test_case "match" "cleanup"
+match_head()
+{
+	atf_set descr 'Basic match keyword test'
+	atf_set require.user root
+}
+
+match_body()
+{
+	altq_init
+	is_altq_supported hfsc
+
+	epair=$(vnet_mkepair)
+	vnet_mkjail altq_match ${epair}b
+
+	ifconfig ${epair}a 192.0.2.1/24 up
+	jexec altq_match 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_match pfctl -e
+	pft_set_rules altq_match \
+	    "altq on ${epair}b bandwidth 100000000b hfsc queue { default, slow }" \
+	    "queue default hfsc(default linkshare 80000000b)" \
+	    "queue slow hfsc(linkshare 80b upperlimit 80b)" \
+	    "match proto icmp queue slow" \
+	    "pass"
+
+	# 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
+}
+
+match_cleanup()
+{
+	altq_cleanup
+}
+
 atf_init_test_cases()
 {
 	atf_add_test_case "hfsc"
+	atf_add_test_case "match"
 }
 



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