diff options
author | Ole Troan <ot@cisco.com> | 2016-06-10 13:22:36 +0200 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2016-06-14 17:10:53 +0000 |
commit | 964f93e59f72b93191ed938d823af337b7d2c17e (patch) | |
tree | 1e41c9174c4a3d931a92068d1be2b5d7893c1c2c /vlib | |
parent | 07929f2612585bd28dce8cc56c0297215a20953a (diff) |
Fix node siblings
Siblings did not work at all. Fixed by generating sibling relationships
earlier in vlib_node_main_init(). Also adding a node dynamically before
nodes were initialised failed for sibling nodes.
Change-Id: I2fb73eb33a6f5ee216f566074e18ed495e20634d
Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'vlib')
-rw-r--r-- | vlib/vlib/main.c | 12 | ||||
-rw-r--r-- | vlib/vlib/node.c | 83 |
2 files changed, 44 insertions, 51 deletions
diff --git a/vlib/vlib/main.c b/vlib/vlib/main.c index 24504e74..f7a27cfd 100644 --- a/vlib/vlib/main.c +++ b/vlib/vlib/main.c @@ -1570,12 +1570,6 @@ int vlib_main (vlib_main_t * vm, unformat_input_t * input) vm->random_seed = clib_cpu_time_now (); clib_random_buffer_init (&vm->random_buffer, vm->random_seed); - /* See unix/main.c; most likely already set up */ - if (vm->init_functions_called == 0) - vm->init_functions_called = hash_create (0, /* value bytes */ 0); - if ((error = vlib_call_all_init_functions (vm))) - goto done; - /* Initialize node graph. */ if ((error = vlib_node_main_init (vm))) { @@ -1586,6 +1580,12 @@ int vlib_main (vlib_main_t * vm, unformat_input_t * input) goto done; } + /* See unix/main.c; most likely already set up */ + if (vm->init_functions_called == 0) + vm->init_functions_called = hash_create (0, /* value bytes */ 0); + if ((error = vlib_call_all_init_functions (vm))) + goto done; + /* Create default buffer free list. */ vlib_buffer_get_or_create_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES, "default"); diff --git a/vlib/vlib/node.c b/vlib/vlib/node.c index 7378701a..5d250d00 100644 --- a/vlib/vlib/node.c +++ b/vlib/vlib/node.c @@ -163,17 +163,8 @@ vlib_node_add_next_with_slot (vlib_main_t * vm, node = vec_elt (nm->nodes, node_index); next = vec_elt (nm->nodes, next_node_index); - /* Fill in static next nodes if runtime has yet to be initialized. */ - if (slot == ~0 && ! (nm->flags & VLIB_NODE_MAIN_RUNTIME_STARTED)) - { - uword i; - for (i = 0; i < vec_len (node->next_node_names); i++) - { - char * a = node->next_node_names[i]; - if (a) - vlib_node_add_named_next_with_slot (vm, node->index, a, i); - } - } + /* Runtime has to be initialized. */ + ASSERT(nm->flags & VLIB_NODE_MAIN_RUNTIME_STARTED); if ((p = hash_get (node->next_slot_by_node, next_node_index))) { @@ -315,6 +306,8 @@ static void register_node (vlib_main_t * vm, /* Node index of next sibling will be filled in by vlib_node_main_init. */ n->sibling_of = r->sibling_of; + if (r->sibling_of && r->n_next_nodes > 0) + clib_error ("sibling node should not have any next nodes `%v'", n->name); if (r->type == VLIB_NODE_TYPE_INTERNAL) ASSERT (r->vector_size > 0); @@ -473,6 +466,40 @@ vlib_node_main_init (vlib_main_t * vm) nm->flags |= VLIB_NODE_MAIN_RUNTIME_STARTED; + /* Generate sibling relationships */ + { + vlib_node_t * n, * sib; + uword si; + + for (ni = 0; ni < vec_len (nm->nodes); ni++) + { + n = vec_elt (nm->nodes, ni); + + if (! n->sibling_of) + continue; + + sib = vlib_get_node_by_name (vm, (u8 *) n->sibling_of); + if (! sib) + clib_error ("sibling `%s' not found for node `%v'", n->sibling_of, n->name); + + clib_bitmap_foreach (si, sib->sibling_bitmap, ({ + vlib_node_t * m = vec_elt (nm->nodes, si); + + /* Connect all of sibling's siblings to us. */ + m->sibling_bitmap = clib_bitmap_ori (m->sibling_bitmap, n->index); + + /* Connect us to all of sibling's siblings. */ + n->sibling_bitmap = clib_bitmap_ori (n->sibling_bitmap, si); + })); + + /* Connect sibling to us. */ + sib->sibling_bitmap = clib_bitmap_ori (sib->sibling_bitmap, n->index); + + /* Connect us to sibling. */ + n->sibling_bitmap = clib_bitmap_ori (n->sibling_bitmap, sib->index); + } + } + /* Resolve next names into next indices. */ for (ni = 0; ni < vec_len (nm->nodes); ni++) { @@ -545,40 +572,6 @@ vlib_node_main_init (vlib_main_t * vm) } } - /* Generate node sibling relationships. */ - { - vlib_node_t * n, * sib; - uword si; - - for (ni = 0; ni < vec_len (nm->nodes); ni++) - { - n = vec_elt (nm->nodes, ni); - - if (! n->sibling_of) - continue; - - sib = vlib_get_node_by_name (vm, (u8 *) n->sibling_of); - if (! sib) - clib_error ("sibling `%s' not found for node `%v'", n->sibling_of, n->name); - - clib_bitmap_foreach (si, sib->sibling_bitmap, ({ - vlib_node_t * m = vec_elt (nm->nodes, si); - - /* Connect all of sibling's siblings to us. */ - m->sibling_bitmap = clib_bitmap_ori (m->sibling_bitmap, n->index); - - /* Connect us to all of sibling's siblings. */ - n->sibling_bitmap = clib_bitmap_ori (n->sibling_bitmap, si); - })); - - /* Connect sibling to us. */ - sib->sibling_bitmap = clib_bitmap_ori (sib->sibling_bitmap, n->index); - - /* Connect us to sibling. */ - n->sibling_bitmap = clib_bitmap_ori (n->sibling_bitmap, sib->index); - } - } - done: return error; } |