From nobody Fri Oct 22 12:32:44 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D967218000BA; Fri, 22 Oct 2021 12:32:45 +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 4HbNzK4F2Zz4ZK2; Fri, 22 Oct 2021 12:32:45 +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 E22E76BA5; Fri, 22 Oct 2021 12:32:44 +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 19MCWitE038564; Fri, 22 Oct 2021 12:32:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19MCWij1038563; Fri, 22 Oct 2021 12:32:44 GMT (envelope-from git) Date: Fri, 22 Oct 2021 12:32:44 GMT Message-Id: <202110221232.19MCWij1038563@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: 9365113e89a5 - stable/13 - pf tests: ensure that $nr expansion is correct List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org 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: 9365113e89a52ce025d4097a5986e2228234f5ca Auto-Submitted: auto-generated X-Spam: Yes X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=9365113e89a52ce025d4097a5986e2228234f5ca commit 9365113e89a52ce025d4097a5986e2228234f5ca Author: Kristof Provost AuthorDate: 2021-10-03 16:07:04 +0000 Commit: Kristof Provost CommitDate: 2021-10-22 07:34:33 +0000 pf tests: ensure that $nr expansion is correct Test the $nr expansion in labels is correct, even if the optimiser reduces the rule count. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D32489 (cherry picked from commit 914ec9c78dcd5d8f77552fb93d3bc15efe9c0f40) --- tests/sys/netpfil/pf/Makefile | 1 + tests/sys/netpfil/pf/macro.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/tests/sys/netpfil/pf/Makefile b/tests/sys/netpfil/pf/Makefile index 2f9ce73f381b..246c267e7d2b 100644 --- a/tests/sys/netpfil/pf/Makefile +++ b/tests/sys/netpfil/pf/Makefile @@ -14,6 +14,7 @@ ATF_TESTS_SH+= altq \ get_state \ icmp \ killstate \ + macro \ map_e \ names \ nat \ diff --git a/tests/sys/netpfil/pf/macro.sh b/tests/sys/netpfil/pf/macro.sh new file mode 100644 index 000000000000..442677c9f946 --- /dev/null +++ b/tests/sys/netpfil/pf/macro.sh @@ -0,0 +1,40 @@ +. $(atf_get_srcdir)/utils.subr + +atf_test_case "nr" "cleanup" +nr_head() +{ + atf_set descr 'Test $nr expansion' + atf_set require.user root +} + +nr_body() +{ + # Ensure that when the optimiser collapses rules the macro expansion + # has the correct rule number + pft_init + + vnet_mkjail alcatraz + jexec alcatraz ifconfig lo0 inet 127.0.0.1/8 + jexec alcatraz ifconfig lo0 inet 127.0.0.2/32 alias + + pft_set_rules alcatraz \ + "pass quick on lo from lo:network to lo:network" \ + "block quick all label \"ruleNo:\$nr\"" + + no=$(jexec alcatraz pfctl -sr -vv | awk '/ruleNo/ { gsub("@", "", $1); print $1; }') + ruleno=$(jexec alcatraz pfctl -sr -vv | awk '/ruleNo/ { gsub(/"ruleNo:/, "", $7); gsub(/"/, "", $7); print $7; }') + if [ "${no}" -ne "${ruleno}" ]; + then + atf_fail "Expected ruleNo $no != $ruleno" + fi +} + +nr_cleanup() +{ + pft_cleanup +} + +atf_init_test_cases() +{ + atf_add_test_case "nr" +}