summaryrefslogtreecommitdiffstats
path: root/src/vnet/fib
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/fib')
-rw-r--r--src/vnet/fib/fib_entry.c23
-rw-r--r--src/vnet/fib/fib_path.c4
-rw-r--r--src/vnet/fib/fib_table.h8
-rw-r--r--src/vnet/fib/fib_types.c15
-rw-r--r--src/vnet/fib/fib_types.h4
-rw-r--r--src/vnet/fib/ip4_fib.c5
-rw-r--r--src/vnet/fib/ip6_fib.c6
7 files changed, 59 insertions, 6 deletions
diff --git a/src/vnet/fib/fib_entry.c b/src/vnet/fib/fib_entry.c
index 0e5482840bf..d8c57fd1032 100644
--- a/src/vnet/fib/fib_entry.c
+++ b/src/vnet/fib/fib_entry.c
@@ -1713,6 +1713,29 @@ fib_entry_pool_size (void)
return (pool_elts(fib_entry_pool));
}
+#ifdef CLIB_DEBUG
+void
+fib_table_assert_empty (const fib_table_t *fib_table)
+{
+ fib_node_index_t *fei, *feis = NULL;
+ fib_entry_t *fib_entry;
+
+ pool_foreach (fib_entry, fib_entry_pool,
+ ({
+ if (fib_entry->fe_fib_index == fib_table->ft_index)
+ vec_add1 (feis, fib_entry_get_index(fib_entry));
+ }));
+
+ if (vec_len(feis))
+ {
+ vec_foreach (fei, feis)
+ clib_error ("%U", format_fib_entry, *fei, FIB_ENTRY_FORMAT_DETAIL);
+ }
+
+ ASSERT(0);
+}
+#endif
+
static clib_error_t *
show_fib_entry_command (vlib_main_t * vm,
unformat_input_t * input,
diff --git a/src/vnet/fib/fib_path.c b/src/vnet/fib/fib_path.c
index 1eb195d3a52..ef5d58c9e2b 100644
--- a/src/vnet/fib/fib_path.c
+++ b/src/vnet/fib/fib_path.c
@@ -1590,8 +1590,8 @@ fib_path_cmp_i (const fib_path_t *path1,
path2->attached.fp_interface);
break;
case FIB_PATH_TYPE_RECURSIVE:
- res = ip46_address_cmp(&path1->recursive.fp_nh,
- &path2->recursive.fp_nh);
+ res = ip46_address_cmp(&path1->recursive.fp_nh.fp_ip,
+ &path2->recursive.fp_nh.fp_ip);
if (0 == res)
{
diff --git a/src/vnet/fib/fib_table.h b/src/vnet/fib/fib_table.h
index 59ebb0b0161..a11f0560338 100644
--- a/src/vnet/fib/fib_table.h
+++ b/src/vnet/fib/fib_table.h
@@ -957,4 +957,12 @@ extern void fib_table_sub_tree_walk(u32 fib_index,
*/
extern u8 *format_fib_table_memory(u8 *s, va_list *args);
+/**
+ * Debug function
+ */
+#ifdef CLIB_DEBUG
+extern void fib_table_assert_empty(const fib_table_t *fib_table);
+#endif
+
+
#endif
diff --git a/src/vnet/fib/fib_types.c b/src/vnet/fib/fib_types.c
index 3ac5c1d1183..c859913eeff 100644
--- a/src/vnet/fib/fib_types.c
+++ b/src/vnet/fib/fib_types.c
@@ -166,6 +166,21 @@ fib_prefix_is_cover (const fib_prefix_t *p1,
return (0);
}
+u8
+fib_prefix_get_host_length (fib_protocol_t proto)
+{
+ switch (proto)
+ {
+ case FIB_PROTOCOL_IP4:
+ return (32);
+ case FIB_PROTOCOL_IP6:
+ return (128);
+ case FIB_PROTOCOL_MPLS:
+ return (21);
+ }
+ return (0);
+}
+
int
fib_prefix_is_host (const fib_prefix_t *prefix)
{
diff --git a/src/vnet/fib/fib_types.h b/src/vnet/fib/fib_types.h
index 11e5bf4ebae..333b2abd240 100644
--- a/src/vnet/fib/fib_types.h
+++ b/src/vnet/fib/fib_types.h
@@ -18,7 +18,7 @@
#include <stdbool.h>
#include <vlib/vlib.h>
-#include <vnet/ip/ip6_packet.h>
+#include <vnet/ip/ip46_address.h>
#include <vnet/mpls/packet.h>
#include <vnet/dpo/dpo.h>
#include <vnet/bier/bier_types.h>
@@ -265,7 +265,7 @@ extern int fib_prefix_is_cover(const fib_prefix_t *p1,
* \brief Return true is the prefix is a host prefix
*/
extern int fib_prefix_is_host(const fib_prefix_t *p);
-
+extern u8 fib_prefix_get_host_length (fib_protocol_t proto);
/**
* \brief Host prefix from ip
diff --git a/src/vnet/fib/ip4_fib.c b/src/vnet/fib/ip4_fib.c
index e4ff1bf77cc..d4ef698bc9a 100644
--- a/src/vnet/fib/ip4_fib.c
+++ b/src/vnet/fib/ip4_fib.c
@@ -182,7 +182,10 @@ ip4_fib_table_destroy (u32 fib_index)
/*
* validate no more routes.
*/
- ASSERT(0 == fib_table->ft_total_route_counts);
+#ifdef CLIB_DEBUG
+ if (0 != fib_table->ft_total_route_counts)
+ fib_table_assert_empty(fib_table);
+#endif
vec_foreach(n_locks, fib_table->ft_src_route_counts)
{
diff --git a/src/vnet/fib/ip6_fib.c b/src/vnet/fib/ip6_fib.c
index 06160c5a15a..784f52c0460 100644
--- a/src/vnet/fib/ip6_fib.c
+++ b/src/vnet/fib/ip6_fib.c
@@ -154,7 +154,11 @@ ip6_fib_table_destroy (u32 fib_index)
/*
* validate no more routes.
*/
- ASSERT(0 == fib_table->ft_total_route_counts);
+#ifdef CLIB_DEBUG
+ if (0 != fib_table->ft_total_route_counts)
+ fib_table_assert_empty(fib_table);
+#endif
+
vec_foreach_index(source, fib_table->ft_src_route_counts)
{
ASSERT(0 == fib_table->ft_src_route_counts[source]);