aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/fib
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2017-11-29 00:59:31 -0800
committerDamjan Marion <dmarion.lists@gmail.com>2017-11-29 11:17:08 +0000
commitc87aafad759f92ae630fec52079a08ace607410b (patch)
tree36d534722eccc9ea03144eb42bf6104bf1dd294e /src/vnet/fib
parent72454dd4c5196594b366883bbf732c9e067c64ec (diff)
Include allocated table memory in 'sh fib mem' output
DBGvpp# sh fib mem 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 Change-Id: I8c8f6f1c87502a40265bf4f302d0daef111a4a4e Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/fib')
-rw-r--r--src/vnet/fib/fib_node.c35
-rw-r--r--src/vnet/fib/fib_table.c10
-rw-r--r--src/vnet/fib/fib_table.h5
-rw-r--r--src/vnet/fib/ip4_fib.c81
-rw-r--r--src/vnet/fib/ip4_fib.h1
-rw-r--r--src/vnet/fib/ip6_fib.c12
-rw-r--r--src/vnet/fib/ip6_fib.h2
-rw-r--r--src/vnet/fib/mpls_fib.c12
-rw-r--r--src/vnet/fib/mpls_fib.h2
9 files changed, 148 insertions, 12 deletions
diff --git a/src/vnet/fib/fib_node.c b/src/vnet/fib/fib_node.c
index 54c300aec1e..d2e3f04de27 100644
--- a/src/vnet/fib/fib_node.c
+++ b/src/vnet/fib/fib_node.c
@@ -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
@@ -234,6 +236,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 %=8s", "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 +262,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) = {
diff --git a/src/vnet/fib/fib_table.c b/src/vnet/fib/fib_table.c
index 4dd6e7c5421..80e5a0fe1a0 100644
--- a/src/vnet/fib/fib_table.c
+++ b/src/vnet/fib/fib_table.c
@@ -1296,3 +1296,13 @@ fib_table_flush (u32 fib_index,
vec_free(ctx.ftf_entries);
}
+
+u8 *
+format_fib_table_memory (u8 *s, va_list *args)
+{
+ s = format(s, "%U", format_ip4_fib_table_memory);
+ s = format(s, "%U", format_ip6_fib_table_memory);
+ s = format(s, "%U", format_mpls_fib_table_memory);
+
+ return (s);
+}
diff --git a/src/vnet/fib/fib_table.h b/src/vnet/fib/fib_table.h
index d2522aa50c8..8a0c73968fb 100644
--- a/src/vnet/fib/fib_table.h
+++ b/src/vnet/fib/fib_table.h
@@ -808,4 +808,9 @@ extern void fib_table_walk(u32 fib_index,
fib_table_walk_fn_t fn,
void *ctx);
+/**
+ * @brief format (display) the memory used by the FIB tables
+ */
+extern u8 *format_fib_table_memory(u8 *s, va_list *args);
+
#endif
diff --git a/src/vnet/fib/ip4_fib.c b/src/vnet/fib/ip4_fib.c
index 36cf6e73629..45f197444e4 100644
--- a/src/vnet/fib/ip4_fib.c
+++ b/src/vnet/fib/ip4_fib.c
@@ -481,6 +481,43 @@ ip4_fib_table_show_one (ip4_fib_t *fib,
FIB_ENTRY_FORMAT_DETAIL));
}
+u8 *
+format_ip4_fib_table_memory (u8 * s, va_list * args)
+{
+ fib_table_t *fib_table;
+ u64 total_memory;
+
+ total_memory = 0;
+
+ pool_foreach (fib_table, ip4_main.fibs,
+ ({
+ ip4_fib_t *fib;
+ uword fib_size;
+ int i;
+
+ fib = pool_elt_at_index(ip4_main.v4_fibs, fib_table->ft_index);
+ fib_size = ip4_fib_mtrie_memory_usage(&fib->mtrie);
+
+ for (i = 0; i < ARRAY_LEN (fib->fib_entry_by_dst_address); i++)
+ {
+ uword * hash = fib->fib_entry_by_dst_address[i];
+
+ if (NULL != hash)
+ {
+ fib_size += hash_bytes(hash);
+ }
+ }
+
+ total_memory += fib_size;
+ }));
+
+ s = format(s, "%=30s %=6d %=8ld\n",
+ "IPv4 unicast",
+ pool_elts(ip4_main.fibs), total_memory);
+
+ return (s);
+}
+
static clib_error_t *
ip4_show_fib (vlib_main_t * vm,
unformat_input_t * input,
@@ -488,15 +525,17 @@ ip4_show_fib (vlib_main_t * vm,
{
ip4_main_t * im4 = &ip4_main;
fib_table_t * fib_table;
- int verbose, matching, mtrie;
+ u64 total_mtrie_memory, total_hash_memory;
+ int verbose, matching, mtrie, memory;
ip4_address_t matching_address;
u32 matching_mask = 32;
int i, table_id = -1, fib_index = ~0;
int detail = 0;
verbose = 1;
- matching = 0;
- mtrie = 0;
+ matching = mtrie = memory = 0;
+ total_hash_memory = total_mtrie_memory = 0;
+
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (input, "brief") || unformat (input, "summary")
@@ -509,6 +548,10 @@ ip4_show_fib (vlib_main_t * vm,
else if (unformat (input, "mtrie"))
mtrie = 1;
+ else if (unformat (input, "mem") ||
+ unformat (input, "memory"))
+ memory = 1;
+
else if (unformat (input, "%U/%d",
unformat_ip4_address, &matching_address, &matching_mask))
matching = 1;
@@ -535,6 +578,32 @@ ip4_show_fib (vlib_main_t * vm,
if (fib_index != ~0 && fib_index != (int)fib->index)
continue;
+ if (memory)
+ {
+ uword mtrie_size, hash_size;
+
+ mtrie_size = ip4_fib_mtrie_memory_usage(&fib->mtrie);
+ hash_size = 0;
+
+ for (i = 0; i < ARRAY_LEN (fib->fib_entry_by_dst_address); i++)
+ {
+ uword * hash = fib->fib_entry_by_dst_address[i];
+ if (NULL != hash)
+ {
+ hash_size += hash_bytes(hash);
+ }
+ }
+ if (verbose)
+ vlib_cli_output (vm, "%U mtrie:%d hash:%d",
+ format_fib_table_name, fib->index,
+ FIB_PROTOCOL_IP4,
+ mtrie_size,
+ hash_size);
+ total_mtrie_memory += mtrie_size;
+ total_hash_memory += hash_size;
+ continue;
+ }
+
s = format(s, "%U, fib_index:%d, flow hash:[%U] locks:[",
format_fib_table_name, fib->index,
FIB_PROTOCOL_IP4,
@@ -584,6 +653,12 @@ ip4_show_fib (vlib_main_t * vm,
}
}));
+ if (memory)
+ vlib_cli_output (vm, "totals: mtrie:%ld hash:%ld all:%ld",
+ total_mtrie_memory,
+ total_hash_memory,
+ total_mtrie_memory + total_hash_memory);
+
return 0;
}
diff --git a/src/vnet/fib/ip4_fib.h b/src/vnet/fib/ip4_fib.h
index 495b45ccab4..438eb2405bf 100644
--- a/src/vnet/fib/ip4_fib.h
+++ b/src/vnet/fib/ip4_fib.h
@@ -131,6 +131,7 @@ extern u32 ip4_fib_table_find_or_create_and_lock(u32 table_id,
fib_source_t src);
extern u32 ip4_fib_table_create_and_lock(fib_source_t src);
+extern u8 *format_ip4_fib_table_memory(u8 * s, va_list * args);
static inline
u32 ip4_fib_index_from_table_id (u32 table_id)
diff --git a/src/vnet/fib/ip6_fib.c b/src/vnet/fib/ip6_fib.c
index f37ae0d2f45..3400987018f 100644
--- a/src/vnet/fib/ip6_fib.c
+++ b/src/vnet/fib/ip6_fib.c
@@ -524,6 +524,18 @@ ip6_fib_table_show_one (ip6_fib_t *fib,
FIB_ENTRY_FORMAT_DETAIL));
}
+u8 *
+format_ip6_fib_table_memory (u8 * s, va_list * args)
+{
+ s = format(s, "%=30s %=6d %=8ld\n",
+ "IPv6 unicast",
+ pool_elts(ip6_main.fibs),
+ mheap_bytes(ip6_main.ip6_table[IP6_FIB_TABLE_NON_FWDING].ip6_hash.mheap) +
+ mheap_bytes(ip6_main.ip6_table[IP6_FIB_TABLE_FWDING].ip6_hash.mheap));
+
+ return (s);
+}
+
typedef struct {
u32 fib_index;
u64 count_by_prefix_length[129];
diff --git a/src/vnet/fib/ip6_fib.h b/src/vnet/fib/ip6_fib.h
index 9728eecca8b..eda53628b01 100644
--- a/src/vnet/fib/ip6_fib.h
+++ b/src/vnet/fib/ip6_fib.h
@@ -148,6 +148,8 @@ extern u32 ip6_fib_table_find_or_create_and_lock(u32 table_id,
fib_source_t src);
extern u32 ip6_fib_table_create_and_lock(fib_source_t src);
+extern u8 *format_ip6_fib_table_memory(u8 * s, va_list * args);
+
static inline ip6_fib_t *
ip6_fib_get (fib_node_index_t index)
{
diff --git a/src/vnet/fib/mpls_fib.c b/src/vnet/fib/mpls_fib.c
index 4eeef7abb73..15931203122 100644
--- a/src/vnet/fib/mpls_fib.c
+++ b/src/vnet/fib/mpls_fib.c
@@ -359,6 +359,18 @@ mpls_fib_table_walk (mpls_fib_t *mpls_fib,
}));
}
+u8 *
+format_mpls_fib_table_memory (u8 * s, va_list * args)
+{
+ u64 n_tables, mem;
+
+ n_tables = pool_elts(mpls_main.fibs);
+ mem = n_tables * sizeof(mpls_fib_t);
+ s = format(s, "%=30s %=6ld %=8ld\n", "MPLS", n_tables, mem);
+
+ return (s);
+}
+
static void
mpls_fib_table_show_all (const mpls_fib_t *mpls_fib,
vlib_main_t * vm)
diff --git a/src/vnet/fib/mpls_fib.h b/src/vnet/fib/mpls_fib.h
index 29cd1d20dab..9e0c7d76ff8 100644
--- a/src/vnet/fib/mpls_fib.h
+++ b/src/vnet/fib/mpls_fib.h
@@ -105,6 +105,8 @@ extern void mpls_fib_table_walk(mpls_fib_t *fib,
fib_table_walk_fn_t fn,
void *ctx);
+extern u8 *format_mpls_fib_table_memory(u8 * s, va_list * args);
+
/**
* @brief
* Lookup a label and EOS bit in the MPLS_FIB table to retrieve the