diff options
author | rwatson <rwatson@FreeBSD.org> | 2006-03-17 20:40:17 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2006-03-17 20:40:17 +0000 |
commit | 76be92c1fd12cec9a2581cc5005447062182a4ab (patch) | |
tree | 61ebc965b2fffece1ff25d1b6c69913d8480e955 /sys/netatalk | |
parent | cbcf9b2ad93aae5c590fdea1786ba60eac7c97fa (diff) | |
download | FreeBSD-src-76be92c1fd12cec9a2581cc5005447062182a4ab.zip FreeBSD-src-76be92c1fd12cec9a2581cc5005447062182a4ab.tar.gz |
Modify netatalk to ensure, and assert, that pcb's remain attached to
sockets as long as the sockets have not been aborted or detached. Do
not try to free the socket in pru_detach(), since sofree() will do so,
if needed, once pru_detach() returns.
Annotate a bug in ddp_abort(), which fails to free the socket; this
is probably OK as ddp_abort() should never be called, so should
instead be deleted.
Diffstat (limited to 'sys/netatalk')
-rw-r--r-- | sys/netatalk/ddp_pcb.c | 5 | ||||
-rw-r--r-- | sys/netatalk/ddp_usrreq.c | 32 |
2 files changed, 11 insertions, 26 deletions
diff --git a/sys/netatalk/ddp_pcb.c b/sys/netatalk/ddp_pcb.c index 23ccd8c..3c8ac96 100644 --- a/sys/netatalk/ddp_pcb.c +++ b/sys/netatalk/ddp_pcb.c @@ -302,12 +302,11 @@ at_pcbdetach(struct socket *so, struct ddpcb *ddp) */ DDP_LIST_XLOCK_ASSERT(); DDP_LOCK_ASSERT(ddp); + KASSERT(so->so_pcb != NULL, ("at_pcbdetach: so_pcb == NULL")); + /* XXXRW: Why bother to disconnect it now? */ soisdisconnected(so); - ACCEPT_LOCK(); - SOCK_LOCK(so); so->so_pcb = NULL; - sotryfree(so); /* remove ddp from ddp_ports list */ if (ddp->ddp_lsat.sat_port != ATADDR_ANYPORT && diff --git a/sys/netatalk/ddp_usrreq.c b/sys/netatalk/ddp_usrreq.c index e3bde16..df04cab 100644 --- a/sys/netatalk/ddp_usrreq.c +++ b/sys/netatalk/ddp_usrreq.c @@ -56,8 +56,7 @@ ddp_attach(struct socket *so, int proto, struct thread *td) int error = 0; ddp = sotoddpcb(so); - if (ddp != NULL) - return (EINVAL); + KASSERT(ddp == NULL, ("ddp_attach: ddp != NULL")); /* * Allocate socket buffer space first so that it's present @@ -79,8 +78,7 @@ ddp_detach(struct socket *so) struct ddpcb *ddp; ddp = sotoddpcb(so); - if (ddp == NULL) - return (EINVAL); + KASSERT(ddp != NULL, ("ddp_detach: ddp == NULL")); DDP_LIST_XLOCK(); DDP_LOCK(ddp); @@ -96,9 +94,7 @@ ddp_bind(struct socket *so, struct sockaddr *nam, struct thread *td) int error = 0; ddp = sotoddpcb(so); - if (ddp == NULL) { - return (EINVAL); - } + KASSERT(ddp != NULL, ("ddp_bind: ddp == NULL")); DDP_LIST_XLOCK(); DDP_LOCK(ddp); error = at_pcbsetaddr(ddp, nam, td); @@ -114,10 +110,7 @@ ddp_connect(struct socket *so, struct sockaddr *nam, struct thread *td) int error = 0; ddp = sotoddpcb(so); - if (ddp == NULL) { - return (EINVAL); - } - + KASSERT(ddp != NULL, ("ddp_connect: ddp == NULL")); DDP_LIST_XLOCK(); DDP_LOCK(ddp); if (ddp->ddp_fsat.sat_port != ATADDR_ANYPORT) { @@ -141,9 +134,7 @@ ddp_disconnect(struct socket *so) struct ddpcb *ddp; ddp = sotoddpcb(so); - if (ddp == NULL) { - return (EINVAL); - } + KASSERT(ddp != NULL, ("ddp_disconnect: ddp == NULL")); DDP_LOCK(ddp); if (ddp->ddp_fsat.sat_addr.s_node == ATADDR_ANYNODE) { DDP_UNLOCK(ddp); @@ -163,9 +154,7 @@ ddp_shutdown(struct socket *so) struct ddpcb *ddp; ddp = sotoddpcb(so); - if (ddp == NULL) { - return (EINVAL); - } + KASSERT(ddp != NULL, ("ddp_shutdown: ddp == NULL")); socantsendmore(so); return (0); } @@ -178,9 +167,7 @@ ddp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, int error = 0; ddp = sotoddpcb(so); - if (ddp == NULL) { - return (EINVAL); - } + KASSERT(ddp != NULL, ("ddp_send: ddp == NULL")); if (control && control->m_len) { return (EINVAL); @@ -219,13 +206,12 @@ ddp_abort(struct socket *so) struct ddpcb *ddp; ddp = sotoddpcb(so); - if (ddp == NULL) { - return (EINVAL); - } + KASSERT(ddp != NULL, ("ddp_abort: ddp == NULL")); DDP_LIST_XLOCK(); DDP_LOCK(ddp); at_pcbdetach(so, ddp); DDP_LIST_XUNLOCK(); + /* XXXRW: Should be calling sotryfree() here? */ return (0); } |