From nobody Tue Nov 09 15:36:07 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 2D03218489FF; Tue, 9 Nov 2021 15:36:08 +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 4HpXBb4wzgz4tkV; Tue, 9 Nov 2021 15:36:07 +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 1D2E92752B; Tue, 9 Nov 2021 15:36:07 +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 1A9Fa7LC099977; Tue, 9 Nov 2021 15:36:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A9Fa7kJ099976; Tue, 9 Nov 2021 15:36:07 GMT (envelope-from git) Date: Tue, 9 Nov 2021 15:36:07 GMT Message-Id: <202111091536.1A9Fa7kJ099976@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: bd27c71c4573 - main - netstat: reduce use of historical Internet classes 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/main X-Git-Reftype: branch X-Git-Commit: bd27c71c4573e14916ccd27e545a69606f0a8192 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by karels: URL: https://cgit.FreeBSD.org/src/commit/?id=bd27c71c4573e14916ccd27e545a69606f0a8192 commit bd27c71c4573e14916ccd27e545a69606f0a8192 Author: Mike Karels AuthorDate: 2021-10-27 03:39:10 +0000 Commit: Mike Karels CommitDate: 2021-11-09 15:34:22 +0000 netstat: reduce use of historical Internet classes When attempting to characterize bound addresses, netstat was checking for host 0 on a (historical) net using inet_lnaof(). Such addresses are not normally bound, as they would not work, with the exception of the unspecified address, INADDR_ANY. Check for that explicitly. Similarly, don't check bound addresses for a match to a network name. MFC after: 1 month Reviewed by: tuexen Differential Revision: https://reviews.freebsd.org/D32714 --- usr.bin/netstat/inet.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index 2d3a4bb10d52..dc777b0be990 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -296,14 +296,14 @@ protopr(u_long off, const char *name, int af1, int proto) ( (istcp && tp->t_state == TCPS_LISTEN) || (af1 == AF_INET && - inet_lnaof(inp->inp_laddr) == INADDR_ANY) + inp->inp_laddr.s_addr == INADDR_ANY) #ifdef INET6 || (af1 == AF_INET6 && IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr)) #endif /* INET6 */ || (af1 == AF_UNSPEC && (((inp->inp_vflag & INP_IPV4) != 0 && - inet_lnaof(inp->inp_laddr) == INADDR_ANY) + inp->inp_laddr.s_addr == INADDR_ANY) #ifdef INET6 || ((inp->inp_vflag & INP_IPV6) != 0 && IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr)) @@ -1479,24 +1479,13 @@ inetname(struct in_addr *inp) char *cp; static char line[MAXHOSTNAMELEN]; struct hostent *hp; - struct netent *np; cp = 0; if (!numeric_addr && inp->s_addr != INADDR_ANY) { - int net = inet_netof(*inp); - int lna = inet_lnaof(*inp); - - if (lna == INADDR_ANY) { - np = getnetbyaddr(net, AF_INET); - if (np) - cp = np->n_name; - } - if (cp == NULL) { - hp = gethostbyaddr((char *)inp, sizeof (*inp), AF_INET); - if (hp) { - cp = hp->h_name; - trimdomain(cp, strlen(cp)); - } + hp = gethostbyaddr((char *)inp, sizeof (*inp), AF_INET); + if (hp) { + cp = hp->h_name; + trimdomain(cp, strlen(cp)); } } if (inp->s_addr == INADDR_ANY)