X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fsession%2Fsession_table.c;h=1f586f8cba220f9e4ea598014ac8f24672353f16;hb=19e52c96dcd5f523c2b97aee56cb2e7751d4690a;hp=5d160a4b2dc22ba37e79c1c716da651d62fa6bac;hpb=c97a7398fc465c480a3ac66cf4b0f91a034ed564;p=vpp.git diff --git a/src/vnet/session/session_table.c b/src/vnet/session/session_table.c index 5d160a4b2dc..1f586f8cba2 100644 --- a/src/vnet/session/session_table.c +++ b/src/vnet/session/session_table.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Cisco and/or its affiliates. + * Copyright (c) 2017-2019 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: @@ -32,7 +32,7 @@ session_table_alloc (void) { session_table_t *slt; pool_get_aligned (lookup_tables, slt, CLIB_CACHE_LINE_BYTES); - memset (slt, 0, sizeof (*slt)); + clib_memset (slt, 0, sizeof (*slt)); return slt; } @@ -45,9 +45,9 @@ session_table_index (session_table_t * slt) session_table_t * session_table_get (u32 table_index) { - if (vec_len (lookup_tables) <= table_index) + if (pool_is_free_index (lookup_tables, table_index)) return 0; - return vec_elt_at_index (lookup_tables, table_index); + return pool_elt_at_index (lookup_tables, table_index); } #define foreach_hash_table_parameter \ @@ -78,29 +78,55 @@ session_table_init (session_table_t * slt, u8 fib_proto) #undef _ #define _(af,table,parm,value) \ - if (session_manager_main.configured_##af##_##table##_table_##parm) \ + if (session_main.configured_##af##_##table##_table_##parm) \ configured_##af##_##table##_table_##parm = \ - session_manager_main.configured_##af##_##table##_table_##parm; + session_main.configured_##af##_##table##_table_##parm; foreach_hash_table_parameter; #undef _ if (fib_proto == FIB_PROTOCOL_IP4 || all) { - clib_bihash_init_16_8 (&slt->v4_session_hash, "v4 session table", - configured_v4_session_table_buckets, - configured_v4_session_table_memory); - clib_bihash_init_16_8 (&slt->v4_half_open_hash, "v4 half-open table", - configured_v4_halfopen_table_buckets, - configured_v4_halfopen_table_memory); + clib_bihash_init2_args_16_8_t _a, *a = &_a; + + memset (a, 0, sizeof (*a)); + a->h = &slt->v4_session_hash; + a->name = "v4 session table"; + a->nbuckets = configured_v4_session_table_buckets; + a->memory_size = configured_v4_session_table_memory; + a->dont_add_to_all_bihash_list = 1; + a->instantiate_immediately = 1; + clib_bihash_init2_16_8 (a); + + memset (a, 0, sizeof (*a)); + a->h = &slt->v4_half_open_hash; + a->name = "v4 half-open table"; + a->nbuckets = configured_v4_halfopen_table_buckets; + a->memory_size = configured_v4_halfopen_table_memory; + a->dont_add_to_all_bihash_list = 1; + a->instantiate_immediately = 1; + clib_bihash_init2_16_8 (a); } if (fib_proto == FIB_PROTOCOL_IP6 || all) { - clib_bihash_init_48_8 (&slt->v6_session_hash, "v6 session table", - configured_v6_session_table_buckets, - configured_v6_session_table_memory); - clib_bihash_init_48_8 (&slt->v6_half_open_hash, "v6 half-open table", - configured_v6_halfopen_table_buckets, - configured_v6_halfopen_table_memory); + clib_bihash_init2_args_48_8_t _a, *a = &_a; + + memset (a, 0, sizeof (*a)); + a->h = &slt->v6_session_hash; + a->name = "v6 session table"; + a->nbuckets = configured_v6_session_table_buckets; + a->memory_size = configured_v6_session_table_memory; + a->dont_add_to_all_bihash_list = 1; + a->instantiate_immediately = 1; + clib_bihash_init2_48_8 (a); + + memset (a, 0, sizeof (*a)); + a->h = &slt->v6_half_open_hash; + a->name = "v6 half-open table"; + a->nbuckets = configured_v6_halfopen_table_buckets; + a->memory_size = configured_v6_halfopen_table_memory; + a->dont_add_to_all_bihash_list = 1; + a->instantiate_immediately = 1; + clib_bihash_init2_48_8 (a); } for (i = 0; i < TRANSPORT_N_PROTO; i++)