git: 146681af729c - stable/13 - pf tests: Test setting and retrieving nested anchors

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

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

commit 146681af729c09c1edac3acdcdf7a8b7a0a4fad9
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:40 +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 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"
 }