Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 9 Mar 2015 20:29:17 +0000 (UTC)
From:      Julien Charbon <jch@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r279821 - head/sys/netinet
Message-ID:  <201503092029.t29KTHRV021183@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jch
Date: Mon Mar  9 20:29:16 2015
New Revision: 279821
URL: https://svnweb.freebsd.org/changeset/base/279821

Log:
  In TCP, connect() can return incorrect error code EINVAL
  instead of EADDRINUSE or ECONNREFUSED
  
  PR:			https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=196035
  Differential Revision:	https://reviews.freebsd.org/D1982
  Reported by:		Mark Nunberg <mnunberg@haskalah.org>
  Submitted by:		Harrison Grundy <harrison.grundy@astrodoggroup.com>
  Reviewed by:		adrian, jch, glebius, gnn
  Approved by:		jhb
  MFC after:		2 weeks

Modified:
  head/sys/netinet/tcp_usrreq.c

Modified: head/sys/netinet/tcp_usrreq.c
==============================================================================
--- head/sys/netinet/tcp_usrreq.c	Mon Mar  9 20:26:42 2015	(r279820)
+++ head/sys/netinet/tcp_usrreq.c	Mon Mar  9 20:29:16 2015	(r279821)
@@ -476,8 +476,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);
@@ -523,8 +527,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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201503092029.t29KTHRV021183>