From nobody Fri Dec 10 16:29:09 2021 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 29D6518D6764; Fri, 10 Dec 2021 16:29:10 +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 4J9bvT6NLMz3Ds3; Fri, 10 Dec 2021 16:29:09 +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 BAE0E1D36D; Fri, 10 Dec 2021 16:29:09 +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 1BAGT9ew076878; Fri, 10 Dec 2021 16:29:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BAGT9sb076877; Fri, 10 Dec 2021 16:29:09 GMT (envelope-from git) Date: Fri, 10 Dec 2021 16:29:09 GMT Message-Id: <202112101629.1BAGT9sb076877@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mike Karels Subject: git: cdae3f501d1b - stable/13 - kernel: deprecate Internet Class A/B/C 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org 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/stable/13 X-Git-Reftype: branch X-Git-Commit: cdae3f501d1b0d6dc7598868a957dc27eeb7efc2 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639153749; 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=3g5HeGJfl1mP3DwJwBu2oc7cFBc91ojhAegEy2cBygc=; b=CfSIVIz7WACJ/C+I6roBsgBfVU4prjD196LNaWrvMMPZw9HE8nj9pZEdu4xVCBIk0amleU /1jKzcy93grOlZgxjhklEVtJJTTP4/Lu7Y0jPOaahLYT8fNzxI4ZX3BMByWvIddQBBBee4 8LKdiqnG/RjTSRLXhmZwJkrY38BKt+icYnMs0m7i/HaWhZ1OQtD60ICbxoBAyvPUB90dym vXj8awqpFz5+hJY0orLkhb1aaqwwoC87LlFOm6lKv27DrncK8kgJjLbudSzBpJtJjcd5cV HjqprDhqARWYn1lI9wcSRqwfTTBa5Bibk0x+ICTXzMI+YY5EE/3cMgYi2od4ug== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639153749; a=rsa-sha256; cv=none; b=I7Ow7MR1WXSpAzSj5IEtPRiexhdeOY8zmo/AtBWzSHynQWr67wJH245fVrnBUxqT8irkyg xDuf9zUvGJO6CirgGR+bt44Uy5SKOym0hXHC/Epq9bYgcuFvzpVXloK+0OdNnTXYEr6BF2 B7/NZnozMAKq9VSs8e5maPtAi5FWgy6bqvnhYMdEf0PRL/N4atTYEtu2MSNG2CruugwkSV whxV+yzpkEl7EeXEXU8ZacU6GSoyrUahPX0CgcJjCUU0LGZXv/IIjH7udAZXYznnlUU9iJ FNiSf49nk+oJ8ug/B2vI86/gEQRbeEc28F3UAegk28CgDjj15bNGHBUHPS/UUQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by karels: URL: https://cgit.FreeBSD.org/src/commit/?id=cdae3f501d1b0d6dc7598868a957dc27eeb7efc2 commit cdae3f501d1b0d6dc7598868a957dc27eeb7efc2 Author: Mike Karels AuthorDate: 2021-10-27 03:01:09 +0000 Commit: Mike Karels CommitDate: 2021-12-10 16:24:15 +0000 kernel: deprecate Internet Class A/B/C Hide historical Class A/B/C macros unless IN_HISTORICAL_NETS is defined; define it for user level. Define IN_MULTICAST separately from IN_CLASSD, and use it in pf instead of IN_CLASSD. Stop using class for setting default masks when not specified; instead, define new default mask (24 bits). Warn when an Internet address is set without a mask. (cherry picked from commit 20d59403961d531467cfab22163f49c131cc8b55) --- sys/contrib/ipfilter/netinet/fil.c | 2 +- sys/netinet/in.c | 19 +++++++++---------- sys/netinet/in.h | 22 +++++++++++++++++----- sys/nfs/bootp_subr.c | 16 ++++++++-------- 4 files changed, 35 insertions(+), 24 deletions(-) diff --git a/sys/contrib/ipfilter/netinet/fil.c b/sys/contrib/ipfilter/netinet/fil.c index 09b4c27a1cb4..4a53ee1727d4 100644 --- a/sys/contrib/ipfilter/netinet/fil.c +++ b/sys/contrib/ipfilter/netinet/fil.c @@ -1715,7 +1715,7 @@ ipf_pr_ipv4hdr(fin) fin->fin_crc += fi->fi_saddr; fi->fi_daddr = ip->ip_dst.s_addr; fin->fin_crc += fi->fi_daddr; - if (IN_CLASSD(ntohl(fi->fi_daddr))) + if (IN_MULTICAST(ntohl(fi->fi_daddr))) fin->fin_flx |= FI_MULTICAST|FI_MBCAST; /* diff --git a/sys/netinet/in.c b/sys/netinet/in.c index b51f1111b88a..3cf1504097bd 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -458,18 +458,17 @@ in_aifaddr_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp, struct thread *td) ia->ia_sockmask = *mask; ia->ia_subnetmask = ntohl(ia->ia_sockmask.sin_addr.s_addr); } else { - in_addr_t i = ntohl(addr->sin_addr.s_addr); - /* - * Be compatible with network classes, if netmask isn't - * supplied, guess it based on classes. + * If netmask isn't supplied, use default for now. + * 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)) - ia->ia_subnetmask = IN_CLASSA_NET; - else if (IN_CLASSB(i)) - ia->ia_subnetmask = IN_CLASSB_NET; - else - ia->ia_subnetmask = IN_CLASSC_NET; + if ((ifp->if_flags & (IFF_POINTOPOINT | IFF_LOOPBACK)) == 0) + printf("%s: set address: WARNING: network mask" + " should be specified; using default mask\n", + ifp->if_xname); + ia->ia_subnetmask = IN_NETMASK_DEFAULT; ia->ia_sockmask.sin_addr.s_addr = htonl(ia->ia_subnetmask); } ia->ia_subnet = ntohl(addr->sin_addr.s_addr) & ia->ia_subnetmask; diff --git a/sys/netinet/in.h b/sys/netinet/in.h index 0206fd16d2fe..ec7efba32f23 100644 --- a/sys/netinet/in.h +++ b/sys/netinet/in.h @@ -342,10 +342,15 @@ __END_DECLS #define IPPORT_MAX 65535 /* - * Definitions of bits in internet address integers. - * On subnets, the decomposition of addresses to host and net parts - * is done according to subnet mask, not the masks here. + * Historical definitions of bits in internet address integers + * (pre-CIDR). Class A/B/C are long obsolete, and now deprecated. + * Hide these definitions from the kernel unless IN_HISTORICAL_NETS + * is defined. Provide the historical definitions to user level for now. */ +#ifndef _KERNEL +#define IN_HISTORICAL_NETS +#endif +#ifdef IN_HISTORICAL_NETS #define IN_CLASSA(i) (((in_addr_t)(i) & 0x80000000) == 0) #define IN_CLASSA_NET 0xff000000 #define IN_CLASSA_NSHIFT 24 @@ -362,12 +367,17 @@ __END_DECLS #define IN_CLASSC_NET 0xffffff00 #define IN_CLASSC_NSHIFT 8 #define IN_CLASSC_HOST 0x000000ff +#endif /* IN_HISTORICAL_NETS */ + +#define IN_NETMASK_DEFAULT 0xffffff00 /* mask when forced to guess */ -#define IN_CLASSD(i) (((in_addr_t)(i) & 0xf0000000) == 0xe0000000) +#define IN_MULTICAST(i) (((in_addr_t)(i) & 0xf0000000) == 0xe0000000) +#ifdef IN_HISTORICAL_NETS +#define IN_CLASSD(i) IN_MULTICAST(i) #define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */ #define IN_CLASSD_NSHIFT 28 /* net and host fields, but */ #define IN_CLASSD_HOST 0x0fffffff /* routing needn't know. */ -#define IN_MULTICAST(i) IN_CLASSD(i) +#endif /* IN_HISTORICAL_NETS */ #define IN_EXPERIMENTAL(i) (((in_addr_t)(i) & 0xf0000000) == 0xf0000000) #define IN_BADCLASS(i) (((in_addr_t)(i) & 0xf0000000) == 0xf0000000) @@ -398,7 +408,9 @@ __END_DECLS #define INADDR_ALLMDNS_GROUP ((in_addr_t)0xe00000fb) /* 224.0.0.251 */ #define INADDR_MAX_LOCAL_GROUP ((in_addr_t)0xe00000ff) /* 224.0.0.255 */ +#ifdef IN_HISTORICAL_NETS #define IN_LOOPBACKNET 127 /* official! */ +#endif /* IN_HISTORICAL_NETS */ #define IN_RFC3021_MASK ((in_addr_t)0xfffffffe) diff --git a/sys/nfs/bootp_subr.c b/sys/nfs/bootp_subr.c index fd0e0653a02c..0067efa81106 100644 --- a/sys/nfs/bootp_subr.c +++ b/sys/nfs/bootp_subr.c @@ -654,7 +654,7 @@ bootpc_call(struct bootpc_globalcontext *gctx, struct thread *td) error, (int )bootp_so->so_state); /* Set netmask to 255.0.0.0 */ - sin->sin_addr.s_addr = htonl(IN_CLASSA_NET); + sin->sin_addr.s_addr = htonl(0xff000000); error = ifioctl(bootp_so, SIOCAIFADDR, (caddr_t)ifra, td); if (error != 0) @@ -882,7 +882,7 @@ bootpc_fakeup_interface(struct bootpc_ifcontext *ifctx, struct thread *td) clear_sinaddr(sin); sin = (struct sockaddr_in *)&ifra->ifra_mask; clear_sinaddr(sin); - sin->sin_addr.s_addr = htonl(IN_CLASSA_NET); + sin->sin_addr.s_addr = htonl(0xff000000); sin = (struct sockaddr_in *)&ifra->ifra_broadaddr; clear_sinaddr(sin); sin->sin_addr.s_addr = htonl(INADDR_BROADCAST); @@ -1485,12 +1485,12 @@ bootpc_decode_reply(struct nfsv3_diskless *nd, struct bootpc_ifcontext *ifctx, printf("\n"); if (ifctx->gotnetmask == 0) { - if (IN_CLASSA(ntohl(ifctx->myaddr.sin_addr.s_addr))) - ifctx->netmask.sin_addr.s_addr = htonl(IN_CLASSA_NET); - else if (IN_CLASSB(ntohl(ifctx->myaddr.sin_addr.s_addr))) - ifctx->netmask.sin_addr.s_addr = htonl(IN_CLASSB_NET); - else - ifctx->netmask.sin_addr.s_addr = htonl(IN_CLASSC_NET); + /* + * If there is no netmask, use a default, but we really + * need the right mask from the server. + */ + printf("%s: no netmask received!\n", ifctx->ireq.ifr_name); + ifctx->netmask.sin_addr.s_addr = htonl(IN_NETMASK_DEFAULT); } }