From b6f93a1d1acf0f6ad2cdac0f0ea72842f36776a1 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Thu, 16 Mar 2017 17:46:41 +0100 Subject: vlib: additional runtime_data checks Change-Id: I9b6ed9741fae89bdefa6f601398eb63a21155069 Signed-off-by: Damjan Marion --- src/vlib/threads.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/vlib/threads.c') diff --git a/src/vlib/threads.c b/src/vlib/threads.c index 3756c3fa..40789f59 100644 --- a/src/vlib/threads.c +++ b/src/vlib/threads.c @@ -681,9 +681,10 @@ start_workers (vlib_main_t * vm) vlib_node_t *n = vlib_get_node (vm, rt->node_index); rt->cpu_index = vm_clone->cpu_index; /* copy initial runtime_data from node */ - if (n->runtime_data_bytes > 0) + if (n->runtime_data && n->runtime_data_bytes > 0) clib_memcpy (rt->runtime_data, n->runtime_data, - VLIB_NODE_RUNTIME_DATA_SIZE); + clib_min (VLIB_NODE_RUNTIME_DATA_SIZE, + n->runtime_data_bytes)); else if (CLIB_DEBUG > 0) memset (rt->runtime_data, 0xfe, VLIB_NODE_RUNTIME_DATA_SIZE); @@ -696,9 +697,10 @@ start_workers (vlib_main_t * vm) vlib_node_t *n = vlib_get_node (vm, rt->node_index); rt->cpu_index = vm_clone->cpu_index; /* copy initial runtime_data from node */ - if (n->runtime_data_bytes > 0) + if (n->runtime_data && n->runtime_data_bytes > 0) clib_memcpy (rt->runtime_data, n->runtime_data, - VLIB_NODE_RUNTIME_DATA_SIZE); + clib_min (VLIB_NODE_RUNTIME_DATA_SIZE, + n->runtime_data_bytes)); else if (CLIB_DEBUG > 0) memset (rt->runtime_data, 0xfe, VLIB_NODE_RUNTIME_DATA_SIZE); @@ -961,8 +963,10 @@ vlib_worker_thread_node_runtime_update (void) vlib_node_t *n = vlib_get_node (vm, rt->node_index); rt->cpu_index = vm_clone->cpu_index; /* copy runtime_data, will be overwritten later for existing rt */ - clib_memcpy (rt->runtime_data, n->runtime_data, - VLIB_NODE_RUNTIME_DATA_SIZE); + if (n->runtime_data && n->runtime_data_bytes > 0) + clib_memcpy (rt->runtime_data, n->runtime_data, + clib_min (VLIB_NODE_RUNTIME_DATA_SIZE, + n->runtime_data_bytes)); } for (j = 0; j < vec_len (old_rt); j++) @@ -985,8 +989,10 @@ vlib_worker_thread_node_runtime_update (void) vlib_node_t *n = vlib_get_node (vm, rt->node_index); rt->cpu_index = vm_clone->cpu_index; /* copy runtime_data, will be overwritten later for existing rt */ - clib_memcpy (rt->runtime_data, n->runtime_data, - VLIB_NODE_RUNTIME_DATA_SIZE); + if (n->runtime_data && n->runtime_data_bytes > 0) + clib_memcpy (rt->runtime_data, n->runtime_data, + clib_min (VLIB_NODE_RUNTIME_DATA_SIZE, + n->runtime_data_bytes)); } for (j = 0; j < vec_len (old_rt); j++) -- cgit 1.2.3-korg