From e5200dc285352cecc7238af1d64a326cc3fc2829 Mon Sep 17 00:00:00 2001 From: Masakazu Asama Date: Sun, 12 Oct 2025 14:10:01 +0000 Subject: [PATCH 1/2] sys/socket: accept interface index in `Ipv6MembershipRequest::new` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `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. --- src/sys/socket/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index e3a1eae934..70c2f96fbd 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -9,7 +9,7 @@ use crate::sys::time::TimeSpec; use crate::sys::time::TimeVal; use crate::{errno::Errno, Result}; use cfg_if::cfg_if; -use libc::{self, c_int, size_t, socklen_t}; +use libc::{self, c_int, c_uint, size_t, socklen_t}; #[cfg(all(feature = "uio", not(target_os = "redox")))] use libc::{ c_void, iovec, CMSG_DATA, CMSG_FIRSTHDR, CMSG_LEN, CMSG_NXTHDR, CMSG_SPACE, @@ -633,10 +633,10 @@ pub struct Ipv6MembershipRequest(libc::ipv6_mreq); impl Ipv6MembershipRequest { /// Instantiate a new `Ipv6MembershipRequest` - pub const fn new(group: net::Ipv6Addr) -> Self { + pub const fn new(group: net::Ipv6Addr, interface: c_uint) -> Self { Ipv6MembershipRequest(libc::ipv6_mreq { ipv6mr_multiaddr: ipv6addr_to_libc(&group), - ipv6mr_interface: 0, + ipv6mr_interface: interface, }) } } From 0d849f55cb8ccb7513b891894f5095a6dbd2e207 Mon Sep 17 00:00:00 2001 From: Masakazu Asama Date: Sun, 12 Oct 2025 14:27:47 +0000 Subject: [PATCH 2/2] Add changelog/2688.changed.md --- changelog/2688.changed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/2688.changed.md diff --git a/changelog/2688.changed.md b/changelog/2688.changed.md new file mode 100644 index 0000000000..ca4432e361 --- /dev/null +++ b/changelog/2688.changed.md @@ -0,0 +1 @@ +changed Ipv6MembershipRequest::new to take an additional interface (ifindex) argument