From nobody  Wed Jan  6 16:39:41 1999
Received: (from nobody@localhost)
          by hub.freebsd.org (8.8.8/8.8.8) id QAA01134;
          Wed, 6 Jan 1999 16:39:41 -0800 (PST)
          (envelope-from nobody)
Message-Id: <199901070039.QAA01134@hub.freebsd.org>
Date: Wed, 6 Jan 1999 16:39:41 -0800 (PST)
From: dwhite@pond.net
To: freebsd-gnats-submit@freebsd.org
Subject: can't select() for writes on a bpf
X-Send-Pr-Version: www-1.0

>Number:         9355
>Category:       kern
>Synopsis:       [MFC] can't select() for writes on a bpf
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jan  6 16:40:02 PST 1999
>Closed-Date:    Thu Sep 20 13:23:37 PDT 2001
>Last-Modified:  Thu Sep 20 13:24:57 PDT 2001
>Originator:     Doug White
>Release:        2.2.7-RELEASE
>Organization:
Pacific Crest Networks, Inc.
>Environment:
FreeBSD sturbei.pond.net 2.2.7-RELEASE FreeBSD 2.2.7-RELEASE #0: Mon Dec 21 14:44:26 PST 1998     dwhite@sturbei.pond.net:/usr/src/sys/compile/STURBEI  i386

>Description:
The Berkeley Packet Filter (bpf) does not appear to support select()ing
or poll()ing for writability.  Needless to say this is stupid and keeps
it from being used for something actually useful.
>How-To-Repeat:
Write a program that selects() a bpf file descriptor for writes, and 
be prepared to wait.
>Fix:
Add these two lines in just before the check for the read flag:

For 2.2.X:

if(rw & FWRITE)
	return(1);

for 3.X:

if(events & POLLOUT)
   return (1);

This makes bpf always accept writes.  I don't think the bpf needs to
throttle writes anyway.  If such logic actually
exists it should be trivially easy to add a check.  I just don't know
enough about the kernel side of bpf to make a good patch.
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: gad 
State-Changed-When: Wed Mar 21 13:11:32 PST 2001 
State-Changed-Why:  
Garrett Rooney <rooneg@electricjellyfish.net> looked into this PR, and 
says it works in 2.2.8, 3.x, and 4.x... 

http://www.freebsd.org/cgi/query-pr.cgi?pr=9355 
State-Changed-From-To: closed->suspended 
State-Changed-By: gad 
State-Changed-When: Wed Apr 4 16:27:55 PDT 2001 
State-Changed-Why:  
Well, Garrett Rooney <rooneg@electricjellyfish.net> was mortified to find 
out that this bug wasn't really fixed at all.  As it happens, bde had a 
patch which he thought should fix it, but it had not been applied or tested 
yet.  GarrettR "was volunteered" to do the testing, as penance for having 
goofed up on his original analysis.  He wrote a program to test the problem, 
applied the patch, and verified that it worked. 

The patch has been committed to current, and is awaiting MFC... 


http://www.freebsd.org/cgi/query-pr.cgi?pr=9355 
State-Changed-From-To: suspended->closed 
State-Changed-By: gad 
State-Changed-When: Thu Sep 20 13:23:37 PDT 2001 
State-Changed-Why:  
The fix for this bug with bpf has been MFC'ed into RELENG_4.  (4.4-stable) 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=9355 
>Unformatted:
