return (bsrc);
}
+int
+mfib_entry_is_sourced (fib_node_index_t mfib_entry_index,
+ mfib_source_t source)
+{
+ mfib_entry_t *mfib_entry;
+
+ mfib_entry = mfib_entry_get(mfib_entry_index);
+
+ return (NULL != mfib_entry_src_find(mfib_entry, source, NULL));
+}
+
static void
mfib_entry_src_flush (mfib_entry_src_t *msrc)
{
}
}
-static void
-mfib_entry_last_lock_gone (fib_node_t *node)
-{
- mfib_entry_t *mfib_entry;
- mfib_entry_src_t *msrc;
-
- mfib_entry = mfib_entry_from_fib_node(node);
-
- dpo_reset(&mfib_entry->mfe_rep);
-
- MFIB_ENTRY_DBG(mfib_entry, "last-lock");
-
- vec_foreach(msrc, mfib_entry->mfe_srcs)
- {
- mfib_entry_src_flush(msrc);
- }
-
- vec_free(mfib_entry->mfe_srcs);
-
- fib_node_deinit(&mfib_entry->mfe_node);
- pool_put(mfib_entry_pool, mfib_entry);
-}
-
-/*
- * mfib_entry_back_walk_notify
- *
- * A back walk has reach this entry.
- */
-static fib_node_back_walk_rc_t
-mfib_entry_back_walk_notify (fib_node_t *node,
- fib_node_back_walk_ctx_t *ctx)
-{
- // FIXME - re-evalute
-
- return (FIB_NODE_BACK_WALK_CONTINUE);
-}
-
-static void
-mfib_entry_show_memory (void)
-{
- fib_show_memory_usage("multicast-Entry",
- pool_elts(mfib_entry_pool),
- pool_len(mfib_entry_pool),
- sizeof(mfib_entry_t));
-}
-
-/*
- * The MFIB entry's graph node virtual function table
- */
-static const fib_node_vft_t mfib_entry_vft = {
- .fnv_get = mfib_entry_get_node,
- .fnv_last_lock = mfib_entry_last_lock_gone,
- .fnv_back_walk = mfib_entry_back_walk_notify,
- .fnv_mem_show = mfib_entry_show_memory,
-};
-
u32
mfib_entry_child_add (fib_node_index_t mfib_entry_index,
fib_node_type_t child_type,
{
mfib_entry_t *mfib_entry;
- pool_get(mfib_entry_pool, mfib_entry);
+ pool_get_aligned(mfib_entry_pool, mfib_entry, CLIB_CACHE_LINE_BYTES);
fib_node_init(&mfib_entry->mfe_node,
FIB_NODE_TYPE_MFIB_ENTRY);
mfib_entry->mfe_srcs = NULL;
mfib_entry->mfe_itfs = NULL;
mfib_entry->mfe_rpf_id = MFIB_RPF_ID_NONE;
+ mfib_entry->mfe_pl = FIB_NODE_INDEX_INVALID;
dpo_reset(&mfib_entry->mfe_rep);
mfib_entry_src_t *msrc;
} mfib_entry_collect_forwarding_ctx_t;
-static int
+static fib_path_list_walk_rc_t
mfib_entry_src_collect_forwarding (fib_node_index_t pl_index,
fib_node_index_t path_index,
void *arg)
*/
if (!fib_path_is_resolved(path_index))
{
- return (!0);
+ return (FIB_PATH_LIST_WALK_CONTINUE);
}
/*
if (NULL != path_ext &&
!(path_ext->mfpe_flags & MFIB_ITF_FLAG_FORWARD))
{
- return (!0);
+ return (FIB_PATH_LIST_WALK_CONTINUE);
}
switch (ctx->fct)
break;
}
- return (!0);
+ return (FIB_PATH_LIST_WALK_CONTINUE);
}
static void
dp = fib_proto_to_dpo(mfib_entry_get_proto(mfib_entry));
+ /*
+ * unlink the enty from the previous path list.
+ */
+ if (FIB_NODE_INDEX_INVALID != mfib_entry->mfe_pl)
+ {
+ fib_path_list_child_remove(mfib_entry->mfe_pl,
+ mfib_entry->mfe_sibling);
+ }
+
if (NULL != msrc &&
FIB_NODE_INDEX_INVALID != msrc->mfes_pl)
{
dpo_reset(&ctx.next_hops[0].path_dpo);
vec_free(ctx.next_hops);
}
+
+ /*
+ * link the entry to the path-list.
+ * The entry needs to be a child so that we receive the back-walk
+ * updates to recalculate forwarding.
+ */
+ mfib_entry->mfe_pl = msrc->mfes_pl;
+ mfib_entry->mfe_sibling =
+ fib_path_list_child_add(mfib_entry->mfe_pl,
+ FIB_NODE_TYPE_MFIB_ENTRY,
+ mfib_entry_get_index(mfib_entry));
}
else
{
* entry
*/
fib_node_index_t old_pl_index;
- fib_protocol_t fp;
+ dpo_proto_t dp;
dpo_id_t dpo = DPO_INVALID;
- fp = mfib_entry_get_proto(mfib_entry);
+ dp = fib_proto_to_dpo(mfib_entry_get_proto(mfib_entry));
old_pl_index = msrc->mfes_pl;
- dpo_set(&dpo, DPO_REPLICATE,
- fib_proto_to_dpo(fp),
- repi);
+ dpo_set(&dpo, DPO_REPLICATE, dp, repi);
msrc->mfes_pl =
- fib_path_list_create_special(fp,
+ fib_path_list_create_special(dp,
FIB_PATH_LIST_FLAG_EXCLUSIVE,
&dpo);
*mfib_entry_index2));
}
+static void
+mfib_entry_last_lock_gone (fib_node_t *node)
+{
+ mfib_entry_t *mfib_entry;
+ mfib_entry_src_t *msrc;
+
+ mfib_entry = mfib_entry_from_fib_node(node);
+
+ dpo_reset(&mfib_entry->mfe_rep);
+
+ MFIB_ENTRY_DBG(mfib_entry, "last-lock");
+
+ vec_foreach(msrc, mfib_entry->mfe_srcs)
+ {
+ mfib_entry_src_flush(msrc);
+ }
+
+ vec_free(mfib_entry->mfe_srcs);
+
+ fib_node_deinit(&mfib_entry->mfe_node);
+ pool_put(mfib_entry_pool, mfib_entry);
+}
+
+/*
+ * mfib_entry_back_walk_notify
+ *
+ * A back walk has reach this entry.
+ */
+static fib_node_back_walk_rc_t
+mfib_entry_back_walk_notify (fib_node_t *node,
+ fib_node_back_walk_ctx_t *ctx)
+{
+ mfib_entry_recalculate_forwarding(mfib_entry_from_fib_node(node));
+
+ return (FIB_NODE_BACK_WALK_CONTINUE);
+}
+
+static void
+mfib_entry_show_memory (void)
+{
+ fib_show_memory_usage("multicast-Entry",
+ pool_elts(mfib_entry_pool),
+ pool_len(mfib_entry_pool),
+ sizeof(mfib_entry_t));
+}
+
+/*
+ * The MFIB entry's graph node virtual function table
+ */
+static const fib_node_vft_t mfib_entry_vft = {
+ .fnv_get = mfib_entry_get_node,
+ .fnv_last_lock = mfib_entry_last_lock_gone,
+ .fnv_back_walk = mfib_entry_back_walk_notify,
+ .fnv_mem_show = mfib_entry_show_memory,
+};
+
void
mfib_entry_lock (fib_node_index_t mfib_entry_index)
{