acl: use ip4_preflen_to_mask instead of artisanal function 03/41203/4
authorAndrew Yourtchenko <[email protected]>
Thu, 18 Jul 2024 12:01:53 +0000 (14:01 +0200)
committerAndrew Yourtchenko <[email protected]>
Wed, 2 Apr 2025 19:00:50 +0000 (19:00 +0000)
Type: improvement
Change-Id: I4cd52a9f2b8814e8d27a72ea3547fd9f8ee23562
Signed-off-by: Andrew Yourtchenko <[email protected]>
src/plugins/acl/hash_lookup.c

index 9c3c662..b4f8620 100644 (file)
@@ -946,31 +946,15 @@ hash_acl_reapply(acl_main_t *am, u32 lc_index, int acl_index)
 static void
 make_ip6_address_mask(ip6_address_t *addr, u8 prefix_len)
 {
+  ASSERT (prefix_len <= 128);
   ip6_address_mask_from_width(addr, prefix_len);
 }
 
-
-/* Maybe should be moved into the core somewhere */
-always_inline void
-ip4_address_mask_from_width (ip4_address_t * a, u32 width)
-{
-  int i, byte, bit, bitnum;
-  ASSERT (width <= 32);
-  clib_memset (a, 0, sizeof (a[0]));
-  for (i = 0; i < width; i++)
-    {
-      bitnum = (7 - (i & 7));
-      byte = i / 8;
-      bit = 1 << bitnum;
-      a->as_u8[byte] |= bit;
-    }
-}
-
-
 static void
 make_ip4_address_mask(ip4_address_t *addr, u8 prefix_len)
 {
-  ip4_address_mask_from_width(addr, prefix_len);
+  ASSERT (prefix_len <= 32);
+  ip4_preflen_to_mask (prefix_len, addr);
 }
 
 static void