aboutsummaryrefslogtreecommitdiff
path: root/tests/sys/netpfil/pf
diff options
context:
space:
mode:
authorKristof Provost <kp@FreeBSD.org>2021-04-16 15:47:47 +0000
committerKristof Provost <kp@FreeBSD.org>2021-04-20 07:30:39 +0000
commit9af2317423f399b30ff028e078d01eef553efc7f (patch)
treed3f7ca3306f60834f2dbaa686de90649a480eeee /tests/sys/netpfil/pf
parent065b5c7fb26eb4239e9bd513dde5a55ef78e45c4 (diff)
downloadsrc-9af2317423f399b30ff028e078d01eef553efc7f.tar.gz
src-9af2317423f399b30ff028e078d01eef553efc7f.zip
pf tests: IPv6 test case for the 'kill state(s)' feature
Reviewed by: donner MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D29797
Diffstat (limited to 'tests/sys/netpfil/pf')
-rw-r--r--tests/sys/netpfil/pf/killstate.sh73
1 files changed, 73 insertions, 0 deletions
diff --git a/tests/sys/netpfil/pf/killstate.sh b/tests/sys/netpfil/pf/killstate.sh
index 994ce130a814..d54858d5452c 100644
--- a/tests/sys/netpfil/pf/killstate.sh
+++ b/tests/sys/netpfil/pf/killstate.sh
@@ -101,6 +101,78 @@ v4_cleanup()
pft_cleanup
}
+atf_test_case "v6" "cleanup"
+v6_head()
+{
+ atf_set descr 'Test killing states by IPv6 address'
+ atf_set require.user root
+ atf_set require.progs scapy
+}
+
+v6_body()
+{
+ pft_init
+
+ epair=$(vnet_mkepair)
+ ifconfig ${epair}a inet6 2001:db8::1/64 up no_dad
+
+ vnet_mkjail alcatraz ${epair}b
+ jexec alcatraz ifconfig ${epair}b inet6 2001:db8::2/64 up no_dad
+ jexec alcatraz pfctl -e
+
+ pft_set_rules alcatraz "block all" \
+ "pass in proto icmp6"
+
+ # Sanity check & establish state
+ # Note: use pft_ping so we always use the same ID, so pf considers all
+ # echo requests part of the same flow.
+ atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \
+ --ip6 \
+ --sendif ${epair}a \
+ --to 2001:db8::2 \
+ --replyif ${epair}a
+
+ # Change rules to now deny the ICMP traffic
+ pft_set_rules noflush alcatraz "block all"
+
+ # Established state means we can still ping alcatraz
+ atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \
+ --ip6 \
+ --sendif ${epair}a \
+ --to 2001:db8::2 \
+ --replyif ${epair}a
+
+ # Killing with the wrong IP doesn't affect our state
+ jexec alcatraz pfctl -k 2001:db8::3
+ atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \
+ --ip6 \
+ --sendif ${epair}a \
+ --to 2001:db8::2 \
+ --replyif ${epair}a
+
+ # Killing with one correct address and one incorrect doesn't kill the state
+ jexec alcatraz pfctl -k 2001:db8::1 -k 2001:db8::3
+ atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \
+ --ip6 \
+ --sendif ${epair}a \
+ --to 2001:db8::2 \
+ --replyif ${epair}a
+
+ # Killing with correct address does remove the state
+ jexec alcatraz pfctl -k 2001:db8::1
+ atf_check -s exit:1 -o ignore ${common_dir}/pft_ping.py \
+ --ip6 \
+ --sendif ${epair}a \
+ --to 2001:db8::2 \
+ --replyif ${epair}a
+
+}
+
+v6_cleanup()
+{
+ pft_cleanup
+}
+
atf_test_case "label" "cleanup"
label_head()
{
@@ -171,5 +243,6 @@ label_cleanup()
atf_init_test_cases()
{
atf_add_test_case "v4"
+ atf_add_test_case "v6"
atf_add_test_case "label"
}