Author: adrian.chadd
Date: Sun Feb 22 23:02:45 2009
New Revision: 13849
Modified:
playpen/LUSCA_HEAD_bgp/libsqbgp/bgp_rib.c
playpen/LUSCA_HEAD_bgp/libsqbgp/bgp_rib.h
playpen/LUSCA_HEAD_bgp/src/bgp.c
Log:
Track the number of prefixes; expose this statistic via cachemgr.
Modified: playpen/LUSCA_HEAD_bgp/libsqbgp/bgp_rib.c
==============================================================================
--- playpen/LUSCA_HEAD_bgp/libsqbgp/bgp_rib.c (original)
+++ playpen/LUSCA_HEAD_bgp/libsqbgp/bgp_rib.c Sun Feb 22 23:02:45 2009
@@ -70,12 +70,14 @@
bgp_rib_destroy(bgp_rib_head_t *head)
{
Destroy_Radix(head->rh, bgp_rib_asn_free, NULL);
+ head->num_prefixes = 0;
}
void
bgp_rib_clean(bgp_rib_head_t *head)
{
Clear_Radix(head->rh, bgp_rib_asn_free, NULL);
+ head->num_prefixes = 0;
}
@@ -102,6 +104,7 @@
a = xcalloc(1, sizeof(bgp_rib_aspath_t));
a->origin_as = origin_as;
n->data = a;
+ head->num_prefixes++;
return 1;
}
@@ -125,8 +128,6 @@
bgp_rib_asn_free(n, NULL);
radix_remove(head->rh, n);
Deref_Prefix(p);
+ head->num_prefixes--;
return 1;
-
-
-
}
Modified: playpen/LUSCA_HEAD_bgp/libsqbgp/bgp_rib.h
==============================================================================
--- playpen/LUSCA_HEAD_bgp/libsqbgp/bgp_rib.h (original)
+++ playpen/LUSCA_HEAD_bgp/libsqbgp/bgp_rib.h Sun Feb 22 23:02:45 2009
@@ -3,6 +3,7 @@
struct _bgp_rib_head {
radix_tree_t *rh;
+ int num_prefixes;
};
typedef struct _bgp_rib_head bgp_rib_head_t;
Modified: playpen/LUSCA_HEAD_bgp/src/bgp.c
==============================================================================
--- playpen/LUSCA_HEAD_bgp/src/bgp.c (original)
+++ playpen/LUSCA_HEAD_bgp/src/bgp.c Sun Feb 22 23:02:45 2009
@@ -8,12 +8,25 @@
static bgp_conn_t *bc = NULL;
+static void
+bgpStats(StoreEntry *e)
+{
+ storeAppendPrintf(e, "Table size: %d entries\n",
bc->bi.rn.num_prefixes);
+}
+
void
bgpStart(void)
{
+ static int initialised = 0;
+
/* Is it configured? If not, don't bother. */
if (! Config.bgp.enable)
return;
+
+ if (! initialised) {
+ initialised = 1;
+ cachemgrRegister("bgp_stats", "BGP statistics", bgpStats, 0, 1);
+ }
/* Do we have a BGP instance? If not, create one */
if (bc == NULL) {
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"lusca-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/lusca-commit?hl=en
-~----------~----~----~----~------~----~------~--~---