Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F110675982
D32484.id96853.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D32484.id96853.diff
View Options
Index: tests/sys/netpfil/pf/Makefile
===================================================================
--- tests/sys/netpfil/pf/Makefile
+++ tests/sys/netpfil/pf/Makefile
@@ -35,6 +35,7 @@
${PACKAGE}FILES+= CVE-2019-5597.py \
CVE-2019-5598.py \
+ daytime_inetd.conf \
echo_inetd.conf \
fragcommon.py \
frag-overindex.py \
Index: tests/sys/netpfil/pf/daytime_inetd.conf
===================================================================
--- /dev/null
+++ tests/sys/netpfil/pf/daytime_inetd.conf
@@ -0,0 +1,31 @@
+# $FreeBSD$
+#
+# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+#
+# Copyright (c) 2021 Kristof Provost <kp@FreeBSD.org>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# 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
+# SUCH DAMAGE.
+
+daytime stream tcp nowait root internal
+daytime stream tcp6 nowait root internal
+daytime dgram udp wait root internal
+daytime dgram udp6 wait root internal
Index: tests/sys/netpfil/pf/ether.sh
===================================================================
--- tests/sys/netpfil/pf/ether.sh
+++ tests/sys/netpfil/pf/ether.sh
@@ -295,6 +295,82 @@
pft_cleanup
}
+atf_test_case "captive_long" "cleanup"
+captive_long_head()
+{
+ atf_set descr 'More complex captive portal setup'
+ atf_set require.user root
+}
+
+captive_long_body()
+{
+ # Host is client, jail 'gw' is the captive portal gateway, jail 'srv'
+ # is a random (web)server. We use the echo protocol rather than http
+ # for the test, because that's easier.
+ pft_init
+
+ epair_gw=$(vnet_mkepair)
+ epair_srv=$(vnet_mkepair)
+ epair_gw_a_mac=$(ifconfig ${epair_gw}a ether | awk '/ether/ { print $2; }')
+
+ vnet_mkjail gw ${epair_gw}b ${epair_srv}a
+ vnet_mkjail srv ${epair_srv}b
+
+ ifconfig ${epair_gw}a 192.0.2.2/24 up
+ route add -net 198.51.100.0/24 192.0.2.1
+ jexec gw ifconfig ${epair_gw}b 192.0.2.1/24 up
+ jexec gw ifconfig lo0 127.0.0.1/8 up
+ jexec gw sysctl net.inet.ip.forwarding=1
+
+ jexec gw ifconfig ${epair_srv}a 198.51.100.1/24 up
+ jexec srv ifconfig ${epair_srv}b 198.51.100.2/24 up
+ jexec srv route add -net 192.0.2.0/24 198.51.100.1
+
+ jexec gw dnctl pipe 1 config bw 300KByte/s
+
+ # Sanity check
+ atf_check -s exit:0 -o ignore ping -c 1 -t 1 198.51.100.2
+
+ pft_set_rules gw \
+ "ether anchor \"captiveportal\" on { ${epair_gw}b } {" \
+ "ether pass quick proto { 0x0806, 0x8035, 0x888e, 0x88c7, 0x8863, 0x8864 }" \
+ "ether pass tag \"captive\"" \
+ "}" \
+ "rdr on ${epair_gw}b proto tcp to port daytime tagged captive -> 127.0.0.1 port echo"
+ jexec gw pfctl -e
+
+ # ICMP should still work, because we don't redirect it.
+ atf_check -s exit:0 -o ignore ping -c 1 -t 1 198.51.100.2
+
+ jexec gw /usr/sbin/inetd -p gw.pid $(atf_get_srcdir)/echo_inetd.conf
+ jexec srv /usr/sbin/inetd -p srv.pid $(atf_get_srcdir)/daytime_inetd.conf
+
+ echo foo | nc -N 198.51.100.2 13
+
+ # Confirm that we're getting redirected
+ atf_check -s exit:0 -o match:"^foo$" -x "echo foo | nc -N 198.51.100.2 13"
+
+ # Now update the rules to allow our client to pass without redirect
+ pft_set_rules gw \
+ "ether anchor \"captiveportal\" on { ${epair_gw}b } {" \
+ "ether pass quick proto { 0x0806, 0x8035, 0x888e, 0x88c7, 0x8863, 0x8864 }" \
+ "ether pass quick from { ${epair_gw_a_mac} } dnpipe 1" \
+ "ether pass tag \"captive\"" \
+ "}" \
+ "rdr on ${epair_gw}b proto tcp to port daytime tagged captive -> 127.0.0.1 port echo"
+
+ # We're not being redirected and get datime information now
+ atf_check -s exit:0 -o match:"^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)" -x "echo foo | nc -N 198.51.100.2 13"
+
+ jexec gw killall inetd
+ jexec srv killall inetd
+}
+
+captive_long_cleanup()
+{
+ pft_cleanup
+}
+
atf_test_case "dummynet" "cleanup"
dummynet_head()
{
@@ -404,6 +480,7 @@
atf_add_test_case "proto"
atf_add_test_case "direction"
atf_add_test_case "captive"
+ atf_add_test_case "captive_long"
atf_add_test_case "dummynet"
atf_add_test_case "anchor"
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Feb 22, 7:09 PM (9 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16777656
Default Alt Text
D32484.id96853.diff (5 KB)
Attached To
Mode
D32484: pf tests: slightly more complect captive portal setup
Attached
Detach File
Event Timeline
Log In to Comment