#include <stdlib.h>
#include <netinet/in.h>
#include <errno.h>
+#include <stdbool.h>
#include <ulogd/ulogd.h>
#include <libnfnetlink/libnfnetlink.h>
unsigned char *nfulog_buf;
struct ulogd_fd nful_fd;
int nlbufsiz;
+ bool nful_overrun_warned;
};
/* configuration entries */
* 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)) {
"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,
"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;
if (ulogd_register_fd(&ui->nful_fd) < 0)
goto out_bind;
+ ui->nful_overrun_warned = false;
+
return 0;
out_bind: