From 969f32dab5a27c492f52b7335e87b9139c16642a Mon Sep 17 00:00:00 2001 From: Thibaut Vandervelden Date: Fri, 17 Nov 2023 15:41:55 +0100 Subject: [PATCH] fix: clarify mtu+=2 for IEEE802154 This fixes #622, where at the time of writing, it was not clear why SIOCGIFMTU returned 123 instead of the more logical 125 or 127 (with FCS). --- src/phy/raw_socket.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/phy/raw_socket.rs b/src/phy/raw_socket.rs index 0a4cc2990..19c5b98d2 100644 --- a/src/phy/raw_socket.rs +++ b/src/phy/raw_socket.rs @@ -32,9 +32,14 @@ impl RawSocket { let mut mtu = lower.interface_mtu()?; - // FIXME(thvdveld): this is a workaround for https://github.com/smoltcp-rs/smoltcp/issues/622 #[cfg(feature = "medium-ieee802154")] if medium == Medium::Ieee802154 { + // SIOCGIFMTU returns 127 - (ACK_PSDU - FCS - 1) - FCS. + // 127 - (5 - 2 - 1) - 2 = 123 + // For IEEE802154, we want to add (ACK_PSDU - FCS - 1), since that is what SIOCGIFMTU + // uses as the size of the link layer header. + // + // https://github.com/torvalds/linux/blob/7475e51b87969e01a6812eac713a1c8310372e8a/net/mac802154/iface.c#L541 mtu += 2; }