stats: Add node names in /sys/nodes/names 85/17885/6
authorOle Troan <ot@cisco.com>
Tue, 26 Feb 2019 21:14:13 +0000 (22:14 +0100)
committerNeale Ranns <nranns@cisco.com>
Fri, 1 Mar 2019 09:19:10 +0000 (09:19 +0000)
Change-Id: I9c92d51cc0e9dccf3c3726c4de8d7f15537778c9
Signed-off-by: Ole Troan <ot@cisco.com>
src/vpp/stats/stat_segment.c
src/vpp/stats/stat_segment.h

index aa32aed..8496f84 100644 (file)
@@ -416,6 +416,33 @@ update_node_counters (stat_segment_main_t * sm)
       stat_validate_counter_vector (&sm->directory_vector
                                    [STAT_COUNTER_NODE_SUSPENDS], l);
 
+      vec_validate (sm->nodes, l);
+      stat_segment_directory_entry_t *ep;
+      ep = &sm->directory_vector[STAT_COUNTER_NODE_NAMES];
+      ep->offset = stat_segment_offset (shared_header, sm->nodes);
+
+      int i;
+      u64 *offset_vector =
+       ep->offset_vector ? stat_segment_pointer (shared_header,
+                                                 ep->offset_vector) : 0;
+      /* Update names dictionary */
+      vec_validate (offset_vector, l);
+      vlib_node_t **nodes = node_dups[0];
+      for (i = 0; i < vec_len (nodes); i++)
+       {
+         vlib_node_t *n = nodes[i];
+         u8 *s = 0;
+         s = format (s, "%v%c", n->name, 0);
+         if (sm->nodes[n->index])
+           vec_free (sm->nodes[n->index]);
+         sm->nodes[n->index] = s;
+         offset_vector[i] =
+           sm->nodes[i] ? stat_segment_offset (shared_header,
+                                               sm->nodes[i]) : 0;
+
+       }
+      ep->offset_vector = stat_segment_offset (shared_header, offset_vector);
+
       vlib_stat_segment_unlock ();
       clib_mem_set_heap (oldheap);
       no_max_nodes = l;
index 917b512..6e75e63 100644 (file)
@@ -33,6 +33,7 @@ typedef enum
  STAT_COUNTER_NODE_CALLS,
  STAT_COUNTER_NODE_SUSPENDS,
  STAT_COUNTER_INTERFACE_NAMES,
+ STAT_COUNTER_NODE_NAMES,
  STAT_COUNTERS
 } stat_segment_counter_t;
 
@@ -46,7 +47,8 @@ typedef enum
   _(NODE_VECTORS, COUNTER_VECTOR_SIMPLE, vectors, /sys/node)   \
   _(NODE_CALLS, COUNTER_VECTOR_SIMPLE, calls, /sys/node)       \
   _(NODE_SUSPENDS, COUNTER_VECTOR_SIMPLE, suspends, /sys/node) \
-  _(INTERFACE_NAMES, NAME_VECTOR, names, /if)
+  _(INTERFACE_NAMES, NAME_VECTOR, names, /if)                   \
+  _(NODE_NAMES, NAME_VECTOR, names, /sys/node)
 
 typedef struct
 {
@@ -104,6 +106,7 @@ typedef struct
   uword *directory_vector_by_name;
   stat_segment_directory_entry_t *directory_vector;
   u8 **interfaces;
+  u8 **nodes;
 
   clib_spinlock_t *stat_segment_lockp;
   clib_socket_t *socket;