Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Improve the "Generic error" message when compiled against old libpcap #625

Merged
merged 1 commit into from
May 2, 2015

Conversation

dpw
Copy link
Contributor

@dpw dpw commented May 1, 2015

If gopacket is compiled against an older pcap.h that doesn't have pcap_set_immediate_mode, it supplies a dummy definition that always returns PCAP_ERROR. That becomes "Generic error", which is not very helpful. The real pcap_set_set_immediate never returns PCAP_ERROR, so this turns it into a more informative message.

Fixes #623

@bboreham
Copy link
Contributor

bboreham commented May 1, 2015

Could you put a call to this code in a test in pcap_test.go, so it would then be caught at unit-test time?

@dpw
Copy link
Contributor Author

dpw commented May 1, 2015

Could you put a call to this code in a test in pcap_test.go, so it would then be caught at unit-test time?

If some of the tests start requiring pcap, it will get checked, no? Is there value in checking even if pcap is not actively used?

Also, it is unlikely that you won't already have a working version of libpcap (Tom found ubuntu 12.04 doesn't). So it's really about making the error message more obvious in the rare event you don't, rather than checking as such.

@dpw
Copy link
Contributor Author

dpw commented May 1, 2015

Having second thoughts on this one. Probably going to cancel this PR unless I need to repurpose it for a very different patch.

If gopacket is compiled against an older pcap.h that doesn't have
pcap_set_immediate_mode, it supplies a dummy definition that
always returns PCAP_ERROR.  That becomes "Generic error", which
is not very helpful.  The real pcap_set_set_immediate never
returns PCAP_ERROR, so this turns it into a more informative
message.
@dpw dpw force-pushed the check-libpcap-version branch from f67fbc5 to be98393 Compare May 1, 2015 20:41
@dpw dpw changed the title Check whether we have a good version of libpcap Improve the "Generic error" message when compiled against old libpcap May 1, 2015
@dpw
Copy link
Contributor Author

dpw commented May 1, 2015

I've reimagined this and #623.

We could report the "generic error" as an issue against gopacket, but having looked at their code again, I think improvements on their side are unlikely. Because their approach is to supply a substitute pcap_set_immediate_mode in the C section of pcap.go, they are limited to the existing libpcap error status codes. They could do things differently in order to provide a better error message, but I could totally understand if they weren't convinced by the cost/benefit of doing so.

@rade rade merged commit be98393 into weaveworks:master May 2, 2015
@rade rade modified the milestone: 0.11.0 May 12, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

weave shouldn't fail with "Generic error" when compiled against an old libpcap
3 participants