summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2023-10-12 17:38:52 +0000
committerAndrew Yourtchenko <ayourtch@gmail.com>2023-10-13 10:39:24 +0000
commit29aabcf8f6746b386be70f535ce28d7f3605ecca (patch)
treed1c8f8293a4fa2f664909a92d33053af8493d47e /src
parentc9275dadefe42418da3c15726f2a80a550b50156 (diff)
vlib: properly replicate nexts when sibling node is created on runtime
Change-Id: I5aff21b5ca32e7eb84b11cca8387e7ac42fbbe23 Type: improvement Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/vlib/node.c65
1 files changed, 33 insertions, 32 deletions
diff --git a/src/vlib/node.c b/src/vlib/node.c
index e613a85adc8..c98f390e334 100644
--- a/src/vlib/node.c
+++ b/src/vlib/node.c
@@ -358,11 +358,25 @@ vlib_register_node (vlib_main_t *vm, vlib_node_registration_t *r, char *fmt,
...)
{
vlib_node_main_t *nm = &vm->node_main;
- vlib_node_t *n;
+ vlib_node_t *n, *sib = 0;
va_list va;
u32 size;
int i;
+ if (r->sibling_of)
+ {
+ if (r->n_next_nodes > 0)
+ clib_error ("sibling node should not have any next nodes `%v'",
+ r->name);
+ if (nm->flags & VLIB_NODE_MAIN_RUNTIME_STARTED)
+ {
+ sib = vlib_get_node_by_name (vm, (u8 *) r->sibling_of);
+
+ if (sib == 0)
+ clib_error ("unknown sibling node '%s'", r->sibling_of);
+ }
+ }
+
if (CLIB_DEBUG > 0)
{
/* Default (0) type should match INTERNAL. */
@@ -413,37 +427,6 @@ vlib_register_node (vlib_main_t *vm, vlib_node_registration_t *r, char *fmt,
r->index = n->index; /* save index in registration */
n->function = r->function;
- /* Node index of next sibling will be filled in by vlib_node_main_init. */
- n->sibling_of = r->sibling_of;
- if (r->sibling_of)
- {
- if (r->n_next_nodes > 0)
- clib_error ("sibling node should not have any next nodes `%v'",
- n->name);
-
- if (nm->flags & VLIB_NODE_MAIN_RUNTIME_STARTED)
- {
- vlib_node_t *sib;
- u32 slot, i;
-
- sib = vlib_get_node_by_name (vm, (u8 *) n->sibling_of);
-
- if (sib == 0)
- clib_error ("unknown sibling node '%s'", n->sibling_of);
-
- vec_foreach_index (i, sib->next_nodes)
- {
- slot = vlib_node_add_next_with_slot (vm, n->index,
- sib->next_nodes[i], i);
- ASSERT (slot == i);
- }
-
- vlib_node_add_to_sibling_bitmap (vm, n, sib);
-
- r->n_next_nodes = vec_len (n->next_nodes);
- }
- }
-
if (r->type == VLIB_NODE_TYPE_INTERNAL)
ASSERT (r->vector_size > 0);
@@ -620,6 +603,24 @@ vlib_register_node (vlib_main_t *vm, vlib_node_registration_t *r, char *fmt,
vec_free (n->runtime_data);
}
#undef _
+
+ if (sib)
+ {
+ u32 slot, i;
+
+ vec_foreach_index (i, sib->next_nodes)
+ {
+ slot =
+ vlib_node_add_next_with_slot (vm, n->index, sib->next_nodes[i], i);
+ ASSERT (slot == i);
+ }
+
+ vlib_node_add_to_sibling_bitmap (vm, n, sib);
+
+ r->n_next_nodes = vec_len (n->next_nodes);
+ }
+ n->sibling_of = r->sibling_of;
+
return r->index;
}