From owner-p4-projects@FreeBSD.ORG Wed Mar 12 17:41:41 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5D7621065674; Wed, 12 Mar 2008 17:41:41 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1C40C1065672 for ; Wed, 12 Mar 2008 17:41:41 +0000 (UTC) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 10AC58FC27 for ; Wed, 12 Mar 2008 17:41:41 +0000 (UTC) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m2CHfer4090309 for ; Wed, 12 Mar 2008 17:41:40 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m2CHfe29090307 for perforce@freebsd.org; Wed, 12 Mar 2008 17:41:40 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Wed, 12 Mar 2008 17:41:40 GMT Message-Id: <200803121741.m2CHfe29090307@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Cc: Subject: PERFORCE change 137527 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Mar 2008 17:41:41 -0000 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