From owner-svn-src-head@freebsd.org Thu Jul 16 16:46:25 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A823A366F92; Thu, 16 Jul 2020 16:46:25 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4B70Wj3vYYz3WXC; Thu, 16 Jul 2020 16:46:25 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6A7EEB4E8; Thu, 16 Jul 2020 16:46:25 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 06GGkPd9043742; Thu, 16 Jul 2020 16:46:25 GMT (envelope-from tuexen@FreeBSD.org) Received: (from tuexen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 06GGkPfH043741; Thu, 16 Jul 2020 16:46:25 GMT (envelope-from tuexen@FreeBSD.org) Message-Id: <202007161646.06GGkPfH043741@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tuexen set sender to tuexen@FreeBSD.org using -f From: Michael Tuexen Date: Thu, 16 Jul 2020 16:46:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r363256 - head/sys/netinet X-SVN-Group: head X-SVN-Commit-Author: tuexen X-SVN-Commit-Paths: head/sys/netinet X-SVN-Commit-Revision: 363256 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Jul 2020 16:46:25 -0000 Author: tuexen Date: Thu Jul 16 16:46:24 2020 New Revision: 363256 URL: https://svnweb.freebsd.org/changeset/base/363256 Log: (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 Modified: head/sys/netinet/tcp_usrreq.c Modified: head/sys/netinet/tcp_usrreq.c ============================================================================== --- head/sys/netinet/tcp_usrreq.c Thu Jul 16 16:32:16 2020 (r363255) +++ head/sys/netinet/tcp_usrreq.c Thu Jul 16 16:46:24 2020 (r363256) @@ -553,9 +553,8 @@ tcp_usr_connect(struct socket *so, struct sockaddr *na && 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 *n 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 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,