-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: ethernet frame header is 14 not 18 #3025
base: main
Are you sure you want to change the base?
Conversation
Not sure / don't remember where the 18 is actually from. We probably should clarify the description of |
I think we just size our internal buffer larger than needed and we don't even need to account for the ethernet frame header since max_transmission_unit already includes it The problem you experienced was fixed by you in smoltcp-rs/smoltcp#1038 i.e. we set DeviceCapabilities::max_transmission_unit so we shouldn't get anything larger than that from smoltcp and we can just size our buffer as MTU |
smoltcp doesn't transmit larger packets
Testing looks like it works with the change (at least with the default 1492). |
Awesome - smoltcp says
I haven't found any documentation on the drivers itself about it |
I saw this which claims a max of 4017, but don't know if there's better info elsewhere or even if that is accurate. |
Interesting - but not sure if that's really the case and even if it was that issue it's quite old unfortunately |
Thank you for your contribution!
We appreciate the time and effort you've put into this pull request.
To help us review it efficiently, please ensure you've gone through the following checklist:
Submission Checklist 📝
cargo xtask fmt-packages
command to ensure that all changed code is formatted correctly.CHANGELOG.md
in the proper section.Extra:
Pull Request Details 📖
Description
ETHERNET_HEADER_FRAME_SIZE
= 18 in the following codeesp-hal/esp-wifi/src/wifi/mod.rs
Line 76 in f247b40
is only used here
esp-hal/esp-wifi/src/wifi/mod.rs
Line 950 in f247b40
which is only used here
esp-hal/esp-wifi/src/wifi/mod.rs
Line 2715 in f247b40
I thought maybe the extra 4 bytes were for the fcs at the end but the buffer is passed with the length given by caller here
esp-hal/esp-wifi/src/wifi/mod.rs
Lines 2717 to 2721 in f247b40
so that can't be it.
The only reason I noticed this is because smoltcp doesn't support ipv6 fragmentation and ignores if the given MTU is too large (see here) and I tried to send a max MTU UDP packet. It panicked indexing
[..len]
so I calculated what the max non-fragmenting size would be like so:but was surprised to find the calculated MTU seemed to be 4 bytes less than the panic message implied was valid. I believe I tracked down the source of this discrepancy to the changed line in the PR. As seen here and here an ethernet header is 14 bytes not 18.
I don't know if this would be considered public facing enough to warrant a change log entry, but I'm pretty sure it's a bug.
If my analysis is wrong and the fcs is included in that sizing, then there should at least be an assert that the passed length matches the configured MTU and not config.MTU+4 as it does now. The index check of
[..len]
should optimize out if the assert occurs before it.Sidenote: It's a good thing the buffer index was checked and panicked in the esp-wifi code or I probably would never have figured this out. Also, I'll file an issue with smoltcp to at least warn when a packet which is too large and can't be fragmented needs to be sent.
Testing
See above.