Author: jch
Date: Fri May 15 12:35:18 2015
New Revision: 282968
URL: https://svnweb.freebsd.org/changeset/base/282968

Log:
  MFC r279821:
  
      In TCP, connect() can return incorrect error code EINVAL
      instead of EADDRINUSE or ECONNREFUSED
  
      PR:                         196035
      Differential Revision:      https://reviews.freebsd.org/D1982
      Reported by:                Mark Nunberg <mnunb...@haskalah.org>
      Submitted by:               Harrison Grundy 
<harrison.gru...@astrodoggroup.com>
      Reviewed by:                adrian, jch, glebius, gnn
      Approved by:                jhb

Modified:
  stable/10/sys/netinet/tcp_usrreq.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/netinet/tcp_usrreq.c
==============================================================================
--- stable/10/sys/netinet/tcp_usrreq.c  Fri May 15 12:32:17 2015        
(r282967)
+++ stable/10/sys/netinet/tcp_usrreq.c  Fri May 15 12:35:18 2015        
(r282968)
@@ -475,8 +475,12 @@ tcp_usr_connect(struct socket *so, struc
        inp = sotoinpcb(so);
        KASSERT(inp != NULL, ("tcp_usr_connect: inp == NULL"));
        INP_WLOCK(inp);
-       if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) {
-               error = EINVAL;
+       if (inp->inp_flags & INP_TIMEWAIT) {
+               error = EADDRINUSE;
+               goto out;
+       }
+       if (inp->inp_flags & INP_DROPPED) {
+               error = ECONNREFUSED;
                goto out;
        }
        tp = intotcpcb(inp);
@@ -522,8 +526,12 @@ tcp6_usr_connect(struct socket *so, stru
        inp = sotoinpcb(so);
        KASSERT(inp != NULL, ("tcp6_usr_connect: inp == NULL"));
        INP_WLOCK(inp);
-       if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) {
-               error = EINVAL;
+       if (inp->inp_flags & INP_TIMEWAIT) {
+               error = EADDRINUSE;
+               goto out;
+       }
+       if (inp->inp_flags & INP_DROPPED) {
+               error = ECONNREFUSED;
                goto out;
        }
        tp = intotcpcb(inp);
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to