Skip to content

Conversation

m-asama
Copy link

@m-asama m-asama commented Oct 12, 2025

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:

  • I have read CONTRIBUTING.md
  • I have written necessary tests and rustdoc comments
  • A change log has been added if this PR modifies nix's API

`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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant