Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Mar 2008 17:41:40 GMT
From:      Robert Watson <rwatson@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 137527 for review
Message-ID:  <200803121741.m2CHfe29090307@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=137527

Change 137527 by rwatson@rwatson_cinnamon on 2008/03/12 17:41:35

	When there's no data to return from a check for new BPF data,
	zero it even though we also return an error.  Doesn't cost much,
	but makes debugging easier.
	
	Add comment on how we pick the shared memory buffer size.
	
	Minor style nit.

Affected files ...

.. //depot/projects/zcopybpf/src/contrib/libpcap/pcap-bpf.c#24 edit

Differences ...

==== //depot/projects/zcopybpf/src/contrib/libpcap/pcap-bpf.c#24 (text+ko) ====

@@ -181,6 +181,7 @@
 			return (1);
 		}
 	}
+	*cc = 0;
 	return (0);
 }
 
@@ -806,6 +807,15 @@
 	bufmode = BPF_BUFMODE_ZBUF;
 	if (ioctl(fd, BIOCSETBUFMODE, (caddr_t)&bufmode) == 0) {
 		p->zerocopy = 1;
+
+		/*
+		 * How to pick a buffer size: first, query the maximum buffer
+		 * size supported by zero-copy.  This also lets us quickly
+		 * determine whether the kernel generally supports zero-copy.
+		 * Then, query the default buffer size, which reflects kernel
+		 * policy for a desired default.  Round to the nearest page
+		 * size.
+		 */
 		if (ioctl(fd, BIOCGETZMAX, (caddr_t)&zbufmax) < 0) {
 			snprintf(ebuf, PCAP_ERRBUF_SIZE, "BIOCGETZMAX: %s",
 			    pcap_strerror(errno));
@@ -843,7 +853,6 @@
 			    device, pcap_strerror(errno));
 			goto bad;
 		}
-
 		v = p->zbufsize - sizeof(struct bpf_zbuf_header);
 	} else {
 #endif



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200803121741.m2CHfe29090307>