Skip to content

Commit 48cb672

Browse files
authored
Merge pull request #871 from thvdveld/neighbor-cache-with-expiration
neigh: add fill_with_expiration method
2 parents cec04d9 + ece00ac commit 48cb672

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/iface/neighbor.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,21 @@ impl Cache {
7272
debug_assert!(protocol_addr.is_unicast());
7373
debug_assert!(hardware_addr.is_unicast());
7474

75+
let expires_at = timestamp + Self::ENTRY_LIFETIME;
76+
self.fill_with_expiration(protocol_addr, hardware_addr, expires_at);
77+
}
78+
79+
pub fn fill_with_expiration(
80+
&mut self,
81+
protocol_addr: IpAddress,
82+
hardware_addr: HardwareAddress,
83+
expires_at: Instant,
84+
) {
85+
debug_assert!(protocol_addr.is_unicast());
86+
debug_assert!(hardware_addr.is_unicast());
87+
7588
let neighbor = Neighbor {
76-
expires_at: timestamp + Self::ENTRY_LIFETIME,
89+
expires_at,
7790
hardware_addr,
7891
};
7992
match self.storage.insert(protocol_addr, neighbor) {

0 commit comments

Comments
 (0)