summaryrefslogtreecommitdiff
path: root/sys/net/rtsock.c
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2017-11-02 14:01:19 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2017-11-02 14:01:19 +0000
commit263c04e1bde3d1faacc0c2054395ce503cb8aaba (patch)
tree5b7c1d09c54db9a030990e551146b261d49c426f /sys/net/rtsock.c
parentccad25ba8977c4d9f2c8d78763d09e00ab0068e5 (diff)
Move PRU_DETACH out of pr_usrreq into per proto pr_detach
functions to pave way for more fine grained locking. Suggested by, comments & OK mpi
Diffstat (limited to 'sys/net/rtsock.c')
-rw-r--r--sys/net/rtsock.c45
1 files changed, 29 insertions, 16 deletions
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index dc77a2411b3..c2adc8d26ce 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtsock.c,v 1.251 2017/10/09 08:35:38 mpi Exp $ */
+/* $OpenBSD: rtsock.c,v 1.252 2017/11/02 14:01:18 florian Exp $ */
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/*
@@ -174,7 +174,6 @@ route_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
struct mbuf *control, struct proc *p)
{
struct routecb *rop;
- int af;
int error = 0;
soassertlocked(so);
@@ -198,20 +197,6 @@ route_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
rop->flags &= ~ROUTECB_FLAG_FLUSH;
break;
- case PRU_DETACH:
- timeout_del(&rop->timeout);
- af = rop->rcb.rcb_proto.sp_protocol;
- if (af == AF_INET)
- route_cb.ip_count--;
- else if (af == AF_INET6)
- route_cb.ip6_count--;
-#ifdef MPLS
- else if (af == AF_MPLS)
- route_cb.mpls_count--;
-#endif
- route_cb.any_count--;
- LIST_REMOVE(rop, rcb_list);
- /* FALLTHROUGH */
default:
error = raw_usrreq(so, req, m, nam, control, p);
}
@@ -271,6 +256,33 @@ route_attach(struct socket *so, int proto)
}
int
+route_detach(struct socket *so)
+{
+ struct routecb *rop;
+ int af;
+
+ soassertlocked(so);
+
+ rop = sotoroutecb(so);
+ if (rop == NULL)
+ return (EINVAL);
+
+ timeout_del(&rop->timeout);
+ af = rop->rcb.rcb_proto.sp_protocol;
+ if (af == AF_INET)
+ route_cb.ip_count--;
+ else if (af == AF_INET6)
+ route_cb.ip6_count--;
+#ifdef MPLS
+ else if (af == AF_MPLS)
+ route_cb.mpls_count--;
+#endif
+ route_cb.any_count--;
+ LIST_REMOVE(rop, rcb_list);
+ return (raw_detach(so));
+}
+
+int
route_ctloutput(int op, struct socket *so, int level, int optname,
struct mbuf *m)
{
@@ -1922,6 +1934,7 @@ struct protosw routesw[] = {
.pr_ctloutput = route_ctloutput,
.pr_usrreq = route_usrreq,
.pr_attach = route_attach,
+ .pr_detach = route_detach,
.pr_init = route_prinit,
.pr_sysctl = sysctl_rtable
}