From 9549faae95c3710582240829593ab59ddee2bf06 Mon Sep 17 00:00:00 2001 From: Eric Leblond Date: Fri, 28 Oct 2011 17:43:00 +0200 Subject: [PATCH] af-packet: add kernel statistics to exit stats. This patch should fix #325. --- src/source-af-packet.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/source-af-packet.c b/src/source-af-packet.c index 2bf79bb0c0..501751a936 100644 --- a/src/source-af-packet.c +++ b/src/source-af-packet.c @@ -627,6 +627,19 @@ TmEcode ReceiveAFPThreadInit(ThreadVars *tv, void *initdata, void **data) { void ReceiveAFPThreadExitStats(ThreadVars *tv, void *data) { SCEnter(); AFPThreadVars *ptv = (AFPThreadVars *)data; +#ifdef PACKET_STATISTICS + struct tpacket_stats kstats; + socklen_t len = sizeof (struct tpacket_stats); +#endif + +#ifdef PACKET_STATISTICS + if (getsockopt(ptv->socket, SOL_PACKET, PACKET_STATISTICS, + &kstats, &len) > -1) { + SCLogInfo("(%s) Kernel: Packets %" PRIu32 ", dropped %" PRIu32 "", + tv->name, + kstats.tp_packets, kstats.tp_drops); + } +#endif SCLogInfo("(%s) Packets %" PRIu32 ", bytes %" PRIu64 "", tv->name, ptv->pkts, ptv->bytes); }