summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--include/log.h2
-rw-r--r--src/cache_iterators.c2
-rw-r--r--src/cache_wt.c13
-rw-r--r--src/log.c28
-rw-r--r--src/stats-mode.c2
6 files changed, 35 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index d6fbe30..045988a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -23,6 +23,7 @@ o minor cleanups
= conntrackd =
o fix asymmetric path support (reported by Gary Richards)
o improve netlink overrun handling
+o add more verbose error notification when we fail to inject a conntrack
version 0.9.6 (2008/03/08)
------------------------------
diff --git a/include/log.h b/include/log.h
index b258633..f5c5b4f 100644
--- a/include/log.h
+++ b/include/log.h
@@ -7,7 +7,7 @@ struct nf_conntrack;
int init_log(void);
void dlog(int priority, const char *format, ...);
-void dlog_ct(struct nf_conntrack *ct);
+void dlog_ct(FILE *fd, struct nf_conntrack *ct, unsigned int type);
void close_log(void);
#endif
diff --git a/src/cache_iterators.c b/src/cache_iterators.c
index 92b7b7f..c26d349 100644
--- a/src/cache_iterators.c
+++ b/src/cache_iterators.c
@@ -98,6 +98,8 @@ static int do_commit(void *data1, void *data2)
c->commit_exist++;
break;
default:
+ dlog(LOG_ERR, "commit: %s", strerror(errno));
+ dlog_ct(STATE(log), u->ct, NFCT_O_PLAIN);
c->commit_fail++;
break;
}
diff --git a/src/cache_wt.c b/src/cache_wt.c
index 65eb3fe..65a1fc4 100644
--- a/src/cache_wt.c
+++ b/src/cache_wt.c
@@ -35,16 +35,21 @@ static void add_wt(struct us_conntrack *u)
switch (ret) {
case -1:
dlog(LOG_ERR, "cache_wt problem: %s", strerror(errno));
+ dlog_ct(STATE(log), u->ct, NFCT_O_PLAIN);
break;
case 0:
memcpy(ct, u->ct, nfct_maxsize());
- if (nl_create_conntrack(ct) == -1)
+ if (nl_create_conntrack(ct) == -1) {
dlog(LOG_ERR, "cache_wt create: %s", strerror(errno));
+ dlog_ct(STATE(log), u->ct, NFCT_O_PLAIN);
+ }
break;
case 1:
memcpy(ct, u->ct, nfct_maxsize());
- if (nl_update_conntrack(ct) == -1)
+ if (nl_update_conntrack(ct) == -1) {
dlog(LOG_ERR, "cache_wt crt-upd: %s", strerror(errno));
+ dlog_ct(STATE(log), u->ct, NFCT_O_PLAIN);
+ }
break;
}
}
@@ -56,8 +61,10 @@ static void upd_wt(struct us_conntrack *u)
memcpy(ct, u->ct, nfct_maxsize());
- if (nl_update_conntrack(ct) == -1)
+ if (nl_update_conntrack(ct) == -1) {
dlog(LOG_ERR, "cache_wt update:%s", strerror(errno));
+ dlog_ct(STATE(log), u->ct, NFCT_O_PLAIN);
+ }
}
static void writethrough_add(struct us_conntrack *u, void *data)
diff --git a/src/log.c b/src/log.c
index 51e757f..d97a69f 100644
--- a/src/log.c
+++ b/src/log.c
@@ -104,18 +104,30 @@ void dlog(int priority, const char *format, ...)
}
}
-void dlog_ct(struct nf_conntrack *ct)
+void dlog_ct(FILE *fd, struct nf_conntrack *ct, unsigned int type)
{
- FILE *fd = STATE(stats_log);
time_t t;
char buf[1024];
char *tmp;
-
- t = time(NULL);
- ctime_r(&t, buf);
- tmp = buf + strlen(buf);
- buf[strlen(buf)-1]='\t';
- nfct_snprintf(buf+strlen(buf), 1024-strlen(buf), ct, 0, 0, 0);
+ unsigned int flags = 0;
+
+ buf[0]='\0';
+
+ switch(type) {
+ case NFCT_O_PLAIN:
+ t = time(NULL);
+ ctime_r(&t, buf);
+ tmp = buf + strlen(buf);
+ buf[strlen(buf)-1]='\t';
+ break;
+ case NFCT_O_XML:
+ tmp = buf;
+ flags |= NFCT_OF_TIME;
+ break;
+ default:
+ return;
+ }
+ nfct_snprintf(buf+strlen(buf), 1024-strlen(buf), ct, 0, type, flags);
if (fd) {
snprintf(buf+strlen(buf), 1024-strlen(buf), "\n");
diff --git a/src/stats-mode.c b/src/stats-mode.c
index 3773feb..5808320 100644
--- a/src/stats-mode.c
+++ b/src/stats-mode.c
@@ -170,7 +170,7 @@ static int event_destroy_stats(struct nf_conntrack *ct)
if (cache_del(STATE_STATS(cache), ct)) {
debug_ct(ct, "cache destroy");
- dlog_ct(ct);
+ dlog_ct(STATE(stats_log), ct, NFCT_O_PLAIN);
return 1;
} else {
debug_ct(ct, "can't destroy!");