]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
af-packet: dump counters when timeout occurs
authorEric Leblond <eric@regit.org>
Thu, 19 Apr 2018 17:13:20 +0000 (19:13 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 16 Jul 2018 11:30:49 +0000 (13:30 +0200)
When traffic is becoming null (mainly seen in tests) we reach the
situation where there is timeouts in the poll on the socket and
only that. Existing code is then just looping on the poll and
the result is that the packet iface counters are not updated.

This patch calls the dump counter function to be sure to get
the counter right faster (and not only right at exit).

src/source-af-packet.c

index f1cfb908ec5da704485503b0dcac657257df2b95..8a6edca6969d8b887fcb582eedd7b33e640ef263 100644 (file)
@@ -1505,6 +1505,12 @@ TmEcode ReceiveAFPLoop(ThreadVars *tv, void *data, void *slot)
                     break;
             }
         } else if (unlikely(r == 0)) {
+            /* Trigger one dump of stats every second */
+            current_time = time(NULL);
+            if (current_time != last_dump) {
+                AFPDumpCounters(ptv);
+                last_dump = current_time;
+            }
             /* poll timed out, lets see if we need to inject a fake packet  */
             TmThreadsCaptureInjectPacket(tv, ptv->slot, NULL);