aboutsummaryrefslogtreecommitdiff
path: root/sys/net/bpf_zerocopy.c
Commit message (Collapse)AuthorAgeFilesLines
* - Modify vm_page_unwire() and vm_page_enqueue() to directly acceptAttilio Rao2014-06-161-1/+1
| | | | | | | | | | | | | | | | | | | | | the queue where to enqueue pages that are going to be unwired. - Add stronger checks to the enqueue/dequeue for the pagequeues when adding and removing pages to them. Of course, for unmanaged pages the queue parameter of vm_page_unwire() will be ignored, just as the active parameter today. This makes adding new pagequeues quicker. This change effectively modifies the KPI. __FreeBSD_version will be, however, bumped just when the full cache of free pages will be evicted. Sponsored by: EMC / Isilon storage division Reviewed by: alc Tested by: pho Notes: svn path=/head/; revision=267548
* After the PHYS_TO_VM_PAGE() function was de-inlined, the main reasonKonstantin Belousov2012-08-051-0/+1
| | | | | | | | | | | | | | | | to pull vm_param.h was removed. Other big dependency of vm_page.h on vm_param.h are PA_LOCK* definitions, which are only needed for in-kernel code, because modules use KBI-safe functions to lock the pages. Stop including vm_param.h into vm_page.h. Include vm_param.h explicitely for the kernel code which needs it. Suggested and reviewed by: alc MFC after: 2 weeks Notes: svn path=/head/; revision=239065
* Fix old panic when BPF consumer attaches to destroying interface.Alexander V. Chernikov2012-05-211-5/+5
| | | | | | | | | | | | | | | | | | | | 'flags' field is added to the end of bpf_if structure. Currently the only flag is BPFIF_FLAG_DYING which is set on bpf detach and checked by bpf_attachd() Problem can be easily triggered on SMP stable/[89] by the following command (sort of): 'while true; do ifconfig vlan222 create vlan 222 vlandev em0 up ; tcpdump -pi vlan222 & ; ifconfig vlan222 destroy ; done' Fix possible use-after-free when BPF detaches itself from interface, freeing bpf_bif memory, while interface is still UP and there can be routes via this interface. Freeing is now delayed till ifnet_departure_event is received via eventhandler(9) api. Convert bpfd rwlock back to mutex due lack of performance gain (currently checking if packet matches filter is done without holding bpfd lock and we have to acquire write lock if packet matches) Approved by: kib(mentor) MFC in: 4 weeks Notes: svn path=/head/; revision=235745
* - Improve BPF locking model.Alexander V. Chernikov2012-04-061-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | Interface locks and descriptor locks are converted from mutex(9) to rwlock(9). This greately improves performance: in most common case we need to acquire 1 reader lock instead of 2 mutexes. - Remove filter(descriptor) (reader) lock in bpf_mtap[2] This was suggested by glebius@. We protect filter by requesting interface writer lock on filter change. - Cover struct bpf_if under BPF_INTERNAL define. This permits including bpf.h without including rwlock stuff. However, this is is temporary solution, struct bpf_if should be made opaque for any external caller. Found by: Dmitrij Tejblum <tejblum@yandex-team.ru> Sponsored by: Yandex LLC Reviewed by: glebius (previous version) Reviewed by: silence on -net@ Approved by: (mentor) MFC after: 3 weeks Notes: svn path=/head/; revision=233937
* - Fix trivial typoEitan Adler2012-01-141-1/+1
| | | | | | | | Approved by: nwhitehorn MFC after: 3 days Notes: svn path=/head/; revision=230108
* Introduce and use a new VM interface for temporarily pinning pages. ThisAlan Cox2010-12-251-6/+2
| | | | | | | | | | new interface replaces the combined use of vm_fault_quick() and pmap_extract_and_hold() throughout the kernel. In collaboration with: kib@ Notes: svn path=/head/; revision=216699
* Remove page queues locking from all sf_buf_mext()-like functions. The pageAlan Cox2010-05-061-2/+0
| | | | | | | | | lock now suffices. Fix a couple nearby style violations. Notes: svn path=/head/; revision=207708
* Add page locking to the vm_page_cow* functions.Alan Cox2010-05-041-2/+0
| | | | | | | | | | Push down the acquisition and release of the page queues lock into vm_page_wire(). Reviewed by: kib Notes: svn path=/head/; revision=207617
* This is the first step in transitioning responsibility for synchronizingAlan Cox2010-05-031-0/+2
| | | | | | | | | access to the page's wire_count from the page queues lock to the page lock. Submitted by: kmacy Notes: svn path=/head/; revision=207548
* On Alan's advice, rather than do a wholesale conversion on a singleKip Macy2010-04-301-0/+2
| | | | | | | | | | | | | | | architecture from page queue lock to a hashed array of page locks (based on a patch by Jeff Roberson), I've implemented page lock support in the MI code and have only moved vm_page's hold_count out from under page queue mutex to page lock. This changes pmap_extract_and_hold on all pmaps. Supported by: Bitgravity Inc. Discussed with: alc, jeffr, and kib Notes: svn path=/head/; revision=207410
* Always embed pointer to BPF JIT function in BPF descriptorJung-uk Kim2009-08-121-1/+0
| | | | | | | | | | to avoid inconsistency when opt_bpf.h is not included. Reviewed by: rwatson Approved by: re (rwatson) Notes: svn path=/head/; revision=196150
* Clarify some comments, fix some types, and rename ZBUF_FLAG_IMMUTABLE toRobert Watson2009-03-071-18/+18
| | | | | | | | ZBUF_FLAG_ASSIGNED to make it clear why the buffer can't be written to: it is assigned to userspace. Notes: svn path=/head/; revision=189489
* Make sure we are clearing the ZBUF_FLAG_IMMUTABLE any time a free bufferChristian S.J. Peron2008-07-051-0/+18
| | | | | | | | | | | is reclaimed by the kernel. This fixes a bug resulted in the kernel over writing packet data while user-space was still processing it when zerocopy is enabled. (Or a panic if invariants was enabled). Discussed with: rwatson Notes: svn path=/head/; revision=180310
* Maintain and observe a ZBUF_FLAG_IMMUTABLE flag on zero-copy BPFRobert Watson2008-04-071-4/+73
| | | | | | | | | | | | | | | | | | | | | | | | | buffer kernel descriptors, which is used to allow the buffer currently in the BPF "store" position to be assigned to userspace when it fills, even if userspace hasn't acknowledged the buffer in the "hold" position yet. To implement this, notify the buffer model when a buffer becomes full, and check that the store buffer is writable, not just for it being full, before trying to append new packet data. Shared memory buffers will be assigned to userspace at most once per fill, be it in the store or in the hold position. This removes the restriction that at most one shared memory can by owned by userspace, reducing the chances that userspace will need to call select() after acknowledging one buffer in order to wait for the next buffer when under high load. This more fully realizes the goal of zero system calls in order to process a high-speed packet stream from BPF. Update bpf.4 to reflect that both buffers may be owned by userspace at once; caution against assuming this. Notes: svn path=/head/; revision=177966
* Add a comment explaining that we initialize the 'a' buffer forRobert Watson2008-03-261-0/+5
| | | | | | | | | | | | zero-copy to the store buffer position on the BPF descriptor, and the 'b' buffer as the free buffer in order to fill them in the order documented in bpf(4). MFC after: 4 months Suggested by: csjp Notes: svn path=/head/; revision=177647
* Fix build with option BPF_JITTER.Jung-uk Kim2008-03-241-1/+2
| | | | Notes: svn path=/head/; revision=177585
* Introduce support for zero-copy BPF buffering, which reduces theChristian S.J. Peron2008-03-241-0/+510
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. Notes: svn path=/head/; revision=177548