mirror of
https://github.com/jmcorgan/fips.git
synced 2026-08-09 16:24:45 +00:00
Add MTU fields to lookup packets for path MTU discovery
Add min_mtu (u16) to LookupRequest and path_mtu (u16) to LookupResponse, enabling the discovery system to report transport MTU capability along the lookup path. LookupRequest carries min_mtu (origin's minimum MTU requirement, default 0 = no requirement). LookupResponse carries path_mtu (initialized to u16::MAX by the target, reduced by transit nodes via min(path_mtu, outgoing_link_mtu) on the reverse path). path_mtu is a transit annotation like SessionDatagram.path_mtu and is NOT included in the proof signature. The originator stores the discovered path_mtu in CacheEntry alongside cached coordinates. Wire format: +2 bytes each for LookupRequest and LookupResponse.
This commit is contained in:
Vendored
+26
@@ -79,6 +79,32 @@ impl CoordCache {
|
||||
self.entries.insert(addr, entry);
|
||||
}
|
||||
|
||||
/// Insert or update a cache entry with path MTU information.
|
||||
///
|
||||
/// Used by discovery response handling to store the discovered path MTU
|
||||
/// alongside the target's coordinates.
|
||||
pub fn insert_with_path_mtu(
|
||||
&mut self,
|
||||
addr: NodeAddr,
|
||||
coords: TreeCoordinate,
|
||||
current_time_ms: u64,
|
||||
path_mtu: u16,
|
||||
) {
|
||||
if let Some(entry) = self.entries.get_mut(&addr) {
|
||||
entry.update(coords, current_time_ms, self.default_ttl_ms);
|
||||
entry.set_path_mtu(path_mtu);
|
||||
return;
|
||||
}
|
||||
|
||||
if self.entries.len() >= self.max_entries {
|
||||
self.evict_one(current_time_ms);
|
||||
}
|
||||
|
||||
let mut entry = CacheEntry::new(coords, current_time_ms, self.default_ttl_ms);
|
||||
entry.set_path_mtu(path_mtu);
|
||||
self.entries.insert(addr, entry);
|
||||
}
|
||||
|
||||
/// Insert with a custom TTL.
|
||||
pub fn insert_with_ttl(
|
||||
&mut self,
|
||||
|
||||
Vendored
+17
@@ -13,6 +13,12 @@ pub struct CacheEntry {
|
||||
last_used: u64,
|
||||
/// When this entry expires (Unix milliseconds).
|
||||
expires_at: u64,
|
||||
/// Path MTU discovered during lookup (if available).
|
||||
///
|
||||
/// Set from the `LookupResponse.path_mtu` field when a discovery
|
||||
/// response is cached. `None` when populated from SessionSetup or
|
||||
/// other sources that don't carry path MTU information.
|
||||
path_mtu: Option<u16>,
|
||||
}
|
||||
|
||||
impl CacheEntry {
|
||||
@@ -23,6 +29,7 @@ impl CacheEntry {
|
||||
created_at: current_time_ms,
|
||||
last_used: current_time_ms,
|
||||
expires_at: current_time_ms.saturating_add(ttl_ms),
|
||||
path_mtu: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +53,16 @@ impl CacheEntry {
|
||||
self.expires_at
|
||||
}
|
||||
|
||||
/// Get the path MTU discovered during lookup, if available.
|
||||
pub fn path_mtu(&self) -> Option<u16> {
|
||||
self.path_mtu
|
||||
}
|
||||
|
||||
/// Set the path MTU discovered during lookup.
|
||||
pub fn set_path_mtu(&mut self, mtu: u16) {
|
||||
self.path_mtu = Some(mtu);
|
||||
}
|
||||
|
||||
/// Check if this entry has expired.
|
||||
pub fn is_expired(&self, current_time_ms: u64) -> bool {
|
||||
current_time_ms > self.expires_at
|
||||
|
||||
Reference in New Issue
Block a user