aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Mikhailov (imichail) <imichail@cisco.com>2017-07-03 17:01:50 -0700
committerDamjan Marion <dmarion.lists@gmail.com>2017-07-11 15:35:57 +0000
commit02989064e4c26a4940a5292ba6c47023e6dd3131 (patch)
tree498d5f2bb2b54f4be29526349c7369d5f29b60b8
parentd6a11c430b58e76acb7462190eed095820cae008 (diff)
VPP-895 multi-thread: fix vpp crash on show runtime
In multi-threaded model (e.g. 1 main and 1 worker threads), after an ethernet interface is deleted (e.g. vhost-user interface), 'show runtime' command produces garbled output and sometimes leads to vpp crash. The reason is because vlib_node_rename() frees and reallocates node's 'n->name' vector, however the change is not propagated into copies of the node on worker threads. Change-Id: Ibf22422913b7f2df22f70f3b2fe8dafd34c1dd06 Signed-off-by: Igor Mikhailov (imichail) <imichail@cisco.com>
-rw-r--r--src/vlib/node.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/vlib/node.c b/src/vlib/node.c
index 2cda0f06475..e6739dc7cf9 100644
--- a/src/vlib/node.c
+++ b/src/vlib/node.c
@@ -72,6 +72,32 @@ node_set_elog_name (vlib_main_t * vm, uword node_index)
n->name_elog_string = elog_string (&vm->elog_main, "%v%c", n->name, 0);
}
+static void
+vlib_worker_thread_node_rename (u32 node_index)
+{
+ int i;
+ vlib_main_t *vm;
+ vlib_node_t *n;
+
+ if (vec_len (vlib_mains) == 1)
+ return;
+
+ vm = vlib_mains[0];
+ n = vlib_get_node (vm, node_index);
+
+ ASSERT (vlib_get_thread_index () == 0);
+ ASSERT (*vlib_worker_threads->wait_at_barrier == 1);
+
+ for (i = 1; i < vec_len (vlib_mains); i++)
+ {
+ vlib_main_t *vm_worker = vlib_mains[i];
+ vlib_node_t *n_worker = vlib_get_node (vm_worker, node_index);
+
+ n_worker->name = n->name;
+ n_worker->name_elog_string = n->name_elog_string;
+ }
+}
+
void
vlib_node_rename (vlib_main_t * vm, u32 node_index, char *fmt, ...)
{
@@ -87,6 +113,9 @@ vlib_node_rename (vlib_main_t * vm, u32 node_index, char *fmt, ...)
hash_set (nm->node_by_name, n->name, n->index);
node_set_elog_name (vm, node_index);
+
+ /* Propagate the change to all worker threads */
+ vlib_worker_thread_node_rename (node_index);
}
static void