summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorKlemens Nanni <kn@cvs.openbsd.org>2022-11-30 13:58:40 +0000
committerKlemens Nanni <kn@cvs.openbsd.org>2022-11-30 13:58:40 +0000
commit44d797b28dbfd6fd7302b8c02c9252298dad5bba (patch)
tree53d5edfe4ba6fc0c24760c495e9d98caac69bc55 /sys
parent886191e4b5a92070eb862ed972032345e65b3056 (diff)
Use shared socket/net lock for IP sockets
so{,un}lock_shared() take the shared net lock for PF_INET and PF_INET6 while sticking to the exclusive rwlock elsewhere. getsockopt(2), getsockname(2) and getpeername(2) (all UNLOCK) do not write, so the exclusive net lock is overkill here. OK mvs
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/uipc_syscalls.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index ddb612a8043..900e6709ba2 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_syscalls.c,v 1.204 2022/09/03 21:13:48 mbuhl Exp $ */
+/* $OpenBSD: uipc_syscalls.c,v 1.205 2022/11/30 13:58:39 kn Exp $ */
/* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */
/*
@@ -1268,9 +1268,9 @@ sys_getsockopt(struct proc *p, void *v, register_t *retval)
valsize = 0;
m = m_get(M_WAIT, MT_SOOPTS);
so = fp->f_data;
- solock(so);
+ solock_shared(so);
error = sogetopt(so, SCARG(uap, level), SCARG(uap, name), m);
- sounlock(so);
+ sounlock_shared(so);
if (error == 0 && SCARG(uap, val) && valsize && m != NULL) {
if (valsize > m->m_len)
valsize = m->m_len;
@@ -1320,9 +1320,9 @@ sys_getsockname(struct proc *p, void *v, register_t *retval)
goto bad;
}
m = m_getclr(M_WAIT, MT_SONAME);
- solock(so);
+ solock_shared(so);
error = pru_sockaddr(so, m);
- sounlock(so);
+ sounlock_shared(so);
if (error)
goto bad;
error = copyaddrout(p, m, SCARG(uap, asa), len, SCARG(uap, alen));
@@ -1367,9 +1367,9 @@ sys_getpeername(struct proc *p, void *v, register_t *retval)
if (error)
goto bad;
m = m_getclr(M_WAIT, MT_SONAME);
- solock(so);
+ solock_shared(so);
error = pru_peeraddr(so, m);
- sounlock(so);
+ sounlock_shared(so);
if (error)
goto bad;
error = copyaddrout(p, m, SCARG(uap, asa), len, SCARG(uap, alen));