Fix assert issue in ip_csum_add_even() 55/13055/6
authorHongjun Ni <hongjun.ni@intel.com>
Thu, 14 Jun 2018 21:32:23 +0000 (05:32 +0800)
committerDave Barach <openvpp@barachs.net>
Tue, 26 Jun 2018 19:54:12 +0000 (19:54 +0000)
ASSERT (ip_csum_with_carry (d, x) == c) will raise assert
if d equals to zero while x not equals to zero.

Change-Id: Ia9ccdbf801ae565eaadd49f04569d13bfc31cba8
Signed-off-by: Hongjun Ni <hongjun.ni@intel.com>
src/vnet/ip/ip_packet.h

index 3c532f1..6c86e3e 100644 (file)
@@ -107,7 +107,8 @@ ip_csum_add_even (ip_csum_t c, ip_csum_t x)
   /* Fold in carry from high bit. */
   d -= d > c;
 
-  ASSERT (ip_csum_with_carry (d, x) == c);
+  ip_csum_t t = ip_csum_with_carry (d, x);
+  ASSERT ((t - c == 0) || (t - c == ~0));
 
   return d;
 }