summaryrefslogtreecommitdiffstats
path: root/src/vnet/interface_format.c
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2019-05-17 10:46:40 -0400
committerDave Wallace <dwallacelf@gmail.com>2019-05-17 21:06:13 +0000
commit8fdde3c22ff981f0c41b78d3640e3249873e8495 (patch)
tree15016f3c45d2c9a7ec68863302820ee342445c13 /src/vnet/interface_format.c
parentce5c2ce518346990d081e4e0c56070be4a743586 (diff)
Add a debug-CLI leak-checker
leak-check { <any-debug-cli-command-and-args> } Hint: "set term history off" or you'll have to sort through a bunch of bogus leaks related to the debug cli history mechanism. Cleaned up a set of reported leaks in the "show interface" command. At some point, we thought about making a per-thread vlib_mains vector, but we never did that. Several interface-related CLI's maintained local static cache vectors. Not a bad idea, but not useful as things shook out. Removed the static vectors. Change-Id: I756bf2721a0d91993ecfded34c79da406f30a548 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vnet/interface_format.c')
-rw-r--r--src/vnet/interface_format.c90
1 files changed, 33 insertions, 57 deletions
diff --git a/src/vnet/interface_format.c b/src/vnet/interface_format.c
index ee332f398e9..e25a05aa9f1 100644
--- a/src/vnet/interface_format.c
+++ b/src/vnet/interface_format.c
@@ -219,66 +219,46 @@ format_vnet_sw_interface_cntrs (u8 * s, vnet_interface_main_t * im,
vnet_sw_interface_t * si)
{
u32 indent, n_printed;
- int i, j, n_counters;
- static vnet_main_t **my_vnet_mains;
-
- vec_reset_length (my_vnet_mains);
+ int j, n_counters;
+ u8 *n = 0;
indent = format_get_indent (s);
n_printed = 0;
- {
- vlib_combined_counter_main_t *cm;
- vlib_counter_t v, vtotal;
- u8 *n = 0;
-
- for (i = 0; i < vec_len (vnet_mains); i++)
- {
- if (vnet_mains[i])
- vec_add1 (my_vnet_mains, vnet_mains[i]);
- }
+ n_counters = vec_len (im->combined_sw_if_counters);
- if (vec_len (my_vnet_mains) == 0)
- vec_add1 (my_vnet_mains, &vnet_main);
-
- /* Each vnet_main_t has its own copy of the interface counters */
- n_counters = vec_len (im->combined_sw_if_counters);
-
- /* rx, tx counters... */
- for (j = 0; j < n_counters; j++)
- {
- vtotal.packets = 0;
- vtotal.bytes = 0;
-
- for (i = 0; i < vec_len (my_vnet_mains); i++)
- {
- im = &my_vnet_mains[i]->interface_main;
- cm = im->combined_sw_if_counters + j;
- vlib_get_combined_counter (cm, si->sw_if_index, &v);
- vtotal.packets += v.packets;
- vtotal.bytes += v.bytes;
- }
+ /* rx, tx counters... */
+ for (j = 0; j < n_counters; j++)
+ {
+ vlib_combined_counter_main_t *cm;
+ vlib_counter_t v, vtotal;
+ vtotal.packets = 0;
+ vtotal.bytes = 0;
- /* Only display non-zero counters. */
- if (vtotal.packets == 0)
- continue;
+ cm = im->combined_sw_if_counters + j;
+ vlib_get_combined_counter (cm, si->sw_if_index, &v);
+ vtotal.packets += v.packets;
+ vtotal.bytes += v.bytes;
- if (n_printed > 0)
- s = format (s, "\n%U", format_white_space, indent);
- n_printed += 2;
+ /* Only display non-zero counters. */
+ if (vtotal.packets == 0)
+ continue;
- if (n)
- _vec_len (n) = 0;
- n = format (n, "%s packets", cm->name);
- s = format (s, "%-16v%16Ld", n, vtotal.packets);
+ if (n_printed > 0)
+ s = format (s, "\n%U", format_white_space, indent);
+ n_printed += 2;
+ if (n)
_vec_len (n) = 0;
- n = format (n, "%s bytes", cm->name);
- s = format (s, "\n%U%-16v%16Ld",
- format_white_space, indent, n, vtotal.bytes);
- }
- vec_free (n);
- }
+ n = format (n, "%s packets", cm->name);
+ s = format (s, "%-16v%16Ld", n, vtotal.packets);
+
+ _vec_len (n) = 0;
+ n = format (n, "%s bytes", cm->name);
+ s = format (s, "\n%U%-16v%16Ld",
+ format_white_space, indent, n, vtotal.bytes);
+ }
+ vec_free (n);
{
vlib_simple_counter_main_t *cm;
@@ -290,14 +270,10 @@ format_vnet_sw_interface_cntrs (u8 * s, vnet_interface_main_t * im,
{
vtotal = 0;
- for (i = 0; i < vec_len (my_vnet_mains); i++)
- {
- im = &my_vnet_mains[i]->interface_main;
- cm = im->sw_if_counters + j;
+ cm = im->sw_if_counters + j;
- v = vlib_get_simple_counter (cm, si->sw_if_index);
- vtotal += v;
- }
+ v = vlib_get_simple_counter (cm, si->sw_if_index);
+ vtotal += v;
/* Only display non-zero counters. */
if (vtotal == 0)