From b0bf4303109a76eb4224015b9abebf88e96116ef Mon Sep 17 00:00:00 2001 From: Kristof Provost Date: Mon, 31 Oct 2022 12:15:58 +0100 Subject: [PATCH] pf tests: verify syncookie status report Verify that pfctl -si -v correctly shows syncookies to be active/inactive. Sponsored by: Rubicon Communications, LLC ("Netgate") --- tests/sys/netpfil/pf/syncookie.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/sys/netpfil/pf/syncookie.sh b/tests/sys/netpfil/pf/syncookie.sh index 36d80b82289b..9ef20fad4554 100644 --- a/tests/sys/netpfil/pf/syncookie.sh +++ b/tests/sys/netpfil/pf/syncookie.sh @@ -29,6 +29,14 @@ common_dir=$(atf_get_srcdir)/../common +syncookie_state() +{ + jail=$1 + + jexec $jail pfctl -si -v | grep -A 2 '^Syncookies' | grep active \ + | awk '{ print($2); }' +} + atf_test_case "basic" "cleanup" basic_head() { @@ -63,6 +71,14 @@ basic_body() then atf_fail "Failed to connect to syncookie protected echo daemon" fi + + + # Check that status shows syncookies as being active + active=$(syncookie_state alcatraz) + if [ "$active" != "active" ]; + then + atf_fail "syncookies not active" + fi } basic_cleanup() @@ -196,12 +212,26 @@ adaptive_body() # Sanity check atf_check -s exit:0 -o ignore ping -c 1 192.0.2.1 + # Check that status shows syncookies as being inactive + active=$(syncookie_state alcatraz) + if [ "$active" != "inactive" ]; + then + atf_fail "syncookies active when they should not be" + fi + # Now syn flood to create many states ${common_dir}/pft_synflood.py \ --sendif ${epair}a \ --to 192.0.2.2 \ --count 100 + # Check that status shows syncookies as being active + active=$(syncookie_state alcatraz) + if [ "$active" != "active" ]; + then + atf_fail "syncookies not active" + fi + # Adaptive mode should kick in and stop us from creating more than # about 10 states states=$(jexec alcatraz pfctl -ss | grep tcp | wc -l)