From owner-dev-commits-src-all@freebsd.org Fri Sep 17 00:42:36 2021 Return-Path: Delivered-To: dev-commits-src-all@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 DF96D6AADEA; Fri, 17 Sep 2021 00:42:36 +0000 (UTC) (envelope-from git@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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4H9Zt45XVJz3rSL; Fri, 17 Sep 2021 00:42:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9E2D4347F; Fri, 17 Sep 2021 00:42:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 18H0gag9091288; Fri, 17 Sep 2021 00:42:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 18H0gadO091287; Fri, 17 Sep 2021 00:42:36 GMT (envelope-from git) Date: Fri, 17 Sep 2021 00:42:36 GMT Message-Id: <202109170042.18H0gadO091287@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mike Karels Subject: git: fd0765933c3c - main - Change lowest address on subnet (host 0) not to broadcast by default. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: karels X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fd0765933c3ccb059ad7456e657b2e8ed22f58b0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Sep 2021 00:42:36 -0000 The branch main has been updated by karels: URL: https://cgit.FreeBSD.org/src/commit/?id=fd0765933c3ccb059ad7456e657b2e8ed22f58b0 commit fd0765933c3ccb059ad7456e657b2e8ed22f58b0 Author: Mike Karels AuthorDate: 2021-09-05 18:14:04 +0000 Commit: Mike Karels CommitDate: 2021-09-17 00:42:20 +0000 Change lowest address on subnet (host 0) not to broadcast by default. The address with a host part of all zeros was used as a broadcast long ago, but the default has been all ones since 4.3BSD and RFC1122. Until now, we would broadcast the host zero address as well as the configured address. Change to not broadcasting that address by default, but add a sysctl (net.inet.ip.broadcast_lowest) to re-enable it. Note that the correct way to use the zero address for broadcast would be to configure it as the broadcast address for the network. See https:/datatracker.ietf.org/doc/draft-schoen-intarea-lowest-address/ and the discussion in https://reviews.freebsd.org/D19316. Note, Linux now implements this. Reviewed by: rgrimes, tuexen; melifaro (previous version) MFC after: 1 month Relnotes: yes Differential Revision: https://reviews.freebsd.org/D31861 --- sys/netinet/in.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sys/netinet/in.c b/sys/netinet/in.c index e968a559a13c..b51f1111b88a 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -88,6 +88,12 @@ SYSCTL_INT(_net_inet_ip, OID_AUTO, no_same_prefix, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nosameprefix), 0, "Refuse to create same prefixes on different interfaces"); +VNET_DEFINE_STATIC(bool, broadcast_lowest); +#define V_broadcast_lowest VNET(broadcast_lowest) +SYSCTL_BOOL(_net_inet_ip, OID_AUTO, broadcast_lowest, CTLFLAG_VNET | CTLFLAG_RW, + &VNET_NAME(broadcast_lowest), 0, + "Treat lowest address on a subnet (host 0) as broadcast"); + VNET_DECLARE(struct inpcbinfo, ripcbinfo); #define V_ripcbinfo VNET(ripcbinfo) @@ -1170,10 +1176,10 @@ in_ifaddr_broadcast(struct in_addr in, struct in_ifaddr *ia) return ((in.s_addr == ia->ia_broadaddr.sin_addr.s_addr || /* - * Check for old-style (host 0) broadcast, but + * Optionally check for old-style (host 0) broadcast, but * taking into account that RFC 3021 obsoletes it. */ - (ia->ia_subnetmask != IN_RFC3021_MASK && + (V_broadcast_lowest && ia->ia_subnetmask != IN_RFC3021_MASK && ntohl(in.s_addr) == ia->ia_subnet)) && /* * Check for an all one subnetmask. These