Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix checksum on replies
this closes #17.
When an ICMP echo request with ID 0, sequence 0 and either no or some 0x00 Bytes as payload, the checksum calculation was wrong
  • Loading branch information
tabascoeye committed Jun 10, 2015
1 parent a6661b1 commit 32c32d8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/ipv4/icmp.c
Expand Up @@ -196,7 +196,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
ICMPH_TYPE_SET(iecho, ICMP_ER);
#if CHECKSUM_GEN_ICMP
/* adjust the checksum */
if (iecho->chksum >= PP_HTONS(0xffffU - (ICMP_ECHO << 8))) {
if (iecho->chksum > PP_HTONS(0xffffU - (ICMP_ECHO << 8))) {
iecho->chksum += PP_HTONS(ICMP_ECHO << 8) + 1;

This comment has been minimized.

Copy link
@rahuldeo2047

rahuldeo2047 Oct 27, 2017

Hi all,
Is there any way to recreate the issue in a controlled manner?

This comment has been minimized.

Copy link
@tabascoeye

tabascoeye Oct 28, 2017

Author Owner

this was 2 years ago, so I don't know if a current version of lwip even has the issue.
However, with a packet generator or a piece of code/script using raw socket, you can generate an ICMP echo packet and send it to a device running lwip to recreate the problem.
A short piece of python code could easily create such a packet.

This comment has been minimized.

Copy link
@rahuldeo2047

rahuldeo2047 Nov 2, 2017

@tabascoeye : Thank you for your response.

My test failed.
I incorporated this particular change and tested on the scenario. It shows the same "checksum mismatch from IP" message as earlier.
What can be wrong? It happens at one place. I have multiple instances of the same code running in different geo locations.

} else {
iecho->chksum += PP_HTONS(ICMP_ECHO << 8);
Expand Down

0 comments on commit 32c32d8

Please sign in to comment.