-
Notifications
You must be signed in to change notification settings - Fork 2k
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
pkg/lwip: fix wrong icmp chksum in IPv4 #19853
Conversation
Without this change I am seeing ICMP checksums working for IPv4 and IPv6. I used |
Hi! I perform in the lab experiment like you mentioned, on a most recent RIOT code (current master branch) and I still cannot ping my board. Please looked at the attached screenshot. What kind of board you use? I tested on STM nucleo-207zg - so maybe this bahaviour concerns only this family of boards? Experiment screenshot - RIOT shell, windows shell and wireshark. Board IP 192.168.143.65, windows IP 192.168.143.77. |
pkg/lwip/Makefile.include
Outdated
#These flags enable calculating ICMP chksum in LWIP software. | ||
#Without these flags RIOT device respond with ICMP chsum equal to 0, and | ||
#cannot be successfully "pinged" from Windows hosts. | ||
CFLAGS +=-DCHECKSUM_GEN_ICMP=0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is strange. According to https://www.nongnu.org/lwip/2_1_x/group__lwip__opts__checksum.html#ga2291ec5bec0a551545da6d5f9f9316b2 this would disable the generation of ICMP checksums, rather than enabling it.
I haven't looked at the code yet, but I kind of doubt that this is such an obvious bug in lwIP that CHECKSUM_GEN_ICMP
is checked for being zero to generate the checksum. I fear that there is some other bug lurking that only gets hidden by the flags. But as said: I didn't look at the code, so these are just guesses.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, these flags are very weird but I found them in a some forum post concerning micro-controllers and similar issue - now after a more than month I cannot find this page :( .
When I used this solution, my understanding is that used in Nucleo board ethernet controller calculate IP checksum in hardware when received from micro-controller packet set this field to 0. I try to check this in board documentation.
pkg/lwip/Makefile.include
Outdated
#Without these flags RIOT device respond with ICMP chsum equal to 0, and | ||
#cannot be successfully "pinged" from Windows hosts. | ||
CFLAGS +=-DCHECKSUM_GEN_ICMP=0 | ||
CFLAGS +=-DLWIP_CHECKSUM_CTRL_PER_NETIF=1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would add runtime overhead so that checksum generation and validation can be enabled/disabled for each network interface. IMO it would be better to just enable ICMP checksum generation for all interface at compile time by default. If there really is need to fine-tune checksum generation and validation, this could be exposed as a module that users would have to enable explicitly in order to trade some RAM and CPU cycles for the ability to fine-tune checksum settings at runtime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand idea of special module you mentioned. Could you send link to similar module which is currently in RIOT?
After @yarrick tests I suspect that this issue concerns only subset of boards - probably Nucleo boards. Next week I should heva access to other Nucleo boards - I perform additional experiments. But now, I have other solution - maybe conditional addition of these flags - only for required boards is simpler solution than additional module about which programmer must remember.
This looks related: zephyrproject-rtos/zephyr#57629 |
lwIP will fill them in already. Having this enabled causes empty checksums to be sent: RIOT-OS#19853
@yarrick thank you for info and PR. I did some additional investigations.
|
Instead of adding checks on board names inside lwIP we should make network interfaces that use hw checksumming enable some pseudomodule and then lwIP would act on that and disable the relevant calculations. Of course this could still cause issues for boards with multiple different interfaces (which is why calculating them always is safest). |
I don't understand idea of such pseudomodule (wchich could enable some features on request). Could you send me a link to such pseudomodule in RIOT? |
I added pseudomodules in #16966 |
@yarrick thanks for a link. |
Due to fact that PR #19952 is merged to |
Contribution description
Device with RIOT OS and LWIP IPv4 stack did not respond to ping from Windows hosts. Linux hosts could
ping device without problems. In the network trace icmp responses with chksum set to 0 could be observed.
Additionally Wireshark flag icmp requests as "no response found!". The cause of such behavior is icmp chksum
set to 0.
This PR enables calculation of icmp chksum in the LWIP stack.
I tested this behavior and PR using LWIP 2.2.0 provided by PR #19780 - the stack behaves in this same manner and
this PR fix problem.
Testing procedure
Run any LWIP code, for e.g.
examples/coap
with enabled IPv4 stack. To do this:to
main.c
code which configure IPv4 addressand in main function:
Ping 192.168.79.150 from Windows machine - without this PR ping should fail.
I tested this PR code in hardware -
nucleo-f207zg
.Issues/PRs references
Tested with PR #19780 .