From f53e687bb8f870b37979184fe04c8275717dc524 Mon Sep 17 00:00:00 2001 From: Eric Leblond Date: Thu, 19 Apr 2018 19:13:20 +0200 Subject: [PATCH] af-packet: dump counters when timeout occurs 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 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/source-af-packet.c b/src/source-af-packet.c index 874118f890..d6c7c0aea5 100644 --- a/src/source-af-packet.c +++ b/src/source-af-packet.c @@ -1582,6 +1582,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);