PERFORCE change 137527 for review

Robert Watson rwatson at FreeBSD.org
Wed Mar 12 17:41:41 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=137527

Change 137527 by rwatson at 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


More information about the p4-projects mailing list