From nobody Thu Oct 24 16:54:53 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 4XZBq21ZRVz5ZfSY; Thu, 24 Oct 2024 16:54:54 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XZBq216hsz4Z9d; Thu, 24 Oct 2024 16:54:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729788894; 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=ymTr2jXVXapd5Au5qqHumu6agXAn1tRMfzoc6Y3HJWs=; b=qkbIvIBIzmhlZOYQ66yK4tpdpTcUBnAU7u2Pf3n9os/EvRdtgitxoJQOb85Bj8kbWucTMb BHaPBCHQPjjKjvhHfV9wwyXzNnJQOUokPSk6WSTpidWEN6MmumISaWDxXRRLSaW/9F+5PN BkLG1L8i3+LyExAoR1fjfjmAaqtaBZQUqGdPJGytegoxMDNz+Ty6v0zohjx+MZ+vBnPGUZ ewhV0vgLzP0YcIYeGsW9pFZgnydut5ty5XDBHWgCmxi0pqY4xOHmCZpwRfJpj0ic08FvRW tGMJvLwq4iOXJcN6+DG8Tk9PUxVZw/2rinljRcGPZAtZCt5Dmc+aRnLXun3U2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729788894; 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=ymTr2jXVXapd5Au5qqHumu6agXAn1tRMfzoc6Y3HJWs=; b=M1xBAnbhcR+2L3rTdlZG5D/m67eC4u7yQ7KceGKylrqpsUHrDdl+Xq9yTXXFWQfIwCrQRf L3JQxAJRVW4yIGcosjTwRswXNww586qdpi5uXkPpE9bYzQaw4xpsGR9zSy8oA584IrC3Ym xJYNXB/U8lxvN60pVpiPHyXHGqyolme2fQjKIw3aRdqd/4FaEuxuH5nt3I2S/sg0qOE9WJ xtOsBELPh841BQQVOe/JmkUh29kTQx3T6VHhMUaZK5GQg/lSZsO9FIOVU6SHc3S1YV/ZEi AZhsf1gAWG6Rpg7H//K5metzFx9OVYCjNi6aElYtkfhsx1C9/Kzn9sai6VoyZw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729788894; a=rsa-sha256; cv=none; b=wjVP0gbEmA7g/N06X86uuz1mDZl7pfsg1qI/1ZjlnpDMLFWBqegqPjFDPkhgYAdXkw14Kq 9zP3QR/UtE5x2NEfVoVLiQJErE/E3zjdb+eq/4P+fGMgFvHCAszu4QBnFBddfVm26JcHIx Pl2GMHpkME9qlOrE4Y7/r2lo2xK4QTO5naHRI5FSUnolI9j9LDHf4FFkSwKnPaA8STvdaC 8yNlUcfnyGuCXmiNvMcIflFPFYB9gBGd7T0jk+Ys0cS+XH1oJzwGGlFhFSjZJRVa6DhaO/ h6SpU1owVGyWEmkkZnxrLEgC6047U/ajnw196/unwwLytYPhY1nwZiOLhlJxfQ== 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 4XZBq20bXLzrC8; Thu, 24 Oct 2024 16:54:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49OGsr8s062926; Thu, 24 Oct 2024 16:54:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49OGsrk3062923; Thu, 24 Oct 2024 16:54:53 GMT (envelope-from git) Date: Thu, 24 Oct 2024 16:54:53 GMT Message-Id: <202410241654.49OGsrk3062923@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: f3a097d0312c - main - netstat: switch to using the sysctl-exported stats for live stats 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: kevans X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f3a097d0312cbadefa9bbb00cf3c6af784f9fbb9 Auto-Submitted: auto-generated The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=f3a097d0312cbadefa9bbb00cf3c6af784f9fbb9 commit f3a097d0312cbadefa9bbb00cf3c6af784f9fbb9 Author: Kyle Evans AuthorDate: 2024-10-24 16:53:59 +0000 Commit: Kyle Evans CommitDate: 2024-10-24 16:54:21 +0000 netstat: switch to using the sysctl-exported stats for live stats Now that we export the relevant stats via the net.route.stats sysctl, switch to using that to avoid having to dig around in mem(4) for live kernel statistics. Based on callers of kresolve_list(), this is the last live path using mem(4) that could be functional today. Tested both with `netstat -rs` and `netstat -rs -M`. Note that this will not be able to extract stats from a running kernel that predates 3360a15898 / 1500026, but this can be worked around by specifying `-M /dev/mem` explicitly in the interim to fallback to libkvm against /dev/mem. Reviewed by: glebius, markj, zlei Differential Revision: https://reviews.freebsd.org/D47231 --- usr.bin/netstat/main.c | 7 ++----- usr.bin/netstat/route.c | 8 +++----- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c index eaca38365ed8..97509ea6798b 100644 --- a/usr.bin/netstat/main.c +++ b/usr.bin/netstat/main.c @@ -523,12 +523,9 @@ main(int argc, char *argv[]) if (rflag) { xo_open_container("statistics"); xo_set_version(NETSTAT_XO_VERSION); - if (sflag) { - if (live) { - kresolve_list(nl); - } + if (sflag) rt_stats(); - } else + else routepr(fib, af); xo_close_container("statistics"); if (xo_finish() < 0) diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c index f32ddee8403f..74797e2addb8 100644 --- a/usr.bin/netstat/route.c +++ b/usr.bin/netstat/route.c @@ -699,13 +699,11 @@ void rt_stats(void) { struct rtstat rtstat; - u_long rtsaddr; - if ((rtsaddr = nl[N_RTSTAT].n_value) == 0) { - xo_emit("{W:rtstat: symbol not in namelist}\n"); + if (fetch_stats("net.route.stats", nl[N_RTSTAT].n_value, &rtstat, + sizeof(rtstat), kread_counters) != 0) return; - } - kread_counters(rtsaddr, (char *)&rtstat, sizeof (rtstat)); + xo_emit("{T:routing}:\n"); #define p(f, m) if (rtstat.f || sflag <= 1) \