From aca85a321b1ef10a65bf586ad104a9629ea55f0d Mon Sep 17 00:00:00 2001 From: claudio Date: Tue, 28 Mar 2023 12:06:15 +0000 Subject: [PATCH] Include the memory size usage of the prefix tree in rde_memstats. OK tb@ --- usr.sbin/bgpd/bgpd.h | 3 ++- usr.sbin/bgpd/rde_prefix.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h index 02c70720ddf..4cec43bcbe1 100644 --- a/usr.sbin/bgpd/bgpd.h +++ b/usr.sbin/bgpd/bgpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.h,v 1.465 2023/03/13 16:52:41 claudio Exp $ */ +/* $OpenBSD: bgpd.h,v 1.466 2023/03/28 12:06:15 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -1246,6 +1246,7 @@ struct rde_memstats { long long prefix_cnt; long long rib_cnt; long long pt_cnt[AID_MAX]; + long long pt_size[AID_MAX]; long long nexthop_cnt; long long aspath_cnt; long long aspath_size; diff --git a/usr.sbin/bgpd/rde_prefix.c b/usr.sbin/bgpd/rde_prefix.c index 3a85cd85726..e7223320240 100644 --- a/usr.sbin/bgpd/rde_prefix.c +++ b/usr.sbin/bgpd/rde_prefix.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_prefix.c,v 1.42 2022/08/17 15:15:26 claudio Exp $ */ +/* $OpenBSD: rde_prefix.c,v 1.43 2023/03/28 12:06:15 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker @@ -310,6 +310,7 @@ pt_alloc(struct pt_entry *op) if (p == NULL) fatal("pt_alloc"); rdemem.pt_cnt[op->aid]++; + rdemem.pt_size[op->aid] += pt_sizes[op->aid]; memcpy(p, op, pt_sizes[op->aid]); return (p); @@ -319,5 +320,6 @@ static void pt_free(struct pt_entry *pte) { rdemem.pt_cnt[pte->aid]--; + rdemem.pt_size[pte->aid] -= pt_sizes[pte->aid]; free(pte); } -- 2.20.1