vlib: fix dangling reference in node_by_name hash
When recycling a debug CLI process node, unix_cli_file_add() needs to
delete and recreate the related node_by_name hash table entry.
Type: fix
@@ -2863,6 +2863,7 @@ unix_cli_file_add (unix_cli_main_t * cm, char *name, int fd)
{
unix_main_t *um = &unix_main;
clib_file_main_t *fm = &file_main;
+ vlib_node_main_t *nm = &vlib_get_main ()->node_main;
unix_cli_file_t *cf;
clib_file_t template = { 0 };
vlib_main_t *vm = um->vlib_main;
@@ -2896,10 +2897,12 @@ unix_cli_file_add (unix_cli_main_t * cm, char *name, int fd)
old_name = n->name;
n->name = (u8 *) name;
}
+ ASSERT (old_name);
+ hash_unset (nm->node_by_name, old_name);
+ hash_set (nm->node_by_name, name, n->index);
vec_free (old_name);
vlib_node_set_state (vm, n->index, VLIB_NODE_STATE_POLLING);
-
_vec_len (cm->unused_cli_process_node_indices) = l - 1;
}
else
