Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 302587 Details for
Bug 441446
double-count received packets
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
don't double-count received packets
libpcap-0.9.4-packetstats.patch (text/plain), 4.88 KB, created by
Miroslav Lichvar
on 2008-04-16 12:02:49 UTC
(
hide
)
Description:
don't double-count received packets
Filename:
MIME Type:
Creator:
Miroslav Lichvar
Created:
2008-04-16 12:02:49 UTC
Size:
4.88 KB
patch
obsolete
>Index: libpcap/pcap-int.h >=================================================================== >RCS file: /tcpdump/master/libpcap/pcap-int.h,v >retrieving revision 1.68.2.6 >retrieving revision 1.68.2.7 >diff -u -r1.68.2.6 -r1.68.2.7 >--- libpcap/pcap-int.h 7 Jul 2005 06:56:04 -0000 1.68.2.6 >+++ libpcap/pcap-int.h 24 Nov 2005 19:28:23 -0000 1.68.2.7 >@@ -30,7 +30,7 @@ > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * >- * @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.68.2.6 2005/07/07 06:56:04 guy Exp $ (LBL) >+ * @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.68.2.7 2005/11/24 19:28:23 guy Exp $ (LBL) > */ > > #ifndef pcap_int_h >@@ -88,6 +88,7 @@ > int ifindex; /* interface index of device we're bound to */ > int lo_ifindex; /* interface index of the loopback device */ > struct pcap *next; /* list of open promiscuous sock_packet pcaps */ >+ u_int packets_read; /* count of packets read with recvfrom() */ > #endif > > #ifdef HAVE_DAG_API >Index: libpcap/pcap-linux.c >=================================================================== >RCS file: /tcpdump/master/libpcap/pcap-linux.c,v >retrieving revision 1.110.2.7 >retrieving revision 1.110.2.8 >diff -u -r1.110.2.7 -r1.110.2.8 >--- libpcap/pcap-linux.c 8 Oct 2005 11:31:16 -0000 1.110.2.7 >+++ libpcap/pcap-linux.c 24 Nov 2005 19:28:23 -0000 1.110.2.8 >@@ -704,8 +704,18 @@ > * here, but it's not clear that always incrementing > * the count is more expensive than always testing a flag > * in memory. >+ * >+ * We keep the count in "md.packets_read", and use that for >+ * "ps_recv" if we can't get the statistics from the kernel. >+ * We do that because, if we *can* get the statistics from >+ * the kernel, we use "md.stat.ps_recv" and "md.stat.ps_drop" >+ * as running counts, as reading the statistics from the >+ * kernel resets the kernel statistics, and if we directly >+ * increment "md.stat.ps_recv" here, that means it will >+ * count packets *twice* on systems where we can get kernel >+ * statistics - once here, and once in pcap_stats_linux(). > */ >- handle->md.stat.ps_recv++; >+ handle->md.packets_read++; > > /* Call the user supplied callback function */ > callback(userdata, &pcap_header, bp); >@@ -853,8 +863,14 @@ > * > * "ps_recv" doesn't include packets not yet read from > * the kernel by libpcap. >+ * >+ * We maintain the count of packets processed by libpcap in >+ * "md.packets_read", for reasons described in the comment >+ * at the end of pcap_read_packet(). We have no idea how many >+ * packets were dropped. > */ >- *stats = handle->md.stat; >+ stats->ps_recv = handle->md.packets_read; >+ stats->ps_drop = 0; > return 0; > } > >Index: libpcap/pcap-linux.c >=================================================================== >RCS file: /tcpdump/master/libpcap/pcap-linux.c,v >retrieving revision 1.110.2.9 >retrieving revision 1.110.2.10 >diff -u -r1.110.2.9 -r1.110.2.10 >--- libpcap/pcap-linux.c 22 Jan 2006 20:12:09 -0000 1.110.2.9 >+++ libpcap/pcap-linux.c 23 Feb 2006 07:35:35 -0000 1.110.2.10 >@@ -789,6 +789,23 @@ > if (getsockopt(handle->fd, SOL_PACKET, PACKET_STATISTICS, > &kstats, &len) > -1) { > /* >+ * On systems where the PACKET_STATISTICS "getsockopt()" >+ * argument is supported on PF_PACKET sockets: >+ * >+ * "ps_recv" counts only packets that *passed* the >+ * filter, not packets that didn't pass the filter. >+ * This includes packets later dropped because we >+ * ran out of buffer space. >+ * >+ * "ps_drop" counts packets dropped because we ran >+ * out of buffer space. It doesn't count packets >+ * dropped by the interface driver. It counts only >+ * packets that passed the filter. >+ * >+ * Both statistics include packets not yet read from >+ * the kernel by libpcap, and thus not yet seen by >+ * the application. >+ * > * In "linux/net/packet/af_packet.c", at least in the > * 2.4.9 kernel, "tp_packets" is incremented for every > * packet that passes the packet filter *and* is >@@ -818,6 +835,8 @@ > */ > handle->md.stat.ps_recv += kstats.tp_packets; > handle->md.stat.ps_drop += kstats.tp_drops; >+ *stats = handle->md.stat; >+ return 0; > } > else > { >@@ -837,21 +856,6 @@ > #endif > /* > * On systems where the PACKET_STATISTICS "getsockopt()" argument >- * is supported on PF_PACKET sockets: >- * >- * "ps_recv" counts only packets that *passed* the filter, >- * not packets that didn't pass the filter. This includes >- * packets later dropped because we ran out of buffer space. >- * >- * "ps_drop" counts packets dropped because we ran out of >- * buffer space. It doesn't count packets dropped by the >- * interface driver. It counts only packets that passed >- * the filter. >- * >- * Both statistics include packets not yet read from the >- * kernel by libpcap, and thus not yet seen by the application. >- * >- * On systems where the PACKET_STATISTICS "getsockopt()" argument > * is not supported on PF_PACKET sockets: > * > * "ps_recv" counts only packets that *passed* the filter,
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 441446
: 302587