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.
This commit is contained in:
Johnathan Corgan
2026-05-08 14:54:40 +00:00
parent e4f37082c2
commit f32bc83034
2 changed files with 7 additions and 3 deletions
+4 -2
View File
@@ -267,8 +267,10 @@ pub struct EthernetConfig {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ethertype: Option<u16>,
/// 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<u16>,
+3 -1
View File
@@ -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<DiscoveryBuffer>,