Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177546575
D60950.1794680037.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D60950.1794680037.diff
View Options
diff --git a/sys/netpfil/pf/if_pfsync.c b/sys/netpfil/pf/if_pfsync.c
--- a/sys/netpfil/pf/if_pfsync.c
+++ b/sys/netpfil/pf/if_pfsync.c
@@ -866,7 +866,9 @@
timeout = V_pf_default_rule.timeout[st->timeout];
/* sp->expire may have been adaptively scaled by export. */
- st->expire -= (timeout - ntohl(sp->pfs_1301.expire)) * 1000;
+ if (timeout >= ntohl(sp->pfs_1301.expire))
+ st->expire -= (timeout - ntohl(sp->pfs_1301.expire))
+ * 1000;
}
if (! (st->act.rtableid == -1 ||
diff --git a/tests/sys/netpfil/pf/pfsync.sh b/tests/sys/netpfil/pf/pfsync.sh
--- a/tests/sys/netpfil/pf/pfsync.sh
+++ b/tests/sys/netpfil/pf/pfsync.sh
@@ -1742,6 +1742,95 @@
pfsynct_cleanup
}
+atf_test_case "tcp" "cleanup"
+tcp_head()
+{
+ atf_set descr 'pfsync test for TCP states'
+ atf_set require.user root
+}
+
+tcp_body()
+{
+ pfsynct_init
+
+ epair_sync=$(vnet_mkepair)
+ epair_one=$(vnet_mkepair)
+ epair_two=$(vnet_mkepair)
+
+ vnet_mkjail one ${epair_one}a ${epair_sync}a
+ vnet_mkjail two ${epair_two}a ${epair_sync}b
+
+ # pfsync interface
+ jexec one ifconfig ${epair_sync}a 192.0.2.1/24 up
+ jexec one ifconfig ${epair_one}a 198.51.100.1/24 up
+ jexec one ifconfig pfsync0 \
+ syncdev ${epair_sync}a \
+ maxupd 1 \
+ up
+ jexec two ifconfig ${epair_two}a 198.51.100.2/24 up
+
+ # Enable pf!
+ jexec one pfctl -e
+ pft_set_rules one \
+ "set timeout tcp.closed 5000" \
+ "set skip on ${epair_sync}a" \
+ "pass out keep state"
+ jexec two pfctl -e
+ pft_set_rules two \
+ "set timeout tcp.closed 5" \
+ "set skip on ${epair_sync}b" \
+ "pass out keep state (tcp.closed 5)"
+
+ hostid_one=$(jexec one pfctl -si -v | awk '/Hostid:/ { gsub(/0x/, "", $2); printf($2); }')
+
+ ifconfig ${epair_one}b 198.51.100.254/24 up
+ /usr/sbin/inetd -p ${PWD}/inetd.pid \
+ $(atf_get_srcdir)/echo_inetd.conf
+
+ cat one | jexec one nc -N 198.51.100.254 7
+
+ sleep 15
+
+ # Allow for a bulk update
+ jexec two ifconfig ${epair_sync}b 192.0.2.2/24 up
+ jexec two ifconfig pfsync0 \
+ syncdev ${epair_sync}b \
+ maxupd 1 \
+ up
+
+ # Give pfsync time to do its thing
+ sleep 2
+
+ echo "One"
+ jexec one pfctl -s states -vv
+ echo "Two"
+ jexec two pfctl -s states -vv
+
+ if ! jexec two pfctl -s states | grep tcp | grep 198.51.100.1 | \
+ grep 198.51.100.254 ; then
+ atf_fail "state not found on synced host"
+ fi
+
+ if ! jexec two pfctl -sc | grep ""${hostid_one}"";
+ then
+ jexec two pfctl -sc
+ atf_fail "HostID for host one not found on two"
+ fi
+
+ sleep 10
+
+ jexec two pfctl -s states -vv
+ if jexec two pfctl -s states | grep tcp | grep 198.51.100.1 | \
+ grep 198.51.100.254 ; then
+ atf_fail "state failed to expire on two"
+ fi
+}
+
+tcp_cleanup()
+{
+ pfsynct_cleanup
+}
+
atf_init_test_cases()
{
atf_add_test_case "basic"
@@ -1767,4 +1856,5 @@
atf_add_test_case "altq_queues"
atf_add_test_case "rt_af"
atf_add_test_case "flush_by_intf"
+ atf_add_test_case "tcp"
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 14, 6:13 PM (18 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41711831
Default Alt Text
D60950.1794680037.diff (2 KB)
Attached To
Mode
D60950: pfsync: avoid overflow on different timeouts
Attached
Detach File
Event Timeline