ipsec: fix logic in ext_hdr_is_pre_esp 48/39248/2
authorPiotr Bronowski <piotrx.bronowski@intel.com>
Thu, 23 Feb 2023 09:56:49 +0000 (09:56 +0000)
committerFan Zhang <fanzhang.oss@gmail.com>
Fri, 21 Jul 2023 00:28:05 +0000 (00:28 +0000)
When _VEC128 instructions are not enabled logic is buggy.
The function always returned 1.

Type: fix

Signed-off-by: Piotr Bronowski <piotrx.bronowski@intel.com>
Change-Id: I603200637e8d65813f4e49ef15d798e74b79b9cf

src/vnet/ipsec/esp_encrypt.c

index 7f9b5ed..86f9094 100644 (file)
@@ -182,9 +182,9 @@ ext_hdr_is_pre_esp (u8 nexthdr)
 
   return !u8x16_is_all_zero (ext_hdr_types == u8x16_splat (nexthdr));
 #else
-  return ((nexthdr ^ IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS) |
-         (nexthdr ^ IP_PROTOCOL_IPV6_ROUTE) |
-         ((nexthdr ^ IP_PROTOCOL_IPV6_FRAGMENTATION) != 0));
+  return (!(nexthdr ^ IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS) ||
+         !(nexthdr ^ IP_PROTOCOL_IPV6_ROUTE) ||
+         !(nexthdr ^ IP_PROTOCOL_IPV6_FRAGMENTATION));
 #endif
 }