summaryrefslogtreecommitdiff
path: root/src/stats-mode.c
diff options
context:
space:
mode:
author/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org>2008-04-09 15:25:59 +0000
committer/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org>2008-04-09 15:25:59 +0000
commit5e5d8cdb3cfed98f1af3f3e265220c90df684674 (patch)
tree7515c853a8462a4ed13b788c20c231c53c0e651c /src/stats-mode.c
parent92701a6b224c533346f233061226bee5bb29a5dd (diff)
downloadconntrack-tools-5e5d8cdb3cfed98f1af3f3e265220c90df684674.tar.gz
conntrack-tools-5e5d8cdb3cfed98f1af3f3e265220c90df684674.zip
improve netlink overrun handling
Diffstat (limited to 'src/stats-mode.c')
-rw-r--r--src/stats-mode.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/stats-mode.c b/src/stats-mode.c
index 42fa35a..3773feb 100644
--- a/src/stats-mode.c
+++ b/src/stats-mode.c
@@ -22,10 +22,12 @@
#include "cache.h"
#include "log.h"
#include "conntrackd.h"
+#include "us-conntrack.h"
#include <errno.h>
#include <string.h>
#include <stdlib.h>
+#include <libnetfilter_conntrack/libnetfilter_conntrack.h>
static int init_stats(void)
{
@@ -93,9 +95,9 @@ static void dump_stats(struct nf_conntrack *ct)
debug_ct(ct, "resync entry");
}
-static int overrun_cb(enum nf_conntrack_msg_type type,
- struct nf_conntrack *ct,
- void *data)
+static int overrun_stats(enum nf_conntrack_msg_type type,
+ struct nf_conntrack *ct,
+ void *data)
{
if (ignore_conntrack(ct))
return NFCT_CB_CONTINUE;
@@ -115,28 +117,25 @@ static int overrun_cb(enum nf_conntrack_msg_type type,
return NFCT_CB_CONTINUE;
}
-static void overrun_stats(void)
+static int purge_step(void *data1, void *data2)
{
int ret;
- struct nfct_handle *h;
- int family = CONFIG(family);
+ struct us_conntrack *u = data2;
- h = nfct_open(CONNTRACK, 0);
- if (!h) {
- dlog(LOG_ERR, "can't open overrun handler");
- return;
+ ret = nfct_query(STATE(dump), NFCT_Q_GET, u->ct);
+ if (ret == -1 && errno == ENOENT) {
+ debug_ct(u->ct, "overrun purge stats");
+ cache_del(STATE_STATS(cache), u->ct);
}
- nfct_callback_register(h, NFCT_T_ALL, overrun_cb, NULL);
-
- cache_flush(STATE_STATS(cache));
+ return 0;
+}
- ret = nfct_query(h, NFCT_Q_DUMP, &family);
- if (ret == -1)
- dlog(LOG_ERR,
- "overrun query error %s", strerror(errno));
+static int purge_stats(void)
+{
+ cache_iterate(STATE_STATS(cache), NULL, purge_step);
- nfct_close(h);
+ return 0;
}
static void event_new_stats(struct nf_conntrack *ct)
@@ -187,6 +186,7 @@ struct ct_mode stats_mode = {
.kill = kill_stats,
.dump = dump_stats,
.overrun = overrun_stats,
+ .purge = purge_stats,
.event_new = event_new_stats,
.event_upd = event_update_stats,
.event_dst = event_destroy_stats