diff options
author | 2017-03-07 09:23:27 +0000 | |
---|---|---|
committer | 2017-03-07 09:23:27 +0000 | |
commit | 143ab7fc259aff7c83770a7286feb60e15721391 (patch) | |
tree | 6c133422618844e51864253d24d9b090a48feb05 /sys/kern | |
parent | tls_close() can return TLS_WANT_POLLIN/TLS_WANT_POLLOUT, handle them (diff) | |
download | wireguard-openbsd-143ab7fc259aff7c83770a7286feb60e15721391.tar.xz wireguard-openbsd-143ab7fc259aff7c83770a7286feb60e15721391.zip |
Do not grab the NET_LOCK() for routing sockets operations.
The only function that need the lock is rtm_output() as it messes with
the routing table. So grab the lock there since it is safe to sleep
in a process context.
ok bluhm@
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/uipc_socket.c | 5 | ||||
-rw-r--r-- | sys/kern/uipc_socket2.c | 13 |
2 files changed, 11 insertions, 7 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 1affe913afc..93162a4e256 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_socket.c,v 1.178 2017/03/03 09:41:20 mpi Exp $ */ +/* $OpenBSD: uipc_socket.c,v 1.179 2017/03/07 09:23:27 mpi Exp $ */ /* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */ /* @@ -1038,11 +1038,12 @@ sorflush(struct socket *so) { struct sockbuf *sb = &so->so_rcv; struct protosw *pr = so->so_proto; + sa_family_t af = pr->pr_domain->dom_family; struct sockbuf asb; sb->sb_flags |= SB_NOINTR; sblock(sb, M_WAITOK, - (pr->pr_domain->dom_family != PF_LOCAL) ? &netlock : NULL); + (af != PF_LOCAL && af != PF_ROUTE) ? &netlock : NULL); socantrcvmore(so); sbunlock(sb); asb = *sb; diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c index 3a09b229477..aca06097411 100644 --- a/sys/kern/uipc_socket2.c +++ b/sys/kern/uipc_socket2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_socket2.c,v 1.72 2017/02/14 09:46:21 mpi Exp $ */ +/* $OpenBSD: uipc_socket2.c,v 1.73 2017/03/07 09:23:27 mpi Exp $ */ /* $NetBSD: uipc_socket2.c,v 1.11 1996/02/04 02:17:55 christos Exp $ */ /* @@ -273,7 +273,8 @@ solock(struct socket *so) { int s; - if (so->so_proto->pr_domain->dom_family != PF_LOCAL) + if ((so->so_proto->pr_domain->dom_family != PF_LOCAL) && + (so->so_proto->pr_domain->dom_family != PF_ROUTE)) NET_LOCK(s); else s = -42; @@ -291,16 +292,18 @@ sounlock(int s) void soassertlocked(struct socket *so) { - if (so->so_proto->pr_domain->dom_family != PF_LOCAL) + if ((so->so_proto->pr_domain->dom_family != PF_LOCAL) && + (so->so_proto->pr_domain->dom_family != PF_ROUTE)) NET_ASSERT_LOCKED(); } int sosleep(struct socket *so, void *ident, int prio, const char *wmesg, int timo) { - if (so->so_proto->pr_domain->dom_family != PF_LOCAL) + if ((so->so_proto->pr_domain->dom_family != PF_LOCAL) && + (so->so_proto->pr_domain->dom_family != PF_ROUTE)) { return rwsleep(ident, &netlock, prio, wmesg, timo); - else + } else return tsleep(ident, prio, wmesg, timo); } |