aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlib
diff options
context:
space:
mode:
Diffstat (limited to 'src/vlib')
-rw-r--r--src/vlib/error.c25
-rw-r--r--src/vlib/error.h1
2 files changed, 19 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;
diff --git a/src/vlib/error.h b/src/vlib/error.h
index c7e7ce49269..b5cc264b60d 100644
--- a/src/vlib/error.h
+++ b/src/vlib/error.h
@@ -79,6 +79,7 @@ typedef struct
void vlib_register_errors (struct vlib_main_t *vm, u32 node_index,
u32 n_errors, char *error_strings[],
vlib_error_desc_t counters[]);
+void vlib_unregister_errors (struct vlib_main_t *vm, u32 node_index);
unformat_function_t unformat_vlib_error;