-
Couldn't load subscription status.
- Fork 716
sys/socket: accept interface index in Ipv6MembershipRequest::new
#2688
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
`Ipv6MembershipRequest::new` hardcoded `ipv6mr_interface` to 0, which maps to the "default" multicast interface. That works for some scopes, but for link-local groups (ff02::/16) and many practical deployments an explicit ifindex is required. Because the wrapper’s inner `ipv6_mreq` is private, callers had no way to override the interface. This change updates `new()` to take an additional `c_uint` argument for the interface index and forwards it to `ipv6mr_interface`. Passing 0 preserves the previous behavior.
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.
Uh oh!
There was an error while loading. Please reload this page.
What does this PR do
Summary
This PR changes Ipv6MembershipRequest::new so that it accepts an interface index (c_uint) in addition to the multicast group address. The interface index is then passed to ipv6mr_interface instead of being hardcoded to 0.
Passing 0 preserves the previous behavior (use the default multicast interface). Supplying a non-zero ifindex allows explicit interface selection.
Motivation
IPv6 multicast membership is maintained per interface. Hardcoding ipv6mr_interface = 0 works for some scopes, but it prevents joining link-local groups (e.g. ff02::/16) or joining on a specific interface. Because the wrapper hides the underlying ipv6_mreq fields, there was no way for users to set the ifindex themselves.
Allowing the caller to pass an interface index makes the API consistent with the semantics of ipv6_mreq on Linux and *BSD, and covers real-world cases where explicit interface selection is required.
Alternatives
Add a separate constructor, e.g. with_ifindex(group, ifindex), and keep new(group) as-is (non-breaking).
If maintainers prefer a non-breaking approach, I can submit a separate PR adding with_ifindex instead of modifying new.
Checklist:
CONTRIBUTING.md