fib: log an error when destroying non-empty tables 25/39525/6
authorBenoît Ganne <[email protected]>
Wed, 13 Sep 2023 15:21:04 +0000 (17:21 +0200)
committerNeale Ranns <[email protected]>
Fri, 12 Jul 2024 03:05:02 +0000 (03:05 +0000)
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 <[email protected]>
src/vnet/fib/fib_entry.c
src/vnet/fib/fib_table.h
src/vnet/fib/ip4_fib.c
src/vnet/fib/ip6_fib.c

index b78346c..adf880b 100644 (file)
@@ -1828,10 +1828,18 @@ fib_entry_pool_size (void)
     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 @@ fib_table_assert_empty (const fib_table_t *fib_table)
     }
 
     ASSERT(0);
-}
 #endif
+}
 
 static clib_error_t *
 show_fib_entry_command (vlib_main_t * vm,
index 0eaaa67..d78c9e6 100644 (file)
@@ -980,9 +980,7 @@ extern u8 *format_fib_table_memory(u8 *s, va_list *args);
 /**
  * Debug function
  */
-#if CLIB_DEBUG > 0
 extern void fib_table_assert_empty(const fib_table_t *fib_table);
-#endif
 
 
 #endif
index 0eff8d0..23f70a7 100644 (file)
@@ -201,10 +201,7 @@ ip4_fib_table_destroy (u32 fib_index)
     /*
      * validate no more routes.
      */
-#if CLIB_DEBUG > 0
-    if (0 != fib_table->ft_total_route_counts)
-        fib_table_assert_empty(fib_table);
-#endif
+    fib_table_assert_empty(fib_table);
 
     vec_foreach(n_locks, fib_table->ft_src_route_counts)
     {
index d37b77e..ccf8e22 100644 (file)
@@ -160,10 +160,7 @@ ip6_fib_table_destroy (u32 fib_index)
     /*
      * validate no more routes.
      */
-#if CLIB_DEBUG > 0
-    if (0 != fib_table->ft_total_route_counts)
-        fib_table_assert_empty(fib_table);
-#endif
+    fib_table_assert_empty(fib_table);
 
     vec_foreach_index(source, fib_table->ft_src_route_counts)
     {