Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Feb 2015 10:41:06 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-bugs@FreeBSD.org
Subject:   [Bug 197592] can't switch bpf to zero-copy mode
Message-ID:  <bug-197592-8@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
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@FreeBSD.org
          Reporter: aigars@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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-197592-8>