From c380f600ad6c50f307bb89da92cbe5d4ff29cfe1 Mon Sep 17 00:00:00 2001 From: sam Date: Wed, 22 Nov 2006 17:16:54 +0000 Subject: Change error codes returned by protocol operations when an inpcb is marked INP_DROPPED or INP_TIMEWAIT: o return ECONNRESET instead of EINVAL for close, disconnect, shutdown, rcvd, rcvoob, and send operations o return ECONNABORTED instead of EINVAL for accept These changes should reduce confusion in applications since EINVAL is normally interpreted to mean an invalid file descriptor. This change does not conflict with POSIX or other standards I checked. The return of EINVAL has always been possible but rare; it's become more common with recent changes to the socket/inpcb handling and with finer-grained locking and preemption. Note: there are other instances of EINVAL for this state that were left unchanged; they should be reviewed. Reviewed by: rwatson, andre, ru MFC after: 1 month --- sys/netinet/tcp_usrreq.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'sys/netinet/tcp_usrreq.c') diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index fb61602..fa522b4 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -571,7 +571,7 @@ tcp_usr_disconnect(struct socket *so) KASSERT(inp != NULL, ("tcp_usr_disconnect: inp == NULL")); INP_LOCK(inp); if (inp->inp_vflag & (INP_TIMEWAIT | INP_DROPPED)) { - error = EINVAL; + error = ECONNRESET; goto out; } tp = intotcpcb(inp); @@ -648,7 +648,7 @@ tcp6_usr_accept(struct socket *so, struct sockaddr **nam) KASSERT(inp != NULL, ("tcp6_usr_accept: inp == NULL")); INP_LOCK(inp); if (inp->inp_vflag & (INP_TIMEWAIT | INP_DROPPED)) { - error = EINVAL; + error = ECONNABORTED; goto out; } tp = intotcpcb(inp); @@ -718,7 +718,7 @@ tcp_usr_shutdown(struct socket *so) KASSERT(inp != NULL, ("inp == NULL")); INP_LOCK(inp); if (inp->inp_vflag & (INP_TIMEWAIT | INP_DROPPED)) { - error = EINVAL; + error = ECONNRESET; goto out; } tp = intotcpcb(inp); @@ -750,7 +750,7 @@ tcp_usr_rcvd(struct socket *so, int flags) KASSERT(inp != NULL, ("tcp_usr_rcvd: inp == NULL")); INP_LOCK(inp); if (inp->inp_vflag & (INP_TIMEWAIT | INP_DROPPED)) { - error = EINVAL; + error = ECONNRESET; goto out; } tp = intotcpcb(inp); @@ -804,7 +804,7 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, m_freem(control); if (m) m_freem(m); - error = EINVAL; + error = ECONNRESET; goto out; } #ifdef INET6 @@ -1015,7 +1015,7 @@ tcp_usr_rcvoob(struct socket *so, struct mbuf *m, int flags) KASSERT(inp != NULL, ("tcp_usr_rcvoob: inp == NULL")); INP_LOCK(inp); if (inp->inp_vflag & (INP_TIMEWAIT | INP_DROPPED)) { - error = EINVAL; + error = ECONNRESET; goto out; } tp = intotcpcb(inp); -- cgit v1.1