aboutsummaryrefslogtreecommitdiff
path: root/sys/netipsec
diff options
context:
space:
mode:
authorRobert Watson <rwatson@FreeBSD.org>2006-07-21 17:11:15 +0000
committerRobert Watson <rwatson@FreeBSD.org>2006-07-21 17:11:15 +0000
commita152f8a36128ce99cc252941396d7db06ec7084e (patch)
treec584d49beb0289bc5110816075b0f48383df5bfd /sys/netipsec
parent05a7329cbad79bc2d72b63eee9badbdb4deff62d (diff)
downloadsrc-a152f8a36128ce99cc252941396d7db06ec7084e.tar.gz
src-a152f8a36128ce99cc252941396d7db06ec7084e.zip
Change semantics of socket close and detach. Add a new protocol switch
function, pru_close, to notify protocols that the file descriptor or other consumer of a socket is closing the socket. pru_abort is now a notification of close also, and no longer detaches. pru_detach is no longer used to notify of close, and will be called during socket tear-down by sofree() when all references to a socket evaporate after an earlier call to abort or close the socket. This means detach is now an unconditional teardown of a socket, whereas previously sockets could persist after detach of the protocol retained a reference. This faciliates sharing mutexes between layers of the network stack as the mutex is required during the checking and removal of references at the head of sofree(). With this change, pru_detach can now assume that the mutex will no longer be required by the socket layer after completion, whereas before this was not necessarily true. Reviewed by: gnn
Notes
Notes: svn path=/head/; revision=160549
Diffstat (limited to 'sys/netipsec')
-rw-r--r--sys/netipsec/keysock.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/sys/netipsec/keysock.c b/sys/netipsec/keysock.c
index a590f1ef43d0..b93d6d69d1e3 100644
--- a/sys/netipsec/keysock.c
+++ b/sys/netipsec/keysock.c
@@ -439,6 +439,17 @@ key_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
}
/*
+ * key_close()
+ * derived from net/rtsock.c:rts_close().
+ */
+static void
+key_abort(struct socket *so)
+{
+
+ raw_usrreqs.pru_close(so);
+}
+
+/*
* key_connect()
* derived from net/rtsock.c:rts_connect()
*/
@@ -553,6 +564,7 @@ struct pr_usrreqs key_usrreqs = {
.pru_send = key_send,
.pru_shutdown = key_shutdown,
.pru_sockaddr = key_sockaddr,
+ .pru_close = key_close,
};
/* sysctl */