mirror of
https://github.com/smoltcp-rs/smoltcp.git
synced 2025-09-29 22:02:05 +00:00
Reset expiry of entries in the neighbor cache on packet reception
This commit is contained in:
parent
53caf70f64
commit
fd758773d8
@ -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),
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user