summaryrefslogtreecommitdiffstats
path: root/sys/netatm
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2006-04-01 15:42:02 +0000
committerrwatson <rwatson@FreeBSD.org>2006-04-01 15:42:02 +0000
commit5479e5d69217e0a6876338fc7cde604067b679ca (patch)
tree7431f8c0d78c14bc446d524dcda6a00888732015 /sys/netatm
parent68ff3be0b395955e8feac72262824b90a155a710 (diff)
downloadFreeBSD-src-5479e5d69217e0a6876338fc7cde604067b679ca.zip
FreeBSD-src-5479e5d69217e0a6876338fc7cde604067b679ca.tar.gz
Chance protocol switch method pru_detach() so that it returns void
rather than an error. Detaches do not "fail", they other occur or the protocol flags SS_PROTOREF to take ownership of the socket. soclose() no longer looks at so_pcb to see if it's NULL, relying entirely on the protocol to decide whether it's time to free the socket or not using SS_PROTOREF. so_pcb is now entirely owned and managed by the protocol code. Likewise, no longer test so_pcb in other socket functions, such as soreceive(), which have no business digging into protocol internals. Protocol detach routines no longer try to free the socket on detach, this is performed in the socket code if the protocol permits it. In rts_detach(), no longer test for rp != NULL in detach, and likewise in other protocols that don't permit a NULL so_pcb, reduce the incidence of testing for it during detach. netinet and netinet6 are not fully updated to this change, which will be in an upcoming commit. In their current state they may leak memory or panic. MFC after: 3 months
Diffstat (limited to 'sys/netatm')
-rw-r--r--sys/netatm/atm_aal5.c10
-rw-r--r--sys/netatm/atm_socket.c17
-rw-r--r--sys/netatm/atm_usrreq.c2
-rw-r--r--sys/netatm/atm_var.h2
4 files changed, 9 insertions, 22 deletions
diff --git a/sys/netatm/atm_aal5.c b/sys/netatm/atm_aal5.c
index 2a5e1e3..f21ad798 100644
--- a/sys/netatm/atm_aal5.c
+++ b/sys/netatm/atm_aal5.c
@@ -66,7 +66,7 @@ u_long atm_aal5_recvspace = 64 * 1024; /* XXX */
* Local functions
*/
static int atm_aal5_attach(struct socket *, int, struct thread *td);
-static int atm_aal5_detach(struct socket *);
+static void atm_aal5_detach(struct socket *);
static int atm_aal5_bind(struct socket *, struct sockaddr *,
struct thread *td);
static int atm_aal5_listen(struct socket *, int backlog,
@@ -290,15 +290,15 @@ out:
* errno error processing request - reason indicated
*
*/
-static int
+static void
atm_aal5_detach(so)
struct socket *so;
{
- ATM_INTRO("detach");
+ ATM_INTRO_NOERR("detach");
- err = atm_sock_detach(so);
+ atm_sock_detach(so);
- ATM_OUTRO();
+ ATM_OUTRO_NOERR();
}
diff --git a/sys/netatm/atm_socket.c b/sys/netatm/atm_socket.c
index 2cdab95..d2aecf1 100644
--- a/sys/netatm/atm_socket.c
+++ b/sys/netatm/atm_socket.c
@@ -146,12 +146,8 @@ atm_sock_attach(so, send, recv)
* Arguments:
* so pointer to socket
*
- * Returns:
- * 0 detach successful
- * errno detach failed - reason indicated
- *
*/
-int
+void
atm_sock_detach(so)
struct socket *so;
{
@@ -160,8 +156,7 @@ atm_sock_detach(so)
/*
* Make sure we're still attached
*/
- if (atp == NULL)
- return (ENOTCONN);
+ KASSERT(atp != NULL, ("atm_sock_detach: atp == NULL"));
/*
* Terminate any (possibly pending) connection
@@ -170,17 +165,9 @@ atm_sock_detach(so)
(void) atm_sock_disconnect(so);
}
- /*
- * Break links and free control blocks
- */
- ACCEPT_LOCK();
- SOCK_LOCK(so);
so->so_pcb = NULL;
- sotryfree(so);
uma_zfree(atm_pcb_zone, atp);
-
- return (0);
}
diff --git a/sys/netatm/atm_usrreq.c b/sys/netatm/atm_usrreq.c
index db5a2ab..8facb95 100644
--- a/sys/netatm/atm_usrreq.c
+++ b/sys/netatm/atm_usrreq.c
@@ -70,7 +70,7 @@ struct pr_usrreqs atm_dgram_usrreqs = {
.pru_attach = atm_dgram_attach,
.pru_bind = atm_proto_notsupp2,
.pru_control = atm_dgram_control,
- .pru_detach = atm_proto_notsupp1,
+ .pru_detach = atm_proto_notsupp5,
.pru_disconnect = atm_proto_notsupp1,
.pru_peeraddr = atm_proto_notsupp3,
.pru_send = atm_proto_notsupp4,
diff --git a/sys/netatm/atm_var.h b/sys/netatm/atm_var.h
index 23e43192..788acc9 100644
--- a/sys/netatm/atm_var.h
+++ b/sys/netatm/atm_var.h
@@ -151,7 +151,7 @@ int atm_create_stack(Atm_connvc *, struct stack_list *,
/* atm_socket.c */
void atm_sock_init(void);
int atm_sock_attach(struct socket *, u_long, u_long);
-int atm_sock_detach(struct socket *);
+void atm_sock_detach(struct socket *);
int atm_sock_bind(struct socket *, struct sockaddr *);
int atm_sock_listen(struct socket *, Atm_endpoint *, int);
int atm_sock_connect(struct socket *, struct sockaddr *,
OpenPOWER on IntegriCloud