From nobody@FreeBSD.org  Tue Jul 26 19:03:19 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id CD65A106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 26 Jul 2011 19:03:19 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id BDB528FC0C
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 26 Jul 2011 19:03:19 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p6QJ3IiJ053402
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 26 Jul 2011 19:03:18 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p6QJ3IHN053396;
	Tue, 26 Jul 2011 19:03:18 GMT
	(envelope-from nobody)
Message-Id: <201107261903.p6QJ3IHN053396@red.freebsd.org>
Date: Tue, 26 Jul 2011 19:03:18 GMT
From: Stephen Sanders <ssanders@opnet.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: pcap fd select() vs zero copy issue
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         159214
>Category:       ports
>Synopsis:       net/libpcap: pcap fd select() vs zero copy issue
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    wxs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jul 26 19:10:06 UTC 2011
>Closed-Date:    Fri Sep 09 02:23:19 UTC 2011
>Last-Modified:  Fri Sep 09 02:23:19 UTC 2011
>Originator:     Stephen Sanders
>Release:        8.1-RELEASE
>Organization:
OPNET
>Environment:
FreeBSD acelive86-1.opnet.com 8.1-RELEASE FreeBSD 8.1-RELEASE #0: Thu May 19 12:18:04 PDT 2011     jtoung@focus8.networkphysics.com:/u1/builds/8.6/ALKernel.jt/src/sys/amd64/compile/NPBAB8  amd64
>Description:
We have a packet capture application that is looking for TCP RST via doing a select() on pcap_fileno() and then calling pcap_next().

This has been fine for FreeBSD 6.3 but not FreeBSD 8.x.

The select indicates data ready but the call to pcap_next() does not return immediately but waits.

The application starts at boot time and will wedge in pcap_next() until restarted.  After a restart, the application works fine.

Recompiling libpcap such that zero copy is turned off and re-linking, the capture application works as anticipated. 

It appears that there is some issue with co-ordination of select() and zero copy.

>How-To-Repeat:

>Fix:
Recompile libpcap with zero copy turned off.

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->wxs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Wed Jul 27 02:49:02 UTC 2011 
Responsible-Changed-Why:  
Fix synopsis and assign. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=159214 

From: Wesley Shields <wxs@FreeBSD.org>
To: Stephen Sanders <ssanders@opnet.com>
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/159214: net/libpcap: pcap fd select() vs zero copy issue
Date: Mon, 1 Aug 2011 10:11:29 -0400

 Hi Stephen!
 
 I'd be more than happy to look into this but I am rather tight on time
 at the moment. Do you have a small program which exhibits this behavior
 I can use in testing?
 
 -- WXS

From: Stephen Sanders <ssanders@opnet.com>
To: Wesley Shields <wxs@FreeBSD.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/159214: net/libpcap: pcap fd select() vs zero copy issue
Date: Mon, 01 Aug 2011 10:13:56 -0400

 This is a multi-part message in MIME format.
 --------------060100080101020100020608
 Content-Type: text/plain; charset=ISO-8859-1
 Content-Transfer-Encoding: 7bit
 
 I don't have anything readily available but I will put together a test
 program this week.
 
 Thanks
 
 On 8/1/2011 10:11 AM, Wesley Shields wrote:
 > Hi Stephen!
 >
 > I'd be more than happy to look into this but I am rather tight on time
 > at the moment. Do you have a small program which exhibits this behavior
 > I can use in testing?
 >
 > -- WXS
 >
 
 --------------060100080101020100020608
 Content-Type: text/x-vcard; charset=utf-8;
  name="ssanders.vcf"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
  filename="ssanders.vcf"
 
 begin:vcard
 fn:Stephen Sanders
 n:Sanders;Stephen
 org:OPNET;APPTECH
 adr;dom:;;7255 Woodmont;Bethesda;MD;20814
 email;internet:ssanders@opnet.com
 title:Senior Software Engineer
 tel;work:240.497.3000 x 2237
 url:http://www.opnet.com
 version:2.1
 end:vcard
 
 
 --------------060100080101020100020608--
State-Changed-From-To: open->feedback 
State-Changed-By: wxs 
State-Changed-When: Mon Aug 1 21:17:13 UTC 2011 
State-Changed-Why:  
Pending test program from submitter. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=159214 

From: Stephen Sanders <ssanders@opnet.com>
To: bug-followup@FreeBSD.org, ssanders@opnet.com
Cc:  
Subject: Re: ports/159214: net/libpcap: pcap fd select() vs zero copy issue
Date: Tue, 02 Aug 2011 11:29:23 -0400

 This is a multi-part message in MIME format.
 --------------000801020201020803020604
 Content-Type: text/plain; charset=ISO-8859-1
 Content-Transfer-Encoding: 7bit
 
 Attached is an abbreviated form of the application that is having the issue.
 
 The filter should be looking for TCP RST or GRE packets. 
 
 We have a mis-behaving application here that generates 3 TCP RSTs but I
 can't really include that as part of the package.
 
 If you can generate 3 TCP RSTs directed at the capture host, one should
 see the select succeeding, the pcap_next() fails and eventually
 pcap_next() is called with no packet available.
 
 Thanks for the attention.
 
 
 
 
 --------------000801020201020803020604
 Content-Type: text/plain;
  name="pcapErratum.c"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
  filename="pcapErratum.c"
 
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stddef.h> //avoid conflicting offsetof() in <netinet/ip_compat.h>
 #include <syslog.h>
 #include <time.h>
 #include <fcntl.h>
 #include <sys/ioctl.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/time.h>
 #include <net/ethernet.h>
 #include <net/if.h>
 #include <netinet/in_systm.h>
 #include <netinet/in.h>
 #include <netinet/ip.h>
 #include <netinet/ip_compat.h>
 #include <netinet/ip_icmp.h>
 #include <netinet/tcp.h>
 #include <arpa/inet.h>
 #include <netdb.h>
 #include <pcap.h>
 #include <pcap-int.h>
 #include <errno.h>
 
 /* find the first up interface with an IP address. */
 int get_if_info(char *ifName, uint32_t *ifAddress)
 {
     int fd, len, lastlen;
     struct ifconf ifc;
     struct ifreq ifr, *ifrp;
     struct sockaddr_in sa;
     char *buf, *ptr;
     char loifName[24];
 
     if ( (fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) 
     {
         fprintf(stderr,"%s(%d) - socket\n", __func__,__LINE__ );
         exit(1);
     }
 
     /* 
     * prevent the result to be truncated if the buffer is not large enough.
     */
     lastlen = 0;
     len = 20 * sizeof(struct ifreq);
     
     for( ; ; ) 
     {
         buf = (char*)malloc(len);
         ifc.ifc_len = len;
         ifc.ifc_buf = buf;
         if (ioctl(fd, SIOCGIFCONF, (char*)&ifc) < 0) 
         {
             fprintf(stderr,"%s(%d) - ioctl(SIOCGIFCONF)\n", __func__,__LINE__ );
             exit(1);
         }
         else 
         {
             if (ifc.ifc_len == lastlen)
                 break;
             lastlen = ifc.ifc_len;
         }
         len += 10 * sizeof(struct ifreq);
         free(buf);
     }
 
     strcpy(loifName,"lo0");
     
     for (ptr = buf; ptr < buf+ifc.ifc_len;) 
     {
         ifrp = (struct ifreq*) ptr;
         strncpy(ifr.ifr_name, ifrp->ifr_name, IFNAMSIZ);
     
         /* check sa_len for in case when ifru_addr is larger
          than sizeof(sockaddr).
         */
         ptr += 
         sizeof(ifrp->ifr_name)  + (ifrp->ifr_addr.sa_len > sizeof(struct sockaddr)
                 ? ifrp->ifr_addr.sa_len : sizeof(struct sockaddr));
         
         if ( ioctl(fd, SIOCGIFFLAGS, (char*)&ifr) < 0)
             continue;
         
         if ( !(ifr.ifr_flags & IFF_UP) )/* if down */
             continue;
     
         if (ifr.ifr_flags & IFF_LOOPBACK) 
         { /* if loopback */
             strcpy(loifName,ifr.ifr_name);
             continue;
         }
         
         /* get if address */
         if ( ioctl(fd, SIOCGIFADDR, (char*)&ifr) < 0)  
             continue; /* ignore those active interface without an IPaddress */
         
         /* save if address */
         memcpy(&sa, &ifr.ifr_ifru.ifru_addr,sizeof(struct sockaddr_in));
         strcpy(ifName, ifr.ifr_name);
         *ifAddress = sa.sin_addr.s_addr;
         
         fprintf(stderr, "%s(%d) - interface=%s address=%s\n", 
             __func__,__LINE__ , ifName, inet_ntoa( sa.sin_addr) );
         
         free(buf);
         close(fd);
         return 0;
     }
 
     /* interface not found, use 'lo' */
     strcpy(ifName, loifName);
     *ifAddress = inet_addr("127.0.0.1");
     
     free(buf);
     return 0;
 }
 
 pcap_t *open_pcap(char *device, uint32_t address) 
 {
 
     pcap_t *pd;
 
     uint32_t localnet, netmask;
     char cmd[1024], errbuf[PCAP_ERRBUF_SIZE];
     struct bpf_program fcode;
 
     errbuf[0] = '\0';   /* to detect pcap warnings */
 
     /* Worst case:
        IP header plus GRE header plus payload IP header plus ICMP header
        plus original IP header plus 8 bytes of the original datagram
        plus ample room for options plus the ethernet frame. */
     const int snaplen = 20 + 4 + 20 + 8 + 20 + 8 + 16 + 14;
     const int promisc = 0;
     const int to_ms = 0;
     
     if ( (pd = pcap_open_live(device, snaplen, promisc, to_ms, errbuf)) == NULL) 
     {
         fprintf(stderr, "%s(%d) - pcap_open_live=%s\n", __func__,__LINE__ ,
             errbuf);
         exit(1);
     }
     if (pcap_lookupnet(device, &localnet, &netmask, errbuf) < 0) {
         fprintf(stderr,"%s(%d) - pcap_lookupnet=%s\n", __func__,__LINE__ ,
             errbuf);
         exit(1);
     }
     
     /* Set the following to 0 for testing, 1 for failure */
 #if 1
     /* TCP resets and GRE datagrams, addressed to us: */
     struct in_addr inaddr;
     inaddr.s_addr = address;
     snprintf(cmd, sizeof(cmd), "(tcp[13]&4!=0 or ip[9]=47) and dst %s",
         inet_ntoa(inaddr));
 
     if (pcap_compile(pd, &fcode, cmd, 0, netmask) < 0) 
     {
         fprintf(stderr,"%s(%d) - pcap_compile=%s\n", __func__,__LINE__
             ,pcap_geterr(pd) );
         exit(1);
     }
     
     if (pcap_setfilter(pd, &fcode) < 0) 
     {
        fprintf(stderr, "%s(%d) - pcap_setfilter=%s\n", __func__,__LINE__,
             pcap_geterr(pd) );
         exit(1);
     }
 #endif
     /* We will assume that the datalink type is ethernet */
 
     if (errbuf[0] != '\0') 
     {    /* output pcap warnings, if any */
         fprintf(stderr, "%s(%d) - pcap_warning=%s\n", __func__,__LINE__, errbuf );
     }
     /* This ioctl is necessary on FreeBSD, to get BPF read to work with select: */
     const int on = 1;
     if (ioctl(pd->fd, BIOCIMMEDIATE, &on) < 0) 
     {
         fprintf(stderr, "%s(%d) - ioctl\n", __func__,__LINE__ );
         exit(1);
     }
     return pd;
 }
 
 int recv_pcap(pcap_t *pd ) 
 {
     
     char *ptr;
     struct pcap_pkthdr hdr;
     struct ether_header *eptr;
 
     fprintf( stderr, "calling pcap_next()\n" );
     ptr = (char *) pcap_next(pd, &hdr);
     fprintf( stderr, "pcap_next() returned\n");
 
     if (ptr == NULL)
         return 0;
   
     return 1;
 }
 
 int receive( pcap_t *pd )
 {
     fd_set fds;
     FD_ZERO(&fds);
     
     FD_SET( pcap_fileno( pd ), &fds );
 
     // Identify which descriptors are ready.
     int r = select( pcap_fileno( pd ) + 1 , &fds, NULL, NULL, NULL );
 
     if (r < 0) 
     {
         fprintf(stderr, "%s(%d) - select failed\n", __func__,__LINE__ );
         return 0;
     }
 
     if (FD_ISSET( pcap_fileno( pd ), &fds)) 
     { 
         if (recv_pcap(pd ) == 0)
             return 0;
     }
     
     return 1;
 }
 
 int main( int argc, char **argv )
 {
     char ifName[24];
     uint32_t  ifAddress=0;
     pcap_t *pd = NULL;
     
     /* Find a suitable local interface */
     if (get_if_info(ifName, &ifAddress) < 0) {
         fprintf(stderr, "%s(%d) - can't find local interface information\n",
             __func__,__LINE__ );
         exit(1);
     }
 
     /* Initialize the packet capture library */
     pd = open_pcap(ifName, ifAddress);
     while( 1 ) 
     {
         if( receive( pd ) == 1)
             fprintf(stderr,"Got packet\n");
         else
             fprintf(stderr,"Error receiving\n");
         
         fflush( stderr );
     }
 }
 
 --------------000801020201020803020604
 Content-Type: text/plain;
  name="Makefile"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
  filename="Makefile"
 
 CFLAGS=-g
 LIBS=-lpcap
 OBJECTS=pcapErratum.o
 
 pcapErratum: $(OBJECTS)
 	$(CC) -o pcapErratum  $(OBJECTS) $(LIBS)
 
 --------------000801020201020803020604
 Content-Type: text/x-vcard; charset=utf-8;
  name="ssanders.vcf"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
  filename="ssanders.vcf"
 
 begin:vcard
 fn:Stephen Sanders
 n:Sanders;Stephen
 org:OPNET;APPTECH
 adr;dom:;;7255 Woodmont;Bethesda;MD;20814
 email;internet:ssanders@opnet.com
 title:Senior Software Engineer
 tel;work:240.497.3000 x 2237
 url:http://www.opnet.com
 version:2.1
 end:vcard
 
 
 --------------000801020201020803020604--

From: Wesley Shields <wxs@FreeBSD.org>
To: Stephen Sanders <ssanders@opnet.com>
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/159214: net/libpcap: pcap fd select() vs zero copy issue
Date: Fri, 19 Aug 2011 17:21:38 -0400

 --NzB8fVQJ5HfG6fxh
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 On Tue, Aug 02, 2011 at 03:30:13PM +0000, Stephen Sanders wrote:
 >  Attached is an abbreviated form of the application that is having the issue.
 >  
 >  The filter should be looking for TCP RST or GRE packets. 
 >  
 >  We have a mis-behaving application here that generates 3 TCP RSTs but I
 >  can't really include that as part of the package.
 >  
 >  If you can generate 3 TCP RSTs directed at the capture host, one should
 >  see the select succeeding, the pcap_next() fails and eventually
 >  pcap_next() is called with no packet available.
 >  
 >  Thanks for the attention.
 
 First off, sorry for the delay.
 
 While looking into this I discovered a couple of things.
 
 FreeBSD 8.1 has libpcap 1.0.0, which has the bug your code triggers.
 FreeBSD -CURRENT has libpcap 1.1.1 which also has the same bug.
 
 The beta of libpcap 1.2.0 does not have the bug.  I narrowed it down to
 a specific commit in libpcap that appears to fix it[1]. I am attaching
 that patch.
 
 fix-for-libpcap111.diff: This is the fix that will apply cleanly against
 an unmodified libpcap 1.1.1 directory. This same file will apply to a
 FreeBSD 8.1 source tree - it will have some offset differences but
 patch(1) will find the right place.
 
 I'm now interested in two things, only expecting an answer on (1) from
 you. :)
 
 1. Does this work for you? If so I will commit it to the port and see
 about getting it in the src tree, but it may have to wait until after
 9.0 unfortunately.
 
 2. Given the beta status of 1.2.0 is it even worth committing said fix
 to the port and base? It might just be easier to wait for the 1.2.0
 release and update the port and base then, or just the port and apply
 this patch to the base.
 
 [1]:
 https://github.com/mcr/libpcap/commit/b26d8d2aa849c8021cdfa872901e82fb469460ef
 
 -- WXS
 
 --NzB8fVQJ5HfG6fxh
 Content-Type: text/x-diff; charset=us-ascii
 Content-Disposition: attachment; filename="fix-for-libpcap111.diff"
 
 --- pcap-bpf.c.orig	2010-03-11 20:56:54.000000000 -0500
 +++ pcap-bpf.c	2011-08-19 16:57:14.711470759 -0400
 @@ -911,14 +911,28 @@
  		 * processed so far.
  		 */
  		if (p->break_loop) {
 +			p->bp = bp;
 +			p->cc = ep - bp;
 +			/*
 +			 * ep is set based on the return value of read(),
 +			 * but read() from a BPF device doesn't necessarily
 +			 * return a value that's a multiple of the alignment
 +			 * value for BPF_WORDALIGN().  However, whenever we
 +			 * increment bp, we round up the increment value by
 +			 * a value rounded up by BPF_WORDALIGN(), so we
 +			 * could increment bp past ep after processing the
 +			 * last packet in the buffer.
 +			 *
 +			 * We treat ep < bp as an indication that this
 +			 * happened, and just set p->cc to 0.
 +			 */
 +			if (p->cc < 0)
 +				p->cc = 0;
  			if (n == 0) {
  				p->break_loop = 0;
  				return (PCAP_ERROR_BREAK);
 -			} else {
 -				p->bp = bp;
 -				p->cc = ep - bp;
 +			} else
  				return (n);
 -			}
  		}
  
  		caplen = bhp->bh_caplen;
 @@ -970,6 +984,11 @@
  			if (++n >= cnt && cnt > 0) {
  				p->bp = bp;
  				p->cc = ep - bp;
 +				/*
 +				 * See comment above about p->cc < 0.
 +				 */
 +				if (p->cc < 0)
 +					p->cc = 0;
  				return (n);
  			}
  		} else {
 
 --NzB8fVQJ5HfG6fxh--

From: Stephen Sanders <ssanders@opnet.com>
To: Wesley Shields <wxs@FreeBSD.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/159214: net/libpcap: pcap fd select() vs zero copy issue
Date: Mon, 22 Aug 2011 11:07:07 -0400

 This is a multi-part message in MIME format.
 --------------090909040107050604090203
 Content-Type: text/plain; charset=ISO-8859-1
 Content-Transfer-Encoding: 7bit
 
 Patching libpcap.1.1.1 gets a better result but it is still not quite right.
 
 When pcapErratum receives a TCP RST, it should print
 
 calling pcap_next()
 pcap_next() returned
 Got packet
  
 Using a patched libpcap.1.1.1 and setting net.bpf.zerocopy_enable=1,
 pcapErratum succeeds in the select but ends up hanging around in
 pcap_next() waiting for a packet.  So the console looks like
 
 calling pcap_next()
 
 However, instead of being wedged forever, pcap_next() will return if
 another TCP RST shows up.
 
 Setting net.bpf.zerocopy_enable=0 will cause pcapErratum to print the
 correct display.
 
 This is tough to test for as you need access to a misbehaving
 application that causes TCP RST.
 
 Thanks
 
 
 
 On 8/19/2011 5:21 PM, Wesley Shields wrote:
 > On Tue, Aug 02, 2011 at 03:30:13PM +0000, Stephen Sanders wrote:
 >>  Attached is an abbreviated form of the application that is having the issue.
 >>  
 >>  The filter should be looking for TCP RST or GRE packets. 
 >>  
 >>  We have a mis-behaving application here that generates 3 TCP RSTs but I
 >>  can't really include that as part of the package.
 >>  
 >>  If you can generate 3 TCP RSTs directed at the capture host, one should
 >>  see the select succeeding, the pcap_next() fails and eventually
 >>  pcap_next() is called with no packet available.
 >>  
 >>  Thanks for the attention.
 > First off, sorry for the delay.
 >
 > While looking into this I discovered a couple of things.
 >
 > FreeBSD 8.1 has libpcap 1.0.0, which has the bug your code triggers.
 > FreeBSD -CURRENT has libpcap 1.1.1 which also has the same bug.
 >
 > The beta of libpcap 1.2.0 does not have the bug.  I narrowed it down to
 > a specific commit in libpcap that appears to fix it[1]. I am attaching
 > that patch.
 >
 > fix-for-libpcap111.diff: This is the fix that will apply cleanly against
 > an unmodified libpcap 1.1.1 directory. This same file will apply to a
 > FreeBSD 8.1 source tree - it will have some offset differences but
 > patch(1) will find the right place.
 >
 > I'm now interested in two things, only expecting an answer on (1) from
 > you. :)
 >
 > 1. Does this work for you? If so I will commit it to the port and see
 > about getting it in the src tree, but it may have to wait until after
 > 9.0 unfortunately.
 >
 > 2. Given the beta status of 1.2.0 is it even worth committing said fix
 > to the port and base? It might just be easier to wait for the 1.2.0
 > release and update the port and base then, or just the port and apply
 > this patch to the base.
 >
 > [1]:
 > https://github.com/mcr/libpcap/commit/b26d8d2aa849c8021cdfa872901e82fb469460ef
 >
 > -- WXS
 
 --------------090909040107050604090203
 Content-Type: text/x-vcard; charset=utf-8;
  name="ssanders.vcf"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
  filename="ssanders.vcf"
 
 begin:vcard
 fn:Stephen Sanders
 n:Sanders;Stephen
 org:OPNET;APPTECH
 adr;dom:;;7255 Woodmont;Bethesda;MD;20814
 email;internet:ssanders@opnet.com
 title:Senior Software Engineer
 tel;work:240.497.3000 x 2237
 url:http://www.opnet.com
 version:2.1
 end:vcard
 
 
 --------------090909040107050604090203--

From: Wesley Shields <wxs@FreeBSD.org>
To: Stephen Sanders <ssanders@opnet.com>
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/159214: net/libpcap: pcap fd select() vs zero copy issue
Date: Mon, 22 Aug 2011 11:14:53 -0400

 On Mon, Aug 22, 2011 at 11:07:07AM -0400, Stephen Sanders wrote:
 > Patching libpcap.1.1.1 gets a better result but it is still not quite right.
 > 
 > When pcapErratum receives a TCP RST, it should print
 > 
 > calling pcap_next()
 > pcap_next() returned
 > Got packet
 >  
 > Using a patched libpcap.1.1.1 and setting net.bpf.zerocopy_enable=1,
 > pcapErratum succeeds in the select but ends up hanging around in
 > pcap_next() waiting for a packet.  So the console looks like
 > 
 > calling pcap_next()
 > 
 > However, instead of being wedged forever, pcap_next() will return if
 > another TCP RST shows up.
 > 
 > Setting net.bpf.zerocopy_enable=0 will cause pcapErratum to print the
 > correct display.
 
 OK, I'll keep looking into this then.
 
 > This is tough to test for as you need access to a misbehaving
 > application that causes TCP RST.
 
 For my tests I was just doing:
 
 telnet 192.168.1.3 99
 
 Or, basically any machine on the network to a port which isn't open.
 FreeBSD generates a RST for this. This has been sufficient enough for me.
 
 -- WXS
State-Changed-From-To: feedback->closed 
State-Changed-By: wxs 
State-Changed-When: Fri Sep 9 02:23:18 UTC 2011 
State-Changed-Why:  
Per discussion with Stephen privately he has indicated he will use a 
patched version of libpcap 1.1.1 for now. As such I am closing this PR. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=159214 
>Unformatted:
