diff options
author | Florin Coras <fcoras@cisco.com> | 2023-11-17 16:35:04 -0800 |
---|---|---|
committer | Dave Barach <vpp@barachs.net> | 2023-11-20 16:13:44 +0000 |
commit | 894d0a6762caefa50a4cb4391eaa9ae78bd67676 (patch) | |
tree | 5e09e80451454f2237a0152e04cd0451c291191d /src/vnet/session/session_table.c | |
parent | c4d989d6f39799a94321d4a53c982d65a00a0826 (diff) |
session: add session lookup cli for stats
Type: improvement
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I96bff47206ef64ea7369ae92e1b9ff1f74dfd71b
Diffstat (limited to 'src/vnet/session/session_table.c')
-rw-r--r-- | src/vnet/session/session_table.c | 60 |
1 files changed, 60 insertions, 0 deletions
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 |