if(~0 == mask_type_index) {
pool_get_aligned (am->ace_mask_type_pool, mte, CLIB_CACHE_LINE_BYTES);
mask_type_index = mte - am->ace_mask_type_pool;
- clib_memcpy(&mte->mask, mask, sizeof(mte->mask));
+ clib_memcpy_fast(&mte->mask, mask, sizeof(mte->mask));
mte->refcount = 0;
/*
clib_error("ACL plugin failed to allocate lookup heap of %U bytes",
format_memory_size, am->hash_lookup_mheap_size);
}
+#if USE_DLMALLOC != 0
+ /*
+ * 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);
+#endif
}
void *oldheap = clib_mem_set_heap(am->hash_lookup_mheap);
return oldheap;
vec_validate(am->hash_applied_mask_info_vec_by_lc_index, lc_index);
+
+ /* since we know (in case of no split) how much we expand, preallocate that space */
+ if (vec_len(ha->rules) > 0) {
+ int old_vec_len = vec_len(*applied_hash_aces);
+ vec_validate((*applied_hash_aces), old_vec_len + vec_len(ha->rules) - 1);
+ _vec_len((*applied_hash_aces)) = old_vec_len;
+ }
+
/* add the rules from the ACL to the hash table for lookup and append to the vector*/
for(i=0; i < vec_len(ha->rules); i++) {
/*
void *oldheap = hash_acl_set_heap(am);
DBG("HASH ACL add : %d", acl_index);
int i;
- acl_list_t *a = &am->acls[acl_index];
+ acl_rule_t *acl_rules = am->acls[acl_index].rules;
vec_validate(am->hash_acl_infos, acl_index);
hash_acl_info_t *ha = vec_elt_at_index(am->hash_acl_infos, acl_index);
clib_memset(ha, 0, sizeof(*ha));
/* walk the newly added ACL entries and ensure that for each of them there
is a mask type, increment a reference count for that mask type */
- for(i=0; i < a->count; i++) {
+
+ /* avoid small requests by preallocating the entire vector before running the additions */
+ if (vec_len(acl_rules) > 0) {
+ vec_validate(ha->rules, vec_len(acl_rules)-1);
+ vec_reset_length(ha->rules);
+ }
+
+ for(i=0; i < vec_len(acl_rules); i++) {
hash_ace_info_t ace_info;
fa_5tuple_t mask;
clib_memset(&ace_info, 0, sizeof(ace_info));
ace_info.acl_index = acl_index;
ace_info.ace_index = i;
- make_mask_and_match_from_rule(&mask, &a->rules[i], &ace_info);
+ make_mask_and_match_from_rule(&mask, &acl_rules[i], &ace_info);
mask.pkt.flags_reserved = 0b000;
ace_info.base_mask_type_index = assign_mask_type_index(am, &mask);
/* assign the mask type index for matching itself */
if(pae->mask_type_index != coll_mask_type_index) continue;
/* Computing min_mask and max_mask for colliding rules */
if(i==0){
- clib_memcpy(min_tuple, mask, sizeof(fa_5tuple_t));
- clib_memcpy(max_tuple, mask, sizeof(fa_5tuple_t));
+ clib_memcpy_fast(min_tuple, mask, sizeof(fa_5tuple_t));
+ clib_memcpy_fast(max_tuple, mask, sizeof(fa_5tuple_t));
}else{
int j;
for(j=0; j<2; j++){