diff options
-rw-r--r-- | src/vlib/error.c | 25 | ||||
-rw-r--r-- | src/vlib/error.h | 1 | ||||
-rw-r--r-- | src/vnet/interface.c | 2 |
3 files changed, 21 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; diff --git a/src/vnet/interface.c b/src/vnet/interface.c index 9ce7f6f9aef..dd4399864f7 100644 --- a/src/vnet/interface.c +++ b/src/vnet/interface.c @@ -1151,6 +1151,8 @@ vnet_delete_hw_interface (vnet_main_t * vnm, u32 hw_if_index) "interface-%d-output-deleted", hw_if_index); vlib_node_rename (vm, hw->tx_node_index, "interface-%d-tx-deleted", hw_if_index); + vlib_unregister_errors (vm, hw->output_node_index); + vlib_unregister_errors (vm, hw->tx_node_index); vec_add2 (im->deleted_hw_interface_nodes, dn, 1); dn->tx_node_index = hw->tx_node_index; dn->output_node_index = hw->output_node_index; |