summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2018-06-06 06:47:02 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2018-06-06 06:47:02 +0000
commit4bfe4a74ff0d1a4718c00b31d4e10011a2b9470e (patch)
tree78b23e6b60ae599f24777ffe015835e39f408383 /sys
parent12f56e8ec3da24fc59c3013ac46ef24934372a06 (diff)
Asseert that a pfkey or routing socket is referenced by a `fp' instead
of calling sofree(), when its PCB is detached. This is different from TCP which does not always detach `inpcb's from sockets. In the pfkey & routing case caling sofree() there is a noop whereas for TCP it's needed to free closed connections. Having fewer sofree() makes it easier to understand the code and move the locks down. ok visa@
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/uipc_socket.c8
-rw-r--r--sys/net/pfkeyv2.c5
-rw-r--r--sys/net/rtsock.c4
3 files changed, 8 insertions, 9 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 6ad6f8f855e..fcaa2842303 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_socket.c,v 1.221 2018/05/08 15:03:27 bluhm Exp $ */
+/* $OpenBSD: uipc_socket.c,v 1.222 2018/06/06 06:47:01 mpi Exp $ */
/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
/*
@@ -282,8 +282,7 @@ drop:
error = error2;
}
discard:
- if (so->so_state & SS_NOFDREF)
- panic("soclose NOFDREF: so %p, so_type %d", so, so->so_type);
+ KASSERT((so->so_state & SS_NOFDREF) == 0);
so->so_state |= SS_NOFDREF;
sofree(so);
sounlock(s);
@@ -306,8 +305,7 @@ soaccept(struct socket *so, struct mbuf *nam)
soassertlocked(so);
- if ((so->so_state & SS_NOFDREF) == 0)
- panic("soaccept !NOFDREF: so %p, so_type %d", so, so->so_type);
+ KASSERT((so->so_state & SS_NOFDREF) != 0);
so->so_state &= ~SS_NOFDREF;
if ((so->so_state & SS_ISDISCONNECTED) == 0 ||
(so->so_proto->pr_flags & PR_ABRTACPTDIS) == 0)
diff --git a/sys/net/pfkeyv2.c b/sys/net/pfkeyv2.c
index be092461ada..a68995e6411 100644
--- a/sys/net/pfkeyv2.c
+++ b/sys/net/pfkeyv2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfkeyv2.c,v 1.180 2018/05/19 20:04:55 bluhm Exp $ */
+/* $OpenBSD: pfkeyv2.c,v 1.181 2018/06/06 06:47:01 mpi Exp $ */
/*
* @(#)COPYRIGHT 1.1 (NRL) 17 January 1995
@@ -323,8 +323,9 @@ pfkeyv2_detach(struct socket *so)
refcnt_finalize(&kp->refcnt, "pfkeyrefs");
so->so_pcb = NULL;
- sofree(so);
+ KASSERT((so->so_state & SS_NOFDREF) == 0);
free(kp, M_PCB, sizeof(struct keycb));
+
return (0);
}
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index 6a91c13c2ed..d82e7057730 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtsock.c,v 1.265 2018/05/14 07:33:59 mpi Exp $ */
+/* $OpenBSD: rtsock.c,v 1.266 2018/06/06 06:47:01 mpi Exp $ */
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/*
@@ -296,7 +296,7 @@ route_detach(struct socket *so)
refcnt_finalize(&rop->refcnt, "rtsockrefs");
so->so_pcb = NULL;
- sofree(so);
+ KASSERT((so->so_state & SS_NOFDREF) == 0);
free(rop, M_PCB, sizeof(struct routecb));
return (0);