git: 5aaceccdb23b - stable/12 - pf tests: Test setting and retrieving nested anchors

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Thu, 24 Mar 2022 13:14:39 UTC
The branch stable/12 has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=5aaceccdb23b35588133ee329c08bc3e518aafb7

commit 5aaceccdb23b35588133ee329c08bc3e518aafb7
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2022-03-17 18:49:09 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2022-03-24 09:44:41 +0000

    pf tests: Test setting and retrieving nested anchors
    
    MFC after:      1 week
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    
    (cherry picked from commit d58d2e403db48acac7c8459652e9cb19546ab15b)
---
 tests/sys/netpfil/pf/anchor.sh | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/tests/sys/netpfil/pf/anchor.sh b/tests/sys/netpfil/pf/anchor.sh
index 7427c07dd17b..4fd3697155d9 100755
--- a/tests/sys/netpfil/pf/anchor.sh
+++ b/tests/sys/netpfil/pf/anchor.sh
@@ -59,7 +59,42 @@ pr183198_cleanup()
 	pft_cleanup
 }
 
+atf_test_case "nested_anchor" "cleanup"
+nested_anchor_head()
+{
+	atf_set descr 'Test setting and retrieving nested anchors'
+	atf_set require.user root
+}
+
+nested_anchor_body()
+{
+	pft_init
+
+	epair=$(vnet_mkepair)
+	vnet_mkjail alcatraz ${epair}a
+
+	pft_set_rules alcatraz \
+		"anchor \"foo\" { \n\
+			anchor \"bar\" { \n\
+				pass on ${epair}a \n\
+			} \n\
+		}"
+
+	atf_check -s exit:0 -o inline:"anchor \"foo\" all {
+  anchor \"bar\" all {
+    pass on ${epair}a all flags S/SA keep state
+  }
+}
+" jexec alcatraz pfctl -sr -a "*"
+}
+
+nested_anchor_cleanup()
+{
+	pft_cleanup
+}
+
 atf_init_test_cases()
 {
 	atf_add_test_case "pr183198"
+	atf_add_test_case "nested_anchor"
 }