diff options
-rw-r--r-- | netsniff-ng.c | 4 | ||||
-rw-r--r-- | ring_rx.c | 5 | ||||
-rw-r--r-- | ring_rx.h | 2 |
3 files changed, 6 insertions, 5 deletions
diff --git a/netsniff-ng.c b/netsniff-ng.c index c5570fc..19d4db3 100644 --- a/netsniff-ng.c +++ b/netsniff-ng.c @@ -479,7 +479,7 @@ static void receive_to_xmit(struct ctx *ctx) timer_purge(); - sock_rx_net_stats(rx_sock); + sock_rx_net_stats(rx_sock, 0); bpf_release(&bpf_ops); @@ -989,7 +989,7 @@ static void recv_only_or_dump(struct ctx *ctx) timersub(&end, &start, &diff); if (!(ctx->dump_dir && ctx->print_mode == PRINT_NONE)) { - sock_rx_net_stats(sock); + sock_rx_net_stats(sock, frame_count); printf("\r%12lu sec, %lu usec in total\n", diff.tv_sec, diff.tv_usec); @@ -131,7 +131,7 @@ void bind_rx_ring(int sock, struct ring *ring, int ifindex) bind_ring_generic(sock, ring, ifindex); } -void sock_rx_net_stats(int sock) +void sock_rx_net_stats(int sock, unsigned long seen) { int ret; bool v3 = get_sockopt_tpacket(sock) == TPACKET_V3; @@ -147,7 +147,8 @@ void sock_rx_net_stats(int sock) uint64_t packets = stats.k3.tp_packets; uint64_t drops = stats.k3.tp_drops; - printf("\r%12ld packets incoming\n", packets); + printf("\r%12ld packets incoming (%ld unread on exit)\n", + v3 ? seen : packets, v3 ? packets - seen : 0); printf("\r%12ld packets passed filter\n", packets - drops); printf("\r%12ld packets failed filter (out of space)\n", drops); if (stats.k3.tp_packets > 0) @@ -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) { |