Module Name: src
Committed By: christos
Date: Tue Jan 24 20:24:59 UTC 2017
Modified Files:
src/usr.sbin/npf/npfd: npfd.c
Log Message:
output every 5 seconds instead of 60 or every 100 packets
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/npf/npfd/npfd.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.sbin/npf/npfd/npfd.c
diff -u src/usr.sbin/npf/npfd/npfd.c:1.6 src/usr.sbin/npf/npfd/npfd.c:1.7
--- src/usr.sbin/npf/npfd/npfd.c:1.6 Sat Jan 7 11:48:03 2017
+++ src/usr.sbin/npf/npfd/npfd.c Tue Jan 24 15:24:59 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: npfd.c,v 1.6 2017/01/07 16:48:03 christos Exp $ */
+/* $NetBSD: npfd.c,v 1.7 2017/01/24 20:24:59 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: npfd.c,v 1.6 2017/01/07 16:48:03 christos Exp $");
+__RCSID("$NetBSD: npfd.c,v 1.7 2017/01/24 20:24:59 christos Exp $");
#include <stdio.h>
#include <string.h>
@@ -75,6 +75,7 @@ static void
npfd_event_loop(npfd_log_t *log, int delay)
{
struct pollfd pfd;
+ size_t count = 0;
pfd.fd = npfd_log_getsock(log);
pfd.events = POLLHUP | POLLIN;
@@ -91,6 +92,7 @@ npfd_event_loop(npfd_log_t *log, int del
if (flush) {
flush = false;
npfd_log_flush(log);
+ count = 0;
}
switch (poll(&pfd, 1, delay)) {
case -1:
@@ -101,8 +103,13 @@ npfd_event_loop(npfd_log_t *log, int del
/*NOTREACHED*/
case 0:
npfd_log_flush(log);
+ count = 0;
continue;
default:
+ if (count++ >= 100) {
+ npfd_log_flush(log);
+ count = 0;
+ }
npfd_log(log);
}
@@ -168,7 +175,7 @@ main(int argc, char **argv)
bool daemon_off = false;
int ch;
- int delay = 60 * 1000;
+ int delay = 5 * 1000;
const char *iface = "npflog0";
int snaplen = 116;
char *pidname = NULL;