Skip to content

Use unprivileged SOCK_DGRAM ICMP on macOS (no root needed for ping)#18

Open
tenox7 wants to merge 1 commit into
techomancer:mainfrom
tenox7:macos-unprivileged-icmp
Open

Use unprivileged SOCK_DGRAM ICMP on macOS (no root needed for ping)#18
tenox7 wants to merge 1 commit into
techomancer:mainfrom
tenox7:macos-unprivileged-icmp

Conversation

@tenox7
Copy link
Copy Markdown

@tenox7 tenox7 commented May 20, 2026

Problem

On macOS, iris opened the ICMP NAT socket with SOCK_RAW, which requires root. Unprivileged runs printed iris: 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 tries SOCK_DGRAM first and falls back to SOCK_RAW. Linux and Windows behavior is unchanged.

Why the receive path needs no changes

Verified empirically on macOS that SOCK_DGRAM ICMP is a drop-in for SOCK_RAW — and unlike Linux DGRAM:

Behavior macOS DGRAM Linux DGRAM
Opens without root yes yes
recv includes outer IP header yes no (payload only)
ICMP id preserved yes no (kernel rewrites)
Time Exceeded delivered yes no
IP_TTL settable yes yes

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,tlbvmap passes on macOS arm64.
  • Confirmed guest ping works from inside IRIX without sudo.

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.
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.

1 participant