From f32bc830346d25a9ee3262904afc6f0383e2954c Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Fri, 8 May 2026 14:48:23 +0000 Subject: [PATCH] docs: correct Ethernet MTU framing rustdoc The Ethernet data frame format is `[type:1][length:2 LE][payload]`, so the per-link payload MTU is the interface MTU minus 3 bytes, not minus 1. The 2-byte length field is required to trim NIC minimum-frame padding before AEAD verification. The implementation in src/transport/ethernet/mod.rs already uses saturating_sub(3) correctly; only the rustdoc on the effective_mtu field and the EthernetConfig.mtu field's documentation lagged behind. No behaviour change. --- src/config/transport.rs | 6 ++++-- src/transport/ethernet/mod.rs | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/config/transport.rs b/src/config/transport.rs index 2281ee4..cb7b3a8 100644 --- a/src/config/transport.rs +++ b/src/config/transport.rs @@ -267,8 +267,10 @@ pub struct EthernetConfig { #[serde(default, skip_serializing_if = "Option::is_none")] pub ethertype: Option, - /// MTU override. Defaults to the interface's MTU minus 1 (for frame type prefix). - /// Cannot exceed the interface's actual MTU. + /// MTU override. Defaults to the interface's MTU minus 3 bytes of frame + /// header (`[type:1][length:2 LE][payload]`). The 2-byte length field is + /// required to trim NIC minimum-frame padding before AEAD verification. + /// Cannot exceed the interface's actual MTU minus 3. #[serde(default, skip_serializing_if = "Option::is_none")] pub mtu: Option, diff --git a/src/transport/ethernet/mod.rs b/src/transport/ethernet/mod.rs index 759b774..60b0dbf 100644 --- a/src/transport/ethernet/mod.rs +++ b/src/transport/ethernet/mod.rs @@ -49,7 +49,9 @@ pub struct EthernetTransport { local_mac: Option<[u8; 6]>, /// Interface name (from config). interface: String, - /// Effective MTU (interface MTU - 1 for frame type prefix). + /// Effective payload MTU: interface MTU minus 3 bytes of frame header + /// (`[type:1][length:2 LE][payload]`). The 2-byte length field is required + /// to trim NIC minimum-frame padding before AEAD verification. effective_mtu: u16, /// Discovery buffer for discovered peers. discovery_buffer: Arc,