From nobody Fri Dec 10 16:29:15 2021 X-Original-To: dev-commits-src-branches@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 6158918D6A9D; Fri, 10 Dec 2021 16:29: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 4J9bvc14fsz3FBK; Fri, 10 Dec 2021 16:29:15 +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 7B71B1D569; Fri, 10 Dec 2021 16:29:15 +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 1BAGTF2c077005; Fri, 10 Dec 2021 16:29:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BAGTFRa077004; Fri, 10 Dec 2021 16:29:15 GMT (envelope-from git) Date: Fri, 10 Dec 2021 16:29:15 GMT Message-Id: <202112101629.1BAGTFRa077004@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: 2cd55edbb288 - stable/13 - netstat: reduce use of historical Internet classes List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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: 2cd55edbb2887c0ceeb10cdbe776a99059fa85fa Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639153756; 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=mfYlZUOt2WpYBU6BclkbYyrKz17v8SmhRgXbGy1/y/o=; b=et7oa1BVXFN/2B1GOfOJaNZSmL11AH6+0BmhPe+MLOdRp+oGMC3rThWTc0/WI+c4n7ZAfM Uef3olPeeaYjGLnr7tSRlWsEmh8GJChti+LMOI0OXcOO1/UZhL8C67HQC4rGd/MoQLNwCr 9ZP8vyqDXHsboRXUmaNjTZ9r6GAcFP/RBF5dDhcGyfQcWfrGZg3raJ9h19o/vj0fF0WfMZ K8Yfkx5x/5Gnu9kUVLVbDmknjgAi2KAbSKTgyi7h9bx/LEqrISu+oSvYOay6Y3q8aQkug5 1AJ8T2g1jlXgtGEbTHZh3owM3CnNKAY6Q2PCPaXBoGz7dAzbejv6bog/BKR0KA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639153756; a=rsa-sha256; cv=none; b=GjkUT2oWOvAQW6aYROvPQ9vH5tJArpE45+txj6+bVOw06gBJyNi+vGMcH/k/ne4aIF8Cju Eb8o98u5fyhi4CTccnxYtjFR3gFqJ5XhgW/cn3Aoc8aaol2sAV2Alk4VB+H4AGLj7GpGmd scAPaihrq84FseIKUWaVHB0tbGVmD72MQB9KE+2su9zB16s0GzZbl/K/PJYHQlmxQud0FU LpFhdcY2pURWPvfc1WiZj3LMyUdCxD04QLpQEdQLyK5m0NnlckX4lT8gM6UcASudeFc3in 979dirHc8w9lexrJOr6JDJYc/4M+8ovTtaP4k6Gl4T5WnoJwju8zcCR8bNGN3g== 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=2cd55edbb2887c0ceeb10cdbe776a99059fa85fa commit 2cd55edbb2887c0ceeb10cdbe776a99059fa85fa Author: Mike Karels AuthorDate: 2021-10-27 03:39:10 +0000 Commit: Mike Karels CommitDate: 2021-12-10 16:27:02 +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. (cherry picked from commit bd27c71c4573e14916ccd27e545a69606f0a8192) --- 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 49478c4a9247..b46f5c92e808 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)) @@ -1471,24 +1471,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)