diff options
author | Christian Hopps <chopps@labn.net> | 2019-11-03 00:59:49 -0400 |
---|---|---|
committer | Andrew Yourtchenko <ayourtch@gmail.com> | 2019-11-18 13:16:39 +0000 |
commit | d74cb99a98ded19ae851ee4e0858ccd3d1543c8f (patch) | |
tree | 16d7ccbba1f97b9dda8b2e40b48437e62f018249 /src/vlib | |
parent | 511cef1b9e9cdae5ef535beffe7714ebd0333b3a (diff) |
vlib: fix for vlib_node_add_next_with_slot
- vlib_node_add_next_with_slot was not cleaning the old next node
references to the given slot when replacing it with new next node. This mostly
worked until one tried to set the slot to a previously (but not currently) used
next node for that slot.
Type: fix
Signed-off-by: Christian Hopps <chopps@labn.net>
Change-Id: I7ee607625da874e320158b80f12ddc16e377f8e9
(cherry picked from commit 2e8b0618b12d317f2a4632e69a0663dcd8dde472)
Diffstat (limited to 'src/vlib')
-rw-r--r-- | src/vlib/node.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/vlib/node.c b/src/vlib/node.c index b6a44b2e99d..2bb5bceadbc 100644 --- a/src/vlib/node.c +++ b/src/vlib/node.c @@ -201,7 +201,8 @@ vlib_node_add_next_with_slot (vlib_main_t * vm, uword next_node_index, uword slot) { vlib_node_main_t *nm = &vm->node_main; - vlib_node_t *node, *next; + vlib_node_t *node, *next, *old_next; + u32 old_next_index; uword *p; ASSERT (vlib_get_thread_index () == 0); @@ -228,6 +229,14 @@ vlib_node_add_next_with_slot (vlib_main_t * vm, vec_validate_init_empty (node->next_nodes, slot, ~0); vec_validate (node->n_vectors_by_next_node, slot); + if ((old_next_index = node->next_nodes[slot]) != ~0u) + { + hash_unset (node->next_slot_by_node, old_next_index); + old_next = vlib_get_node (vm, old_next_index); + old_next->prev_node_bitmap = + clib_bitmap_andnoti (old_next->prev_node_bitmap, node_index); + } + node->next_nodes[slot] = next_node_index; hash_set (node->next_slot_by_node, next_node_index, slot); |