浏览代码

Avoid panic when max_resp_code is zero

Simon Börjesson 2 月之前
父节点
当前提交
d3ca540a29
共有 1 个文件被更改,包括 7 次插入4 次删除
  1. 7 4
      src/iface/interface/multicast.rs

+ 7 - 4
src/iface/interface/multicast.rs

@@ -522,10 +522,13 @@ impl InterfaceInner {
                 max_resp_code,
                 ..
             } => {
-                // Do not respont immediately to the query, but wait a random time
-                let delay = crate::time::Duration::from_millis(
-                    (self.rand.rand_u16() % max_resp_code).into(),
-                );
+                // Do not respond immediately to the query, but wait a random time
+                let delay = if max_resp_code > 0 {
+                    (self.rand.rand_u16() % max_resp_code).into()
+                } else {
+                    0
+                };
+                let delay = crate::time::Duration::from_millis(delay);
                 // General query
                 if mcast_addr.is_unspecified()
                     && (ip_repr.dst_addr == IPV6_LINK_LOCAL_ALL_NODES