[Bug 197592] can't switch bpf to zero-copy mode

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Fri Feb 13 10:41:06 UTC 2015


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=197592

            Bug ID: 197592
           Summary: can't switch bpf to zero-copy mode
           Product: Base System
           Version: 10.0-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: freebsd-bugs at FreeBSD.org
          Reporter: aigars at ugunssiena.lv

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.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list