Zero-copy BPF update (was: Re: Aggregating many ports into one for tcpdump server.)

Robert Watson rwatson at
Mon Dec 24 16:40:12 PST 2007

On Mon, 24 Dec 2007, Robert Watson wrote:

> I've put up an updated tarball based on some recent changes here:

Unfortunately, there was a problem with a change I made to the kernel check 
for a userspace notification that a buffer was available via shared memory, so 
I have updated the tarball.  While there, I've made the following further 

- bpf.4 has been updated to reflect the shared memory interface.

- I've eliminated the BPF_ZEROCOPY environmental variable in libpcap; libpcap
   will try to use zero-copy BPF if it is compiled into the kernel and enabled.

- The kernel now has a net.bpf.zerocopy_enable sysctl, set to 1 by default,
   which controls whether the kernel will allow new zero-copy BPF sessions to
   be created.

- Memory barriers and atomic operations have been introduced on the shared
   memory interface to improve correctness on platforms with weaker memory

Robert N M Watson
Computer Laboratory
University of Cambridge

> The main changes since this last drop are:
> - BPF_ZERO_COPY environmental variable renamed to BPF_ZEROCOPY to match 
> kernel
>  option name.
> - libpcap support for zero-copy BPF buffers reworked to avoid unconditional
>  call to select() for each buffer when there's already a pending buffer
>  available to use; in general, avoid system calls entirely when there's data
>  already waiting, only use system calls when there isn't a completed buffer
>  to work on next.
> - Comments cleanup and some code cleanup.
> - A README to provide a little more guidance on getting it working. :-)
> You will need to "make clean ; make ; make install" in the modified libpcap 
> against, as the size of pcap_t has changed.  In principle "make ; make 
> install" should DTRT, but it appears not to for me.
> Robert N M Watson
> Computer Laboratory
> University of Cambridge
> _______________________________________________
> freebsd-net at mailing list
> To unsubscribe, send any mail to "freebsd-net-unsubscribe at"

More information about the freebsd-net mailing list