Skip to content

fix(udp): honor IPv4 source addresses on Apple platforms - #3

Merged
thomaseizinger merged 1 commit into
mainfrom
fix/apple-udp-source-address
Oct 28, 2026
Merged

thomaseizinger merged 1 commit into
mainfrom
fix/apple-udp-source-address

Conversation

@thomaseizinger

Copy link
Copy Markdown
Member

Honor requested IPv4 source addresses on Apple platforms so wildcard UDP sockets can send through secondary interfaces. Darwin ignores the current outgoing source-address control message; use IP_PKTINFO for both send paths.

@thomaseizinger
thomaseizinger force-pushed the fix/apple-udp-source-address branch 7 times, most recently from 503eae6 to f1966f1 Compare October 28, 2026 03:13
Darwin ignores `IP_RECVDSTADDR` as an outgoing IPv4 source-address
override. A wildcard socket therefore sends from the route's default
address, regardless of what we set in `src_ip`.

Instead of `IP_RECVDSTADDR`, we now use `IP_PKTINFO` for IPv4, similar
to `IPV6_PKTINFO` for IPv6.

`ipi_ifindex` remains set to zero so routing selects the interface,
otherwise we would force callers to provide an interface index.

The provided test fails prior to the fix and is kept separate due to its
particular setup requirements.
@thomaseizinger
thomaseizinger force-pushed the fix/apple-udp-source-address branch from f1966f1 to ecedfc0 Compare October 28, 2026 03:15
@thomaseizinger
thomaseizinger marked this pull request as ready for review October 28, 2026 03:15
@thomaseizinger
thomaseizinger merged commit 0d6aae8 into main Oct 28, 2026
25 checks passed
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