On Mon, May 21, 2001 at 01:27:10AM +0000, ashley thomas wrote:
> Libpcap on Linux lies about dropped packets.
> Is there any available fix for this ?
None in the tcpdump.org source tree.
However, I infer from one of Alexey Kuznetzov's patches that, *on
2.4[.x]-kernel systems*, a "getsockopt()" call with a "level" argument
of SOL_PACKET and an "optname" argument of PACKET_STATISTICS" gets you a
count of dropped packets; perhaps we should apply that particular
change, which would be (UNTESTED, I don't have a 2.4[.x]-kernel system):
Index: pcap-linux.c
===================================================================
RCS file: /tcpdump/master/libpcap/pcap-linux.c,v
retrieving revision 1.57
diff -c -r1.57 pcap-linux.c
*** pcap-linux.c 2001/04/09 05:55:40 1.57
--- pcap-linux.c 2001/05/21 05:40:41
***************
*** 449,459 ****
/*
* Get the statistics for the given packet capture handle.
- * FIXME: Currently does not report the number of dropped packets.
*/
int
pcap_stats(pcap_t *handle, struct pcap_stat *stats)
{
*stats = handle->md.stat;
return 0;
}
--- 449,470 ----
/*
* Get the statistics for the given packet capture handle.
*/
int
pcap_stats(pcap_t *handle, struct pcap_stat *stats)
{
+ #ifdef PACKET_STATISTICS
+ struct tpacket_stats tps;
+ int olen = sizeof(tps);
+
+ if (getsockopt(handle->fd, SOL_PACKET, PACKET_STATISTICS,
+ (void *)&tps, &olen) == 0) {
+ if (tps.tp_packets) {
+ handle->md.stat.ps_ifdrop = tps.tp_packets -
+handle->md.stat.ps_recv - tps.tp_drops;
+ handle->md.stat.ps_drop = tps.tp_drops;
+ }
+ }
+ #endif
*stats = handle->md.stat;
return 0;
}
-
This is the TCPDUMP workers list. It is archived at
http://www.tcpdump.org/lists/workers/index.html
To unsubscribe use mailto:[EMAIL PROTECTED]?body=unsubscribe