Subject: kern/8674: bpf ioctl BIOCIMMEDIATE doesn't behave as it should
To: None <gnats-bugs@gnats.netbsd.org>
From: None <dave@dtsp.co.nz>
List: netbsd-bugs
Date: 10/24/1999 02:57:43
>Number:         8674
>Category:       kern
>Synopsis:       bpf ioctl BIOCIMMEDIATE doesn't behave as it should
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Oct 24 02:57:01 1999
>Last-Modified:
>Originator:     Dave Sainty
>Organization:
Dynamic Technology Services and Products Ltd (NZ)
>Release:        Recent NetBSD-current
>Environment:
i386, NetBSD-current
System: NetBSD tequila.dave.dtsp.co.nz 1.4K NetBSD 1.4K (TEQUILA) #7: Fri Sep 17 23:43:58 NZST 1999 dave@tequila.dave.dtsp.co.nz:/vol/tequila/userB/u2/NetBSD-current/src/sys/arch/i386/compile/TEQUILA i386

>Description:
	The BIOCIMMEDIATE bpf ioctl() basically behaves just like a
	non-blocking open.  This doesn't match what the man page says, and
	certainly doesn't match what you whould expect.  According to the man
	page, in immediate mode read()'s will still block in this mode, they
	will just return immediately on any received packet.


>How-To-Repeat:
	Set "immediate" mode.  See read()'s return with EWOULDBLOCK.

>Fix:
	The fix appears to be the obvious in sys/net/bpf.c, that is: simply
	fall through and block in immediate mode when the buffer is empty.
	catchpacket() already has handling for immediate mode that ensures it
	is woken early on packet reception.
>Audit-Trail:
>Unformatted: