From 24d635a48ba16e97ef3d6c089c942470141d80b6 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Fri, 25 Feb 2011 14:40:21 +0100 Subject: NFLOG: don't display overrun message once we have reach the buffer limit We only report the overrun once with this patch, instead of spamming the ulogd.log file. Signed-off-by: Pablo Neira Ayuso --- input/packet/ulogd_inppkt_NFLOG.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/input/packet/ulogd_inppkt_NFLOG.c b/input/packet/ulogd_inppkt_NFLOG.c index 7e2f5a4..0eff1f0 100644 --- a/input/packet/ulogd_inppkt_NFLOG.c +++ b/input/packet/ulogd_inppkt_NFLOG.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -26,6 +27,7 @@ struct nflog_input { unsigned char *nfulog_buf; struct ulogd_fd nful_fd; int nlbufsiz; + bool nful_overrun_warned; }; /* configuration entries */ @@ -433,7 +435,7 @@ static int nful_read_cb(int fd, unsigned int what, void *param) * sockets that have pending work */ len = recv(fd, ui->nfulog_buf, bufsiz_ce(upi->config_kset).u.value, 0); if (len < 0) { - if (errno == ENOBUFS) { + if (errno == ENOBUFS && !ui->nful_overrun_warned) { if (nlsockbufmaxsize_ce(upi->config_kset).u.value) { int s = ui->nlbufsiz * 2; if (setnlbufsiz(upi, s)) { @@ -441,6 +443,11 @@ static int nful_read_cb(int fd, unsigned int what, void *param) "We are losing events, " "increasing buffer size " "to %d\n", ui->nlbufsiz); + } else { + /* we have reached the maximum buffer + * limit size, don't perform any + * further treatments on overruns. */ + ui->nful_overrun_warned = true; } } else { ulogd_log(ULOGD_NOTICE, @@ -448,6 +455,8 @@ static int nful_read_cb(int fd, unsigned int what, void *param) "consider using the clauses " "`netlink_socket_buffer_size' and " "`netlink_socket_buffer_maxsize'\n"); + /* display the previous log message once. */ + ui->nful_overrun_warned = true; } } return len; @@ -606,6 +615,8 @@ static int start(struct ulogd_pluginstance *upi) if (ulogd_register_fd(&ui->nful_fd) < 0) goto out_bind; + ui->nful_overrun_warned = false; + return 0; out_bind: -- cgit v1.2.3