aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/interface
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2022-04-15 15:53:17 +0200
committerOle Tr�an <otroan@employees.org>2022-04-26 10:32:11 +0000
commitc5d81b91be30c9a69bb5333f2685f536246dd1f8 (patch)
tree91b1782b6224ab8d256e16d43a5066a4aa61a5e4 /src/vnet/interface
parent45e05396399b7ead25d87e79a806f0c03b78965b (diff)
stats: string vector and node collector improvements
Type: improvement Change-Id: Ibdadeb4e685f45a93f45504a84709391489abb6a Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vnet/interface')
-rw-r--r--src/vnet/interface/stats.c38
1 files changed, 12 insertions, 26 deletions
diff --git a/src/vnet/interface/stats.c b/src/vnet/interface/stats.c
index 55e49eb1bc2..f58ffa32586 100644
--- a/src/vnet/interface/stats.c
+++ b/src/vnet/interface/stats.c
@@ -9,7 +9,7 @@
#include <vnet/devices/devices.h> /* vnet_get_aggregate_rx_packets */
#include <vnet/interface.h>
-static u32 if_names_stats_entry_index = ~0;
+vlib_stats_string_vector_t if_names = 0;
static u32 **dir_entry_indices = 0;
static struct
@@ -25,21 +25,15 @@ static struct
static clib_error_t *
statseg_sw_interface_add_del (vnet_main_t *vnm, u32 sw_if_index, u32 is_add)
{
- vlib_stats_segment_t *sm = vlib_stats_get_segment ();
- vlib_stats_entry_t *e;
- void *oldheap;
-
- if (if_names_stats_entry_index == ~0)
+ if (if_names == 0)
{
- if_names_stats_entry_index = vlib_stats_add_string_vector ("/if/names");
+ if_names = vlib_stats_add_string_vector ("/if/names");
for (int i = 0; i < ARRAY_LEN (if_counters); i++)
if_counters[i].index = vlib_stats_find_entry_index (
"/%s/%s", if_counters[i].prefix, if_counters[i].name);
}
- e = sm->directory_vector + if_names_stats_entry_index;
-
vec_validate (dir_entry_indices, sw_if_index);
vlib_stats_segment_lock ();
@@ -48,40 +42,32 @@ statseg_sw_interface_add_del (vnet_main_t *vnm, u32 sw_if_index, u32 is_add)
{
vnet_sw_interface_t *si, *si_sup;
vnet_hw_interface_t *hi_sup;
- u8 *s;
+ u8 *name;
si = vnet_get_sw_interface (vnm, sw_if_index);
si_sup = vnet_get_sup_sw_interface (vnm, si->sw_if_index);
ASSERT (si_sup->type == VNET_SW_INTERFACE_TYPE_HARDWARE);
hi_sup = vnet_get_hw_interface (vnm, si_sup->hw_if_index);
- oldheap = clib_mem_set_heap (sm->heap);
- s = format (0, "%v", hi_sup->name);
+ name = format (0, "%v", hi_sup->name);
if (si->type != VNET_SW_INTERFACE_TYPE_HARDWARE)
- s = format (s, ".%d", si->sub.id);
- s = format (s, "%c", 0);
+ name = format (name, ".%d", si->sub.id);
- vec_validate (e->string_vector, sw_if_index);
+ vlib_stats_set_string_vector (&if_names, sw_if_index, "%v", name);
- ASSERT (e->string_vector[sw_if_index] == 0);
- e->string_vector[sw_if_index] = s;
- clib_mem_set_heap (oldheap);
-
- s = format (0, "/interfaces/%U", format_vlib_stats_symlink, s);
for (u32 index, i = 0; i < ARRAY_LEN (if_counters); i++)
{
- index = vlib_stats_add_symlink (if_counters[i].index, sw_if_index,
- "%v/%s", s, if_counters[i].name);
+ index = vlib_stats_add_symlink (
+ if_counters[i].index, sw_if_index, "/interfaces/%U/%s",
+ format_vlib_stats_symlink, name, if_counters[i].name);
ASSERT (index != ~0);
vec_add1 (dir_entry_indices[sw_if_index], index);
}
- vec_free (s);
+
+ vec_free (name);
}
else
{
- oldheap = clib_mem_set_heap (sm->heap);
- vec_free (e->string_vector[sw_if_index]);
- clib_mem_set_heap (oldheap);
for (u32 i = 0; i < vec_len (dir_entry_indices[sw_if_index]); i++)
vlib_stats_remove_entry (dir_entry_indices[sw_if_index][i]);
vec_free (dir_entry_indices[sw_if_index]);