Skip to content

Commit 3f31068

Browse files
committed
fix: apply suggestion from review comment
#1842 (comment)
1 parent 4ae5ad6 commit 3f31068

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

io/zenoh-links/zenoh-link-udp/src/multicast.rs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -323,29 +323,23 @@ impl LinkManagerMulticastUdp {
323323

324324
// If TTL is specified, add set the socket's TTL
325325
if let Some(ttl_str) = config.get(UDP_MULTICAST_TTL) {
326-
let ttl = match ttl_str.parse::<u32>() {
327-
Ok(ttl) => ttl,
328-
Err(e) => bail!("Can not parse TTL '{}' to a u32: {}", ttl_str, e),
329-
};
330-
331326
match &local_addr {
332327
IpAddr::V4(_) => {
333-
ucast_sock
334-
.set_multicast_ttl_v4(ttl)
335-
.map_err(|e| zerror!("{}: {}", mcast_addr, e))?;
328+
let ttl = match ttl_str.parse::<u32>() {
329+
Ok(ttl) => ttl,
330+
Err(e) => bail!("Can not parse TTL '{}' to a u32: {}", ttl_str, e),
331+
};
332+
333+
ucast_sock.set_multicast_ttl_v4(ttl).map_err(|e| {
334+
zerror!("Can not set multicast TTL {} on {}: {}", ttl, mcast_addr, e)
335+
})?;
336336
}
337-
IpAddr::V6(_) => match zenoh_util::net::get_index_of_interface(local_addr) {
338-
Ok(_) => {
339-
tracing::warn!(
340-
"set_multicast_ttl_v4 on v6 socket (may have no effect): {}",
337+
IpAddr::V6(_) => {
338+
tracing::warn!(
339+
"UDP multicast hop limit not supported for v6 socket: {}. See https://github.com/rust-lang/rust/pull/138744.",
341340
mcast_addr
342341
);
343-
ucast_sock
344-
.set_multicast_ttl_v4(ttl)
345-
.map_err(|e| zerror!("{}: {}", mcast_addr, e))?
346-
}
347-
Err(e) => bail!("{}: {}", mcast_addr, e),
348-
},
342+
}
349343
}
350344
}
351345

0 commit comments

Comments
 (0)