3 . $(atf_get_srcdir)/utils.subr
5 atf_test_case "exhaust" "cleanup"
8 atf_set descr 'Test exhausting the NAT pool'
9 atf_set require.user root
16 epair_nat=$(vnet_mkepair)
17 epair_echo=$(vnet_mkepair)
19 vnet_mkjail nat ${epair_nat}b ${epair_echo}a
20 vnet_mkjail echo ${epair_echo}b
22 ifconfig ${epair_nat}a 192.0.2.2/24 up
23 route add -net 198.51.100.0/24 192.0.2.1
25 jexec nat ifconfig ${epair_nat}b 192.0.2.1/24 up
26 jexec nat ifconfig ${epair_echo}a 198.51.100.1/24 up
27 jexec nat sysctl net.inet.ip.forwarding=1
29 jexec echo ifconfig ${epair_echo}b 198.51.100.2/24 up
30 jexec echo /usr/sbin/inetd $(atf_get_srcdir)/echo_inetd.conf
35 "nat pass on ${epair_echo}a inet from 192.0.2.0/24 to any -> (${epair_echo}a) port 30000:30001 sticky-address"
38 atf_check -s exit:0 -o ignore ping -c 3 198.51.100.2
40 echo "foo" | nc -N 198.51.100.2 7
41 echo "foo" | nc -N 198.51.100.2 7
43 # This one will fail, but that's expected
44 echo "foo" | nc -N 198.51.100.2 7 &
48 # If the kernel is stuck in pf_get_sport() this will not succeed either.
49 timeout 2 jexec nat pfctl -sa
50 if [ $? -eq 124 ]; then
52 atf_fail "pfctl timeout"
63 atf_add_test_case "exhaust"