Darwin: correct ipv6_pktinfo to IPV6_3542PKTINFO (46) - #233
Merged
swhitty merged 1 commit intoJul 28, 2026
Conversation
The hardcoded value 50 is IPV6_3542DSTOPTS in <netinet6/in6.h>, not IPV6_PKTINFO — so the cmsg_type the kernel delivers for IPV6_RECVPKTINFO (61) never matched and received IPv6 datagram Messages always carried nil interfaceIndex/localAddress. The RFC 3542 value paired with IPV6_RECVPKTINFO is IPV6_3542PKTINFO (46). Swift cannot define __APPLE_USE_RFC_3542, hence the hardcoded constants. Closes TVT-1131 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #233 +/- ##
==========================================
+ Coverage 92.83% 92.97% +0.13%
==========================================
Files 71 71
Lines 3743 3743
==========================================
+ Hits 3475 3480 +5
+ Misses 268 263 -5 ☔ View full report in Codecov by Harness. |
Owner
|
Great I think the original implementation was made and tested on Linux so Darwin was only quickly added and included in some tests. Thank you |
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.
Summary
The hardcoded Darwin
ipv6_pktinfoconstant is50, which per the macOS SDK<netinet6/in6.h>isIPV6_3542DSTOPTS(destination-options header) — not pktinfo. The RFC 3542 value paired with the already-usedIPV6_RECVPKTINFO(61) isIPV6_3542PKTINFO(46):Swift cannot define
__APPLE_USE_RFC_3542before importing Darwin, so these constants must be hardcoded — but with 50,getPacketInfoControlnever matches thecmsg_typethe kernel actually delivers (46), and every received IPv6 datagramMessagecarriesinterfaceIndex: nil, localAddress: nilon Darwin.Changes
Socket+Darwin.swift:ipv6_pktinfo50 → 46; comments corrected from__APPLE_USE_RFC_2292to__APPLE_USE_RFC_3542(61 and 46 are RFC 3542 values).receiveMessage_ParsesIPv6PacketInfo: IPv6 loopback datagram round-trip asserting the receivedMessagecarries the parsed interface index and::1local address. Verified to fail with 50 and pass with 46 on macOS.Notes
This is a prerequisite for a follow-up fix to the send-side pktinfo control message (its
cmsg_levelis currentlySOL_SOCKET, which Darwin ignores; once corrected toIPPROTO_IPV6, the kernel interpretscmsg_type— and with 50 rejects IPv6 sends withEACCES).🤖 Generated with Claude Code