From nobody@FreeBSD.org  Tue Jun 12 18:50:48 2001
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id 3DA5337B403
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 12 Jun 2001 18:50:48 -0700 (PDT)
	(envelope-from nobody@FreeBSD.org)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.3/8.11.3) id f5D1omm93213;
	Tue, 12 Jun 2001 18:50:48 -0700 (PDT)
	(envelope-from nobody)
Message-Id: <200106130150.f5D1omm93213@freefall.freebsd.org>
Date: Tue, 12 Jun 2001 18:50:48 -0700 (PDT)
From: jl@ntt-20.ecl.net
To: freebsd-gnats-submit@FreeBSD.org
Subject: Packet capture does not work well with -pthead option.
X-Send-Pr-Version: www-1.0

>Number:         28112
>Category:       kern
>Synopsis:       Packet capture does not work well with -pthead option.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jun 12 19:00:02 PDT 2001
>Closed-Date:    Thu Jan 17 00:45:00 PST 2002
>Last-Modified:  Thu Jan 17 00:45:43 PST 2002
>Originator:     Kugimoto Takeshi
>Release:        4.3-RELEASE
>Organization:
NTT Network Innovations Labs.
>Environment:
4.3-RELEASE FreeBSD 4.3-RELEASE

>Description:
When a program that uses pcap library is compiled with -pthread
option, the program rarely caputure packets. 

The problem started with 4.3-RELEASE.


>How-To-Repeat:
The problem occurs with any program that uses pcap library,
eg. trafshow.  Trafshow is in FreeBSD ports collection.

Compile trafshow with -pthread option and run it.


>Fix:

>Release-Note:
>Audit-Trail:

From: Brian Mitchell <bem@atlanta-bsd.org>
To: freebsd-gnats-submit@FreeBSD.org, jl@ntt-20.ecl.net?sub
Cc:  
Subject: Re: kern/28112: Packet capture does not work well with -pthead option.
Date: Fri, 15 Jun 2001 23:12:02 -0400

 The problem is due to how pcap works. It is largely blocking based, and 
 will return
 packets as it gets them. PCAP was never intended to be multithreaded, 
 and the read
 of the bpf device will call sys_read() rather than the libc_r wrapper 
 for read, so your
 other threads will never be scheduled.
 
 If you only want to read packets in 1 thread, and do other things in the 
 other threads, compiling pcap with -pthread _may_ be acceptable, but I 
 have not looked at the code
 recently. As I recall, there was atleast _some_ static data, but as long 
 as all the pcap
 calls take place in a single thread, you should be ok. YMMV.
 
 
 
State-Changed-From-To: open->closed 
State-Changed-By: bmah 
State-Changed-When: Sat Nov 17 10:54:39 PST 2001 
State-Changed-Why:  


http://www.FreeBSD.org/cgi/query-pr.cgi?pr=28112 
State-Changed-From-To: closed->open 
State-Changed-By: bmah 
State-Changed-When: Sat Nov 17 10:55:15 PST 2001 
State-Changed-Why:  
Closed by mistake.  BTW, I don't think the pcap library was intended 
to support threaded applications anyways...this could *probably* be 
closed. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=28112 
State-Changed-From-To: open->suspended 
State-Changed-By: ashp 
State-Changed-When: Wed Jan 16 19:49:26 PST 2002 
State-Changed-Why:  
Moved to suspended, based on bmah's comments.  This libary isn't intended 
to work in a threaded fashion.  This can be reopened if anyone has interest 
/intent to solve it. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=28112 

From: Edwin Groothuis <edwin@mavetju.org>
To: ashp@FreeBSD.org, jl@ntt-20.ecl.net,
	freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: kern/28112: Packet capture does not work well with -pthead option.
Date: Thu, 17 Jan 2002 15:52:17 +1100

 On Wed, Jan 16, 2002 at 07:50:03PM -0800, ashp@FreeBSD.org wrote:
 > Synopsis: Packet capture does not work well with -pthead option.
 > 
 > State-Changed-From-To: open->suspended
 > State-Changed-By: ashp
 > State-Changed-When: Wed Jan 16 19:49:26 PST 2002
 > State-Changed-Why: 
 > Moved to suspended, based on bmah's comments.  This libary isn't intended
 > to work in a threaded fashion.  This can be reopened if anyone has interest
 > /intent to solve it.
 > 
 > http://www.FreeBSD.org/cgi/query-pr.cgi?pr=28112
 
 This can be closedi, patches are made and incorperated in -current
 and 4.5
 
 See also http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/31649 and
 http://www.freebsd.org/cgi/query-pr.cgi?pr=22063
 
 If the originator is interested I will have a look if I can find
 the patches and send them to him. Note, they were for 4.4, not 4.3.
 
 Edwin
 
 -- 
 Edwin Groothuis   |              Personal website: http://www.MavEtJu.org
 edwin@mavetju.org |           Interested in MUDs? Visit Fatal Dimensions:
 ------------------+                       http://www.FatalDimensions.org/
State-Changed-From-To: suspended->closed 
State-Changed-By: sheldonh 
State-Changed-When: Thu Jan 17 00:45:00 PST 2002 
State-Changed-Why:  
Closed as per bin/31649 and kern/22063. 

Thanks, Edwin! 

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