fib: Fix the display (or lack of) for fib node types in dependent children lists
Type: fix
When registering a new FIB node type, no name was required on the API, and so no name was printed.
Signed-off-by: Neale Ranns <neale@graphiant.com>
Change-Id: I8a99cf29c194637a550061b0a5e9782ffe8b31dd
diff --git a/src/plugins/abf/abf_itf_attach.c b/src/plugins/abf/abf_itf_attach.c
index 4f17f72..6f85ff6 100644
--- a/src/plugins/abf/abf_itf_attach.c
+++ b/src/plugins/abf/abf_itf_attach.c
@@ -760,7 +760,7 @@
abf_itf_bond_init (vlib_main_t * vm)
{
abf_itf_attach_fib_node_type =
- fib_node_register_new_type (&abf_itf_attach_vft);
+ fib_node_register_new_type ("abf-attach", &abf_itf_attach_vft);
clib_error_t *acl_init_res = acl_plugin_exports_init (&acl_plugin);
if (acl_init_res)
return (acl_init_res);
diff --git a/src/plugins/abf/abf_policy.c b/src/plugins/abf/abf_policy.c
index 945434b..1921df1 100644
--- a/src/plugins/abf/abf_policy.c
+++ b/src/plugins/abf/abf_policy.c
@@ -456,7 +456,8 @@
static clib_error_t *
abf_policy_init (vlib_main_t * vm)
{
- abf_policy_fib_node_type = fib_node_register_new_type (&abf_policy_vft);
+ abf_policy_fib_node_type =
+ fib_node_register_new_type ("abf-policy", &abf_policy_vft);
return (NULL);
}
diff --git a/src/plugins/cnat/cnat_translation.c b/src/plugins/cnat/cnat_translation.c
index 049809a..748d531 100644
--- a/src/plugins/cnat/cnat_translation.c
+++ b/src/plugins/cnat/cnat_translation.c
@@ -825,7 +825,7 @@
ip6_main_t *i6m = &ip6_main;
cnat_main_t *cm = &cnat_main;
cnat_translation_fib_node_type =
- fib_node_register_new_type (&cnat_translation_vft);
+ fib_node_register_new_type ("cnat-translation", &cnat_translation_vft);
clib_bihash_init_8_8 (&cnat_translation_db, "CNat translation DB",
cm->translation_hash_buckets,
diff --git a/src/plugins/gtpu/gtpu.c b/src/plugins/gtpu/gtpu.c
index 67c91dd..db59670 100644
--- a/src/plugins/gtpu/gtpu.c
+++ b/src/plugins/gtpu/gtpu.c
@@ -1262,7 +1262,7 @@
sizeof (ip46_address_t),
sizeof (mcast_shared_t));
- gtm->fib_node_type = fib_node_register_new_type (>pu_vft);
+ gtm->fib_node_type = fib_node_register_new_type ("gtpu", >pu_vft);
return 0;
}
diff --git a/src/plugins/ila/ila.c b/src/plugins/ila/ila.c
index 6e062cb..0672ad9 100644
--- a/src/plugins/ila/ila.c
+++ b/src/plugins/ila/ila.c
@@ -939,7 +939,7 @@
ilm->lookup_table_nbuckets, ilm->lookup_table_size);
ila_dpo_type = dpo_register_new_type(&ila_vft, ila_nodes);
- ila_fib_node_type = fib_node_register_new_type(&ila_fib_node_vft);
+ ila_fib_node_type = fib_node_register_new_type ("ila", &ila_fib_node_vft);
ila_fib_src = fib_source_allocate("ila",
FIB_SOURCE_PRIORITY_HI,
FIB_SOURCE_BH_SIMPLE);
diff --git a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_ioam.c b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_ioam.c
index 59798dc..870de92 100644
--- a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_ioam.c
+++ b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_ioam.c
@@ -751,7 +751,8 @@
vxlan_gpe_ioam_interface_init (void)
{
vxlan_gpe_ioam_main_t *hm = &vxlan_gpe_ioam_main;
- hm->fib_entry_type = fib_node_register_new_type (&vxlan_gpe_ioam_vft);
+ hm->fib_entry_type =
+ fib_node_register_new_type ("vxlan-gpe", &vxlan_gpe_ioam_vft);
return;
}
diff --git a/src/plugins/l3xc/l3xc.c b/src/plugins/l3xc/l3xc.c
index 021a850..0f7324c 100644
--- a/src/plugins/l3xc/l3xc.c
+++ b/src/plugins/l3xc/l3xc.c
@@ -381,7 +381,7 @@
static clib_error_t *
l3xc_init (vlib_main_t * vm)
{
- l3xc_fib_node_type = fib_node_register_new_type (&l3xc_vft);
+ l3xc_fib_node_type = fib_node_register_new_type ("l3xc", &l3xc_vft);
return (NULL);
}
diff --git a/src/plugins/lb/lb.c b/src/plugins/lb/lb.c
index 6fc7f0f..5bc7cf2 100644
--- a/src/plugins/lb/lb.c
+++ b/src/plugins/lb/lb.c
@@ -1412,7 +1412,7 @@
lb_dpo_nat4_port_nodes);
lbm->dpo_nat6_port_type = dpo_register_new_type(&lb_vft,
lb_dpo_nat6_port_nodes);
- lbm->fib_node_type = fib_node_register_new_type(&lb_fib_node_vft);
+ lbm->fib_node_type = fib_node_register_new_type ("lb", &lb_fib_node_vft);
//Init AS reference counters
vlib_refcount_init(&lbm->as_refcount);
diff --git a/src/plugins/nsh/nsh-md2-ioam/nsh_md2_ioam.c b/src/plugins/nsh/nsh-md2-ioam/nsh_md2_ioam.c
index 63e6a98..b401530 100644
--- a/src/plugins/nsh/nsh-md2-ioam/nsh_md2_ioam.c
+++ b/src/plugins/nsh/nsh-md2-ioam/nsh_md2_ioam.c
@@ -500,7 +500,7 @@
nsh_md2_ioam_interface_init (void)
{
nsh_md2_ioam_main_t *hm = &nsh_md2_ioam_main;
- hm->fib_entry_type = fib_node_register_new_type (&nsh_md2_ioam_vft);
+ hm->fib_entry_type = fib_node_register_new_type ("nsh", &nsh_md2_ioam_vft);
return;
}
diff --git a/src/vnet/fib/fib_node.c b/src/vnet/fib/fib_node.c
index 1d3abd5..ff72bcf 100644
--- a/src/vnet/fib/fib_node.c
+++ b/src/vnet/fib/fib_node.c
@@ -31,23 +31,20 @@
/*
* the node type names
*/
-static const char *fn_type_names[] = FIB_NODE_TYPES;
+static const char *fn_type_builtin_names[] = FIB_NODE_TYPES;
+static const char **fn_type_names;
const char*
fib_node_type_get_name (fib_node_type_t type)
{
- if (type < FIB_NODE_TYPE_LAST)
- return (fn_type_names[type]);
+ if ((type < vec_len(fn_type_names)) &&
+ (NULL != fn_type_names[type]))
+ {
+ return (fn_type_names[type]);
+ }
else
{
- if (NULL != fn_vfts[type].fnv_format)
- {
- return ("fixme");
- }
- else
- {
- return ("unknown");
- }
+ return ("unknown");
}
}
@@ -56,9 +53,10 @@
*
* Register the function table for a given type
*/
-void
-fib_node_register_type (fib_node_type_t type,
- const fib_node_vft_t *vft)
+static void
+fib_node_register_type_i (fib_node_type_t type,
+ const char *name,
+ const fib_node_vft_t *vft)
{
/*
* assert that one only registration is made per-node type
@@ -74,16 +72,31 @@
vec_validate(fn_vfts, type);
fn_vfts[type] = *vft;
+ vec_validate(fn_type_names, type);
+ fn_type_names[type] = name;
+}
+
+/**
+ * fib_node_register_type
+ *
+ * Register the function table for a given type
+ */
+void
+fib_node_register_type (fib_node_type_t type,
+ const fib_node_vft_t *vft)
+{
+ fib_node_register_type_i(type, fn_type_builtin_names[type], vft);
}
fib_node_type_t
-fib_node_register_new_type (const fib_node_vft_t *vft)
+fib_node_register_new_type (const char *name,
+ const fib_node_vft_t *vft)
{
fib_node_type_t new_type;
new_type = ++last_new_type;
- fib_node_register_type(new_type, vft);
+ fib_node_register_type_i(new_type, name, vft);
return (new_type);
}
diff --git a/src/vnet/fib/fib_node.h b/src/vnet/fib/fib_node.h
index dd266ee..b6089ec 100644
--- a/src/vnet/fib/fib_node.h
+++ b/src/vnet/fib/fib_node.h
@@ -306,7 +306,6 @@
fib_node_get_t fnv_get;
fib_node_last_lock_gone_t fnv_last_lock;
fib_node_back_walk_t fnv_back_walk;
- format_function_t *fnv_format;
fib_node_memory_show_t fnv_mem_show;
} fib_node_vft_t;
@@ -357,12 +356,13 @@
* @brief
* Create a new FIB node type and Register the function table for it.
*
- * @param vft
- * virtual function table
+ * @param name Name of the type (as display when printing children)
+ * @param vft virtual function table
*
* @return new FIB node type
*/
-extern fib_node_type_t fib_node_register_new_type (const fib_node_vft_t *vft);
+extern fib_node_type_t fib_node_register_new_type (const char *name,
+ const fib_node_vft_t *vft);
/**
* @brief Show the memory usage for a type
diff --git a/src/vnet/ip/ip_path_mtu.c b/src/vnet/ip/ip_path_mtu.c
index 38adb44..40d8c8f 100644
--- a/src/vnet/ip/ip_path_mtu.c
+++ b/src/vnet/ip/ip_path_mtu.c
@@ -826,7 +826,8 @@
adj_delegate_register_new_type (&ip_path_adj_delegate_vft);
ip_pmtu_source = fib_source_allocate ("path-mtu", FIB_SOURCE_PRIORITY_HI,
FIB_SOURCE_BH_SIMPLE);
- ip_pmtu_fib_type = fib_node_register_new_type (&ip_ptmu_fib_node_vft);
+ ip_pmtu_fib_type =
+ fib_node_register_new_type ("ip-pmtu", &ip_ptmu_fib_node_vft);
ip_pmtu_db = hash_create_mem (0, sizeof (ip_pmtu_key_t), sizeof (index_t));
ip_pmtu_logger = vlib_log_register_class ("ip", "pmtu");
diff --git a/src/vnet/ipip/sixrd.c b/src/vnet/ipip/sixrd.c
index c6c855d..3fb7b52 100644
--- a/src/vnet/ipip/sixrd.c
+++ b/src/vnet/ipip/sixrd.c
@@ -505,7 +505,8 @@
sixrd_adj_delegate_type =
adj_delegate_register_new_type (&sixrd_adj_delegate_vft);
- sixrd_fib_node_type = fib_node_register_new_type (&sixrd_fib_node_vft);
+ sixrd_fib_node_type =
+ fib_node_register_new_type ("sixrd", &sixrd_fib_node_vft);
return error;
}