Skip to content

Commit d3ca540

Browse files
committed
Avoid panic when max_resp_code is zero
1 parent 3988338 commit d3ca540

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/iface/interface/multicast.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -522,10 +522,13 @@ impl InterfaceInner {
522522
max_resp_code,
523523
..
524524
} => {
525-
// Do not respont immediately to the query, but wait a random time
526-
let delay = crate::time::Duration::from_millis(
527-
(self.rand.rand_u16() % max_resp_code).into(),
528-
);
525+
// Do not respond immediately to the query, but wait a random time
526+
let delay = if max_resp_code > 0 {
527+
(self.rand.rand_u16() % max_resp_code).into()
528+
} else {
529+
0
530+
};
531+
let delay = crate::time::Duration::from_millis(delay);
529532
// General query
530533
if mcast_addr.is_unspecified()
531534
&& (ip_repr.dst_addr == IPV6_LINK_LOCAL_ALL_NODES

0 commit comments

Comments
 (0)