From nobody Tue Jun 18 00:21:18 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4W36qf3NhFz5MDTn; Tue, 18 Jun 2024 00:21:18 +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 4W36qf2l8gz4kyQ; Tue, 18 Jun 2024 00:21:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718670078; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=QpyamKc0y7LCyio2eTBavXy5qX1sGjjJwdF+wzikKKk=; b=kj7PZuJDn+iv9ATycRR9z14HhIn8ZaNDyvZWcyQAUjEpiSqR5T6YVgcsKzcAEXyIE7fW4b Jk+R/jvd2DTT9pXsIdENqcEMvGxQpNES8DU1rMpRIFOIqw5qySf1BWKdgN/3jnJXU6vCEW USu3hIUBkOEvVCLN+05LcbNncX6DlrkLNhTg0IaBt/m5OxPl0x+vckUvWkkNkrc55FS4yd RDhhb5wkg7aOuniwesl64rms3dHH9AFPd5oSTmOxalDMmL/pFW758Zn8W9wTNywADUbZU/ wCa9tRodtkQs04iROjlGpHyQSO1JmX4hPixVKXRyxzhvcUMOthrbLvMvdxVOWg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1718670078; a=rsa-sha256; cv=none; b=SZ7pl/tZRUoNLk06FNYW5KiZZahBRd67PYHNsT8nBOWaXhEGNqdekjIjjzUUSaCZuO4Wn4 YkHD6e38d3CgQYfIXES5NfSABUf+jxgqrHR1BZn4/FSDiMNu0lPgMRERFjBi++vC2MLqku 1J+73Jp27xcyYkNbN5rszp7lF4qW5gcqX03u+rlpCWLjRKCncqS2VMIjC4WC65oTshKtfn JfazKJCSmzrHO7ZeJUt6q4m1bA8fVoKvYqDfn36kyvjGxxHiO20/65YuTYh/8Yg3zX51nQ GN+8qwa2x46wSeR+6HmSvjfcAF+LOIHGJQynJlmeFsXCKzK5ZTsdrf7YHksQvA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718670078; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=QpyamKc0y7LCyio2eTBavXy5qX1sGjjJwdF+wzikKKk=; b=VQ44DARF7/DLcJb5QlUzCOJJRbKIw36fUqbUntX2yngzFL/uC6xvrpiZdYHa1zRJPBtAzx E0T6nZiEyaNknNDlm23LU5ETte30Q86Lb6kHiUNXwaXKCNcxlya5wWCPjV+dNO14CYPijd 6y0vRDYHnRC1QdaaAWjx7Ut2bzTRSewVNM+EWKhgPaE/BFytgMWl79BwyxK+iHnrkenTxD oSAi4cEK9Q/4B57cgjM2iQT0BOQx/TXfAshr873JeTHH0/TAMVmnvhp9KEvTagPA9rFPWZ Xu8fhMuFctsjagUOM4w1okM2S42LJk2MYRmKSUxC006yzufWKMfjG/i2KXQYfw== 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 4W36qf2M3jzcnw; Tue, 18 Jun 2024 00:21:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 45I0LILu093327; Tue, 18 Jun 2024 00:21:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 45I0LIA0093325; Tue, 18 Jun 2024 00:21:18 GMT (envelope-from git) Date: Tue, 18 Jun 2024 00:21:18 GMT Message-Id: <202406180021.45I0LIA0093325@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: e2ad879d4c60 - main - ifconfig: make interface address without mask an error List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e2ad879d4c60fb22e768da5caec92920bc5f626b Auto-Submitted: auto-generated The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=e2ad879d4c60fb22e768da5caec92920bc5f626b commit e2ad879d4c60fb22e768da5caec92920bc5f626b Author: Ed Maste AuthorDate: 2024-06-13 17:37:32 +0000 Commit: Ed Maste CommitDate: 2024-06-18 00:21:06 +0000 ifconfig: make interface address without mask an error In commit d8237b955528, as part of the deprecation of IPv4 address classes, Mike Karels introduced a warning in ifconfig for setting an address without a width or mask. The commit message says "This will hopefully be an error in the future." As the warning has been included in releases from FreeBSD 13.1 on, and sufficient time has passed, turn this into an error. Reviewed by: allanjude, olce, grembo, philip, gordon Relnotes: Yes Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D45585 --- UPDATING | 5 +++++ sbin/ifconfig/af_inet.c | 32 ++++---------------------------- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/UPDATING b/UPDATING index 98d8b58dcd20..2b6f9cb0d956 100644 --- a/UPDATING +++ b/UPDATING @@ -27,6 +27,11 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 15.x IS SLOW: world, or to merely disable the most expensive debugging functionality at runtime, run "ln -s 'abort:false,junk:false' /etc/malloc.conf".) +20240617: + ifconfig now treats IPv4 addresses without a width or mask as an error. + Specify the desired mask or width along with the IP address on the + ifconfig command line and in rc.conf. + 20240428: OpenBSM auditing runtime (auditd, etc.) has been moved into the new package FreeBSD-audit. If you use OpenBSM auditing and pkgbase, you diff --git a/sbin/ifconfig/af_inet.c b/sbin/ifconfig/af_inet.c index e21956cfc4fd..4fd74d481b3a 100644 --- a/sbin/ifconfig/af_inet.c +++ b/sbin/ifconfig/af_inet.c @@ -436,36 +436,13 @@ in_exec_nl(if_ctx *ctx, unsigned long action, void *data) return (e.error); } - -static void -in_setdefaultmask_nl(void) -{ - struct in_px *px = sintab_nl[ADDR]; - - in_addr_t i = ntohl(px->addr.s_addr); - - /* - * If netmask isn't supplied, use historical default. - * This is deprecated for interfaces other than loopback - * or point-to-point; warn in other cases. In the future - * we should return an error rather than warning. - */ - if (IN_CLASSA(i)) - px->plen = 32 - IN_CLASSA_NSHIFT; - else if (IN_CLASSB(i)) - px->plen = 32 - IN_CLASSB_NSHIFT; - else - px->plen = 32 - IN_CLASSC_NSHIFT; - px->maskset = true; -} #endif static void -warn_nomask(int ifflags) +err_nomask(int ifflags) { if ((ifflags & (IFF_POINTOPOINT | IFF_LOOPBACK)) == 0) { - warnx("WARNING: setting interface address without mask " - "is deprecated,\ndefault mask may not be correct."); + errx(1, "ERROR: setting interface address without mask is no longer supported."); } } @@ -474,12 +451,11 @@ in_postproc(if_ctx *ctx __unused, int newaddr, int ifflags) { #ifdef WITHOUT_NETLINK if (sintab[ADDR]->sin_len != 0 && sintab[MASK]->sin_len == 0 && newaddr) { - warn_nomask(ifflags); + err_nomask(ifflags); } #else if (sintab_nl[ADDR]->addrset && !sintab_nl[ADDR]->maskset && newaddr) { - warn_nomask(ifflags); - in_setdefaultmask_nl(); + err_nomask(ifflags); } #endif }