Re: ICMP Checksum Errors

Erwin Rol

Hey all,

I looked into it a bit more and the ICMP checksum calculation is broken.
I made a small patch to try and fix it, and it does seem to fix the
problem, but I don't think the patch is good enough for a pull-request,
comments are welcome.

- Erwin

On 28-6-2017 10:50, Erwin Rol wrote:

while testing my STM32 Ethernet driver I noticed that Wireshark
complained about incorrect ICMP checksums. After a bit more testing I
found out that it started complaining when the total packet size was
128 bytes.
The ICMP checksum is calculated with

u16_t net_calc_chksum(struct net_pkt *pkt, u8_t proto)

in zephyr/subsys/net/ip/utils.c

And that has;
if (proto == IPPROTO_ICMP) {
return htons(calc_chksum(0, net_pkt_ip_data(pkt) +

but unlike the

calc_chksum_pkt(sum, pkt, upper_layer_len);

function calc_chksum does not take into account that data could be
divided over multiple (128byte) net_pkt fragments.

Also are the other uses of calc_chksum in net_calc_chksum correct ?
Because 128 bytes isn't that much and especially with IPv6 things might
need more than 1 net_pkt fragment.

- Erwin
Zephyr-devel mailing list

Join to automatically receive all group messages.