diff options
author | Damjan Marion <damarion@cisco.com> | 2022-03-23 17:36:56 +0100 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2022-03-23 18:40:16 +0000 |
commit | f87acfaf739f7b6361d6299549a897b03b0cc8c6 (patch) | |
tree | 6107b984b0a4ae9b6365eb08e307b377b4266ba5 /src/vnet/interface.c | |
parent | ba465b970e88d02467838bd9c272cb6d5cd653ec (diff) |
vppinfra: change vlib_register_node so it takes format string for node name
This allows specifying both c string and vector for node name
and removes need for crafting temporary string.
Type: improvement
Change-Id: I0b016cd70aeda0f68eb6f9171c5152f303be7369
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vnet/interface.c')
-rw-r--r-- | src/vnet/interface.c | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/src/vnet/interface.c b/src/vnet/interface.c index 412c6755ea8..c44f2647ddf 100644 --- a/src/vnet/interface.c +++ b/src/vnet/interface.c @@ -874,7 +874,6 @@ vnet_register_interface (vnet_main_t * vnm, vnet_feature_config_main_t *fcm; vnet_config_main_t *cm; u32 hw_index, i; - char *tx_node_name = NULL, *output_node_name = NULL; vlib_node_t *if_out_node = vlib_get_node (vm, vnet_interface_output_node.index); @@ -926,9 +925,6 @@ vnet_register_interface (vnet_main_t * vnm, if (dev_class->tx_function == 0 && dev_class->tx_fn_registrations == 0) goto no_output_nodes; /* No output/tx nodes to create */ - tx_node_name = (char *) format (0, "%v-tx", hw->name); - output_node_name = (char *) format (0, "%v-output", hw->name); - /* If we have previously deleted interface nodes, re-use them. */ if (vec_len (im->deleted_hw_interface_nodes) > 0) { @@ -941,8 +937,8 @@ vnet_register_interface (vnet_main_t * vnm, hw->tx_node_index = hn->tx_node_index; hw->output_node_index = hn->output_node_index; - vlib_node_rename (vm, hw->tx_node_index, "%v", tx_node_name); - vlib_node_rename (vm, hw->output_node_index, "%v", output_node_name); + vlib_node_rename (vm, hw->tx_node_index, "%v-tx", hw->name); + vlib_node_rename (vm, hw->output_node_index, "%v-output", hw->name); foreach_vlib_main () { @@ -1016,7 +1012,6 @@ vnet_register_interface (vnet_main_t * vnm, r.vector_size = sizeof (u32); r.flags = VLIB_NODE_FLAG_IS_OUTPUT; - r.name = tx_node_name; if (dev_class->tx_fn_registrations) { r.function = 0; @@ -1025,14 +1020,13 @@ vnet_register_interface (vnet_main_t * vnm, else r.function = dev_class->tx_function; - hw->tx_node_index = vlib_register_node (vm, &r); + hw->tx_node_index = vlib_register_node (vm, &r, "%v-tx", hw->name); vlib_node_add_named_next_with_slot (vm, hw->tx_node_index, "error-drop", VNET_INTERFACE_TX_NEXT_DROP); r.flags = 0; - r.name = output_node_name; r.format_trace = format_vnet_interface_output_trace; if (if_out_node->node_fn_registrations) { @@ -1052,7 +1046,8 @@ vnet_register_interface (vnet_main_t * vnm, r.n_errors = ARRAY_LEN (e); r.error_strings = e; } - hw->output_node_index = vlib_register_node (vm, &r); + hw->output_node_index = + vlib_register_node (vm, &r, "%v-output", hw->name); vlib_node_add_named_next_with_slot (vm, hw->output_node_index, "error-drop", @@ -1095,9 +1090,6 @@ no_output_nodes: VNET_INTERFACE_SET_FLAGS_HELPER_IS_CREATE); vnet_hw_interface_set_flags_helper (vnm, hw_index, /* flags */ 0, VNET_INTERFACE_SET_FLAGS_HELPER_IS_CREATE); - vec_free (tx_node_name); - vec_free (output_node_name); - return hw_index; } |