diff options
author | Dave Barach <dave@barachs.net> | 2021-06-11 12:57:23 -0400 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2021-06-13 17:42:07 +0000 |
commit | 52c33d60bc63626d400067e38ab0af312fdb8594 (patch) | |
tree | 383aa736a5e26a2cd115d0d5fb905921de76c456 /src/vlib/unix | |
parent | ba02641cc7a27ff02aca65036ffc4bd003497f0b (diff) |
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
Signed-off-by: Dave Barach <dave@barachs.net>
Change-Id: I635da4918509d5b22eae37627c2d9b3608380ca6
Diffstat (limited to 'src/vlib/unix')
-rw-r--r-- | src/vlib/unix/cli.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/vlib/unix/cli.c b/src/vlib/unix/cli.c index 6c98867253f..44ec11fdb35 100644 --- a/src/vlib/unix/cli.c +++ b/src/vlib/unix/cli.c @@ -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 |