From 278f62a9da99dcca7a7b95f34635b0fcd1a88185 Mon Sep 17 00:00:00 2001 From: Daniel Borkmann Date: Tue, 25 Jun 2013 12:30:58 +0200 Subject: netsniff-ng: tpacketv3: 'fix' packet accounting output In netsniff-ng, we use tpacketv3 for capturing-only mode. The issue observed lately is that when using f.e. -n10 or capturing a pcap and then quitting, the pcap or actually seen number of packets are less than what the statistics tell us from getsockopt(2). This is due to the fact that tpacketv3 divides its ring buffer into blocks of frames. Meaning, while we are traversing block n, the kernel already fills up block n+1 and following if new packets arrive. While doing so, it increments packet counters. Thus, when we ^C, we haven't seen those blocks, so the stats tell us mostly a slightly higher result. Fix this by adjusting socket stats printing to this fact. Signed-off-by: Daniel Borkmann --- ring_rx.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ring_rx.h') diff --git a/ring_rx.h b/ring_rx.h index 6f3cdab..8bf439b 100644 --- a/ring_rx.h +++ b/ring_rx.h @@ -19,7 +19,7 @@ extern void alloc_rx_ring_frames(int sock, struct ring *ring); extern void bind_rx_ring(int sock, struct ring *ring, int ifindex); extern void setup_rx_ring_layout(int sock, struct ring *ring, unsigned int size, bool jumbo_support, bool v3); -extern void sock_rx_net_stats(int sock); +extern void sock_rx_net_stats(int sock, unsigned long seen); static inline int user_may_pull_from_rx(struct tpacket2_hdr *hdr) { -- cgit v1.2.3-54-g00ecf