fib: log an error when destroying non-empty tables
Destroying a non-empty fib table can lead to difficult to diagnose bugs,
like dandling fib entries preventing entries to be inserting to the
mtrie.
Always log an error to help diagnose those issues.
Type: improvement
Change-Id: I2c771a80595035b440931b74cca4429af22161a2
Signed-off-by: Benoît Ganne <bganne@cisco.com>
diff --git a/src/vnet/fib/fib_entry.c b/src/vnet/fib/fib_entry.c
index b78346c..adf880b 100644
--- a/src/vnet/fib/fib_entry.c
+++ b/src/vnet/fib/fib_entry.c
@@ -1828,10 +1828,18 @@
return (pool_elts(fib_entry_pool));
}
-#if CLIB_DEBUG > 0
void
fib_table_assert_empty (const fib_table_t *fib_table)
{
+ if (0 == fib_table->ft_total_route_counts)
+ return;
+
+ vlib_log_err (fib_entry_logger,
+ "BUG: %U table %d (index %d) is not empty",
+ format_fib_protocol, fib_table->ft_proto,
+ fib_table->ft_table_id, fib_table->ft_index);
+
+#if CLIB_DEBUG > 0
fib_node_index_t *fei, *feis = NULL;
fib_entry_t *fib_entry;
@@ -1848,8 +1856,8 @@
}
ASSERT(0);
-}
#endif
+}
static clib_error_t *
show_fib_entry_command (vlib_main_t * vm,