From owner-freebsd-bugs Tue Oct 17 14:40: 7 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id B3D3E37B4F9 for ; Tue, 17 Oct 2000 14:40:00 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id OAA77322; Tue, 17 Oct 2000 14:40:00 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: by hub.freebsd.org (Postfix, from userid 32767) id 265D137B4CF; Tue, 17 Oct 2000 14:39:00 -0700 (PDT) Message-Id: <20001017213900.265D137B4CF@hub.freebsd.org> Date: Tue, 17 Oct 2000 14:39:00 -0700 (PDT) From: vanepp@sfu.ca To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-1.0 Subject: kern/22063: bpf when used with the select system call with timeout doesn't forward packets on timeout Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 22063 >Category: kern >Synopsis: bpf when used with the select system call with timeout doesn't forward packets on timeout >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Oct 17 14:40:00 PDT 2000 >Closed-Date: >Last-Modified: >Originator: Peter Van Epp >Release: 4.1-RELEASE >Organization: Simon Fraser University >Environment: FreeBSD demob.ucs.sfu.ca 4.1-RELEASE FreeBSD 4.1-RELEASE #19: Tue Oct 17 12:37:56 PDT 2000 vanepp@demob.ucs.sfu.ca:/usr/src/sys/compile/GENERIC i386 >Description: When bpf is accessed via libpcap with the select system call with a timeout set if a less than full buffer of packets received on the interface (and passed to bpf.c) they will never be returned to libpcap even on a timeout. OpenBSD has a partial fix for this (it gets the first packet of 9 up and leaves the other 8) which I have corrected, reported to OpenBSD and ported to FreeBSD. As a side note one of the OpenBSD people is working on a better bpf implementation and would be interested in help by someone knowledgable in the FreeBSD VM system to assist porting his code when finished to FreeBSD. >How-To-Repeat: To reproduce: 1) Install argus-1.8.1.tar.gz and argus-1.8.1.patches from ftp.andrew.cmu.edu/pub/argus 2) Install the test.dif patch below to report Total packets received from libpcap to show the problem. 3) start argus_bpf as below and supply it a less than buffer full of packets (I used tcpreplay from www.anzen.com/research/nidsbench on another machine playing back a tcpdump file: tcpreplay -ixl0 -r1 ip.small.tcpdump). 4) Examine output as below (unpatched then patched). Unpatched bpf.c (all 9 packets still in bpf.c buffer, none get to libpcap): demob# bin/argus_bpf -i xl0 -P0 -w argus.log ^C 9 packets recv'd by filter 0 packets dropped by kernel demob# bin/ra -r argus.log -n Tue 10/17 12:34:19 man 1.168.192.0 255.255.255.0 INT Tue 10/17 12:34:33 man pkts 9 drops 0 flows 0 CLO bpf.c and bpfdesc.h patched as below and kernel recompiled and installed: demob# bin/argus_bpf -ixl0 -P0 -w argus.log Total packets: 1 Total packets: 2 Total packets: 3 Total packets: 4 Total packets: 5 Total packets: 6 Total packets: 7 Total packets: 8 Total packets: 9 ^C 9 packets recv'd by filter 0 packets dropped by kernel demob# bin/ra -r argus.log -n Tue 10/17 09:50:50 man 1.168.192.0 255.255.255.0 INT Tue 10/17 09:51:16 M tcp 130.71.240.184.2197 |> 142.58.12.12.80 RST Tue 10/17 09:51:23 man pkts 9 drops 0 flows 1 CLO demob# Apply in argus-1.8.1/ directory. *** server/cons_ether.c.orig Tue Oct 17 01:45:10 2000 --- server/cons_ether.c Tue Oct 17 01:45:59 2000 *************** *** 95,100 **** --- 95,101 ---- if (p && caplen) { totalPktsRcv++; + printf("Total packets: %d\n", totalPktsRcv); globaltvp.tv_sec = h->ts.tv_sec; globaltvp.tv_usec = h->ts.tv_usec; >Fix: begin 600 patch.dif M*BHJ("]S>7,O;F5T+V)P9BYC+F]R:6<)4V%T($]C=" Q-" Q.3HP,#HU.2 R M,# P"BTM+2 O"AS*3L*(" )PHA( D)"0EI9B H*&0M/F)D7W)T;W5T("$]("TQ*2 F)B * M(2 )"0D)(" @("AD+3YB9%]R9'-T87)T("L@9"T^8F1?"AS*3L*(" )7,O M;F5T+V)P9F1ERelease-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message