From: claudio Date: Tue, 28 Mar 2023 12:07:09 +0000 (+0000) Subject: Use pt_size from struct rde_memstats instead of computing it by hand. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=093d1e70949a865c68b2fc87eb41732302ae7914;p=openbsd Use pt_size from struct rde_memstats instead of computing it by hand. OK tb@ --- diff --git a/usr.sbin/bgpctl/bgpctl.h b/usr.sbin/bgpctl/bgpctl.h index 1f1788e584d..2eab06f2611 100644 --- a/usr.sbin/bgpctl/bgpctl.h +++ b/usr.sbin/bgpctl/bgpctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpctl.h,v 1.19 2023/01/24 11:29:34 claudio Exp $ */ +/* $OpenBSD: bgpctl.h,v 1.20 2023/03/28 12:07:09 claudio Exp $ */ /* * Copyright (c) 2019 Claudio Jeker @@ -38,7 +38,6 @@ struct output { }; extern const struct output show_output, json_output, ometric_output; -extern const size_t pt_sizes[]; #define EOL0(flag) ((flag & F_CTL_SSV) ? ';' : '\n') diff --git a/usr.sbin/bgpctl/output.c b/usr.sbin/bgpctl/output.c index 6faef7fbd2b..28b47dc5202 100644 --- a/usr.sbin/bgpctl/output.c +++ b/usr.sbin/bgpctl/output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: output.c,v 1.37 2023/03/09 13:13:14 claudio Exp $ */ +/* $OpenBSD: output.c,v 1.38 2023/03/28 12:07:09 claudio Exp $ */ /* * Copyright (c) 2003 Henning Brauer @@ -33,8 +33,6 @@ #include "bgpctl.h" #include "parser.h" -const size_t pt_sizes[AID_MAX] = AID_PTSIZE; - static void show_head(struct parse_result *res) { @@ -994,10 +992,10 @@ show_rib_mem(struct rde_memstats *stats) for (i = 0; i < AID_MAX; i++) { if (stats->pt_cnt[i] == 0) continue; - pts += stats->pt_cnt[i] * pt_sizes[i]; + pts += stats->pt_size[i]; printf("%10lld %s network entries using %s of memory\n", stats->pt_cnt[i], aid_vals[i].name, - fmt_mem(stats->pt_cnt[i] * pt_sizes[i])); + fmt_mem(stats->pt_size[i])); } printf("%10lld rib entries using %s of memory\n", stats->rib_cnt, fmt_mem(stats->rib_cnt * diff --git a/usr.sbin/bgpctl/output_json.c b/usr.sbin/bgpctl/output_json.c index 86ac1626e93..3a702917da6 100644 --- a/usr.sbin/bgpctl/output_json.c +++ b/usr.sbin/bgpctl/output_json.c @@ -1,4 +1,4 @@ -/* $OpenBSD: output_json.c,v 1.30 2023/03/09 13:13:14 claudio Exp $ */ +/* $OpenBSD: output_json.c,v 1.31 2023/03/28 12:07:09 claudio Exp $ */ /* * Copyright (c) 2020 Claudio Jeker @@ -939,9 +939,9 @@ json_rib_mem(struct rde_memstats *stats) for (i = 0; i < AID_MAX; i++) { if (stats->pt_cnt[i] == 0) continue; - pts += stats->pt_cnt[i] * pt_sizes[i]; + pts += stats->pt_size[i]; json_rib_mem_element(aid_vals[i].name, stats->pt_cnt[i], - stats->pt_cnt[i] * pt_sizes[i], UINT64_MAX); + stats->pt_size[i], UINT64_MAX); } json_rib_mem_element("rib", stats->rib_cnt, stats->rib_cnt * sizeof(struct rib_entry), UINT64_MAX); diff --git a/usr.sbin/bgpctl/output_ometric.c b/usr.sbin/bgpctl/output_ometric.c index afd9b259fb5..2b0b9be6cb2 100644 --- a/usr.sbin/bgpctl/output_ometric.c +++ b/usr.sbin/bgpctl/output_ometric.c @@ -1,4 +1,4 @@ -/* $OpenBSD: output_ometric.c,v 1.10 2022/12/12 09:51:04 claudio Exp $ */ +/* $OpenBSD: output_ometric.c,v 1.11 2023/03/28 12:07:09 claudio Exp $ */ /* * Copyright (c) 2022 Claudio Jeker @@ -275,9 +275,9 @@ ometric_rib_mem(struct rde_memstats *stats) for (i = 0; i < AID_MAX; i++) { if (stats->pt_cnt[i] == 0) continue; - pts += stats->pt_cnt[i] * pt_sizes[i]; + pts += stats->pt_size[i]; ometric_rib_mem_element(aid_vals[i].name, stats->pt_cnt[i], - stats->pt_cnt[i] * pt_sizes[i], UINT64_MAX); + stats->pt_size[i], UINT64_MAX); } ometric_rib_mem_element("rib", stats->rib_cnt, stats->rib_cnt * sizeof(struct rib_entry), UINT64_MAX);