# SPDX-License-Identifier: BSD-2-Clause1#2# Copyright (c) 2022 Gleb Smirnoff <[email protected]>3# Copyright (c) 2022 Pavel Polyakov <[email protected]>4#5# Redistribution and use in source and binary forms, with or without6# modification, are permitted provided that the following conditions7# are met:8# 1. Redistributions of source code must retain the above copyright9# notice, this list of conditions and the following disclaimer.10# 2. Redistributions in binary form must reproduce the above copyright11# notice, this list of conditions and the following disclaimer in the12# documentation and/or other materials provided with the distribution.13#14# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND15# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE16# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE17# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF24# SUCH DAMAGE.2526. $(atf_get_srcdir)/../common/utils.subr2728atf_test_case "local" "cleanup"29local_head()30{31atf_set descr 'Test that fwd 127.0.0.1,port works'32atf_set require.user root33}3435local_body()36{37firewall_init "ipfw"3839epair=$(vnet_mkepair)40vnet_mkjail alcatraz ${epair}b4142ifconfig ${epair}a 192.0.2.0/31 up43route add 192.0.2.3/32 192.0.2.14445jexec alcatraz ifconfig lo0 127.0.0.1/8 up46jexec alcatraz ifconfig ${epair}b 192.0.2.1/31 up47jexec alcatraz route add default 192.0.2.048jexec alcatraz /usr/sbin/inetd -p /dev/null $(atf_get_srcdir)/fwd_inetd.conf4950firewall_config alcatraz ipfw ipfw \51"ipfw add 10 fwd 127.0.0.1,82 tcp from any to any dst-port 80 in via ${epair}b" \52"ipfw add 20 allow all from any to any"5354# Sanity check55atf_check -s exit:0 -o ignore ping -i .1 -c 3 -s 1200 192.0.2.15657reply=$(nc -nN 192.0.2.3 80 < /dev/null)58atf_check [ "${reply}" = "GOOD 82" ]59}6061local_cleanup()62{63firewall_cleanup $164}6566atf_init_test_cases()67{68atf_add_test_case "local"69}707172