Reset expiry of entries in the neighbor cache on packet reception

This commit is contained in:
Emil Fresk 2024-08-02 10:43:47 +02:00
parent 53caf70f64
commit fd758773d8
3 changed files with 18 additions and 0 deletions

View File

@ -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),

View File

@ -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,

View File

@ -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,