From 3b519b38b0df186f424d2ff2f5e8015408d67c53 Mon Sep 17 00:00:00 2001 From: Andreas Schultz Date: Tue, 12 May 2020 14:41:16 +0200 Subject: ip: fix IPv6 mask to prefix length conversion make sure we don't pass a 0 (zero) to log2. Type: fix Signed-off-by: Andreas Schultz Change-Id: Ib3386ad4686835d3836f48294cee4058e897847a --- src/vat/ip_types.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src/vat') diff --git a/src/vat/ip_types.c b/src/vat/ip_types.c index cd08c5417ad..5041c129245 100644 --- a/src/vat/ip_types.c +++ b/src/vat/ip_types.c @@ -511,16 +511,11 @@ ip6_prefix_max_address_host_order (ip6_address_t * ip, u8 plen, u32 ip6_mask_to_preflen (ip6_address_t * mask) { - u8 first1, first0; - if (mask->as_u64[0] == 0 && mask->as_u64[1] == 0) - return 0; - first1 = log2_first_set (clib_net_to_host_u64 (mask->as_u64[1])); - first0 = log2_first_set (clib_net_to_host_u64 (mask->as_u64[0])); - - if (first1 != 0) - return 128 - first1; - else - return 64 - first0; + if (mask->as_u64[1] != 0) + return 128 - log2_first_set (clib_net_to_host_u64 (mask->as_u64[1])); + if (mask->as_u64[0] != 0) + return 64 - log2_first_set (clib_net_to_host_u64 (mask->as_u64[0])); + return 0; } /* -- cgit 1.2.3-korg