cvs commit: src/sys/net bpf.c bpf.h bpf_buffer.c bpf_buffer.h
bpf_zerocopy.c bpf_zerocopy.h bpfdesc.h src/share/man/man4 bpf.4
src/sys/conf files
Christian S.J. Peron
csjp at FreeBSD.org
Mon Mar 24 06:49:19 PDT 2008
csjp 2008-03-24 13:49:18 UTC
FreeBSD src repository
Modified files:
sys/net bpf.c bpf.h bpfdesc.h
share/man/man4 bpf.4
sys/conf files
Added files:
sys/net bpf_buffer.c bpf_buffer.h bpf_zerocopy.c
bpf_zerocopy.h
Log:
Introduce support for zero-copy BPF buffering, which reduces the
overhead of packet capture by allowing a user process to directly "loan"
buffer memory to the kernel rather than using read(2) to explicitly copy
data from kernel address space.
The user process will issue new BPF ioctls to set the shared memory
buffer mode and provide pointers to buffers and their size. The kernel
then wires and maps the pages into kernel address space using sf_buf(9),
which on supporting architectures will use the direct map region. The
current "buffered" access mode remains the default, and support for
zero-copy buffers must, for the time being, be explicitly enabled using
a sysctl for the kernel to accept requests to use it.
The kernel and user process synchronize use of the buffers with atomic
operations, avoiding the need for system calls under load; the user
process may use select()/poll()/kqueue() to manage blocking while
waiting for network data if the user process is able to consume data
faster than the kernel generates it. Patchs to libpcap are available
to allow libpcap applications to transparently take advantage of this
support. Detailed information on the new API may be found in bpf(4),
including specific atomic operations and memory barriers required to
synchronize buffer use safely.
These changes modify the base BPF implementation to (roughly) abstrac
the current buffer model, allowing the new shared memory model to be
added, and add new monitoring statistics for netstat to print. The
implementation, with the exception of some monitoring hanges that break
the netstat monitoring ABI for BPF, will be MFC'd.
Zerocopy bpf buffers are still considered experimental are disabled
by default. To experiment with this new facility, adjust the
net.bpf.zerocopy_enable sysctl variable to 1.
Changes to libpcap will be made available as a patch for the time being,
and further refinements to the implementation are expected.
Sponsored by: Seccuris Inc.
In collaboration with: rwatson
Tested by: pwood, gallatin
MFC after: 4 months [1]
[1] Certain portions will probably not be MFCed, specifically things
that can break the monitoring ABI.
Revision Changes Path
1.49 +240 -15 src/share/man/man4/bpf.4
1.1283 +2 -0 src/sys/conf/files
1.188 +313 -109 src/sys/net/bpf.c
1.50 +66 -0 src/sys/net/bpf.h
1.1 +210 -0 src/sys/net/bpf_buffer.c (new)
1.1 +50 -0 src/sys/net/bpf_buffer.h (new)
1.1 +510 -0 src/sys/net/bpf_zerocopy.c (new)
1.1 +53 -0 src/sys/net/bpf_zerocopy.h (new)
1.39 +25 -13 src/sys/net/bpfdesc.h
More information about the cvs-src
mailing list