summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2023-03-28 12:07:10 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2023-03-28 12:07:10 +0000
commit988c5fe1a8352158140e255f4fd94225d1a6ea36 (patch)
treebd6c861ee31e255ac6e7b9443174c2a4b30a7fb8 /usr.sbin
parent4c36579ea961e90df0f2e128a49f00df8645ac22 (diff)
Use pt_size from struct rde_memstats instead of computing it by hand.
OK tb@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bgpctl/bgpctl.h3
-rw-r--r--usr.sbin/bgpctl/output.c8
-rw-r--r--usr.sbin/bgpctl/output_json.c6
-rw-r--r--usr.sbin/bgpctl/output_ometric.c6
4 files changed, 10 insertions, 13 deletions
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 <claudio@openbsd.org>
@@ -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 <henning@openbsd.org>
@@ -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 <claudio@openbsd.org>
@@ -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 <claudio@openbsd.org>
@@ -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);