summaryrefslogtreecommitdiffstats
path: root/src/vnet/fib/fib_node.h
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2017-11-25 10:04:32 -0800
committerDamjan Marion <dmarion.lists@gmail.com>2017-11-26 19:16:30 +0000
commit630b9741659b9a4b68c64ebbeb675761c6f26842 (patch)
treea47618e43d9b0598b1be3f8804fd5a139034c782 /src/vnet/fib/fib_node.h
parent020df9a7a55ebf9e06db3f24982efe5fdd68ebb9 (diff)
FIB: store the node type not the function pointer.
Saves memory at no appreciable performance cost. before: DBGvpp# sh fib mem FIB memory Name Size in-use /allocated totals Entry 80 7 / 150 560/12000 after: DBGvpp# sh fib mem FIB memory Name Size in-use /allocated totals Entry 72 7 / 7 504/504 Change-Id: Ic5d3920ceb57b54260dc9af2078c26484335fef1 Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/fib/fib_node.h')
-rw-r--r--src/vnet/fib/fib_node.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/vnet/fib/fib_node.h b/src/vnet/fib/fib_node.h
index d4c96c90b77..532efd54dee 100644
--- a/src/vnet/fib/fib_node.h
+++ b/src/vnet/fib/fib_node.h
@@ -52,7 +52,7 @@ typedef enum fib_node_type_t_ {
*/
FIB_NODE_TYPE_TEST,
FIB_NODE_TYPE_LAST = FIB_NODE_TYPE_TEST,
-} fib_node_type_t;
+} __attribute__ ((packed)) fib_node_type_t;
#define FIB_NODE_TYPE_MAX (FIB_NODE_TYPE_LAST + 1)
@@ -284,18 +284,21 @@ typedef struct fib_node_vft_t_ {
* Objects in the FIB form a graph.
*/
typedef struct fib_node_t_ {
-#if CLIB_DEBUG > 0
/**
* The node's type. make sure we are dynamic/down casting correctly
*/
fib_node_type_t fn_type;
-#endif
+
+ /**
+ * Some pad space the concrete/derived type is free to use
+ */
+ u16 fn_pad;
/**
* The node's VFT.
* we could store the type here instead, and lookup the VFT using that. But
* I like this better,
*/
- const fib_node_vft_t *fn_vft;
+// const fib_node_vft_t *fn_vft;
/**
* Vector of nodes that depend upon/use/share this node
@@ -309,6 +312,8 @@ typedef struct fib_node_t_ {
u32 fn_locks;
} fib_node_t;
+STATIC_ASSERT(sizeof(fib_node_t) == 12, "FIB node type is growing");
+
/**
* @brief
* Register the function table for a given type