aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/fib
diff options
context:
space:
mode:
authorNeale Ranns <neale@graphiant.com>2021-12-02 17:07:14 +0000
committerBeno�t Ganne <bganne@cisco.com>2021-12-03 09:04:44 +0000
commit2008912b56abbf3167faf9b787df76605684d9e1 (patch)
treeb63ea2c8365fa7f1ab93379ba9ccad257e9811cf /src/vnet/fib
parentf68798626c7d4704acfa68751e52f087ca67a13a (diff)
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
Diffstat (limited to 'src/vnet/fib')
-rw-r--r--src/vnet/fib/fib_node.c45
-rw-r--r--src/vnet/fib/fib_node.h8
2 files changed, 33 insertions, 20 deletions
diff --git a/src/vnet/fib/fib_node.c b/src/vnet/fib/fib_node.c
index 1d3abd50a9d..ff72bcfde40 100644
--- a/src/vnet/fib/fib_node.c
+++ b/src/vnet/fib/fib_node.c
@@ -31,23 +31,20 @@ static fib_node_type_t last_new_type = FIB_NODE_TYPE_LAST;
/*
* 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 @@ fib_node_type_get_name (fib_node_type_t 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)
+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 @@ fib_node_register_type (fib_node_type_t type,
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 dd266ee8ff9..b6089ec7b35 100644
--- a/src/vnet/fib/fib_node.h
+++ b/src/vnet/fib/fib_node.h
@@ -306,7 +306,6 @@ typedef struct fib_node_vft_t_ {
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 @@ extern void fib_node_register_type (fib_node_type_t ft,
* @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