summaryrefslogtreecommitdiffstats
path: root/src/vnet/fib/fib_table.c
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2019-12-04 06:11:00 +0000
committerNeale Ranns <neale@graphiant.com>2021-03-16 12:12:23 +0000
commit976b259be2ce9725f1d6756c14ff81069634a396 (patch)
treef4117b32e9230e5c313474a158dbfa847943b99d /src/vnet/fib/fib_table.c
parent400ce717ac043ceec404103dbaa87dd17d92feb7 (diff)
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
Diffstat (limited to 'src/vnet/fib/fib_table.c')
-rw-r--r--src/vnet/fib/fib_table.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/vnet/fib/fib_table.c b/src/vnet/fib/fib_table.c
index e71e6c36bfb..eaeee5bb921 100644
--- a/src/vnet/fib/fib_table.c
+++ b/src/vnet/fib/fib_table.c
@@ -1255,6 +1255,42 @@ fib_table_walk (u32 fib_index,
}
}
+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,