Skip to content
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

Workaround unprivileged PacketConn on darwin returns the entire IP packet in icmp.ListenPacket() #37

Merged
merged 1 commit into from
May 20, 2023

Conversation

floatingstatic
Copy link
Contributor

@floatingstatic floatingstatic commented May 19, 2023

TLDR: unprivileged icmp echo replies are discarded on macOS (darwin)

This is a patch to work around an issue described in golang/go#47369 which can be summarized as follows:

Due to setting the IP_STRPHDR socket option in darwin (macOS) environments,
reads on unprivileged sockets (udp) include the IP header before the ICMP header in the read bytes returned by icmp.ListenPacket(). As a result of this, pro-bing ends up discarding icmp echo replies due to the unexpected ip header bytes returned by icmp.ListenPacket().

While this problem needs to be addressed in go itself, this patch provides a work around until this issue is addressed.

…cket in icmp.ListenPacket()

Signed-off-by: Jeremiah Millay <jmillay@fastly.com>
@floatingstatic
Copy link
Contributor Author

floatingstatic commented May 20, 2023

Also worth pointing out pinger.SetPrivileged(true) works fine on macOS, this is only a problem when this is false

Copy link
Contributor

@SuperQ SuperQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants