tcpdump mailing list archives

Re: select() regression in libpcap-devel?


From: Guy Harris <guy () alum mit edu>
Date: Tue, 28 Jul 2009 19:01:00 -0700


On Jul 26, 2009, at 2:23 PM, Guy Harris wrote:

And not only that, but my test program reports, on my Fedora 9 system (2.6.27.25-78.2.6.fc9.i686 kernel), that, if I unplug an interface on which I'm capturing:

        select() reports that the descriptor is readable;

        there are *NO* packets to get from the memory-mapped buffer;

select() does *not* report that there's an exceptional condition on the descriptor;

so the kernel and driver appear to be continuously reporting through select() a condition *indistinguishable from "there's a packet available"* even though no packets are available.

poll(), however, appears to report an exceptional condition on the descriptor, so that might let you discover a missing netdev.

Fun Facts To Know And Tell about poll() and select() on Linux:

Both are implemented atop the same underlying interface to the objects being tested, which is a poll()-like interface (not surprisingly, as poll()'s capabilities are greater than those of select()).

If any of POLLRDNORM, POLLRDBAND, POLLIN, POLLHUP, or POLLERR are returned, and the descriptor was in the set of descriptors being tested for readability, select() reports the descriptor as readable.

If any of POLLWRBAND, POLLWRNORM, POLLOUT, or POLLERR are returned and the descriptor was in the set of descriptors being tested for writability, select() reports the descriptor as writable.

If POLLPRI is returned and the descriptor was in the set of descriptors being tested for exceptional conditions, select() reports the descriptor as having an exceptional condition.

Note that this means that POLLERR from poll - i.e., an exceptional condition, at least as the Mac OS X 10.5 man page for poll() describes it - does *not* show up as an exceptional condition; it shows up in the exact same fashion as readability, if you're testing for readability, and writability, if you're testing for writability.

I.e., use poll(), not select(), on Linux if you want to be told that a netdev has gone away.
-
This is the tcpdump-workers list.
Visit https://cod.sandelman.ca/ to unsubscribe.


Current thread: