ICMP Checksum Errors

Erwin Rol


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

Join {devel@lists.zephyrproject.org to automatically receive all group messages.