Date: Fri, 7 May 2021 20:14:04 GMT From: Kristof Provost <kp@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: ac200a9c3847 - main - pf tests: Test killing matching states Message-ID: <202105072014.147KE4xp012877@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=ac200a9c3847d3a92c347de60e32a7af430dede6 commit ac200a9c3847d3a92c347de60e32a7af430dede6 Author: Kristof Provost <kp@FreeBSD.org> AuthorDate: 2021-05-03 13:31:03 +0000 Commit: Kristof Provost <kp@FreeBSD.org> CommitDate: 2021-05-07 20:13:31 +0000 pf tests: Test killing matching states MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30093 --- tests/sys/netpfil/pf/killstate.sh | 71 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/tests/sys/netpfil/pf/killstate.sh b/tests/sys/netpfil/pf/killstate.sh index 4ec1adf0d051..ec01910f0867 100644 --- a/tests/sys/netpfil/pf/killstate.sh +++ b/tests/sys/netpfil/pf/killstate.sh @@ -377,6 +377,76 @@ gateway_cleanup() pft_cleanup } +atf_test_case "match" "cleanup" +match_head() +{ + atf_set descr 'Test killing matching states' + atf_set require.user root +} + +match_body() +{ + pft_init + + epair_one=$(vnet_mkepair) + ifconfig ${epair_one}a 192.0.2.1/24 up + + epair_two=$(vnet_mkepair) + + vnet_mkjail alcatraz ${epair_one}b ${epair_two}a + jexec alcatraz ifconfig ${epair_one}b 192.0.2.2/24 up + jexec alcatraz ifconfig ${epair_two}a 198.51.100.1/24 up + jexec alcatraz sysctl net.inet.ip.forwarding=1 + jexec alcatraz pfctl -e + + vnet_mkjail singsing ${epair_two}b + jexec singsing ifconfig ${epair_two}b 198.51.100.2/24 up + jexec singsing route add default 198.51.100.1 + jexec singsing /usr/sbin/inetd -p inetd-echo.pid \ + $(atf_get_srcdir)/echo_inetd.conf + + route add 198.51.100.0/24 192.0.2.2 + + pft_set_rules alcatraz \ + "nat on ${epair_two}a from 192.0.2.0/24 -> (${epair_two}a)" \ + "pass all" + + nc 198.51.100.2 7 & + + # Expect two states + states=$(jexec alcatraz pfctl -s s | wc -l) + if [ $states -ne 2 ] ; + then + atf_fail "Expected two states, found $states" + fi + + # If we don't kill the matching NAT state one should be left + jexec alcatraz pfctl -k 192.0.2.1 + states=$(jexec alcatraz pfctl -s s | wc -l) + if [ $states -ne 1 ] ; + then + atf_fail "Expected one states, found $states" + fi + + # Flush + jexec alcatraz pfctl -F states + + nc 198.51.100.2 7 & + + # Kill matching states, expect all of them to be gone + jexec alcatraz pfctl -M -k 192.0.2.1 + states=$(jexec alcatraz pfctl -s s | wc -l) + if [ $states -ne 0 ] ; + then + atf_fail "Expected zero states, found $states" + fi +} + +match_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "v4" @@ -384,4 +454,5 @@ atf_init_test_cases() atf_add_test_case "label" atf_add_test_case "multilabel" atf_add_test_case "gateway" + atf_add_test_case "match" }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105072014.147KE4xp012877>