diff options
author | Damjan Marion <damarion@cisco.com> | 2022-04-06 11:07:35 +0200 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2022-04-06 10:52:42 +0000 |
commit | 8271dfdff3cf65e3b077e149d4600bd90d2b4b03 (patch) | |
tree | 81c02cedbce9d1c8b67815110e573eae4923f0dc /src/vlib | |
parent | 6e061e784d85c8aedea8987c98c86ec7c1b84321 (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')
-rw-r--r-- | src/vlib/error.c | 25 | ||||
-rw-r--r-- | src/vlib/error.h | 1 |
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; |