+static walk_rc_t
+mfib_table_mark_cb (fib_node_index_t fib_entry_index,
+ void *arg)
+{
+ mfib_table_flush_ctx_t *ctx = arg;
+
+ if (mfib_entry_is_sourced(fib_entry_index, ctx->mftf_source))
+ {
+ mfib_entry_mark(fib_entry_index, ctx->mftf_source);
+ }
+ return (WALK_CONTINUE);
+}
+
+void
+mfib_table_mark (u32 fib_index,
+ fib_protocol_t proto,
+ mfib_source_t source)
+{
+ mfib_table_flush_ctx_t ctx = {
+ .mftf_source = source,
+ };
+ mfib_table_t *mfib_table;
+
+ mfib_table = mfib_table_get(fib_index, proto);
+
+ mfib_table->mft_epoch++;
+ mfib_table->mft_flags |= MFIB_TABLE_FLAG_RESYNC;
+
+ mfib_table_walk(fib_index, proto,
+ mfib_table_mark_cb,
+ &ctx);
+}
+
+static walk_rc_t
+mfib_table_sweep_cb (fib_node_index_t fib_entry_index,
+ void *arg)
+{
+ mfib_table_flush_ctx_t *ctx = arg;
+
+ if (mfib_entry_is_marked(fib_entry_index, ctx->mftf_source))
+ {
+ vec_add1(ctx->mftf_entries, fib_entry_index);
+ }
+ return (WALK_CONTINUE);
+}
+
+void
+mfib_table_sweep (u32 fib_index,
+ fib_protocol_t proto,
+ mfib_source_t source)
+{
+ mfib_table_flush_ctx_t ctx = {
+ .mftf_source = source,
+ };
+ fib_node_index_t *fib_entry_index;
+ mfib_table_t *mfib_table;
+
+ mfib_table = mfib_table_get(fib_index, proto);
+
+ mfib_table->mft_flags &= ~MFIB_TABLE_FLAG_RESYNC;
+
+ mfib_table_walk(fib_index, proto,
+ mfib_table_sweep_cb,
+ &ctx);
+
+ vec_foreach(fib_entry_index, ctx.mftf_entries)
+ {
+ mfib_table_entry_delete_index(*fib_entry_index, source);
+ }
+
+ vec_free(ctx.mftf_entries);
+}
+