Discussion:
select()ing on a pcap descriptor in Solaris
Fernando Gont
2014-08-14 20:34:50 UTC
Permalink
Folks,

While trying to select() on a pcap descriptor in solaris, I found the
following:

1) It seems that pcap descriptors are never readable or writeable. (--
This is different from *BSD and Linux, where at least you seem to be
able to check for readability)

2) It would seem that even trying to select() on such descriptors causes
trouble. For example, I get a kind of random "Bad file number" error
from select when I try to check for readability/writeability.

Is the above assessment correct? Should I not even try to call select()
on pcap descriptors in Solaris?

Thanks!

Best regards,
--
Fernando Gont
e-mail: ***@gont.com.ar || ***@si6networks.com
PGP Fingerprint: 7809 84F5 322E 45C7 F1C9 3945 96EE A9EF D076 FFF1
Guy Harris
2014-08-14 22:01:33 UTC
Permalink
Post by Fernando Gont
While trying to select() on a pcap descriptor in solaris
Which version? Solaris 11 (in which pcap descriptors should refer to BPF devices), or earlier (in which pcap descriptors should refer to DLPI STREAMS devices)?
Post by Fernando Gont
1) It seems that pcap descriptors are never readable or writeable. (--
This is different from *BSD and Linux, where at least you seem to be
able to check for readability)
2) It would seem that even trying to select() on such descriptors causes
trouble. For example, I get a kind of random "Bad file number" error
from select when I try to check for readability/writeability.
I wouldn't expect that prior to Solaris 11 - select() and poll() Just Work on STREAMS devices, as I remember.

It could, however, be that Sun^WOracle screwed up with BPF; unfortunately, Solaris 11 is ClosedSolaris, so I can't just look at the source and see what they did wrong.

I'll try this on my Solaris 11 virtual machine.
Post by Fernando Gont
Is the above assessment correct? Should I not even try to call select()
on pcap descriptors in Solaris?
If they screwed up on Solaris 11, you probably shouldn't try to call select(); instead, you should try to call Oracle and report this as a bug (and tell them that, if they fix this, they should fix it so that if you have a timeout set with BIOCSRTIMEOUT, the timer should start as soon as a select() or poll() is done, so that, when the timeout expires, it can report the descriptor as readable - the original BPF didn't do that, and all the *BSDs and OS X eventually fixed it).
Fernando Gont
2014-08-14 22:09:12 UTC
Permalink
Hi, Guy,
Post by Guy Harris
Post by Fernando Gont
While trying to select() on a pcap descriptor in solaris
Which version? Solaris 11 (in which pcap descriptors should refer to
BPF devices), or earlier (in which pcap descriptors should refer to
DLPI STREAMS devices)?
***@solaris:~/ipv6toolkit$ uname -a
SunOS solaris 5.11 11.1 i86pc i386 i86pc
Post by Guy Harris
Post by Fernando Gont
1) It seems that pcap descriptors are never readable or writeable.
(-- This is different from *BSD and Linux, where at least you seem
to be able to check for readability)
2) It would seem that even trying to select() on such descriptors
causes trouble. For example, I get a kind of random "Bad file
number" error from select when I try to check for
readability/writeability.
I wouldn't expect that prior to Solaris 11 - select() and poll() Just
Work on STREAMS devices, as I remember.
You wouldn't expect them to fail, or to work properly?
Post by Guy Harris
It could, however, be that Sun^WOracle screwed up with BPF;
unfortunately, Solaris 11 is ClosedSolaris, so I can't just look at
the source and see what they did wrong.
Seems like a long time since I last installed it... But I could try with
the CD they released circa 2009 -- that one was open source.
Post by Guy Harris
I'll try this on my Solaris 11 virtual machine.
Post by Fernando Gont
Is the above assessment correct? Should I not even try to call
select() on pcap descriptors in Solaris?
If they screwed up on Solaris 11, you probably shouldn't try to call
select(); instead, you should try to call Oracle and report this as a
bug (and tell them that, if they fix this, they should fix it so that
if you have a timeout set with BIOCSRTIMEOUT, the timer should start
as soon as a select() or poll() is done, so that, when the timeout
expires, it can report the descriptor as readable - the original BPF
didn't do that, and all the *BSDs and OS X eventually fixed it).
Point noted. I'll wait for your response above, and will proceed as
indicated if necessary.

Thanks so much (yet one more time)!

Best regards,
--
Fernando Gont
e-mail: ***@gont.com.ar || ***@si6networks.com
PGP Fingerprint: 7809 84F5 322E 45C7 F1C9 3945 96EE A9EF D076 FFF1
Fernando Gont
2014-08-18 23:06:37 UTC
Permalink
Hi, Guy,
Post by Guy Harris
I wouldn't expect that prior to Solaris 11 - select() and poll() Just
Work on STREAMS devices, as I remember.
It could, however, be that Sun^WOracle screwed up with BPF;
unfortunately, Solaris 11 is ClosedSolaris, so I can't just look at
the source and see what they did wrong.
I'll try this on my Solaris 11 virtual machine.
Were you able to try this?

I did the following check:

I ran my code, and checked with truss that /dev/bpf was being opened...
So apparently I am running the BPF-based libpcap, but still the
underlying descriptor is never readable or writeable...

P.S.: I'm waiting for some feedback from a fellow solaris dev. I will
keep you posted.

Thanks!

Best regards,
--
Fernando Gont
e-mail: ***@gont.com.ar || ***@si6networks.com
PGP Fingerprint: 7809 84F5 322E 45C7 F1C9 3945 96EE A9EF D076 FFF1
Loading...