diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2022-10-25 18:01:11 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2022-10-26 06:28:06 +0200 |
commit | e67039f7128b953a92ab4ca2985ddb1ccd5edcf5 (patch) | |
tree | cdfc35fea662e85977389fedbddc61811139a8a2 /checksum.c | |
parent | c11277b94fda95e32e8d9848457ef2bd91772b30 (diff) | |
download | passt-e67039f7128b953a92ab4ca2985ddb1ccd5edcf5.tar passt-e67039f7128b953a92ab4ca2985ddb1ccd5edcf5.tar.gz passt-e67039f7128b953a92ab4ca2985ddb1ccd5edcf5.tar.bz2 passt-e67039f7128b953a92ab4ca2985ddb1ccd5edcf5.tar.lz passt-e67039f7128b953a92ab4ca2985ddb1ccd5edcf5.tar.xz passt-e67039f7128b953a92ab4ca2985ddb1ccd5edcf5.tar.zst passt-e67039f7128b953a92ab4ca2985ddb1ccd5edcf5.zip |
checksum: Fix calculation for ICMP checksum on IPv4
We need to zero out the checksum field before calculating the
checksum, of course. I have no idea how this passed the "icmp" test
set, looking into it.
Reported-by: Paul Holzinger <pholzing@redhat.com>
Fixes: 67ab6171729c ("Add csum_icmp4() helper for calculating ICMP checksums")
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'checksum.c')
-rw-r--r-- | checksum.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -160,10 +160,13 @@ void csum_udp4(struct udphdr *udp4hr, in_addr_t saddr, in_addr_t daddr, */ void csum_icmp4(struct icmphdr *icmp4hr, const void *payload, size_t len) { - /* Partial checksum for ICMP header alone */ - uint32_t psum = sum_16b(icmp4hr, sizeof(*icmp4hr)); + uint32_t psum; icmp4hr->checksum = 0; + + /* Partial checksum for ICMP header alone */ + psum = sum_16b(icmp4hr, sizeof(*icmp4hr)); + icmp4hr->checksum = csum_unaligned(payload, len, psum); } |