summaryrefslogtreecommitdiffstats
path: root/src/vnet/mfib
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/mfib')
-rw-r--r--src/vnet/mfib/ip4_mfib.c70
-rw-r--r--src/vnet/mfib/ip4_mfib.h11
-rw-r--r--src/vnet/mfib/ip6_mfib.c30
-rw-r--r--src/vnet/mfib/ip6_mfib.h5
-rw-r--r--src/vnet/mfib/mfib_table.c9
-rw-r--r--src/vnet/mfib/mfib_table.h4
6 files changed, 113 insertions, 16 deletions
diff --git a/src/vnet/mfib/ip4_mfib.c b/src/vnet/mfib/ip4_mfib.c
index b2482580678..7040fa71764 100644
--- a/src/vnet/mfib/ip4_mfib.c
+++ b/src/vnet/mfib/ip4_mfib.c
@@ -305,6 +305,42 @@ ip4_mfib_table_walk (ip4_mfib_t *mfib,
}
}
+u8 *
+format_ip4_mfib_table_memory (u8 * s, va_list * args)
+{
+ mfib_table_t *mfib_table;
+ u64 total_memory;
+
+ total_memory = 0;
+
+ pool_foreach (mfib_table, ip4_main.mfibs,
+ ({
+ ip4_mfib_t *mfib = &mfib_table->v4;
+ uword mfib_size;
+ int i;
+
+ mfib_size = 0;
+
+ for (i = 0; i < ARRAY_LEN (mfib->fib_entry_by_dst_address); i++)
+ {
+ uword * hash = mfib->fib_entry_by_dst_address[i];
+
+ if (NULL != hash)
+ {
+ mfib_size += hash_bytes(hash);
+ }
+ }
+
+ total_memory += mfib_size;
+ }));
+
+ s = format(s, "%=30s %=6d %=8ld\n",
+ "IPv4 multicast",
+ pool_elts(ip4_main.mfibs), total_memory);
+
+ return (s);
+}
+
static void
ip4_mfib_table_show_all (ip4_mfib_t *mfib,
vlib_main_t * vm)
@@ -363,20 +399,23 @@ ip4_show_mfib (vlib_main_t * vm,
{
ip4_main_t * im4 = &ip4_main;
mfib_table_t *mfib_table;
- int verbose, matching;
+ int verbose, matching, memory;
ip4_address_t grp, src = {{0}};
u32 mask = 32;
+ u64 total_hash_memory;
int i, table_id = -1, fib_index = ~0;
verbose = 1;
- matching = 0;
+ memory = matching = 0;
+ total_hash_memory = 0;
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (input, "brief") || unformat (input, "summary")
|| unformat (input, "sum"))
verbose = 0;
-
+ else if (unformat (input, "mem") || unformat (input, "memory"))
+ memory = 1;
else if (unformat (input, "%U %U",
unformat_ip4_address, &src,
unformat_ip4_address, &grp))
@@ -412,6 +451,29 @@ ip4_show_mfib (vlib_main_t * vm,
if (fib_index != ~0 && fib_index != (int)mfib->index)
continue;
+ if (memory)
+ {
+ uword hash_size;
+
+ hash_size = 0;
+
+ for (i = 0; i < ARRAY_LEN (mfib->fib_entry_by_dst_address); i++)
+ {
+ uword * hash = mfib->fib_entry_by_dst_address[i];
+ if (NULL != hash)
+ {
+ hash_size += hash_bytes(hash);
+ }
+ }
+ if (verbose)
+ vlib_cli_output (vm, "%U hash:%d",
+ format_mfib_table_name, mfib->index,
+ FIB_PROTOCOL_IP4,
+ hash_size);
+ total_hash_memory += hash_size;
+ continue;
+ }
+
vlib_cli_output (vm, "%U, fib_index %d",
format_mfib_table_name, mfib->index, FIB_PROTOCOL_IP4,
mfib->index);
@@ -439,6 +501,8 @@ ip4_show_mfib (vlib_main_t * vm,
ip4_mfib_table_show_one(mfib, vm, &src, &grp, mask);
}
}));
+ if (memory)
+ vlib_cli_output (vm, "totals: hash:%ld", total_hash_memory);
return 0;
}
diff --git a/src/vnet/mfib/ip4_mfib.h b/src/vnet/mfib/ip4_mfib.h
index e31fb744b9b..7767d795cad 100644
--- a/src/vnet/mfib/ip4_mfib.h
+++ b/src/vnet/mfib/ip4_mfib.h
@@ -98,8 +98,13 @@ extern u32 ip4_mfib_table_get_index_for_sw_if_index(u32 sw_if_index);
* @param fn The function to invoke on each entry visited
* @param ctx A context passed in the visit function
*/
-extern void ip4_mfib_table_walk (ip4_mfib_t *mfib,
- mfib_table_walk_fn_t fn,
- void *ctx);
+extern void ip4_mfib_table_walk(ip4_mfib_t *mfib,
+ mfib_table_walk_fn_t fn,
+ void *ctx);
+
+/**
+ * @brief format (display) the memory usage for IP4 mfibs
+ */
+extern u8 * format_ip4_mfib_table_memory(u8 * s, va_list * args);
#endif
diff --git a/src/vnet/mfib/ip6_mfib.c b/src/vnet/mfib/ip6_mfib.c
index e4861330654..1c1f5db71f7 100644
--- a/src/vnet/mfib/ip6_mfib.c
+++ b/src/vnet/mfib/ip6_mfib.c
@@ -472,6 +472,16 @@ ip6_mfib_module_init (vlib_main_t * vm)
VLIB_INIT_FUNCTION(ip6_mfib_module_init);
+u8 *
+format_ip6_mfib_table_memory (u8 * s, va_list * args)
+{
+ s = format(s, "%=30s %=6d %=8s\n",
+ "IPv6 multicast",
+ pool_elts(ip6_main.mfibs), "???");
+
+ return (s);
+}
+
static void
ip6_mfib_table_show_one (ip6_mfib_t *mfib,
vlib_main_t * vm,
@@ -566,7 +576,7 @@ ip6_show_mfib (vlib_main_t * vm,
unformat_input_t * input,
vlib_cli_command_t * cmd)
{
- ip6_main_t * im4 = &ip6_main;
+ ip6_main_t * im6 = &ip6_main;
mfib_table_t *mfib_table;
int verbose, matching;
ip6_address_t grp, src = {{0}};
@@ -608,7 +618,7 @@ ip6_show_mfib (vlib_main_t * vm,
break;
}
- pool_foreach (mfib_table, im4->mfibs,
+ pool_foreach (mfib_table, im6->mfibs,
({
ip6_mfib_t *mfib = &mfib_table->v6;
@@ -649,7 +659,7 @@ ip6_show_mfib (vlib_main_t * vm,
}
/*
- * This command displays the IPv4 MulticasrFIB Tables (VRF Tables) and
+ * This command displays the IPv6 MulticasrFIB Tables (VRF Tables) and
* the route entries for each table.
*
* @note This command will run for a long time when the FIB tables are
@@ -657,9 +667,9 @@ ip6_show_mfib (vlib_main_t * vm,
* a single table or summary mode.
*
* @cliexpar
- * Example of how to display all the IPv4 Multicast FIB tables:
+ * Example of how to display all the IPv6 Multicast FIB tables:
* @cliexstart{show ip fib}
- * ipv4-VRF:0, fib_index 0
+ * ipv6-VRF:0, fib_index 0
* (*, 0.0.0.0/0): flags:D,
* Interfaces:
* multicast-ip6-chain
@@ -671,18 +681,18 @@ ip6_show_mfib (vlib_main_t * vm,
* test-eth0: Accept,
* multicast-ip6-chain
* [@2]: dpo-replicate: [index:1 buckets:2 to:[0:0]]
- * [0] [@1]: ipv4-mcast: test-eth1: IP6: d0:d1:d2:d3:d4:01 -> 01:00:05:00:00:00
- * [1] [@1]: ipv4-mcast: test-eth2: IP6: d0:d1:d2:d3:d4:02 -> 01:00:05:00:00:00
+ * [0] [@1]: ipv6-mcast: test-eth1: IP6: d0:d1:d2:d3:d4:01 -> 01:00:05:00:00:00
+ * [1] [@1]: ipv6-mcast: test-eth2: IP6: d0:d1:d2:d3:d4:02 -> 01:00:05:00:00:00
*
* @cliexend
- * Example of how to display a summary of all IPv4 FIB tables:
+ * Example of how to display a summary of all IPv6 FIB tables:
* @cliexstart{show ip fib summary}
- * ipv4-VRF:0, fib_index 0, flow hash: src dst sport dport proto
+ * ipv6-VRF:0, fib_index 0, flow hash: src dst sport dport proto
* Prefix length Count
* 0 1
* 8 2
* 32 4
- * ipv4-VRF:7, fib_index 1, flow hash: src dst sport dport proto
+ * ipv6-VRF:7, fib_index 1, flow hash: src dst sport dport proto
* Prefix length Count
* 0 1
* 8 2
diff --git a/src/vnet/mfib/ip6_mfib.h b/src/vnet/mfib/ip6_mfib.h
index ea81b553cd5..5ebdd0a6ff4 100644
--- a/src/vnet/mfib/ip6_mfib.h
+++ b/src/vnet/mfib/ip6_mfib.h
@@ -117,5 +117,10 @@ extern void ip6_mfib_table_walk (ip6_mfib_t *mfib,
mfib_table_walk_fn_t fn,
void *ctx);
+/**
+ * @brief format (display) ipv6 MFIB mempry usage
+ */
+extern u8 *format_ip6_mfib_table_memory(u8 * s, va_list * args);
+
#endif
diff --git a/src/vnet/mfib/mfib_table.c b/src/vnet/mfib/mfib_table.c
index efeadefb2d6..dc51b7c6ce8 100644
--- a/src/vnet/mfib/mfib_table.c
+++ b/src/vnet/mfib/mfib_table.c
@@ -628,6 +628,15 @@ format_mfib_table_name (u8* s, va_list *ap)
return (s);
}
+u8 *
+format_mfib_table_memory (u8 *s, va_list *args)
+{
+ s = format(s, "%U", format_ip4_mfib_table_memory);
+ s = format(s, "%U", format_ip6_mfib_table_memory);
+
+ return (s);
+}
+
static clib_error_t *
mfib_module_init (vlib_main_t * vm)
{
diff --git a/src/vnet/mfib/mfib_table.h b/src/vnet/mfib/mfib_table.h
index 6a5810291fc..63af25b0151 100644
--- a/src/vnet/mfib/mfib_table.h
+++ b/src/vnet/mfib/mfib_table.h
@@ -420,5 +420,9 @@ extern void mfib_table_walk(u32 fib_index,
fib_protocol_t proto,
mfib_table_walk_fn_t fn,
void *ctx);
+/**
+ * @brief format (display) the memory usage for mfibs
+ */
+extern u8 * format_mfib_table_memory(u8 * s, va_list * args);
#endif