Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/npf/npfd output every 5 seconds instead of 60 or ev...



details:   https://anonhg.NetBSD.org/src/rev/43d830db5d1c
branches:  trunk
changeset: 350849:43d830db5d1c
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Jan 24 20:24:59 2017 +0000

description:
output every 5 seconds instead of 60 or every 100 packets

diffstat:

 usr.sbin/npf/npfd/npfd.c |  13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diffs (57 lines):

diff -r fc475c871b03 -r 43d830db5d1c usr.sbin/npf/npfd/npfd.c
--- a/usr.sbin/npf/npfd/npfd.c  Tue Jan 24 19:23:31 2017 +0000
+++ b/usr.sbin/npf/npfd/npfd.c  Tue Jan 24 20:24:59 2017 +0000
@@ -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 @@
 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 @@
                if (flush) {
                        flush = false;
                        npfd_log_flush(log);
+                       count = 0;
                }
                switch (poll(&pfd, 1, delay)) {
                case -1:
@@ -101,8 +103,13 @@
                        /*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 @@
        bool daemon_off = false;
        int ch;
 
-       int delay = 60 * 1000;
+       int delay = 5 * 1000;
        const char *iface = "npflog0";
        int snaplen = 116;
        char *pidname = NULL;



Home | Main Index | Thread Index | Old Index