Bug 54161 - libpcap hangs if no filter set, pcap_next loses every other packet
libpcap hangs if no filter set, pcap_next loses every other packet
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: tcpdump (Show other bugs)
7.1
All Linux
medium Severity medium
: ---
: ---
Assigned To: Harald Hoyer
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-09-29 02:57 EDT by Alexander Dupuy
Modified: 2008-05-01 11:38 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-10-01 05:45:44 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
test program to demonstrate bug (& partial workaround), patch to libpcap (2.99 KB, patch)
2001-09-29 03:01 EDT, Alexander Dupuy
no flags Details | Diff

  None (edit)
Description Alexander Dupuy 2001-09-29 02:57:45 EDT
From Bugzilla Helper:
User-Agent: Mozilla/4.78 [en] (X11; U; Linux 2.4.9 i686)

Description of problem:
When using the PACKET_RX_RING interface, poll() on the packet fd will never
succeed if there is no kernel BPF filter installed.
Due to a fencepost error in packet_ring_recv, the pcap_dispatch and
pcap_loop interfaces will actually receive one more packet than requested. 
The pcap_next function, which only returns one packet, effectively loses
the first one.

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. write a program that uses libpcap but doesn't set a filter
2. write a program that loops calling pcap_next and prints destination
address of packet
3. run the programs and compare output to that of "tcpdump -nes 1"


Actual Results:  the first program never prints anything
the second program only prints every other packet

Expected Results:  the programs should print lines for every packet

Additional info:
Comment 1 Alexander Dupuy 2001-09-29 03:01:55 EDT
Created attachment 32998 [details]
test program to demonstrate bug (& partial workaround), patch to libpcap
Comment 2 Harald Hoyer 2002-01-17 10:26:33 EST
should be fixed in 3.6.2-10 or newer

Note You need to log in before you can comment on or make changes to this bug.