summaryrefslogtreecommitdiff
path: root/sys/netinet6
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/netinet6
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/netinet6')
-rw-r--r--sys/netinet6/in6_proto.c18
-rw-r--r--sys/netinet6/ip6_divert.c21
-rw-r--r--sys/netinet6/ip6_divert.h3
-rw-r--r--sys/netinet6/ip6_var.h3
-rw-r--r--sys/netinet6/raw_ip6.c25
5 files changed, 58 insertions, 12 deletions
diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c
index 2a653e0286e..a112d731163 100644
--- a/sys/netinet6/in6_proto.c
+++ b/sys/netinet6/in6_proto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in6_proto.c,v 1.95 2017/07/13 17:17:27 florian Exp $ */
+/* $OpenBSD: in6_proto.c,v 1.96 2017/11/02 14:01:18 florian Exp $ */
/* $KAME: in6_proto.c,v 1.66 2000/10/10 15:35:47 itojun Exp $ */
/*
@@ -140,6 +140,7 @@ struct protosw inet6sw[] = {
.pr_ctloutput = ip6_ctloutput,
.pr_usrreq = udp_usrreq,
.pr_attach = udp_attach,
+ .pr_detach = udp_detach,
.pr_sysctl = udp_sysctl
},
{
@@ -152,6 +153,7 @@ struct protosw inet6sw[] = {
.pr_ctloutput = tcp_ctloutput,
.pr_usrreq = tcp_usrreq,
.pr_attach = tcp_attach,
+ .pr_detach = tcp_detach,
.pr_sysctl = tcp_sysctl
},
{
@@ -164,6 +166,7 @@ struct protosw inet6sw[] = {
.pr_ctloutput = rip6_ctloutput,
.pr_usrreq = rip6_usrreq,
.pr_attach = rip6_attach,
+ .pr_detach = rip6_detach,
.pr_sysctl = rip6_sysctl
},
{
@@ -176,6 +179,7 @@ struct protosw inet6sw[] = {
.pr_ctloutput = rip6_ctloutput,
.pr_usrreq = rip6_usrreq,
.pr_attach = rip6_attach,
+ .pr_detach = rip6_detach,
.pr_init = icmp6_init,
.pr_fasttimo = icmp6_fasttimo,
.pr_sysctl = icmp6_sysctl
@@ -211,6 +215,7 @@ struct protosw inet6sw[] = {
.pr_ctloutput = rip6_ctloutput,
.pr_usrreq = rip6_usrreq,
.pr_attach = rip6_attach,
+ .pr_detach = rip6_detach,
.pr_sysctl = ah_sysctl
},
{
@@ -222,6 +227,7 @@ struct protosw inet6sw[] = {
.pr_ctloutput = rip6_ctloutput,
.pr_usrreq = rip6_usrreq,
.pr_attach = rip6_attach,
+ .pr_detach = rip6_detach,
.pr_sysctl = esp_sysctl
},
{
@@ -233,6 +239,7 @@ struct protosw inet6sw[] = {
.pr_ctloutput = rip6_ctloutput,
.pr_usrreq = rip6_usrreq,
.pr_attach = rip6_attach,
+ .pr_detach = rip6_detach,
.pr_sysctl = ipcomp_sysctl
},
#endif /* IPSEC */
@@ -248,7 +255,8 @@ struct protosw inet6sw[] = {
#endif
.pr_ctloutput = rip6_ctloutput,
.pr_usrreq = rip6_usrreq, /* XXX */
- .pr_attach = rip6_attach
+ .pr_attach = rip6_attach,
+ .pr_detach = rip6_detach,
},
{
.pr_type = SOCK_RAW,
@@ -263,6 +271,7 @@ struct protosw inet6sw[] = {
.pr_ctloutput = rip6_ctloutput,
.pr_usrreq = rip6_usrreq, /* XXX */
.pr_attach = rip6_attach,
+ .pr_detach = rip6_detach,
},
#if NGIF > 0
{
@@ -274,6 +283,7 @@ struct protosw inet6sw[] = {
.pr_ctloutput = rip6_ctloutput,
.pr_usrreq = rip6_usrreq,
.pr_attach = rip6_attach,
+ .pr_detach = rip6_detach,
.pr_sysctl = etherip_sysctl
},
#endif /* NGIF */
@@ -287,6 +297,7 @@ struct protosw inet6sw[] = {
.pr_ctloutput = rip6_ctloutput,
.pr_usrreq = rip6_usrreq,
.pr_attach = rip6_attach,
+ .pr_detach = rip6_detach,
.pr_sysctl = carp_sysctl
},
#endif /* NCARP */
@@ -299,6 +310,7 @@ struct protosw inet6sw[] = {
.pr_ctloutput = rip6_ctloutput,
.pr_usrreq = divert6_usrreq,
.pr_attach = divert6_attach,
+ .pr_detach = divert6_detach,
.pr_init = divert6_init,
.pr_sysctl = divert6_sysctl
},
@@ -313,6 +325,7 @@ struct protosw inet6sw[] = {
.pr_ctloutput = rip6_ctloutput,
.pr_usrreq = rip6_usrreq,
.pr_attach = rip6_attach,
+ .pr_detach = rip6_detach,
.pr_sysctl = ip_etherip_sysctl
},
#endif /* NETHERIP */
@@ -325,6 +338,7 @@ struct protosw inet6sw[] = {
.pr_ctloutput = rip6_ctloutput,
.pr_usrreq = rip6_usrreq,
.pr_attach = rip6_attach,
+ .pr_detach = rip6_detach,
.pr_init = rip6_init
}
};
diff --git a/sys/netinet6/ip6_divert.c b/sys/netinet6/ip6_divert.c
index 1f20dc64d83..e41e734733c 100644
--- a/sys/netinet6/ip6_divert.c
+++ b/sys/netinet6/ip6_divert.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_divert.c,v 1.54 2017/10/09 08:35:38 mpi Exp $ */
+/* $OpenBSD: ip6_divert.c,v 1.55 2017/11/02 14:01:18 florian Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -257,10 +257,6 @@ divert6_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *addr,
}
switch (req) {
- case PRU_DETACH:
- in_pcbdetach(inp);
- break;
-
case PRU_BIND:
error = in_pcbbind(inp, addr, p);
break;
@@ -338,6 +334,21 @@ divert6_attach(struct socket *so, int proto)
}
int
+divert6_detach(struct socket *so)
+{
+ struct inpcb *inp = sotoinpcb(so);
+
+ soassertlocked(so);
+
+ if (inp == NULL)
+ return (EINVAL);
+
+ in_pcbdetach(inp);
+
+ return (0);
+}
+
+int
divert6_sysctl_div6stat(void *oldp, size_t *oldlenp, void *newp)
{
uint64_t counters[div6s_ncounters];
diff --git a/sys/netinet6/ip6_divert.h b/sys/netinet6/ip6_divert.h
index bbda15b4061..c98a5189136 100644
--- a/sys/netinet6/ip6_divert.h
+++ b/sys/netinet6/ip6_divert.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_divert.h,v 1.8 2017/04/14 20:46:31 bluhm Exp $ */
+/* $OpenBSD: ip6_divert.h,v 1.9 2017/11/02 14:01:18 florian Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -78,6 +78,7 @@ int divert6_sysctl(int *, u_int, void *, size_t *, void *, size_t);
int divert6_usrreq(struct socket *,
int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *);
int divert6_attach(struct socket *, int);
+int divert6_detach(struct socket *);
#endif /* _KERNEL */
#endif /* _IP6_DIVERT_H_ */
diff --git a/sys/netinet6/ip6_var.h b/sys/netinet6/ip6_var.h
index da11f5a1ee5..09dd373bc3e 100644
--- a/sys/netinet6/ip6_var.h
+++ b/sys/netinet6/ip6_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_var.h,v 1.79 2017/10/26 15:39:14 visa Exp $ */
+/* $OpenBSD: ip6_var.h,v 1.80 2017/11/02 14:01:18 florian Exp $ */
/* $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $ */
/*
@@ -345,6 +345,7 @@ int rip6_output(struct mbuf *, struct socket *, struct sockaddr *,
int rip6_usrreq(struct socket *,
int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *);
int rip6_attach(struct socket *, int);
+int rip6_detach(struct socket *);
int rip6_sysctl(int *, u_int, void *, size_t *, void *, size_t);
int dest6_input(struct mbuf **, int *, int, int);
diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c
index c201852c69e..70461915c2e 100644
--- a/sys/netinet6/raw_ip6.c
+++ b/sys/netinet6/raw_ip6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: raw_ip6.c,v 1.121 2017/10/08 14:53:25 deraadt Exp $ */
+/* $OpenBSD: raw_ip6.c,v 1.122 2017/11/02 14:01:18 florian Exp $ */
/* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */
/*
@@ -558,8 +558,6 @@ rip6_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
case PRU_ABORT:
soisdisconnected(so);
- /* FALLTHROUGH */
- case PRU_DETACH:
if (in6p == NULL)
panic("rip6_detach");
#ifdef MROUTING
@@ -716,6 +714,27 @@ rip6_attach(struct socket *so, int proto)
}
int
+rip6_detach(struct socket *so)
+{
+ struct inpcb *in6p = sotoinpcb(so);
+
+ soassertlocked(so);
+
+ if (in6p == NULL)
+ panic("rip6_detach");
+#ifdef MROUTING
+ if (so == ip6_mrouter[in6p->inp_rtableid])
+ ip6_mrouter_done(so);
+#endif
+ free(in6p->inp_icmp6filt, M_PCB, sizeof(struct icmp6_filter));
+ in6p->inp_icmp6filt = NULL;
+
+ in_pcbdetach(in6p);
+
+ return (0);
+}
+
+int
rip6_sysctl_rip6stat(void *oldp, size_t *oldplen, void *newp)
{
struct rip6stat rip6stat;