summaryrefslogtreecommitdiff
path: root/sys/kern/kern_sysctl.c
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2022-03-21 09:12:35 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2022-03-21 09:12:35 +0000
commit524ed1ac6f30d2bbdb4cbd29ff76745f42ccee07 (patch)
treef1e9118e4f1205081c4e4e7acd54d91328a244ab /sys/kern/kern_sysctl.c
parent532c2a45d92460d6ca4616d60f541497e0197cf6 (diff)
Header netinet/in_pcb.h includes sys/mutex.h now. Recommit mutex
for PCB tables. It does not break userland build anymore. pf_socket_lookup() calls in_pcbhashlookup() in the PCB layer. To run pf in parallel, make parts of the stack MP safe. Protect the list and hashes in the PCB tables with a mutex. Note that the protocol notify functions may call pf via tcp_output(). As the pf lock is a sleeping rw_lock, we must not hold a mutex. To solve this for now, collect these PCBs in inp_notify list and protect it with exclusive netlock. OK sashan@
Diffstat (limited to 'sys/kern/kern_sysctl.c')
-rw-r--r--sys/kern/kern_sysctl.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index 0f8d053b4c5..326265d56f2 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sysctl.c,v 1.401 2022/03/14 22:38:43 tb Exp $ */
+/* $OpenBSD: kern_sysctl.c,v 1.402 2022/03/21 09:12:34 bluhm Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
/*-
@@ -1366,16 +1366,24 @@ sysctl_file(int *name, u_int namelen, char *where, size_t *sizep,
struct inpcb *inp;
NET_LOCK();
+ mtx_enter(&tcbtable.inpt_mtx);
TAILQ_FOREACH(inp, &tcbtable.inpt_queue, inp_queue)
FILLSO(inp->inp_socket);
+ mtx_leave(&tcbtable.inpt_mtx);
+ mtx_enter(&udbtable.inpt_mtx);
TAILQ_FOREACH(inp, &udbtable.inpt_queue, inp_queue)
FILLSO(inp->inp_socket);
+ mtx_leave(&udbtable.inpt_mtx);
+ mtx_enter(&rawcbtable.inpt_mtx);
TAILQ_FOREACH(inp, &rawcbtable.inpt_queue, inp_queue)
FILLSO(inp->inp_socket);
+ mtx_leave(&rawcbtable.inpt_mtx);
#ifdef INET6
+ mtx_enter(&rawin6pcbtable.inpt_mtx);
TAILQ_FOREACH(inp, &rawin6pcbtable.inpt_queue,
inp_queue)
FILLSO(inp->inp_socket);
+ mtx_leave(&rawin6pcbtable.inpt_mtx);
#endif
NET_UNLOCK();
}