ip: fix ip zero checksum verification

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 9a79a1ab93).

Type: fix
Fixes: e5f0050c7a

Change-Id: Iacc6b60645a834287b085aecb9e3fdb4554cf0cf
Signed-off-by: Benoît Ganne <bganne@cisco.com>
This commit is contained in:
Benoît Ganne
2020-08-31 18:59:34 +02:00
committed by Damjan Marion
parent 1d104c5ecd
commit 6e334e3e77
10 changed files with 20 additions and 19 deletions

View File

@ -152,7 +152,7 @@ udp_ping_send_flows (flow_report_main_t * frm, flow_report_t * fr,
if (udp->checksum == 0)
udp->checksum = 0xffff;
ASSERT (ip->checksum == ip4_header_checksum (ip));
ASSERT (ip4_header_checksum_is_valid (ip));
to_next[0] = bi0;
f->n_vectors++;
@ -203,7 +203,7 @@ udp_ping_send_flows (flow_report_main_t * frm, flow_report_t * fr,
if (udp->checksum == 0)
udp->checksum = 0xffff;
ASSERT (ip->checksum == ip4_header_checksum (ip));
ASSERT (ip4_header_checksum_is_valid (ip));
to_next[0] = bi0;
f->n_vectors++;