Changeset View
Changeset View
Standalone View
Standalone View
tests/sys/netpfil/pf/syncookie.sh
Show All 23 Lines | |||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
# SUCH DAMAGE. | # SUCH DAMAGE. | ||||
. $(atf_get_srcdir)/utils.subr | . $(atf_get_srcdir)/utils.subr | ||||
common_dir=$(atf_get_srcdir)/../common | common_dir=$(atf_get_srcdir)/../common | ||||
atf_test_case "basic" "cleanup" | |||||
basic_head() | |||||
{ | |||||
atf_set descr 'Basic syncookie test' | |||||
atf_set require.user root | |||||
} | |||||
basic_body() | |||||
{ | |||||
pft_init | |||||
epair=$(vnet_mkepair) | |||||
vnet_mkjail alcatraz ${epair}b | |||||
jexec alcatraz ifconfig ${epair}b 192.0.2.1/24 up | |||||
jexec alcatraz /usr/sbin/inetd -p inetd-alcatraz.pid \ | |||||
$(atf_get_srcdir)/echo_inetd.conf | |||||
ifconfig ${epair}a 192.0.2.2/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 | |||||
reply=$(echo foo | nc -N -w 5 192.0.2.1 7) | |||||
if [ "${reply}" != "foo" ]; | |||||
then | |||||
atf_fail "Failed to connect to syncookie protected echo daemon" | |||||
fi | |||||
} | |||||
basic_cleanup() | |||||
{ | |||||
rm -f inetd-alcatraz.pid | |||||
pft_cleanup | |||||
} | |||||
atf_test_case "forward" "cleanup" | atf_test_case "forward" "cleanup" | ||||
forward_head() | forward_head() | ||||
{ | { | ||||
atf_set descr 'Syncookies for forwarded hosts' | atf_set descr 'Syncookies for forwarded hosts' | ||||
atf_set require.user root | atf_set require.user root | ||||
} | } | ||||
forward_body() | forward_body() | ||||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | |||||
nostate_cleanup() | nostate_cleanup() | ||||
{ | { | ||||
pft_cleanup | pft_cleanup | ||||
} | } | ||||
atf_init_test_cases() | atf_init_test_cases() | ||||
{ | { | ||||
atf_add_test_case "basic" | |||||
atf_add_test_case "forward" | atf_add_test_case "forward" | ||||
atf_add_test_case "nostate" | atf_add_test_case "nostate" | ||||
} | } |