From 405e41b50e336dccfdeeafae93bf4453774ecfec Mon Sep 17 00:00:00 2001 From: John Lo Date: Sat, 23 Apr 2016 15:14:12 -0400 Subject: Improve mechanism for using loopback interface as BVI for BDs When loopback interface is configured as BVI, instead of changing its output node from loopN-output to l2-input, the loopN-output node is now kept while its next tx node is changed from ethernet-input to l2-input. The packet setup previously done in bvi_to_l2 as part of l2-input is now performed in the loop output node. This change adds an extra node in the BVI output path but provides the following improvements: 1. IP address/route created on loopback prior to it being configured as BVI will still work properly. The requirement to (re)configure IP/route on loopback after it is configured as BVI is removed. 2. The output stats for loopback interfaces are always provided irrespective of their BVI configuration. 3. The loopback-BVI output stats can be batch updated outside the packet loop in output node, instead of per packet update in l2-input node, making l2-input node more efficient for BVI packets. 4. Restore original node property as implemented in node.c function vlib_node_add_next_with_slot() where next node indices stored in next slots of each node will remain unique. 5. Packet trace for BVI output includes loopN output node which provides useful packet data. Change-Id: I7f5bc72ef953a367363a179088210596881f9e73 Signed-off-by: John Lo --- vlib/vlib/node.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'vlib') diff --git a/vlib/vlib/node.c b/vlib/vlib/node.c index 1df786f0c89..7378701ab4d 100644 --- a/vlib/vlib/node.c +++ b/vlib/vlib/node.c @@ -177,9 +177,10 @@ vlib_node_add_next_with_slot (vlib_main_t * vm, if ((p = hash_get (node->next_slot_by_node, next_node_index))) { - /* Next already exists: use it if slot not specified or the same. */ - if ((slot == ~0) || (slot == p[0])) - return p[0]; + /* Next already exists: slot must match. */ + if (slot != ~0) + ASSERT (slot == p[0]); + return p[0]; } if (slot == ~0) @@ -189,7 +190,7 @@ vlib_node_add_next_with_slot (vlib_main_t * vm, vec_validate (node->n_vectors_by_next_node, slot); node->next_nodes[slot] = next_node_index; - if (!p) hash_set (node->next_slot_by_node, next_node_index, slot); + hash_set (node->next_slot_by_node, next_node_index, slot); vlib_node_runtime_update (vm, node_index, slot); -- cgit