summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorjch <jch@FreeBSD.org>2015-05-15 12:35:18 +0000
committerjch <jch@FreeBSD.org>2015-05-15 12:35:18 +0000
commit47cc02d0ccd815d336fb20171d05ef470775200a (patch)
treef71c85dc3f8b770a594d021c27b082733307f339 /sys
parentc3c407f451b0e0fd1caedfd880ff942cf71ee717 (diff)
downloadFreeBSD-src-47cc02d0ccd815d336fb20171d05ef470775200a.zip
FreeBSD-src-47cc02d0ccd815d336fb20171d05ef470775200a.tar.gz
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 <mnunberg@haskalah.org> Submitted by: Harrison Grundy <harrison.grundy@astrodoggroup.com> Reviewed by: adrian, jch, glebius, gnn Approved by: jhb
Diffstat (limited to 'sys')
-rw-r--r--sys/netinet/tcp_usrreq.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index 8d92803..be9e0e7 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -475,8 +475,12 @@ tcp_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
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, struct sockaddr *nam, struct thread *td)
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);
OpenPOWER on IntegriCloud