Bug #1674

non-blocking BPF reads return -1/EWOULDBLOCK until the store buffer fills up

Added by guy almost 5 years ago. Updated almost 5 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:-
Target version:-

Description

Non-blocking reads from a BPF device not in immediate mode will not rotate the buffers even if there's data in the store buffer but not in the hold buffer, so, until the store buffer fills up, the reads will return -1 and set errno to EWOULDBLOCK.

To reproduce, compile the attached (C++) program, run it on an adapter with the filter "icmp" on a reasonably quiet network, and then, on the same machine, ping some host the pings to which will go out on the same network. Note that the program doesn't report any packets having been seen.

To fix, apply the attached patch. (A similar bug has been filed against FreeBSD - and will be filed against Mac OS X.)

libpcaptest.cpp Magnifier (4.6 KB) guy, 02/13/2010 08:51 AM

unnamed (2 Bytes) guy, 02/13/2010 08:51 AM

patch.txt Magnifier (652 Bytes) guy, 02/13/2010 08:51 AM

History

#1 Updated by dillon almost 5 years ago

:To reproduce, compile the attached (C++) program, run it on an adapter =
:with the filter "icmp" on a reasonably quiet network, and then, on the =
:same machine, ping some host the pings to which will go out on the same =
:network. Note that the program doesn't report any packets having been =
:seen.
:
:To fix, apply the attached patch. (A similar bug has been filed against =
:FreeBSD - and will be filed against Mac OS X.)

Thanks for the bug report Guy! I've committed the patch.

-Matt

Also available in: Atom PDF