From 32e1c010b0c34fd0984f7fc45fae648a182025c5 Mon Sep 17 00:00:00 2001 From: Neale Ranns Date: Tue, 22 Nov 2016 17:07:28 +0000 Subject: IP Multicast FIB (mfib) - IPv[46] mfib tables with support for (*,G/m), (*,G) and (S,G) exact and longest prefix match - Replication represented via a new replicate DPO. - RPF configuration and data-plane checking - data-plane signals sent to listening control planes. The functions of multicast forwarding entries differ from their unicast conterparts, so we introduce a new mfib_table_t and mfib_entry_t objects. However, we re-use the fib_path_list to resolve and build the entry's output list. the fib_path_list provides the service to construct a replicate DPO for multicast. 'make tests' is added to with two new suites; TEST=mfib, this is invocation of the CLI command 'test mfib' which deals with many path add/remove, flag set/unset scenarios, TEST=ip-mcast, data-plane forwarding tests. Updated applications to use the new MIFB functions; - IPv6 NS/RA. - DHCPv6 unit tests for these are undated accordingly. Change-Id: I49ec37b01f1b170335a5697541c8fd30e6d3a961 Signed-off-by: Neale Ranns --- src/vnet/fib/fib_table.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 2 deletions(-) (limited to 'src/vnet/fib/fib_table.c') diff --git a/src/vnet/fib/fib_table.c b/src/vnet/fib/fib_table.c index 76db42d0ec7..57eb0ae8298 100644 --- a/src/vnet/fib/fib_table.c +++ b/src/vnet/fib/fib_table.c @@ -1043,6 +1043,26 @@ fib_table_destroy (fib_table_t *fib_table) break; } } +void +fib_table_walk (u32 fib_index, + fib_protocol_t proto, + fib_table_walk_fn_t fn, + void *ctx) +{ + switch (proto) + { + case FIB_PROTOCOL_IP4: + ip4_fib_table_walk(ip4_fib_get(fib_index), fn, ctx); + break; + case FIB_PROTOCOL_IP6: + ip6_fib_table_walk(fib_index, fn, ctx); + break; + case FIB_PROTOCOL_MPLS: + mpls_fib_table_walk(mpls_fib_get(fib_index), fn, ctx); + break; + } +} + void fib_table_unlock (u32 fib_index, @@ -1094,11 +1114,56 @@ format_fib_table_name (u8* s, va_list ap) return (s); } +/** + * @brief Table flush context. Store the indicies of matching FIB entries + * that need to be removed. + */ +typedef struct fib_table_flush_ctx_t_ +{ + /** + * The list of entries to flush + */ + fib_node_index_t *ftf_entries; + + /** + * The source we are flushing + */ + fib_source_t ftf_source; +} fib_table_flush_ctx_t; + +static int +fib_table_flush_cb (fib_node_index_t fib_entry_index, + void *arg) +{ + fib_table_flush_ctx_t *ctx = arg; + + if (fib_entry_is_sourced(fib_entry_index, ctx->ftf_source)) + { + vec_add1(ctx->ftf_entries, fib_entry_index); + } + return (1); +} + + void fib_table_flush (u32 fib_index, fib_protocol_t proto, fib_source_t source) { - // FIXME - ASSERT(0); + fib_node_index_t *fib_entry_index; + fib_table_flush_ctx_t ctx = { + .ftf_entries = NULL, + .ftf_source = source, + }; + + fib_table_walk(fib_index, proto, + fib_table_flush_cb, + &ctx); + + vec_foreach(fib_entry_index, ctx.ftf_entries) + { + fib_entry_delete(*fib_entry_index, source); + } + + vec_free(ctx.ftf_entries); } -- cgit 1.2.3-korg