Procházet zdrojové kódy

Merge pull request #1047 from simonborje/handle_max_resp_code_0

Avoid panic when max_resp_code is zero
Dario Nieuwenhuis před 3 měsíci
rodič
revize
f8bfa31120
1 změnil soubory, kde provedl 7 přidání a 4 odebrání
  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