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
This commit is contained in:
Sam Leffler 2006-11-22 17:16:54 +00:00
parent d91b1b4976
commit 21367f630d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=164516

View File

@ -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);