From nobody Tue Oct 05 09:44:40 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 4102712D934E; Tue, 5 Oct 2021 09:44:41 +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 4HNt3D4WTfz4hJC; Tue, 5 Oct 2021 09:44:40 +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 772CB216E; Tue, 5 Oct 2021 09:44:40 +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 1959ieLx016374; Tue, 5 Oct 2021 09:44:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1959ieFk016373; Tue, 5 Oct 2021 09:44:40 GMT (envelope-from git) Date: Tue, 5 Oct 2021 09:44:40 GMT Message-Id: <202110050944.1959ieFk016373@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: ae4fb190fd4a - main - netstat: split ipsec and ipsec6 statistics in libxo 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: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ae4fb190fd4a21649c4562fc6cd81bba4da222a4 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=ae4fb190fd4a21649c4562fc6cd81bba4da222a4 commit ae4fb190fd4a21649c4562fc6cd81bba4da222a4 Author: Mateusz Guzik AuthorDate: 2021-10-05 09:42:58 +0000 Commit: Mateusz Guzik CommitDate: 2021-10-05 09:42:58 +0000 netstat: split ipsec and ipsec6 statistics in libxo In particular fixes --libxo json PR: 254673 Reported by: j.vandeville@gmail.com Sponsored by: Rubicon Communications, LLC ("Netgate") --- usr.bin/netstat/ipsec.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/usr.bin/netstat/ipsec.c b/usr.bin/netstat/ipsec.c index e57d7f4905b5..029dd64f3b35 100644 --- a/usr.bin/netstat/ipsec.c +++ b/usr.bin/netstat/ipsec.c @@ -154,12 +154,10 @@ static struct val2str ipsec_compnames[] = { { -1, NULL }, }; -static void print_ipsecstats(const struct ipsecstat *ipsecstat); - static void -print_ipsecstats(const struct ipsecstat *ipsecstat) +print_ipsecstats(const char *tag, const struct ipsecstat *ipsecstat) { - xo_open_container("ipsec-statistics"); + xo_open_container(tag); #define p(f, m) if (ipsecstat->f || sflag <= 1) \ xo_emit(m, (uintmax_t)ipsecstat->f, plural(ipsecstat->f)) @@ -194,27 +192,30 @@ print_ipsecstats(const struct ipsecstat *ipsecstat) "{N:/mbuf%s inserted during makespace}\n"); #undef p2 #undef p - xo_close_container("ipsec-statistics"); + xo_close_container(tag); } void ipsec_stats(u_long off, const char *name, int af1 __unused, int proto __unused) { struct ipsecstat ipsecstat; + const char *tag; if (strcmp(name, "ipsec6") == 0) { if (fetch_stats("net.inet6.ipsec6.ipsecstats", off,&ipsecstat, sizeof(ipsecstat), kread_counters) != 0) return; + tag = "ipsec6-statistics"; } else { if (fetch_stats("net.inet.ipsec.ipsecstats", off, &ipsecstat, sizeof(ipsecstat), kread_counters) != 0) return; + tag = "ipsec-statistics"; } xo_emit("{T:/%s}:\n", name); - print_ipsecstats(&ipsecstat); + print_ipsecstats(tag, &ipsecstat); }