X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fip%2Fip4_mtrie.c;h=5aa9b926483e1d6ee4fd8094609b62ac7736a4d6;hb=756cd9441752fc8f84104c9ee19099506ba89f85;hp=5b78cbec1ea08ac4a8ca9741bf91c864229f40e5;hpb=c87aafad759f92ae630fec52079a08ace607410b;p=vpp.git diff --git a/src/vnet/ip/ip4_mtrie.c b/src/vnet/ip/ip4_mtrie.c index 5b78cbec1ea..5aa9b926483 100644 --- a/src/vnet/ip/ip4_mtrie.c +++ b/src/vnet/ip/ip4_mtrie.c @@ -176,9 +176,12 @@ ply_create (ip4_fib_mtrie_t * m, u32 leaf_prefix_len, u32 ply_base_len) { ip4_fib_mtrie_8_ply_t *p; - + void *old_heap; /* Get cache aligned ply. */ + + old_heap = clib_mem_set_heap (ip4_main.mtrie_mheap); pool_get_aligned (ip4_ply_pool, p, CLIB_CACHE_LINE_BYTES); + clib_mem_set_heap (old_heap); ply_8_init (p, init_leaf, leaf_prefix_len, ply_base_len); return ip4_fib_mtrie_leaf_set_next_ply_index (p - ip4_ply_pool); @@ -752,8 +755,8 @@ format_ip4_fib_mtrie_ply (u8 * s, va_list * va) { if (ip4_fib_mtrie_leaf_is_non_empty (p, i)) { - FORMAT_PLY (s, p, i, base_address, - p->dst_address_bits_base + 8, indent); + s = FORMAT_PLY (s, p, i, base_address, + p->dst_address_bits_base + 8, indent); } } @@ -788,7 +791,7 @@ format_ip4_fib_mtrie (u8 * s, va_list * va) if (p->dst_address_bits_of_leaves[slot] > 0) { - FORMAT_PLY (s, p, slot, base_address, 16, 2); + s = FORMAT_PLY (s, p, slot, base_address, 16, 2); } } } @@ -796,15 +799,27 @@ format_ip4_fib_mtrie (u8 * s, va_list * va) return s; } +/** Default heap size for the IPv4 mtries */ +#define IP4_FIB_DEFAULT_MTRIE_HEAP_SIZE (32<<20) + static clib_error_t * ip4_mtrie_module_init (vlib_main_t * vm) { - /* Burn one ply so index 0 is taken */ CLIB_UNUSED (ip4_fib_mtrie_8_ply_t * p); + ip4_main_t *im = &ip4_main; + clib_error_t *error = NULL; + uword *old_heap; + + if (0 == im->mtrie_heap_size) + im->mtrie_heap_size = IP4_FIB_DEFAULT_MTRIE_HEAP_SIZE; + im->mtrie_mheap = mheap_alloc (0, im->mtrie_heap_size); + /* Burn one ply so index 0 is taken */ + old_heap = clib_mem_set_heap (ip4_main.mtrie_mheap); pool_get (ip4_ply_pool, p); + clib_mem_set_heap (old_heap); - return (NULL); + return (error); } VLIB_INIT_FUNCTION (ip4_mtrie_module_init);