summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuiz Otavio O Souza <luiz@netgate.com>2017-01-28 20:00:45 -0600
committerLuiz Souza <luiz@netgate.com>2017-07-17 19:29:07 -0500
commit96f4336dc137d807fa8839df573a34ed6a130772 (patch)
treea068c399081b019d8b693af31d3c9dcf9c3c5598
parent9bea8915eb13bccca707a134eadcb1dd82eac4dc (diff)
downloadFreeBSD-src-96f4336dc137d807fa8839df573a34ed6a130772.zip
FreeBSD-src-96f4336dc137d807fa8839df573a34ed6a130772.tar.gz
Do not run the pf purge thread while the VNET variables are not initialized, this can cause a divide by zero (if the VNET initialization takes to long to complete).
Found while debugging Ticker #7124 (cherry picked from commit 5eb28c4fe8597d2b7a5ace3de98ba4b762b2e1a8)
-rw-r--r--sys/netpfil/pf/pf.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c
index 3bc692e..08aaa57 100644
--- a/sys/netpfil/pf/pf.c
+++ b/sys/netpfil/pf/pf.c
@@ -131,6 +131,8 @@ VNET_DEFINE(int, pf_tcp_secret_init);
#define V_pf_tcp_secret_init VNET(pf_tcp_secret_init)
VNET_DEFINE(int, pf_tcp_iss_off);
#define V_pf_tcp_iss_off VNET(pf_tcp_iss_off)
+VNET_DECLARE(int, pf_vnet_active);
+#define V_pf_vnet_active VNET(pf_vnet_active)
/*
* Queue for pf_intr() sends.
@@ -1605,6 +1607,12 @@ pf_purge_thread(void *unused __unused)
kproc_exit(0);
}
+ /* Wait while V_pf_default_rule.timeout is initialized. */
+ if (V_pf_vnet_active == 0) {
+ CURVNET_RESTORE();
+ continue;
+ }
+
/* Process 1/interval fraction of the state table every run. */
idx = pf_purge_expired_states(idx, pf_hashmask /
(V_pf_default_rule.timeout[PFTM_INTERVAL] * 10));
OpenPOWER on IntegriCloud