sys/socket: accept interface index in Ipv6MembershipRequest::new
#2688
+4
−3
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.
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