summaryrefslogtreecommitdiffstats
path: root/src/cache.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2009-01-17 18:03:53 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2009-01-17 18:03:53 +0100
commit7f5a53998abfc9b199b713244fe8baf0a7c2b2fe (patch)
treec44dc23a2767cc65bc8f62bfc56355b62d5215b9 /src/cache.c
parent746f7031f4d1e3bccdd6db3c53835d8b85b73c90 (diff)
cache: add objects statistics
This patch adds the object counter to `conntrackd -s cache'. This is useful to detect object leaks in runtime. This patch also changes the layout of the output to fit the display in less than 24 lines (assuming 24x80 terminal). Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/cache.c')
-rw-r--r--src/cache.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/cache.c b/src/cache.c
index 1e08a33..a5f37dd 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -194,12 +194,14 @@ struct cache_object *cache_object_new(struct cache *c, struct nf_conntrack *ct)
}
memcpy(obj->ct, ct, nfct_sizeof(ct));
obj->status = C_OBJ_NONE;
+ c->stats.objects++;
return obj;
}
void cache_object_free(struct cache_object *obj)
{
+ obj->cache->stats.objects--;
nfct_destroy(obj->ct);
free(obj);
}
@@ -387,18 +389,16 @@ void cache_stats_extended(const struct cache *c, int fd)
int size;
size = snprintf(buf, sizeof(buf),
- "cache:%s\tactive/total entries:\t%12u/%12u\n"
- "\tcreation OK:\t\t\t%12u\n"
- "\tcreation failed:\t\t%12u\n"
+ "cache:%s\tactive objects:\t\t%12u\n"
+ "\tactive/total entries:\t\t%12u/%12u\n"
+ "\tcreation OK/failed:\t\t%12u/%12u\n"
"\t\tno memory available:\t%12u\n"
"\t\tno space left in cache:\t%12u\n"
- "\tupdate OK:\t\t\t%12u\n"
- "\tupdate failed:\t\t\t%12u\n"
+ "\tupdate OK/failed:\t\t%12u/%12u\n"
"\t\tentry not found:\t%12u\n"
- "\tdeletion created:\t\t%12u\n"
- "\tdeletion failed:\t\t%12u\n"
- "\t\tentry not found:\t%12u\n",
- c->name,
+ "\tdeletion created/failed:\t%12u/%12u\n"
+ "\t\tentry not found:\t%12u\n\n",
+ c->name, c->stats.objects,
c->stats.active, hashtable_counter(c->h),
c->stats.add_ok,
c->stats.add_fail,