X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fnat%2Fnat.c;h=c2c812d114b48f8e3db152964e7ae80555074fe4;hb=fd0d50879f475a1b15cedb4ab49059a02c45ccfd;hp=2e1aa770581821698194a931999f883d7473603a;hpb=775f73c6baaf9bc2283e7ab9752c81984823be99;p=vpp.git diff --git a/src/plugins/nat/nat.c b/src/plugins/nat/nat.c index 2e1aa770581..c2c812d114b 100755 --- a/src/plugins/nat/nat.c +++ b/src/plugins/nat/nat.c @@ -322,6 +322,9 @@ nat_user_get_or_create (snat_main_t * sm, ip4_address_t * addr, u32 fib_index, /* add user */ if (clib_bihash_add_del_8_8 (&tsm->user_hash, &kv, 1)) nat_log_warn ("user_hash keay add failed"); + + vlib_set_simple_counter (&sm->total_users, thread_index, 0, + pool_elts (tsm->users)); } else { @@ -397,6 +400,8 @@ nat_session_alloc_or_recycle (snat_main_t * sm, snat_user_t * u, per_user_translation_list_elt - tsm->list_pool); s->user_index = u - tsm->users; + vlib_set_simple_counter (&sm->total_sessions, thread_index, 0, + pool_elts (tsm->sessions)); } return s; @@ -471,6 +476,9 @@ nat_ed_session_alloc (snat_main_t * sm, snat_user_t * u, u32 thread_index, s->per_user_list_head_index, per_user_translation_list_elt - tsm->list_pool); } + + vlib_set_simple_counter (&sm->total_sessions, thread_index, 0, + pool_elts (tsm->sessions)); } return s; @@ -2207,6 +2215,16 @@ snat_init (vlib_main_t * vm) nat_dpo_module_init (); + /* Init counters */ + sm->total_users.name = "total-users"; + sm->total_users.stat_segment_name = "/nat44/total-users"; + vlib_validate_simple_counter (&sm->total_users, 0); + vlib_zero_simple_counter (&sm->total_users, 0); + sm->total_sessions.name = "total-sessions"; + sm->total_sessions.stat_segment_name = "/nat44/total-sessions"; + vlib_validate_simple_counter (&sm->total_sessions, 0); + vlib_zero_simple_counter (&sm->total_sessions, 0); + /* Init IPFIX logging */ snat_ipfix_logging_init (vm);