X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fsession%2Fsession_table.c;h=cbb284d13018d2feb45cd2307759cd848a27555a;hb=894d0a6762caefa50a4cb4391eaa9ae78bd67676;hp=9af8ae6a584bb67ae70a286b5910944e49aec31e;hpb=c4d989d6f39799a94321d4a53c982d65a00a0826;p=vpp.git diff --git a/src/vnet/session/session_table.c b/src/vnet/session/session_table.c index 9af8ae6a584..cbb284d1301 100644 --- a/src/vnet/session/session_table.c +++ b/src/vnet/session/session_table.c @@ -185,6 +185,66 @@ ip4_session_table_walk (clib_bihash_16_8_t * hash, &ctx); } +u32 +session_table_memory_size (session_table_t *st) +{ + u64 total_size = 0; + + if (clib_bihash_is_initialised_16_8 (&st->v4_session_hash)) + { + clib_bihash_alloc_chunk_16_8_t *c = st->v4_session_hash.chunks; + while (c) + { + total_size += c->size; + c = c->next; + } + c = st->v4_half_open_hash.chunks; + while (c) + { + total_size += c->size; + c = c->next; + } + } + + if (clib_bihash_is_initialised_48_8 (&st->v6_session_hash)) + { + clib_bihash_alloc_chunk_48_8_t *c = st->v6_session_hash.chunks; + while (c) + { + total_size += c->size; + c = c->next; + } + c = st->v6_half_open_hash.chunks; + while (c) + { + total_size += c->size; + c = c->next; + } + } + + return total_size; +} + +u8 * +format_session_table (u8 *s, va_list *args) +{ + session_table_t *st = va_arg (*args, session_table_t *); + + if (clib_bihash_is_initialised_16_8 (&st->v4_session_hash)) + { + s = format (s, "%U", format_bihash_16_8, &st->v4_session_hash, 0); + s = format (s, "%U", format_bihash_16_8, &st->v4_half_open_hash, 0); + } + + if (clib_bihash_is_initialised_48_8 (&st->v6_session_hash)) + { + s = format (s, "%U", format_bihash_48_8, &st->v6_session_hash, 0); + s = format (s, "%U", format_bihash_48_8, &st->v6_half_open_hash, 0); + } + + return s; +} + /* *INDENT-ON* */ /* * fd.io coding-style-patch-verification: ON