-
Notifications
You must be signed in to change notification settings - Fork 864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tcpdump -v -w foo.out fails to capture on Solaris #1258
Comments
That's not unique to Solaris, other than the names of the kernel routines used in the BPF code. I'm not sure why this is only showing up on Solaris, but what happens if you change
and revert the timeout change? |
On 04/07/2014 11:57 AM, Guy Harris wrote:
|
I take that back. I had left in the shorter timeout. It's still broken
On 04/07/2014 06:56 PM, Norm Jacobs wrote:
|
My goodness, Sun^WOracle certainly seem to have failed big time here; I'm not having that problem on, for example, OS X, and if it were happening on *BSD, we would probably have heard about it. If Larry hadn't decided to kill OpenSolaris, I could perhaps have looked at the code to see what the problem is. The Single UNIX Specification page for SA_RESTART Implementing that behavior, for character special files such as the
...
In FreeBSD, the equivalent code is
and in NetBSD is
and in OpenBSD is
and in DragonFly BSD is
which might not handle this case; I'll have to try it, but I think there would have been significant complaints if it were broken on *BSD. |
@normjacobs, could you post the following additional information for completeness?
Thank you. |
See also the-tcpdump-group/tcpdump#155. |
Given lack of feedback in the past 6 years, is there any good reason to keep this open? |
reopen if still an issue with recent version. |
@guyharris, is there anything useful to take from this report? Would it make sense to leave a note in a man page or source code comment? |
For what it's worth, I built the tip of the master branch of libpcap, and then built the tip of the master branch of tcpdump with that libpcap, and tested it with However, if I
no packets get captured. So there is a problem - and I'm not sure it's Solaris-only. It does not happen on macOS Catalina; the Catalina code is
and the "Sometimes we may be interrupted often and..." code is probably what makes it work - if there's data in the store buffer, and there's no data in the hold buffer, if a signal happened during the On FreeBSD 12, however, no packets get captured in that case; FreeBSD does not have the "rotate the buffers if the store buffer is non-empty and the hold buffer is empty" code that macOS has. (If I were still working there, I could see whether this is the scenario that caused Apple to add that code.) So there is an issue here, at least with systems using BPF and not having that code. |
So there is an old small problem. A solution does not have to be implemented immediately. I would be OK if this discussion boiled down to a comment with detailed directions in the source code for any future volunteers. Would making the periodic update a separate POSIX thread be an OK solution? The periodic update code would be conditional, so if something like Would the following text in the man page be OK to document the problem for the time being?
|
I'm okay with doing this in tcpdump. I hate having a library that uses threads, but I don't think we need to do that.
so, we'd document the issue. I would go further and suggest that it not be used on Solaris. |
Capture what Guy has figured out so far.
This should have captured all 15 packets received, but it didn't.
Further investigation seems to indicate that this is because of the following:
tcpdump sets are read() timeout for libpcap to 1 second using pcap_set_timeout(1000)
tcpdump sets an alarm timer to 1 second (alarm(1)) to updated the displayed number of packets captured every second when -v and -w are used.
in the bpf module, bpf_read() uses cv_timedwait_sig() to wait for the configured timeout before it returns from read(). This is always interruppted by the alarm causing read() to return EINTR. Dropping the bpf read timeout down to 950 seems to provide enough time for it to work.
The text was updated successfully, but these errors were encountered: