fix(netlink): request unique port identifiers - #910
Open
stephenlclarke wants to merge 1 commit into
Open
Conversation
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
Allow multiple Netlink route sockets in one process by requesting kernel-assigned port identifiers.
Binding every socket with
nl_pid = getpid()makes the second concurrent socket collide with the first. Bind with port identifier zero, read the unique assigned identifier back withgetsockname, and keep exposing it through the existingpidproperty.The initialization path also closes the descriptor on every post-
socket()failure and reports a dedicated socket-name error when the assigned address cannot be read or validated.Testing
Added a Linux-only regression that opens eight concurrent route sockets and verifies every assigned port identifier is non-zero and distinct.
The installed macOS cross-compilation SDK is not compatible with the active Apple Swift compiler, so the Linux test is intentionally delegated to this pull request's native Linux CI rather than treated as locally executed evidence.
git diff --checkand focused Swift formatting of the added code pass.Compatibility
The public property name remains
pidfor source compatibility, but its documentation now reflects Netlink semantics: it is a socket port identifier, not necessarily the process ID.