summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormvs <mvs@openbsd.org>2021-02-15 19:01:30 +0000
committermvs <mvs@openbsd.org>2021-02-15 19:01:30 +0000
commita9252649d3c7afe4a8ecb590e876d29a1a4c2bc3 (patch)
tree4fe418d013209062c3edaad30bce74378286d937
parentOnly print the certificate file once on verifification failure. (diff)
downloadwireguard-openbsd-a9252649d3c7afe4a8ecb590e876d29a1a4c2bc3.tar.xz
wireguard-openbsd-a9252649d3c7afe4a8ecb590e876d29a1a4c2bc3.zip
Simplify error path in in route_attach(). We always call it in thread
context so we always have `curproc' Also protocol control block is not required for soreserve() so we can do it before `rop' allocation. ok bluhm@
-rw-r--r--sys/net/rtsock.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index 65214a9dd1d..f5f86e9f0e2 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtsock.c,v 1.304 2020/11/07 09:51:40 denis Exp $ */
+/* $OpenBSD: rtsock.c,v 1.305 2021/02/15 19:01:30 mvs Exp $ */
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/*
@@ -301,6 +301,9 @@ route_attach(struct socket *so, int proto)
struct rtpcb *rop;
int error;
+ error = soreserve(so, ROUTESNDQ, ROUTERCVQ);
+ if (error)
+ return (error);
/*
* use the rawcb but allocate a rtpcb, this
* code does not care about the additional fields
@@ -312,15 +315,6 @@ route_attach(struct socket *so, int proto)
timeout_set(&rop->rop_timeout, rtm_senddesync_timer, so);
refcnt_init(&rop->rop_refcnt);
- if (curproc == NULL)
- error = EACCES;
- else
- error = soreserve(so, ROUTESNDQ, ROUTERCVQ);
- if (error) {
- pool_put(&rtpcb_pool, rop);
- return (error);
- }
-
rop->rop_socket = so;
rop->rop_proto = proto;