1# $FreeBSD$ 2 3. $(atf_get_srcdir)/utils.subr 4 5atf_test_case "synproxy" "cleanup" 6synproxy_head() 7{ 8 atf_set descr 'Basic synproxy test' 9 atf_set require.user root 10} 11 12synproxy_body() 13{ 14 atf_skip "Kernel panics when flushing epair queue (bug238870)" 15 pft_init 16 17 epair=$(vnet_mkepair) 18 ifconfig ${epair}a 192.0.2.1/24 up 19 route add -net 198.51.100.0/24 192.0.2.2 20 21 link=$(vnet_mkepair) 22 23 vnet_mkjail alcatraz ${epair}b ${link}a 24 jexec alcatraz ifconfig ${epair}b 192.0.2.2/24 up 25 jexec alcatraz ifconfig ${link}a 198.51.100.1/24 up 26 jexec alcatraz sysctl net.inet.ip.forwarding=1 27 28 vnet_mkjail singsing ${link}b 29 jexec singsing ifconfig ${link}b 198.51.100.2/24 up 30 jexec singsing route add default 198.51.100.1 31 32 jexec singsing /usr/sbin/inetd $(atf_get_srcdir)/echo_inetd.conf 33 34 jexec alcatraz pfctl -e 35 pft_set_rules alcatraz "set fail-policy return" \ 36 "scrub in all fragment reassemble" \ 37 "pass out quick on ${epair}b all no state allow-opts" \ 38 "pass in quick on ${epair}b proto tcp from any to any port 7 synproxy state" \ 39 "pass in quick on ${epair}b all no state" 40 41 # Sanity check, can we ping singing 42 atf_check -s exit:0 -o ignore ping -c 1 198.51.100.2 43 44 # Check that we can talk to the singsing jail, after synproxying 45 reply=$(echo ping | nc -N 198.51.100.2 7) 46 if [ "${reply}" != "ping" ]; 47 then 48 atf_fail "echo failed" 49 fi 50} 51 52synproxy_cleanup() 53{ 54 pft_cleanup 55} 56 57atf_init_test_cases() 58{ 59 atf_add_test_case "synproxy" 60} 61