aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vnet/vnet/interface_cli.c7
-rw-r--r--vnet/vnet/interface_format.c55
-rw-r--r--vnet/vnet/interface_funcs.h1
-rw-r--r--vnet/vnet/plugin/p1.c3
4 files changed, 54 insertions, 12 deletions
diff --git a/vnet/vnet/interface_cli.c b/vnet/vnet/interface_cli.c
index 8d986527fc6..94fb3916d4a 100644
--- a/vnet/vnet/interface_cli.c
+++ b/vnet/vnet/interface_cli.c
@@ -70,6 +70,13 @@ show_or_clear_hw_interfaces (vlib_main_t * vm,
/* Implies verbose. */
verbose = 1;
}
+ /* See if user wants to show an interface with a specific hw_if_index. */
+ else if (unformat (input, "%u", &hw_if_index))
+ {
+ vec_add1 (hw_if_indices, hw_if_index);
+ /* Implies verbose. */
+ verbose = 1;
+ }
else if (unformat (input, "verbose"))
verbose = 1;
diff --git a/vnet/vnet/interface_format.c b/vnet/vnet/interface_format.c
index 56faea27217..1ebbfb12e06 100644
--- a/vnet/vnet/interface_format.c
+++ b/vnet/vnet/interface_format.c
@@ -128,23 +128,13 @@ u8 * format_vnet_sw_if_index_name (u8 * s, va_list * args)
vnet_get_sw_interface (vnm, sw_if_index));
}
-u8 * format_vnet_sw_interface (u8 * s, va_list * args)
+u8 * format_vnet_sw_interface_cntrs (u8 * s, vnet_interface_main_t * im,
+ vnet_sw_interface_t * si)
{
- vnet_main_t * vnm = va_arg (*args, vnet_main_t *);
- vnet_sw_interface_t * si = va_arg (*args, vnet_sw_interface_t *);
- vnet_interface_main_t * im = &vnm->interface_main;
uword indent, n_printed;
int i, j, n_counters;
static vnet_main_t ** my_vnet_mains;
- if (! si)
- return format (s, "%=32s%=5s%=16s%=16s%=16s",
- "Name", "Idx", "State", "Counter", "Count");
-
- s = format (s, "%-32U%=5d%=16U",
- format_vnet_sw_interface_name, vnm, si, si->sw_if_index,
- format_vnet_sw_interface_flags, si->flags);
-
vec_reset_length (my_vnet_mains);
indent = format_get_indent (s);
@@ -238,6 +228,47 @@ u8 * format_vnet_sw_interface (u8 * s, va_list * args)
return s;
}
+u8 * format_vnet_sw_interface (u8 * s, va_list * args)
+{
+ vnet_main_t * vnm = va_arg (*args, vnet_main_t *);
+ vnet_sw_interface_t * si = va_arg (*args, vnet_sw_interface_t *);
+ vnet_interface_main_t * im = &vnm->interface_main;
+
+ if (! si)
+ return format (s, "%=32s%=5s%=16s%=16s%=16s",
+ "Name", "Idx", "State", "Counter", "Count");
+
+ s = format (s, "%-32U%=5d%=16U",
+ format_vnet_sw_interface_name, vnm, si, si->sw_if_index,
+ format_vnet_sw_interface_flags, si->flags);
+
+ s = format_vnet_sw_interface_cntrs(s, im, si);
+
+ return s;
+}
+
+u8 * format_vnet_sw_interface_name_override (u8 * s, va_list * args)
+{
+ vnet_main_t * vnm = va_arg (*args, vnet_main_t *);
+ vnet_sw_interface_t * si = va_arg (*args, vnet_sw_interface_t *);
+ /* caller supplied display name for this interface */
+ u8* name = va_arg (*args, u8*);
+ vnet_interface_main_t * im = &vnm->interface_main;
+
+
+ if (! si)
+ return format (s, "%=32s%=5s%=16s%=16s%=16s",
+ "Name", "Idx", "State", "Counter", "Count");
+
+ s = format (s, "%-32v%=5d%=16U",
+ name, si->sw_if_index,
+ format_vnet_sw_interface_flags, si->flags);
+
+ s = format_vnet_sw_interface_cntrs(s, im, si);
+
+ return s;
+}
+
uword unformat_vnet_hw_interface (unformat_input_t * input, va_list * args)
{
vnet_main_t * vnm = va_arg (*args, vnet_main_t *);
diff --git a/vnet/vnet/interface_funcs.h b/vnet/vnet/interface_funcs.h
index f3d3247fd5d..7761bf76d53 100644
--- a/vnet/vnet/interface_funcs.h
+++ b/vnet/vnet/interface_funcs.h
@@ -154,6 +154,7 @@ void vnet_hw_interface_init_for_class (vnet_main_t * vnm, u32 hw_if_index, u32 h
format_function_t format_vnet_hw_interface;
format_function_t format_vnet_sw_interface;
format_function_t format_vnet_sw_interface_name;
+format_function_t format_vnet_sw_interface_name_override;
format_function_t format_vnet_sw_if_index_name;
format_function_t format_vnet_sw_interface_flags;
diff --git a/vnet/vnet/plugin/p1.c b/vnet/vnet/plugin/p1.c
index 2d46beba575..b93ce375f8f 100644
--- a/vnet/vnet/plugin/p1.c
+++ b/vnet/vnet/plugin/p1.c
@@ -30,6 +30,9 @@
#define foreach_plugin_reference \
_(unformat_vnet_hw_interface) \
_(unformat_vnet_sw_interface) \
+_(format_vnet_hw_interface) \
+_(format_vnet_sw_interface) \
+_(format_vnet_sw_interface_name_override) \
_(vnet_hw_interface_rx_redirect_to_node) \
_(vnet_config_add_feature) \
_(vnet_config_del_feature) \