Date: Fri, 12 Aug 2005 00:27:30 +0200 (CEST) From: Rudolf Cejka <cejkar@fit.vutbr.cz> To: FreeBSD-gnats-submit@FreeBSD.org Subject: kern/84823: [PATCH] bpf in non-blocking mode is broken Message-ID: <200508112227.j7BMRUPe011906@kazi.fit.vutbr.cz> Resent-Message-ID: <200508112230.j7BMU9TM085201@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200508112227.j7BMRUPe011906>