Add ability to override the interface name.
Export interface format functions to plugin and allow ability to show a single hardware interface index. Change-Id: If52fae2d63e97da91e1ac9a9a6fb73389b526ebc Signed-off-by: Todd Foggoa (tfoggoa) <tfoggoa@cisco.com>
This commit is contained in:
@ -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;
|
||||
|
@ -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 *);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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) \
|
||||
|
Reference in New Issue
Block a user