diff options
author | sam <sam@FreeBSD.org> | 2006-11-22 17:16:54 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2006-11-22 17:16:54 +0000 |
commit | c380f600ad6c50f307bb89da92cbe5d4ff29cfe1 (patch) | |
tree | 7c18462b52071ca6e1ab135e25aa3aeb56e69a42 /sys/netinet/tcp_usrreq.c | |
parent | bcc8dcd383b99785d2df7ca26b8c621d166e6b82 (diff) | |
download | FreeBSD-src-c380f600ad6c50f307bb89da92cbe5d4ff29cfe1.zip FreeBSD-src-c380f600ad6c50f307bb89da92cbe5d4ff29cfe1.tar.gz |
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
Diffstat (limited to 'sys/netinet/tcp_usrreq.c')
-rw-r--r-- | sys/netinet/tcp_usrreq.c | 12 |
1 files changed, 6 insertions, 6 deletions
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); |