From: Andrew Yourtchenko Date: Thu, 18 Jul 2024 12:01:53 +0000 (+0200) Subject: acl: use ip4_preflen_to_mask instead of artisanal function X-Git-Tag: v25.10-rc0~124 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=8a8bcae52833fbf542c01a766a5984bd75d6a939;p=vpp.git acl: use ip4_preflen_to_mask instead of artisanal function Type: improvement Change-Id: I4cd52a9f2b8814e8d27a72ea3547fd9f8ee23562 Signed-off-by: Andrew Yourtchenko --- diff --git a/src/plugins/acl/hash_lookup.c b/src/plugins/acl/hash_lookup.c index 9c3c662a8f1..b4f86208a71 100644 --- a/src/plugins/acl/hash_lookup.c +++ b/src/plugins/acl/hash_lookup.c @@ -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