From nobody Tue Nov 09 15:36:09 2021 X-Original-To: dev-commits-src-main@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 158301848ADA; Tue, 9 Nov 2021 15:36:11 +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 4HpXBd5V4Gz4tms; Tue, 9 Nov 2021 15:36: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 623D52736D; Tue, 9 Nov 2021 15:36: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 1A9Fa9x3000126; Tue, 9 Nov 2021 15:36:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A9Fa91p000125; Tue, 9 Nov 2021 15:36:09 GMT (envelope-from git) Date: Tue, 9 Nov 2021 15:36:09 GMT Message-Id: <202111091536.1A9Fa91p000125@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: a2e7dfca8649 - main - systat: clean up code assuming network classes List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: a2e7dfca86497e535039a42cfc44cfc48209abf5 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by karels: URL: https://cgit.FreeBSD.org/src/commit/?id=a2e7dfca86497e535039a42cfc44cfc48209abf5 commit a2e7dfca86497e535039a42cfc44cfc48209abf5 Author: Mike Karels AuthorDate: 2021-10-28 23:39:43 +0000 Commit: Mike Karels CommitDate: 2021-11-09 15:35:16 +0000 systat: clean up code assuming network classes Similar to netstat, clean up code that uses inet_lnaof() to check for binding to "host 0" (lowest host on network) as a "network" bind. Such things don't happen, and current networks are seldom if ever found in /etc/networks. MFC after: 1 month Reviewers: tuexen Differential Revision: https://reviews.freebsd.org/D32720 --- usr.bin/systat/netstat.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/usr.bin/systat/netstat.c b/usr.bin/systat/netstat.c index 8199d0c81586..96d4194db72d 100644 --- a/usr.bin/systat/netstat.c +++ b/usr.bin/systat/netstat.c @@ -206,7 +206,7 @@ again: next = &inpcb; if (!aflag) { if (inpcb.inp_vflag & INP_IPV4) { - if (inet_lnaof(inpcb.inp_laddr) == INADDR_ANY) + if (inpcb.inp_laddr.s_addr == INADDR_ANY) continue; } #ifdef INET6 @@ -303,8 +303,7 @@ fetchnetstat_sysctl(void) if (!aflag) { if (xip->inp_vflag & INP_IPV4) { - if (inet_lnaof(xip->inp_laddr) == - INADDR_ANY) + if (xip->inp_laddr.s_addr == INADDR_ANY) continue; } #ifdef INET6 @@ -584,7 +583,6 @@ inetname(struct sockaddr *sa) char *cp = 0; static char line[NI_MAXHOST]; struct hostent *hp; - struct netent *np; struct in_addr in; #ifdef INET6 @@ -601,19 +599,9 @@ inetname(struct sockaddr *sa) in = ((struct sockaddr_in *)sa)->sin_addr; if (!nflag && in.s_addr != INADDR_ANY) { - int net = inet_netof(in); - int lna = inet_lnaof(in); - - if (lna == INADDR_ANY) { - np = getnetbyaddr(net, AF_INET); - if (np) - cp = np->n_name; - } - if (cp == NULL) { - hp = gethostbyaddr((char *)&in, sizeof (in), AF_INET); - if (hp) - cp = hp->h_name; - } + hp = gethostbyaddr((char *)&in, sizeof (in), AF_INET); + if (hp) + cp = hp->h_name; } if (in.s_addr == INADDR_ANY) strcpy(line, "*");