(Re)-allow 0.0.0.0 to be used as an address in connect() for TCP
In r361752 an error handling was introduced for using 0.0.0.0 or 255.255.255.255 as the address in connect() for TCP, since both addresses can't be used. However, the stack maps 0.0.0.0 implicitly to a local address and at least two regressions were reported. Therefore, re-allow the usage of 0.0.0.0. While there, change the error indicated when using 255.255.255.255 from EAFNOSUPPORT to EACCES as mentioned in the man-page of connect(). Reviewed by: rrs MFC after: 1 week Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D25401
This commit is contained in:
parent
d413f7588d
commit
ec7b0c26c0
@ -553,9 +553,8 @@ tcp_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
&& IN_MULTICAST(ntohl(sinp->sin_addr.s_addr)))
|
||||
return (EAFNOSUPPORT);
|
||||
if ((sinp->sin_family == AF_INET) &&
|
||||
((ntohl(sinp->sin_addr.s_addr) == INADDR_BROADCAST) ||
|
||||
(sinp->sin_addr.s_addr == INADDR_ANY)))
|
||||
return(EAFNOSUPPORT);
|
||||
(ntohl(sinp->sin_addr.s_addr) == INADDR_BROADCAST))
|
||||
return (EACCES);
|
||||
if ((error = prison_remote_ip4(td->td_ucred, &sinp->sin_addr)) != 0)
|
||||
return (error);
|
||||
|
||||
@ -656,9 +655,8 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
error = EAFNOSUPPORT;
|
||||
goto out;
|
||||
}
|
||||
if ((ntohl(sin.sin_addr.s_addr) == INADDR_BROADCAST) ||
|
||||
(sin.sin_addr.s_addr == INADDR_ANY)) {
|
||||
error = EAFNOSUPPORT;
|
||||
if (ntohl(sin.sin_addr.s_addr) == INADDR_BROADCAST) {
|
||||
error = EACCES;
|
||||
goto out;
|
||||
}
|
||||
if ((error = prison_remote_ip4(td->td_ucred,
|
||||
@ -1033,11 +1031,10 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m,
|
||||
error = EAFNOSUPPORT;
|
||||
goto out;
|
||||
}
|
||||
if ((ntohl(sinp->sin_addr.s_addr) == INADDR_BROADCAST) ||
|
||||
(sinp->sin_addr.s_addr == INADDR_ANY)) {
|
||||
if (ntohl(sinp->sin_addr.s_addr) == INADDR_BROADCAST) {
|
||||
if (m)
|
||||
m_freem(m);
|
||||
error = EAFNOSUPPORT;
|
||||
error = EACCES;
|
||||
goto out;
|
||||
}
|
||||
if ((error = prison_remote_ip4(td->td_ucred,
|
||||
|
Loading…
Reference in New Issue
Block a user