tcpdump mailing list archives
libpcap linux mmap patch
From: Alexander 'Leo' Bergolth <leo () strike wu-wien ac at>
Date: Thu, 31 Jan 2008 10:37:32 +0100
Hi! I just gave your new linux mmap patch a try, that was committed to svn a few weeks ago. The code works fine, except for two issues: *) There is a typo in the macro RING_GET_FRAME(h) (handle instead of h). The attached patch fixes that. *) If pcap_loop is called with cnt=0 (ngrep erroneously does that), it will busy-loop forever. pcap_read_linux_mmap doesn't handle that case, it returns 0, which is asymmetric to pcap_read_linux's behavior, which reads one packet. The second attached patch returns 0 directly in pcap_loop(), if it is called with cnt=0. Cheers, --leo -- e-mail ::: Leo.Bergolth (at) wu-wien.ac.at fax ::: +43-1-31336-906050 location ::: Computer Center | Vienna University of Economics | Austria
--- pcap-linux.c.with_mmap 2008-01-31 09:44:49.310322964 +0100 +++ pcap-linux.c 2008-01-31 09:46:07.660101750 +0100 @@ -218,7 +218,7 @@ static void pcap_close_linux(pcap_t *); #ifdef HAVE_PACKET_RING -#define RING_GET_FRAME(h) (((struct tpacket_hdr**)h->buffer)[handle->offset]) +#define RING_GET_FRAME(h) (((struct tpacket_hdr**)h->buffer)[h->offset]) static void destroy_ring(pcap_t *handle); static int create_ring(pcap_t* handle, unsigned size, char* errmsg);
--- pcap.c.orig 2008-01-31 10:22:53.997816397 +0100
+++ pcap.c 2008-01-31 10:21:00.463201991 +0100
@@ -92,6 +92,9 @@
{
register int n;
+ if (cnt == 0)
+ return (0);
+
for (;;) {
if (p->sf.rfile != NULL) {
/*
- This is the tcpdump-workers list. Visit https://cod.sandelman.ca/ to unsubscribe.
Current thread:
- libpcap linux mmap patch Alexander 'Leo' Bergolth (Jan 31)
- Re: libpcap linux mmap patch Abeni Paolo (Jan 31)
- Re: libpcap linux mmap patch Alexander 'Leo' Bergolth (Feb 02)
- Re: libpcap linux mmap patch Guy Harris (Feb 02)
- Re: libpcap linux mmap patch Alexander 'Leo' Bergolth (Feb 02)
- Re: libpcap linux mmap patch Guy Harris (Feb 02)
- Re: libpcap linux mmap patch Alexander 'Leo' Bergolth (Feb 02)
- Re: libpcap linux mmap patch Guy Harris (Feb 02)
- Re: libpcap linux mmap patch Guy Harris (Feb 02)
- Re: libpcap linux mmap patch Alexander 'Leo' Bergolth (Feb 02)
- Re: libpcap linux mmap patch Abeni Paolo (Feb 03)
- Re: libpcap linux mmap patch Abeni Paolo (Jan 31)
