Use unprivileged SOCK_DGRAM ICMP on macOS (no root needed for ping)#18
Open
tenox7 wants to merge 1 commit into
Open
Use unprivileged SOCK_DGRAM ICMP on macOS (no root needed for ping)#18tenox7 wants to merge 1 commit into
tenox7 wants to merge 1 commit into
Conversation
macOS supports socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP) for any user, so guest ping no longer requires running iris as root. The macOS path now tries SOCK_DGRAM first and falls back to SOCK_RAW. Verified on macOS that DGRAM ICMP behaves like SOCK_RAW on recv: the kernel prepends the outer IP header, preserves the ICMP identifier, and delivers Time Exceeded replies, so the existing receive path and traceroute support work unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On macOS, iris opened the ICMP NAT socket with
SOCK_RAW, which requires root. Unprivileged runs printediris: ICMP unavailable (Operation not permitted)and guest ping/traceroute timed out.Fix
macOS supports unprivileged
socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP). The macOS path now triesSOCK_DGRAMfirst and falls back toSOCK_RAW. Linux and Windows behavior is unchanged.Why the receive path needs no changes
Verified empirically on macOS that
SOCK_DGRAMICMP is a drop-in forSOCK_RAW— and unlike Linux DGRAM:So macOS already falls correctly under the existing
#[cfg(not(target_os = "linux"))]receive logic — both ping and traceroute work without root. The misleading "Run as root (sudo)" hint was also removed from the macOS error message.Testing
cargo build --features lightning,tlbvmappasses on macOS arm64.pingworks from inside IRIX without sudo.