git: d154dc21130b - main - pf tests: ensure that neighbour discovery works as expected

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Sun, 01 Sep 2024 15:06:09 UTC
The branch main has been updated by kp:

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

commit d154dc21130b607d7903f276dd6d463b990f33f7
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2024-08-26 13:02:22 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2024-09-01 15:05:28 +0000

    pf tests: ensure that neighbour discovery works as expected
    
    Also check repeated calls.
    
    MFC after:      1 week
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 tests/sys/netpfil/pf/icmp6.sh | 48 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/tests/sys/netpfil/pf/icmp6.sh b/tests/sys/netpfil/pf/icmp6.sh
index b9b60a484afc..eb286e23ef4c 100644
--- a/tests/sys/netpfil/pf/icmp6.sh
+++ b/tests/sys/netpfil/pf/icmp6.sh
@@ -149,8 +149,56 @@ ttl_exceeded_cleanup()
 	pft_cleanup
 }
 
+atf_test_case "repeat" "cleanup"
+repeat_head()
+{
+	atf_set descr 'Ensure that repeated NDs work'
+	atf_set require.user root
+	atf_set require.progs ndisc6
+}
+
+repeat_body()
+{
+	pft_init
+
+	epair=$(vnet_mkepair)
+	ifconfig ${epair}a inet6 2001:db8::2/64 up no_dad
+
+	vnet_mkjail alcatraz ${epair}b
+	jexec alcatraz ifconfig ${epair}b inet6 2001:db8::1/64 up no_dad
+
+	# Sanity check
+	atf_check -s exit:0 -o ignore \
+	    ping -c 1 2001:db8::1
+
+	jexec alcatraz pfctl -e
+	pft_set_rules alcatraz \
+		"block all" \
+		"pass quick inet6 proto ipv6-icmp all icmp6-type neighbrsol keep state (if-bound) ridentifier 1000000107"
+
+	jexec alcatraz pfctl -x loud
+	  ndisc6 -m -n -r 1 2001:db8::1 ${epair}a
+	jexec alcatraz pfctl -ss -vv
+
+	atf_check -s exit:0 -o ignore \
+	  ndisc6 -m -n -r 1 2001:db8::1 ${epair}a
+	jexec alcatraz pfctl -ss -vv
+	atf_check -s exit:0 -o ignore \
+	  ndisc6 -m -n -r 1 2001:db8::1 ${epair}a
+	jexec alcatraz pfctl -ss -vv
+	atf_check -s exit:0 -o ignore \
+	  ndisc6 -m -n -r 1 2001:db8::1 ${epair}a
+	jexec alcatraz pfctl -ss -vv
+}
+
+repeat_cleanup()
+{
+	pft_cleanup
+}
+
 atf_init_test_cases()
 {
 	atf_add_test_case "zero_id"
 	atf_add_test_case "ttl_exceeded"
+	atf_add_test_case "repeat"
 }