summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkp <kp@FreeBSD.org>2017-03-12 05:42:57 +0000
committerLuiz Souza <luiz@netgate.com>2017-07-17 19:35:53 -0500
commitaef58d13c34282a7acf422755c71d7b9256e9bce (patch)
tree2244e3d721cde98f01091b666bf4dc79fa04f223
parent05ee643ebaea9e1a1637c956196b14a6d42b5d1d (diff)
downloadFreeBSD-src-aef58d13c34282a7acf422755c71d7b9256e9bce.zip
FreeBSD-src-aef58d13c34282a7acf422755c71d7b9256e9bce.tar.gz
pf: Fix incorrect rw_sleep() in pf_unload()
When we unload we don't hold the pf_rules_lock, so we cannot call rw_sleep() with it, because it would release a lock we do not hold. There's no need for the lock either, so we can just tsleep(). While here also make the same change in pf_purge_thread(), because it explicitly takes the lock before rw_sleep() and then immediately releases it afterwards. (cherry picked from commit 3f3708722474b9af976e8fc216ef7284b86215aa)
-rw-r--r--sys/netpfil/pf/pf.c4
-rw-r--r--sys/netpfil/pf/pf_ioctl.c2
2 files changed, 2 insertions, 4 deletions
diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c
index 08aaa57..3ac1c8b 100644
--- a/sys/netpfil/pf/pf.c
+++ b/sys/netpfil/pf/pf.c
@@ -1593,9 +1593,7 @@ pf_purge_thread(void *unused __unused)
u_int idx = 0;
for (;;) {
- PF_RULES_RLOCK();
- rw_sleep(pf_purge_thread, &pf_rules_lock, 0, "pftm", hz / 10);
- PF_RULES_RUNLOCK();
+ tsleep(pf_purge_thread, 0, "pftm", hz / 10);
VNET_LIST_RLOCK();
VNET_FOREACH(vnet_iter) {
diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c
index 4060e11..9f96c46 100644
--- a/sys/netpfil/pf/pf_ioctl.c
+++ b/sys/netpfil/pf/pf_ioctl.c
@@ -3841,7 +3841,7 @@ pf_unload(void)
pf_end_threads = 1;
while (pf_end_threads < 2) {
wakeup_one(pf_purge_thread);
- rw_sleep(pf_purge_thread, &pf_rules_lock, 0, "pftmo", 0);
+ tsleep(pf_purge_thread, 0, "pftmo", 0);
}
if (pf_dev != NULL)
OpenPOWER on IntegriCloud