kern/84823: [PATCH] bpf in non-blocking mode is broken
Rudolf Cejka
cejkar at fit.vutbr.cz
Thu Aug 11 22:30:10 GMT 2005
>Number: 84823
>Category: kern
>Synopsis: [PATCH] bpf in non-blocking mode is broken
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Thu Aug 11 22:30:08 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator: Rudolf Cejka
>Release: FreeBSD 5.3-STABLE i386
>Organization:
FIT, Brno University of Technology, Czech Republic
>Environment:
Any FreeBSD since Dec 17 2000 with sys/net/bpf.c >= 1.72.
>Description:
When bpf is in non-blocking mode, it always returns EWOULDBLOCK - it
never returns any data. The bpf is broken since following commit:
: Revision 1.72, Sun Dec 17 20:50:22 2000 UTC (4 years, 7 months ago)
:
: Fix bug: a read() on a bpf device which was in non-blocking mode
: and had no data available returned 0. Now it returns -1 with errno
: set to EWOULDBLOCK (== EAGAIN) as it should. This fix makes the bpf
: device usable in threaded programs.
>How-To-Repeat:
>Fix:
Following patch should fix the problem:
--- sys/net/bpf.c.orig Thu Aug 11 23:24:42 2005
+++ sys/net/bpf.c Thu Aug 11 23:27:10 2005
@@ -489,8 +489,13 @@
}
if (ioflag & O_NONBLOCK) {
- BPFD_UNLOCK(d);
- return (EWOULDBLOCK);
+ if (d->bd_slen == 0) {
+ BPFD_UNLOCK(d);
+ return (EWOULDBLOCK);
+ } else {
+ ROTATE_BUFFERS(d);
+ break;
+ }
}
error = msleep(d, &d->bd_mtx, PRINET|PCATCH,
"bpf", d->bd_rtout);
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list