fib: FIB Entry tracking
Instead of all clients directly RR sourcing the entry they are tracking,
use a deidcated 'tracker' object. This tracker object is a entry
delegate and a child of the entry. The clients are then children of the
tracker.
The benefit of this aproach is that each time a new client tracks the
entry it doesn't RR source it. When an entry is sourced all its children
are updated. Thus, new clients tracking an entry is O(n^2). With the
tracker as indirection, the entry is sourced only once.
Type: feature
Change-Id: I5b80bdda6c02057152e5f721e580e786cd840a3b
Signed-off-by: Neale Ranns <nranns@cisco.com>
diff --git a/src/vnet/adj/adj_midchain_delegate.c b/src/vnet/adj/adj_midchain_delegate.c
index 922283e..9e78843 100644
--- a/src/vnet/adj/adj_midchain_delegate.c
+++ b/src/vnet/adj/adj_midchain_delegate.c
@@ -16,6 +16,7 @@
#include <vnet/adj/adj_delegate.h>
#include <vnet/adj/adj_midchain.h>
#include <vnet/fib/fib_table.h>
+#include <vnet/fib/fib_entry_track.h>
/**
* Midchain stacker delegate
@@ -121,13 +122,11 @@
amd->amd_fei = FIB_NODE_INDEX_INVALID;
adj_delegate_add(adj, ADJ_DELEGATE_MIDCHAIN, amd - amd_pool);
- amd->amd_fei = fib_table_entry_special_add(fib_index,
- pfx,
- FIB_SOURCE_RR,
- FIB_ENTRY_FLAG_NONE);
- amd->amd_sibling = fib_entry_child_add(amd->amd_fei,
- FIB_NODE_TYPE_ADJ,
- ai);
+ amd->amd_fei = fib_entry_track(fib_index,
+ pfx,
+ FIB_NODE_TYPE_ADJ,
+ ai,
+ &amd->amd_sibling);
}
adj_midchain_delegate_restack_i(ai, amd);
}
@@ -145,8 +144,7 @@
amd = pool_elt_at_index(amd_pool, ad->ad_index);
- fib_entry_child_remove (amd->amd_fei, amd->amd_sibling);
- fib_table_entry_delete_index (amd->amd_fei, FIB_SOURCE_RR);
+ fib_entry_untrack(amd->amd_fei, amd->amd_sibling);
pool_put(amd_pool, amd);
}