git: d58d2e403db4 - main - pf tests: Test setting and retrieving nested anchors

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Thu, 17 Mar 2022 21:38:40 UTC
The branch main has been updated by kp:

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

commit d58d2e403db48acac7c8459652e9cb19546ab15b
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2022-03-17 18:49:09 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2022-03-17 21:37:06 +0000

    pf tests: Test setting and retrieving nested anchors
    
    MFC after:      1 week
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 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 100644
--- 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"
 }