ipsec: make pre-shared keys harder to misuse
[vpp.git] / src / vnet / fib / fib_node.c
index 54c300a..ff72bcf 100644 (file)
@@ -15,6 +15,8 @@
 
 #include <vnet/fib/fib_node.h>
 #include <vnet/fib/fib_node_list.h>
+#include <vnet/fib/fib_table.h>
+#include <vnet/mfib/mfib_table.h>
 
 /*
  * The per-type vector of virtual function tables
@@ -29,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");
     }
 }
 
@@ -54,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
@@ -72,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);
 }   
@@ -159,7 +174,7 @@ fib_node_back_walk_one (fib_node_ptr_t *ptr,
     return (fn_vfts[ptr->fnp_type].fnv_back_walk(node, ctx));
 }
 
-static int
+static walk_rc_t
 fib_node_ptr_format_one_child (fib_node_ptr_t *ptr,
                               void *arg)
 {
@@ -167,7 +182,7 @@ fib_node_ptr_format_one_child (fib_node_ptr_t *ptr,
 
     *s = fib_node_format(ptr, *s);
 
-    return (1);
+    return (WALK_CONTINUE);
 }
 
 u8*
@@ -234,6 +249,11 @@ fib_memory_show (vlib_main_t * vm,
     fib_node_vft_t *vft;
 
     vlib_cli_output (vm, "FIB memory");
+    vlib_cli_output (vm, "  Tables:");
+    vlib_cli_output (vm, "%=30s %=6s %=12s", "SAFI", "Number", "Bytes");
+    vlib_cli_output (vm, "%U", format_fib_table_memory);
+    vlib_cli_output (vm, "%U", format_mfib_table_memory);
+    vlib_cli_output (vm, "  Nodes:");
     vlib_cli_output (vm, "%=30s %=5s %=8s/%=9s   totals",
                     "Name","Size", "in-use", "allocated");
 
@@ -255,15 +275,25 @@ fib_memory_show (vlib_main_t * vm,
  *
  * @cliexpar
  * @cliexstart{show fib memory}
- * FIB memory
- *             Name               Size  in-use /allocated   totals
- *             Entry              120     11   /    11      1320/1320
- *         Entry Source            32     11   /    11      352/352
- *     Entry Path-Extensions       44      0   /    0       0/0
- *           Path-list             40     11   /    11      440/440
- *             Path                88     11   /    11      968/968
- *      Node-list elements         20     11   /    11      220/220
- *        Node-list heads          8      13   /    13      104/104
+ *FIB memory
+ * Tables:
+ *            SAFI              Number   Bytes
+ *        IPv4 unicast             2    673066
+ *        IPv6 unicast             2    1054608
+ *            MPLS                 1    4194312
+ *       IPv4 multicast            2     2322
+ *       IPv6 multicast            2      ???
+ * Nodes:
+ *            Name               Size  in-use /allocated   totals
+ *            Entry               96     20   /    20      1920/1920
+ *        Entry Source            32      0   /    0       0/0
+ *    Entry Path-Extensions       60      0   /    0       0/0
+ *       multicast-Entry         192     12   /    12      2304/2304
+ *          Path-list             40     28   /    28      1120/1120
+ *          uRPF-list             16     20   /    20      320/320
+ *            Path                72     28   /    28      2016/2016
+ *     Node-list elements         20     28   /    28      560/560
+ *       Node-list heads          8      30   /    30      240/240
  * @cliexend
 ?*/
 VLIB_CLI_COMMAND (show_fib_memory, static) = {