aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/lisp-gpe/lisp_gpe_fwd_entry.c
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2017-04-10 07:54:31 +0200
committerFlorin Coras <florin.coras@gmail.com>2017-04-11 06:30:06 +0000
commit5e189f1a8862f5a8f837dc612c15d63d2b9b6457 (patch)
tree6273347a54f84cb5645124d4a120f116e293fcf6 /src/vnet/lisp-gpe/lisp_gpe_fwd_entry.c
parent92bcecfdcc8b44877349fe952339a8bb24be6dfc (diff)
LSIP: make LISP statistics collecting thread safe, VPP-692
Change-Id: If884835c0f63de162ecf75fecd2a63a1240ee910 Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
Diffstat (limited to 'src/vnet/lisp-gpe/lisp_gpe_fwd_entry.c')
-rw-r--r--src/vnet/lisp-gpe/lisp_gpe_fwd_entry.c72
1 files changed, 49 insertions, 23 deletions
diff --git a/src/vnet/lisp-gpe/lisp_gpe_fwd_entry.c b/src/vnet/lisp-gpe/lisp_gpe_fwd_entry.c
index efa724e0d5b..8b4fbbf1177 100644
--- a/src/vnet/lisp-gpe/lisp_gpe_fwd_entry.c
+++ b/src/vnet/lisp-gpe/lisp_gpe_fwd_entry.c
@@ -409,6 +409,42 @@ lisp_gpe_fwd_entry_mk_paths (lisp_gpe_fwd_entry_t * lfe,
vec_sort_with_function (lfe->paths, lisp_gpe_fwd_entry_path_sort);
}
+void
+vnet_lisp_gpe_add_fwd_counters (vnet_lisp_gpe_add_del_fwd_entry_args_t * a,
+ u32 fwd_entry_index)
+{
+ const lisp_gpe_adjacency_t *ladj;
+ lisp_fwd_path_t *path;
+ lisp_gpe_main_t *lgm = vnet_lisp_gpe_get_main ();
+ lisp_gpe_fwd_entry_t *lfe;
+ lisp_gpe_fwd_entry_key_t fe_key;
+ lisp_stats_key_t key, *stats_key;
+
+ lfe = find_fwd_entry (lgm, a, &fe_key);
+
+ if (LISP_GPE_FWD_ENTRY_TYPE_NORMAL != lfe->type)
+ return;
+
+ memset (&key, 0, sizeof (key));
+ key.fwd_entry_index = fwd_entry_index;
+
+ vec_foreach (path, lfe->paths)
+ {
+ ladj = lisp_gpe_adjacency_get (path->lisp_adj);
+ key.tunnel_index = ladj->tunnel_index;
+
+ pool_get (lgm->stats_key_pool, stats_key);
+ memcpy (stats_key, &key, sizeof (key));
+ hash_set_mem (lgm->lisp_stats_index_by_key, stats_key,
+ stats_key - lgm->stats_key_pool);
+
+ vlib_validate_combined_counter (&lgm->counters,
+ stats_key - lgm->stats_key_pool);
+ vlib_zero_combined_counter (&lgm->counters,
+ stats_key - lgm->stats_key_pool);
+ }
+}
+
/**
* @brief Add/Delete LISP IP forwarding entry.
*
@@ -1171,49 +1207,39 @@ vnet_lisp_gpe_add_del_fwd_entry (vnet_lisp_gpe_add_del_fwd_entry_args_t * a,
}
}
-void
+int
vnet_lisp_flush_stats (void)
{
lisp_gpe_main_t *lgm = vnet_lisp_gpe_get_main ();
- lisp_stats_t *stat;
+ vlib_combined_counter_main_t *cm = &lgm->counters;
+ u32 i;
- /* *INDENT-OFF* */
- pool_foreach (stat, lgm->lisp_stats_pool,
- {
- stat->pkt_count = 0;
- stat->bytes = 0;
- });
- /* *INDENT-ON* */
+ for (i = 0; i < vlib_combined_counter_n_counters (cm); i++)
+ vlib_zero_combined_counter (cm, i);
+
+ return 0;
}
static void
lisp_del_adj_stats (lisp_gpe_main_t * lgm, u32 fwd_entry_index, u32 ti)
{
- hash_pair_t *hp;
lisp_stats_key_t key;
- void *key_copy;
uword *p;
- lisp_stats_t *s;
memset (&key, 0, sizeof (key));
key.fwd_entry_index = fwd_entry_index;
key.tunnel_index = ti;
p = hash_get_mem (lgm->lisp_stats_index_by_key, &key);
- if (p)
- {
- s = pool_elt_at_index (lgm->lisp_stats_pool, p[0]);
- hp = hash_get_pair (lgm->lisp_stats_index_by_key, &key);
- key_copy = (void *) (hp->key);
- hash_unset_mem (lgm->lisp_stats_index_by_key, &key);
- clib_mem_free (key_copy);
- pool_put (lgm->lisp_stats_pool, s);
- }
+ ASSERT (p);
+
+ pool_put_index (lgm->stats_key_pool, p[0]);
+ hash_unset_mem (lgm->lisp_stats_index_by_key, &key);
}
void
-vnet_lisp_del_fwd_stats (vnet_lisp_gpe_add_del_fwd_entry_args_t * a,
- u32 fwd_entry_index)
+vnet_lisp_gpe_del_fwd_counters (vnet_lisp_gpe_add_del_fwd_entry_args_t * a,
+ u32 fwd_entry_index)
{
lisp_gpe_main_t *lgm = &lisp_gpe_main;
lisp_gpe_fwd_entry_key_t fe_key;