summaryrefslogtreecommitdiffstats
path: root/src/plugins/acl/hash_lookup.c
diff options
context:
space:
mode:
authorAndrew Yourtchenko <ayourtch@gmail.com>2020-09-16 12:10:27 +0000
committerDamjan Marion <dmarion@me.com>2020-09-21 13:58:20 +0000
commit88caf28354133160d2446e939f1e54adb71cc144 (patch)
treea4f0de79668d284e1f724d5c692d58d01af393d2 /src/plugins/acl/hash_lookup.c
parent0978e607cce4bb12588b0214298616756f86dc7d (diff)
acl: remove custom ACL-plugin heap
Custom ACL-plugin heap was useful in early stages, but it interferes with other infra optimizations. Remove it and use global heap. Change-Id: I2300548f1d1798dec27bc5a2a41cf37f9fcda95d Type: improvement Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
Diffstat (limited to 'src/plugins/acl/hash_lookup.c')
-rw-r--r--src/plugins/acl/hash_lookup.c55
1 files changed, 4 insertions, 51 deletions
diff --git a/src/plugins/acl/hash_lookup.c b/src/plugins/acl/hash_lookup.c
index 07701b74bab..e8850743f01 100644
--- a/src/plugins/acl/hash_lookup.c
+++ b/src/plugins/acl/hash_lookup.c
@@ -586,45 +586,6 @@ activate_applied_ace_hash_entry(acl_main_t *am,
}
-static void *
-hash_acl_set_heap(acl_main_t *am)
-{
- if (0 == am->hash_lookup_mheap) {
- am->hash_lookup_mheap = mheap_alloc_with_lock (0 /* use VM */ ,
- am->hash_lookup_mheap_size,
- 1 /* locked */);
- if (0 == am->hash_lookup_mheap) {
- clib_error("ACL plugin failed to allocate lookup heap of %U bytes",
- format_memory_size, am->hash_lookup_mheap_size);
- }
- /*
- * DLMALLOC is being "helpful" in that it ignores the heap size parameter
- * by default and tries to allocate the larger amount of memory.
- *
- * Pin the heap so this does not happen and if we run out of memory
- * in this heap, we will bail out with "out of memory", rather than
- * an obscure error sometime later.
- */
- mspace_disable_expand(am->hash_lookup_mheap);
- }
- void *oldheap = clib_mem_set_heap(am->hash_lookup_mheap);
- return oldheap;
-}
-
-void
-acl_plugin_hash_acl_set_validate_heap(int on)
-{
- acl_main_t *am = &acl_main;
- clib_mem_set_heap(hash_acl_set_heap(am));
-}
-
-void
-acl_plugin_hash_acl_set_trace_heap(int on)
-{
- acl_main_t *am = &acl_main;
- clib_mem_set_heap(hash_acl_set_heap(am));
-}
-
static void
assign_mask_type_index_to_pae(acl_main_t *am, u32 lc_index, int is_ip6, applied_hash_ace_entry_t *pae)
{
@@ -672,7 +633,6 @@ hash_acl_apply(acl_main_t *am, u32 lc_index, int acl_index, u32 acl_position)
am->acl_lookup_hash_initialized = 1;
}
- void *oldheap = hash_acl_set_heap(am);
vec_validate(am->hash_entry_vec_by_lc_index, lc_index);
vec_validate(am->hash_acl_infos, acl_index);
applied_hash_ace_entry_t **applied_hash_aces = get_applied_hash_aces(am, lc_index);
@@ -693,14 +653,16 @@ hash_acl_apply(acl_main_t *am, u32 lc_index, int acl_index, u32 acl_position)
if (index != ~0) {
clib_warning("BUG: trying to apply twice acl_index %d on lc_index %d, according to lc",
acl_index, lc_index);
- goto done;
+ ASSERT(0);
+ return;
}
vec_add1(pal->applied_acls, acl_index);
u32 index2 = vec_search((*hash_acl_applied_lc_index), lc_index);
if (index2 != ~0) {
clib_warning("BUG: trying to apply twice acl_index %d on lc_index %d, according to hash h-acl info",
acl_index, lc_index);
- goto done;
+ ASSERT(0);
+ return;
}
vec_add1((*hash_acl_applied_lc_index), lc_index);
@@ -751,8 +713,6 @@ hash_acl_apply(acl_main_t *am, u32 lc_index, int acl_index, u32 acl_position)
check_collision_count_and_maybe_split(am, lc_index, is_ip6, first_index);
}
remake_hash_applied_mask_info_vec(am, applied_hash_aces, lc_index);
-done:
- clib_mem_set_heap (oldheap);
}
static u32
@@ -928,7 +888,6 @@ hash_acl_unapply(acl_main_t *am, u32 lc_index, int acl_index)
return;
}
- void *oldheap = hash_acl_set_heap(am);
int base_offset = i;
int tail_offset = base_offset + vec_len(ha->rules);
int tail_len = vec_len((*applied_hash_aces)) - tail_offset;
@@ -952,8 +911,6 @@ hash_acl_unapply(acl_main_t *am, u32 lc_index, int acl_index)
if (vec_len((*applied_hash_aces)) == 0) {
vec_free((*applied_hash_aces));
}
-
- clib_mem_set_heap (oldheap);
}
/*
@@ -1105,7 +1062,6 @@ int hash_acl_exists(acl_main_t *am, int acl_index)
void hash_acl_add(acl_main_t *am, int acl_index)
{
- void *oldheap = hash_acl_set_heap(am);
DBG("HASH ACL add : %d", acl_index);
int i;
acl_rule_t *acl_rules = am->acls[acl_index].rules;
@@ -1148,12 +1104,10 @@ void hash_acl_add(acl_main_t *am, int acl_index)
hash_acl_reapply(am, *lc_index, acl_index);
}
}
- clib_mem_set_heap (oldheap);
}
void hash_acl_delete(acl_main_t *am, int acl_index)
{
- void *oldheap = hash_acl_set_heap(am);
DBG0("HASH ACL delete : %d", acl_index);
/*
* If the ACL is applied somewhere, remove the references of it (call hash_acl_unapply)
@@ -1188,7 +1142,6 @@ void hash_acl_delete(acl_main_t *am, int acl_index)
}
ha->hash_acl_exists = 0;
vec_free(ha->rules);
- clib_mem_set_heap (oldheap);
}