summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd/rde_rib.c
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2006-01-03 22:49:18 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2006-01-03 22:49:18 +0000
commitb7edfa3948e4771e4f64dfa20a7d3416b0b86f2c (patch)
treecf912a05718faa7293409c263a3ed1a9ff95bdc8 /usr.sbin/bgpd/rde_rib.c
parenta9828406adf7896570c78cd00b9b93f7614451b7 (diff)
Track some (memory) statistics in the RDE. Accessible via bgpctl.
Diffstat (limited to 'usr.sbin/bgpd/rde_rib.c')
-rw-r--r--usr.sbin/bgpd/rde_rib.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/usr.sbin/bgpd/rde_rib.c b/usr.sbin/bgpd/rde_rib.c
index bb51d1514fc..bef5b9c4f2b 100644
--- a/usr.sbin/bgpd/rde_rib.c
+++ b/usr.sbin/bgpd/rde_rib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde_rib.c,v 1.71 2005/12/30 14:07:40 claudio Exp $ */
+/* $OpenBSD: rde_rib.c,v 1.72 2006/01/03 22:49:17 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org>
@@ -272,8 +272,10 @@ path_copy(struct rde_aspath *asp)
nasp = path_get();
nasp->aspath = asp->aspath;
- if (nasp->aspath != NULL)
+ if (nasp->aspath != NULL) {
nasp->aspath->refcnt++;
+ rdemem.aspath_refs++;
+ }
nasp->nexthop = asp->nexthop;
nasp->med = asp->med;
nasp->lpref = asp->lpref;
@@ -299,6 +301,8 @@ path_get(void)
asp = calloc(1, sizeof(*asp));
if (asp == NULL)
fatal("path_alloc");
+ rdemem.path_cnt++;
+
LIST_INIT(&asp->prefix_h);
TAILQ_INIT(&asp->others);
asp->origin = ORIGIN_INCOMPLETE;
@@ -320,6 +324,7 @@ path_put(struct rde_aspath *asp)
rtlabel_unref(asp->rtlabelid);
aspath_put(asp->aspath);
attr_optfree(asp);
+ rdemem.path_cnt--;
free(asp);
}
@@ -663,6 +668,7 @@ prefix_alloc(void)
p = calloc(1, sizeof(*p));
if (p == NULL)
fatal("prefix_alloc");
+ rdemem.prefix_cnt++;
return p;
}
@@ -672,6 +678,7 @@ prefix_free(struct prefix *pref)
{
ENSURE(pref->aspath == NULL &&
pref->prefix == NULL);
+ rdemem.prefix_cnt--;
free(pref);
}
@@ -833,6 +840,7 @@ nexthop_unlink(struct rde_aspath *asp)
LIST_REMOVE(nh, nexthop_l);
rde_send_nexthop(&nh->exit_nexthop, 0);
+ rdemem.nexthop_cnt--;
free(nh);
}
}
@@ -847,6 +855,7 @@ nexthop_get(struct bgpd_addr *nexthop)
nh = calloc(1, sizeof(*nh));
if (nh == NULL)
fatal("nexthop_alloc");
+ rdemem.nexthop_cnt++;
LIST_INIT(&nh->path_h);
nh->state = NEXTHOP_LOOKUP;