fib: Allow the creation of new source on the API
Type: feature
an client can dump the existing sources, examine their
priorities, then define thier own source.
Usefull if a client wants to distingusih between say, static,
ospf, bgp, etc routes it has added over the API.
Signed-off-by: Neale Ranns <nranns@cisco.com>
Signed-off-by: Alexander Chernavin <achernavin@netgate.com>
Change-Id: I5158b4fa1ebe87381ff8707bb173217f56ea274a
diff --git a/src/vnet/fib/fib_table.c b/src/vnet/fib/fib_table.c
index e71e6c3..eaeee5b 100644
--- a/src/vnet/fib/fib_table.c
+++ b/src/vnet/fib/fib_table.c
@@ -1255,6 +1255,42 @@
}
}
+typedef struct fib_table_walk_w_src_ctx_t_
+{
+ fib_table_walk_fn_t fn;
+ void *data;
+ fib_source_t src;
+} fib_table_walk_w_src_cxt_t;
+
+static fib_table_walk_rc_t
+fib_table_walk_w_src_cb (fib_node_index_t fei,
+ void *arg)
+{
+ fib_table_walk_w_src_cxt_t *ctx = arg;
+
+ if (ctx->src == fib_entry_get_best_source(fei))
+ {
+ return (ctx->fn(fei, ctx->data));
+ }
+ return (FIB_TABLE_WALK_CONTINUE);
+}
+
+void
+fib_table_walk_w_src (u32 fib_index,
+ fib_protocol_t proto,
+ fib_source_t src,
+ fib_table_walk_fn_t fn,
+ void *data)
+{
+ fib_table_walk_w_src_cxt_t ctx = {
+ .fn = fn,
+ .src = src,
+ .data = data,
+ };
+
+ fib_table_walk(fib_index, proto, fib_table_walk_w_src_cb, &ctx);
+}
+
void
fib_table_sub_tree_walk (u32 fib_index,
fib_protocol_t proto,