BIOCSETBUFMODE ioctl call on bpf with BPF_BUFMODE_ZBUF argument always returns EBUSY. Reason: bpfopen() in sys/net/bpf.c calls bpf_buffer_ioctl_sblen() on every opened bpf device. bpf_buffer_ioctl_sblen() initializes bd_fbuf and bd_sbuf to freshly allocated memory buffers. Therefore later in BIOCSETBUFMODE ioctl the following condition is always true: if (d->bd_sbuf != NULL || d->bd_hbuf != NULL || d->bd_fbuf != NULL || d->bd_bif != NULL) { BPFD_UNLOCK(d); CURVNET_RESTORE(); return (EBUSY); } Solution: Insert this code in BIOCSETBUFMODE ioctl: if(*(u_int *)addr == BPF_BUFMODE_ZBUF && d->bd_bufmode == BPF_BUFMODE_BUFFER) { bpf_buffer_free(d); d->bd_sbuf = 0; d->bd_fbuf = 0; d->bd_hbuf = 0; } This works for switching to zerocopy mode. Probably some checking and action is needed if someone tries to switch back to BPF_BUFMODE_BUFFER mode after zerocopy mode. 10.1-RELEASE has the same problem.
Moving to -net.
This problem was fixed on head (r286139) and it was MFC'ed to stable/10 (r286850).