summaryrefslogtreecommitdiffstats
path: root/src/vlib/error.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2022-04-06 11:07:35 +0200
committerDamjan Marion <dmarion@me.com>2022-04-06 10:52:42 +0000
commit8271dfdff3cf65e3b077e149d4600bd90d2b4b03 (patch)
tree81c02cedbce9d1c8b67815110e573eae4923f0dc /src/vlib/error.c
parent6e061e784d85c8aedea8987c98c86ec7c1b84321 (diff)
interface: unregister node counters on interface delete
Type: fix Change-Id: I2562ae5833b542c29bcd5025a9a6756e5de95a42 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vlib/error.c')
-rw-r--r--src/vlib/error.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/vlib/error.c b/src/vlib/error.c
index f01e0b63e95..7e72565d47f 100644
--- a/src/vlib/error.c
+++ b/src/vlib/error.c
@@ -123,6 +123,23 @@ format_stats_counter_name (u8 *s, va_list *va)
return s;
}
+void
+vlib_unregister_errors (vlib_main_t *vm, u32 node_index)
+{
+ vlib_error_main_t *em = &vm->error_main;
+ vlib_node_t *n = vlib_get_node (vm, node_index);
+ vlib_error_desc_t *cd;
+
+ if (n->n_errors > 0)
+ {
+ cd = vec_elt_at_index (em->counters_heap, n->error_heap_index);
+ for (u32 i = 0; i < n->n_errors; i++)
+ vlib_stats_remove_entry (cd[i].stats_entry_index);
+ heap_dealloc (em->counters_heap, n->error_heap_handle);
+ n->n_errors = 0;
+ }
+}
+
/* Reserves given number of error codes for given node. */
void
vlib_register_errors (vlib_main_t *vm, u32 node_index, u32 n_errors,
@@ -142,13 +159,7 @@ vlib_register_errors (vlib_main_t *vm, u32 node_index, u32 n_errors,
vlib_stats_segment_lock ();
/* Free up any previous error strings. */
- if (n->n_errors > 0)
- {
- cd = vec_elt_at_index (em->counters_heap, n->error_heap_index);
- for (u32 i = 0; i < n->n_errors; i++)
- vlib_stats_remove_entry (cd[i].stats_entry_index);
- heap_dealloc (em->counters_heap, n->error_heap_handle);
- }
+ vlib_unregister_errors (vm, node_index);
n->n_errors = n_errors;
n->error_counters = counters;