The branch main has been updated by kp:

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

commit 27ab791a55191c0b6503391d411303b042b41047
Author:     Kristof Provost <[email protected]>
AuthorDate: 2021-06-30 13:27:46 +0000
Commit:     Kristof Provost <[email protected]>
CommitDate: 2021-07-20 08:36:14 +0000

    pf tests: ensure syncookie does not create state
    
    Test that with syncookies enabled pf does not create state for
    connections before the remote peer has replied to the SYN|ACK message.
    
    MFC after:      1 week
    Sponsored by:   Modirum MDPay
    Differential Revision:  https://reviews.freebsd.org/D31142
---
 tests/sys/netpfil/pf/syncookie.sh | 49 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/tests/sys/netpfil/pf/syncookie.sh 
b/tests/sys/netpfil/pf/syncookie.sh
index 7bd045249be6..49acd9fab11d 100644
--- a/tests/sys/netpfil/pf/syncookie.sh
+++ b/tests/sys/netpfil/pf/syncookie.sh
@@ -27,6 +27,8 @@
 
 . $(atf_get_srcdir)/utils.subr
 
+common_dir=$(atf_get_srcdir)/../common
+
 atf_test_case "forward" "cleanup"
 forward_head()
 {
@@ -78,7 +80,54 @@ forward_cleanup()
        pft_cleanup
 }
 
+atf_test_case "nostate" "cleanup"
+nostate_head()
+{
+       atf_set descr 'Ensure that we do not create until SYN|ACK'
+       atf_set require.user root
+       atf_set require.progs scapy
+}
+
+nostate_body()
+{
+       pft_init
+
+       epair=$(vnet_mkepair)
+       ifconfig ${epair}a 192.0.2.2/24 up
+
+       vnet_mkjail alcatraz ${epair}b
+       jexec alcatraz ifconfig ${epair}b 192.0.2.1/24 up
+
+       jexec alcatraz pfctl -e
+       pft_set_rules alcatraz \
+               "set syncookies always" \
+               "pass in" \
+               "pass out"
+
+       # Sanity check
+       atf_check -s exit:0 -o ignore ping -c 1 192.0.2.1
+
+       # Now syn flood to create many states
+       ${common_dir}/pft_synflood.py \
+               --sendif ${epair}a \
+               --to 192.0.2.2 \
+               --count 20
+
+       states=$(jexec alcatraz pfctl -ss | grep tcp)
+       if [ -n "$states" ];
+       then
+               echo "$states"
+               atf_fail "Found unexpected state"
+       fi
+}
+
+nostate_cleanup()
+{
+       pft_cleanup
+}
+
 atf_init_test_cases()
 {
        atf_add_test_case "forward"
+       atf_add_test_case "nostate"
 }
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to