summaryrefslogtreecommitdiffstats
path: root/sys/net/pf_ioctl.c
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2017-03-17 17:19:16 +0000
committermpi <mpi@openbsd.org>2017-03-17 17:19:16 +0000
commitb554ebfc5ef68dbcbabda317521525d69f01b5e5 (patch)
treeac930470c4b490bea0d5231c4d25bfe4bb8b51a8 /sys/net/pf_ioctl.c
parentcarp(4) code is always executed in the 'softnet' thread, so remove (diff)
downloadwireguard-openbsd-b554ebfc5ef68dbcbabda317521525d69f01b5e5.tar.xz
wireguard-openbsd-b554ebfc5ef68dbcbabda317521525d69f01b5e5.zip
Revert the NET_LOCK() and bring back pf's contention lock for release.
For the moment the NET_LOCK() is always taken by threads running under KERNEL_LOCK(). That means it doesn't buy us anything except a possible deadlock that we did not spot. So make sure this doesn't happen, we'll have plenty of time in the next release cycle to stress test it. ok visa@
Diffstat (limited to 'sys/net/pf_ioctl.c')
-rw-r--r--sys/net/pf_ioctl.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/sys/net/pf_ioctl.c b/sys/net/pf_ioctl.c
index 56a43a55ab8..887a36481d6 100644
--- a/sys/net/pf_ioctl.c
+++ b/sys/net/pf_ioctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pf_ioctl.c,v 1.307 2017/01/30 17:41:34 benno Exp $ */
+/* $OpenBSD: pf_ioctl.c,v 1.308 2017/03/17 17:19:16 mpi Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -111,6 +111,7 @@ void pf_qid2qname(u_int16_t, char *);
void pf_qid_unref(u_int16_t);
struct pf_rule pf_default_rule, pf_default_rule_new;
+struct rwlock pf_consistency_lock = RWLOCK_INITIALIZER("pfcnslk");
struct {
char statusif[IFNAMSIZ];
@@ -986,7 +987,12 @@ pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
return (EACCES);
}
- NET_LOCK(s);
+ if (flags & FWRITE)
+ rw_enter_write(&pf_consistency_lock);
+ else
+ rw_enter_read(&pf_consistency_lock);
+
+ s = splsoftnet();
switch (cmd) {
case DIOCSTART:
@@ -2382,7 +2388,11 @@ pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
break;
}
fail:
- NET_UNLOCK(s);
+ splx(s);
+ if (flags & FWRITE)
+ rw_exit_write(&pf_consistency_lock);
+ else
+ rw_exit_read(&pf_consistency_lock);
return (error);
}