From 036a0a65c6a3ba95cff48035a25e0bdba6aa0452 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Sun, 21 Dec 2008 19:47:02 +0100 Subject: src: add cache statistics via `-s cache' This patch adds cache statistics that you can check via `conntrackd -s cache'. This information is useful for trouble-shooting. This patch replaces several log messages that can be triggered in runtime. The idea behind this patch is to avoid log message flooding under errors. Signed-off-by: Pablo Neira Ayuso --- include/cache.h | 38 +++++++++++++++++++++++--------------- include/conntrackd.h | 1 + 2 files changed, 24 insertions(+), 15 deletions(-) (limited to 'include') diff --git a/include/cache.h b/include/cache.h index 45c3b7e..ebed70a 100644 --- a/include/cache.h +++ b/include/cache.h @@ -50,21 +50,28 @@ struct cache { unsigned int extra_offset; /* statistics */ - unsigned int active; - - unsigned int add_ok; - unsigned int del_ok; - unsigned int upd_ok; - - unsigned int add_fail; - unsigned int del_fail; - unsigned int upd_fail; - - unsigned int commit_ok; - unsigned int commit_exist; - unsigned int commit_fail; - - unsigned int flush; + struct { + uint32_t active; + + uint32_t add_ok; + uint32_t del_ok; + uint32_t upd_ok; + + uint32_t add_fail; + uint32_t del_fail; + uint32_t upd_fail; + + uint32_t add_fail_enomem; + uint32_t add_fail_enospc; + uint32_t del_fail_enoent; + uint32_t upd_fail_enoent; + + uint32_t commit_ok; + uint32_t commit_exist; + uint32_t commit_fail; + + uint32_t flush; + } stats; }; struct cache_extra { @@ -88,6 +95,7 @@ int __cache_del_timer(struct cache *c, struct us_conntrack *u, int timeout); struct us_conntrack *cache_find(struct cache *c, struct nf_conntrack *ct); int cache_test(struct cache *c, struct nf_conntrack *ct); void cache_stats(const struct cache *c, int fd); +void cache_stats_extended(const struct cache *c, int fd); struct us_conntrack *cache_get_conntrack(struct cache *, void *); void *cache_get_extra(struct cache *, void *); void cache_iterate(struct cache *c, void *data, int (*iterate)(void *data1, void *data2)); diff --git a/include/conntrackd.h b/include/conntrackd.h index 7199985..98934ce 100644 --- a/include/conntrackd.h +++ b/include/conntrackd.h @@ -27,6 +27,7 @@ #define RESET_TIMERS 26 /* reset kernel timers */ #define DEBUG_INFO 27 /* show debug info (if any) */ #define STATS_NETWORK 28 /* extended network stats */ +#define STATS_CACHE 29 /* extended cache stats */ #define DEFAULT_CONFIGFILE "/etc/conntrackd/conntrackd.conf" #define DEFAULT_LOCKFILE "/var/lock/conntrackd.lock" -- cgit v1.2.3