From 78b46e64ac59cfb1ccbc407af7760d420738ebd0 Mon Sep 17 00:00:00 2001 From: iyzhang Date: Thu, 25 Sep 2025 10:00:36 -0700 Subject: [PATCH] runtime: Add max buffer size to inetstack from the network runtime --- src/inetstack/mod.rs | 4 ++++ src/inetstack/protocols/layer2/mod.rs | 4 ++++ src/inetstack/protocols/layer3/mod.rs | 4 ++++ src/inetstack/protocols/layer4/mod.rs | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/src/inetstack/mod.rs b/src/inetstack/mod.rs index d9372b4b2..012b64c47 100644 --- a/src/inetstack/mod.rs +++ b/src/inetstack/mod.rs @@ -294,6 +294,10 @@ impl NetworkTransport for SharedInetStack { /// This implements the memory runtime trait for the inetstack. Other libOSes without a network runtime can directly /// use OS memory but the inetstack requires specialized memory allocated by the lower-level runtime. impl DemiMemoryAllocator for SharedInetStack { + fn max_buffer_size_bytes(&self) -> usize { + self.layer4_endpoint.max_buffer_size_bytes() + } + fn allocate_demi_buffer(&self, size: usize) -> Result { self.layer4_endpoint.allocate_demi_buffer(size) } diff --git a/src/inetstack/protocols/layer2/mod.rs b/src/inetstack/protocols/layer2/mod.rs index aa689e667..239fad986 100644 --- a/src/inetstack/protocols/layer2/mod.rs +++ b/src/inetstack/protocols/layer2/mod.rs @@ -129,6 +129,10 @@ impl DerefMut for SharedLayer2Endpoint { } impl DemiMemoryAllocator for SharedLayer2Endpoint { + fn max_buffer_size_bytes(&self) -> usize { + self.layer1_endpoint.max_buffer_size_bytes() + } + fn allocate_demi_buffer(&self, size: usize) -> Result { self.layer1_endpoint.allocate_demi_buffer(size) } diff --git a/src/inetstack/protocols/layer3/mod.rs b/src/inetstack/protocols/layer3/mod.rs index b6f5a7de7..f33bbb084 100644 --- a/src/inetstack/protocols/layer3/mod.rs +++ b/src/inetstack/protocols/layer3/mod.rs @@ -193,6 +193,10 @@ impl DerefMut for SharedLayer3Endpoint { /// Memory Runtime Trait Implementation for Layer 3. impl DemiMemoryAllocator for SharedLayer3Endpoint { + fn max_buffer_size_bytes(&self) -> usize { + self.layer2_endpoint.max_buffer_size_bytes() + } + fn allocate_demi_buffer(&self, size: usize) -> Result { self.layer2_endpoint.allocate_demi_buffer(size) } diff --git a/src/inetstack/protocols/layer4/mod.rs b/src/inetstack/protocols/layer4/mod.rs index 044ac4d0e..afd07d951 100644 --- a/src/inetstack/protocols/layer4/mod.rs +++ b/src/inetstack/protocols/layer4/mod.rs @@ -394,6 +394,10 @@ impl Peer { //====================================================================================================================== impl DemiMemoryAllocator for Peer { + fn max_buffer_size_bytes(&self) -> usize { + self.layer3_endpoint.max_buffer_size_bytes() + } + fn allocate_demi_buffer(&self, size: usize) -> Result { self.layer3_endpoint.allocate_demi_buffer(size) }