From 6e334e3e77bb156a9317a37500077a218a04f7a3 Mon Sep 17 00:00:00 2001 From: Benoît Ganne Date: Mon, 31 Aug 2020 18:59:34 +0200 Subject: ip: fix ip zero checksum verification MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In one's complement, there are two representations of zero: the all zero and the all one bit values, often referred to as +0 and -0. See RFC 1624 section 3 for more details. This used to be taken care of in ip4_header_checksum(), but it is no longer the case. The check ip->checksum == ip4_header_checksum (ip) is no longer correct in the -0 case. Always use ip4_header_checksum_is_valid() instead (which behaves correctly since 9a79a1ab931c3b5a7ae07d6f0fcfef7c4368a2c4). Type: fix Fixes: e5f0050c7a5d411f96af6401797529d58825e2af Change-Id: Iacc6b60645a834287b085aecb9e3fdb4554cf0cf Signed-off-by: Benoît Ganne --- src/plugins/ping/ping.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/plugins/ping') diff --git a/src/plugins/ping/ping.c b/src/plugins/ping/ping.c index f56f44ffb26..0ce4f9698f0 100644 --- a/src/plugins/ping/ping.c +++ b/src/plugins/ping/ping.c @@ -474,8 +474,8 @@ ip4_icmp_echo_request (vlib_main_t * vm, ip0->checksum = ip_csum_fold (sum0); ip1->checksum = ip_csum_fold (sum1); - ASSERT (ip0->checksum == ip4_header_checksum (ip0)); - ASSERT (ip1->checksum == ip4_header_checksum (ip1)); + ASSERT (ip4_header_checksum_is_valid (ip0)); + ASSERT (ip4_header_checksum_is_valid (ip1)); p0->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED; p1->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED; @@ -531,7 +531,7 @@ ip4_icmp_echo_request (vlib_main_t * vm, ip0->checksum = ip_csum_fold (sum0); - ASSERT (ip0->checksum == ip4_header_checksum (ip0)); + ASSERT (ip4_header_checksum_is_valid (ip0)); p0->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED; } -- cgit 1.2.3-korg