diff --git a/src/iface/interface/ipv4.rs b/src/iface/interface/ipv4.rs index 3a5a864e..84b265c5 100644 --- a/src/iface/interface/ipv4.rs +++ b/src/iface/interface/ipv4.rs @@ -196,6 +196,10 @@ impl InterfaceInner { } } + #[cfg(feature = "medium-ethernet")] + self.neighbor_cache + .reset_expiry_if_existing(IpAddress::Ipv4(ipv4_repr.src_addr), self.now); + match ipv4_repr.next_header { IpProtocol::Icmp => self.process_icmpv4(sockets, ipv4_repr, ip_payload), diff --git a/src/iface/interface/ipv6.rs b/src/iface/interface/ipv6.rs index a72492bb..28c44630 100644 --- a/src/iface/interface/ipv6.rs +++ b/src/iface/interface/ipv6.rs @@ -228,6 +228,10 @@ impl InterfaceInner { #[cfg(not(feature = "socket-raw"))] let handled_by_raw_socket = false; + #[cfg(any(feature = "medium-ethernet", feature = "medium-ieee802154"))] + self.neighbor_cache + .reset_expiry_if_existing(IpAddress::Ipv6(ipv6_repr.src_addr), self.now); + self.process_nxt_hdr( sockets, meta, diff --git a/src/iface/neighbor.rs b/src/iface/neighbor.rs index 8fa1d7d5..543d78c9 100644 --- a/src/iface/neighbor.rs +++ b/src/iface/neighbor.rs @@ -63,6 +63,16 @@ impl Cache { } } + pub fn reset_expiry_if_existing(&mut self, protocol_addr: IpAddress, timestamp: Instant) { + if let Some(Neighbor { + expires_at, + hardware_addr: _, + }) = self.storage.get_mut(&protocol_addr) + { + *expires_at = timestamp + Self::ENTRY_LIFETIME; + } + } + pub fn fill( &mut self, protocol_addr: IpAddress,