Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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
m-asama wants to merge 2 commits into nix-rust:master
base: master
Choose a base branch
Loading
from m-asama:ipv6_mreq

Conversation

@m-asama
Copy link

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

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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /