From owner-freebsd-net Wed Nov 6 0: 2:50 2002 Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4894637B401 for ; Wed, 6 Nov 2002 00:02:48 -0800 (PST) Received: from silver.he.iki.fi (silver.he.iki.fi [193.64.42.241]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0739A43E7B for ; Wed, 6 Nov 2002 00:02:47 -0800 (PST) (envelope-from pete@he.iki.fi) Received: from PHE (silver.he.iki.fi [193.64.42.241]) by silver.he.iki.fi (8.12.6/8.11.4) with SMTP id gA682huO017453; Wed, 6 Nov 2002 10:02:43 +0200 (EET) (envelope-from pete@he.iki.fi) Message-ID: <05af01c2856a$f103c960$862a40c1@PHE> From: "Petri Helenius" To: "Barney Wolff" Cc: References: <03fe01c28386$186fed80$862a40c1@PHE> <20021103225402.GA28812@tp.databus.com> Subject: Re: bpf Date: Wed, 6 Nov 2002 10:03:06 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org > I believe you're misunderstanding the meaning of the timeout in select(2). > Timeout applies only when no FDs are ready. The specific problem with bpf is that one might have a half-full buffer of captured data when the select timeout hits. In that case the select returns with no FDs ready while I think it really should return with the bpf fd. (and if you look at the code on sys/net/bpf.c, there is timeout handling towards that goal) but I´ve yet to figure out where it goes wrong. IMO, at timeout the code should check if bd_slen > 0 and if yes, do ROTATE_BUFFERS and bpf_wakeup() Unfortunately I´m not a kernel wizard enough to have fixed this, at least not yet. The functionality I´m looking for is to get all the packets accumulated, say in 1 second in single read regardless of if I got a buffer´s full of data. > > Also, you might be better off setting immediate mode on your bpf fd, > if you want a return before the buffer is full. > Immediate mode practically causes the reader to be waken up for every packet, ending up with huge number of small reads which is highly ineffective. Pete > On Mon, Nov 04, 2002 at 12:12:26AM +0200, Petri Helenius wrote: > > > > I believe the select operation on bpf is not functioning as supposed to. > > I?m calling select with 100ms timeout. The bpf interface is listening to > > an interface with constant packet rate, so it?s certain that multiple packets > > have been received during the select call. However the fd for the bpf > > device is not set until the bpf buffer is full. (which might be several seconds > > away since I?m using fairly large bpf buffers) > > > > Looking at the code I get the impression that if there are packets on the bpf > > buffer when the select timeouts, it should return the fd for the bpf ? > > > > Pete > > > > > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > > with "unsubscribe freebsd-net" in the body of the message > > -- > Barney Wolff http://www.databus.com/bwresume.pdf > I'm available by contract or FT, in the NYC metro area or via the 'Net. > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message