69 u32 hw_if_index, *hw_if_indices = 0;
70 int i, verbose = -1, is_show, show_bond = 0;
72 is_show = strstr (cmd->
path,
"show") != 0;
78 vec_add1 (hw_if_indices, hw_if_index);
81 else if (
unformat (input,
"%u", &hw_if_index))
82 vec_add1 (hw_if_indices, hw_if_index);
84 else if (
unformat (input,
"verbose"))
109 if (
vec_len (hw_if_indices) == 0)
122 for (i = 0; i <
vec_len (hw_if_indices); i++)
139 shi = vnet_get_hw_interface(vnm, hw_idx);
140 vlib_cli_output (vm,
"%U\n",
141 format_vnet_hw_interface, vnm, shi, verbose);
149 for (i = 0; i <
vec_len (hw_if_indices); i++)
156 if (dc->clear_counters)
196 .path =
"show hardware-interfaces",
197 .short_help =
"show hardware-interfaces [brief|verbose|detail] [bond] [<if-name1> <if-name2> ...]",
204 .path =
"clear hardware-interfaces",
205 .short_help =
"Clear hardware interfaces statistics",
228 u32 sw_if_index = ~(
u32) 0;
229 u8 show_addresses = 0;
230 u8 show_features = 0;
256 if (show_features || show_tag)
258 if (sw_if_index == ~(
u32) 0)
273 tag ? (
char *) tag :
"(none)");
285 _vec_len (sorted_sis) = 0;
288 if (vnet_swif_is_api_visible
289 (si)) vec_add1 (sorted_sis,
309 u32 fib_index4 = 0, fib_index6 = 0;
327 (vm,
"%U (%s): \n unnumbered, use %U",
349 config->
bvi ?
" bvi shg " :
" shg ",
364 r4 = ip_interface_address_get_address (lm4, ia);
367 vlib_cli_output (vm,
" %U/%d table %d",
368 format_ip4_address, r4,
374 vlib_cli_output (vm,
" %U/%d",
375 format_ip4_address, r4,
386 r6 = ip_interface_address_get_address (lm6, ia);
389 vlib_cli_output (vm,
" %U/%d table %d",
390 format_ip6_address, r6,
396 vlib_cli_output (vm,
" %U/%d",
397 format_ip6_address, r6,
419 .path =
"show interface",
420 .short_help =
"show interface [address|addr|features|feat] [<if-name1> <if-name2> ...]",
429 .short_help =
"Interface commands",
435 .path =
"set interface",
436 .short_help =
"Interface commands",
449 int i, j, n_counters;
464 for (j = 0; j < n_counters; j++)
466 for (i = 0; i <
vec_len (my_vnet_mains); i++)
476 for (j = 0; j < n_counters; j++)
478 for (i = 0; i <
vec_len (my_vnet_mains); i++)
491 .path =
"clear interfaces",
492 .short_help =
"Clear interfaces statistics",
564 u32 inner_vlan, outer_vlan;
566 if (
unformat (input,
"any inner-dot1q any"))
568 template->sub.eth.
flags.two_tags = 1;
569 template->sub.eth.flags.outer_vlan_id_any = 1;
570 template->sub.eth.flags.inner_vlan_id_any = 1;
574 template->sub.eth.flags.one_tag = 1;
575 template->sub.eth.flags.outer_vlan_id_any = 1;
577 else if (
unformat (input,
"%d inner-dot1q any", &outer_vlan))
579 template->sub.eth.flags.two_tags = 1;
580 template->sub.eth.flags.inner_vlan_id_any = 1;
581 template->sub.eth.outer_vlan_id = outer_vlan;
583 else if (
unformat (input,
"%d inner-dot1q %d", &outer_vlan, &inner_vlan))
585 template->sub.eth.flags.two_tags = 1;
586 template->sub.eth.outer_vlan_id = outer_vlan;
587 template->sub.eth.inner_vlan_id = inner_vlan;
589 else if (
unformat (input,
"%d", &outer_vlan))
591 template->sub.eth.flags.one_tag = 1;
592 template->sub.eth.outer_vlan_id = outer_vlan;
603 if (
unformat (input,
"exact-match"))
605 template->sub.eth.flags.exact_match = 1;
619 u32 hw_if_index, sw_if_index;
621 u32 id, id_min, id_max;
632 memset (&
template, 0,
sizeof (
template));
633 template.sub.eth.raw_flags = 0;
635 if (
unformat (input,
"%d default", &id_min))
638 template.sub.eth.flags.default_sub = 1;
640 else if (
unformat (input,
"%d untagged", &id_min))
643 template.sub.eth.flags.no_tags = 1;
644 template.sub.eth.flags.exact_match = 1;
646 else if (
unformat (input,
"%d dot1q", &id_min))
654 else if (
unformat (input,
"%d dot1ad", &id_min))
658 template.sub.eth.flags.dot1ad = 1;
663 else if (
unformat (input,
"%d-%d", &id_min, &id_max))
665 template.sub.eth.flags.one_tag = 1;
666 template.sub.eth.flags.exact_match = 1;
670 else if (
unformat (input,
"%d", &id_min))
673 template.sub.eth.flags.one_tag = 1;
674 template.sub.eth.outer_vlan_id = id_min;
675 template.sub.eth.flags.exact_match = 1;
691 "not allowed as %v belong to a BondEthernet interface",
696 for (
id = id_min;
id <= id_max;
id++)
707 clib_warning (
"sup sw_if_index %d, sub id %d already exists\n",
713 *kp = sup_and_sub_key;
718 template.sub.id = id;
720 template.sub.eth.outer_vlan_id = id;
782 .path =
"create sub-interfaces",
783 .short_help =
"create sub-interfaces <nn>[-<nn>] [dot1q|dot1ad|default|untagged]",
831 .path =
"set interface state",
832 .short_help =
"Set interface state",
842 u32 unnumbered_sw_if_index;
843 u32 inherit_from_sw_if_index;
855 &unnumbered_sw_if_index))
870 [unnumbered_sw_if_index] = ~0;
872 [unnumbered_sw_if_index] = ~0;
880 [unnumbered_sw_if_index] =
882 [inherit_from_sw_if_index];
884 [unnumbered_sw_if_index] =
886 [inherit_from_sw_if_index];
900 .path =
"set interface unnumbered",
901 .short_help =
"set interface unnumbered [<intfc> use <intfc> | del <intfc>]",
915 u32 hw_if_index, hw_class_index;
943 .path =
"set interface hw-class",
944 .short_help =
"Set interface hardware class",
963 u32 new_dev_instance;
971 if (!
unformat (input,
"%d", &new_dev_instance))
993 .path =
"renumber interface",
994 .short_help =
"renumber interface <if-name> <new-dev-instance>",
1012 else if (
unformat (input,
"off %U",
1029 .path =
"set interface promiscuous",
1030 .short_help =
"set interface promiscuous [on | off] <intfc>",
1039 u32 hw_if_index, mtu;
1043 if (
unformat (input,
"%d %U", &mtu,
1052 if (mtu < hi->min_supported_packet_bytes)
1054 "must be >= min pkt bytes (%d)", mtu,
1075 .path =
"set interface mtu",
1076 .short_help =
"set interface mtu <value> <intfc>",
1087 u32 sw_if_index = ~0;
1123 .path =
"set interface mac address",
1124 .short_help =
"set interface mac address <intfc> <mac-address>",
1133 u32 sw_if_index = ~0;
1137 vnm, &sw_if_index, &tag))
1148 .path =
"set interface tag",
1149 .short_help =
"set interface tag <intfc> <tag>",
1159 u32 sw_if_index = ~0;
1172 .path =
"clear interface tag",
1173 .short_help =
"clear interface tag <intfc>",
unformat_function_t unformat_vnet_hw_interface
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
#define foreach_ip_interface_address(lm, a, sw_if_index, loop, body)
static clib_error_t * clear_interface_counters(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define VNET_SW_INTERFACE_FLAG_UNNUMBERED
format_function_t format_vnet_sw_interface
static clib_error_t * create_sub_interfaces(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define hash_set(h, key, value)
l2_input_config_t * configs
sll srl srl sll sra u16x4 i
static clib_error_t * promiscuous_cmd(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * set_hw_class(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static int sw_interface_name_compare(void *a1, void *a2)
static clib_error_t * set_state(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static ip6_fib_t * ip6_fib_get(fib_node_index_t index)
static clib_error_t * set_interface_mac_address(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vnet_main_t * vnet_get_main(void)
unformat_function_t unformat_hash_string
vnet_interface_main_t interface_main
clib_error_t * vnet_hw_interface_change_mac_address(vnet_main_t *vnm, u32 hw_if_index, u64 mac_address)
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
vnet_main_t ** vnet_mains
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
word vnet_sw_interface_compare(vnet_main_t *vnm, uword sw_if_index0, uword sw_if_index1)
int vnet_interface_name_renumber(u32 sw_if_index, u32 new_show_dev_instance)
static void vnet_clear_sw_interface_tag(vnet_main_t *vnm, u32 sw_if_index)
static clib_error_t * set_tag(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * renumber_interface_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define hash_set_mem(h, key, value)
ip_lookup_main_t lookup_main
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
uword * sub_interface_sw_if_index_by_id
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
unformat_function_t unformat_vnet_sw_interface
struct _vnet_device_class vnet_device_class_t
format_function_t format_vnet_sw_if_index_name
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
ethernet_main_t ethernet_main
format_function_t format_vnet_hw_interface
void vlib_clear_combined_counters(vlib_combined_counter_main_t *cm)
Clear a collection of combined counters.
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#define VLIB_INIT_FUNCTION(x)
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
vlib_combined_counter_main_t * combined_sw_if_counters
static clib_error_t * parse_vlan_sub_interfaces(unformat_input_t *input, vnet_sw_interface_t *template)
Parse subinterface names.
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_error_return(e, args...)
static clib_error_t * set_unnumbered(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
A collection of simple counters.
static clib_error_t * mtu_cmd(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 max_supported_packet_bytes
vnet_hw_interface_t * hw_interfaces
#define clib_bitmap_foreach(i, ai, body)
Macro to iterate across set bits in a bitmap.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
void ip4_sw_interface_enable_disable(u32 sw_if_index, u32 is_enable)
uword * sw_if_index_by_sup_and_sub
static clib_error_t * show_sw_interfaces(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vlib_simple_counter_main_t * sw_if_counters
word vnet_hw_interface_compare(vnet_main_t *vnm, uword hw_if_index0, uword hw_if_index1)
static int compare_interface_names(void *a1, void *a2)
uword * hw_interface_class_by_name
#define VNET_HW_INTERFACE_BOND_INFO_SLAVE
void vnet_interface_features_show(vlib_main_t *vm, u32 sw_if_index)
Display the set of driver features configured on a specific interface Called by "show interface" hand...
static clib_error_t * clear_tag(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vec_free(V)
Free vector's memory (no header).
static ip4_fib_t * ip4_fib_get(u32 index)
Get the FIB at the given index.
#define clib_warning(format, args...)
#define ETHERNET_INTERFACE_FLAG_MTU
#define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
static clib_error_t * show_or_clear_hw_interfaces(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 unnumbered_sw_if_index
#define VLIB_CLI_COMMAND(x,...)
u32 * if_address_pool_index_by_sw_if_index
Head of doubly linked list of interface addresses for each software interface.
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
uword unformat_ethernet_address(unformat_input_t *input, va_list *args)
ip_lookup_main_t lookup_main
static void vnet_set_sw_interface_tag(vnet_main_t *vnm, u8 *tag, u32 sw_if_index)
Bitmaps built as vectors of machine words.
static u8 * vnet_get_sw_interface_tag(vnet_main_t *vnm, u32 sw_if_index)
static void * clib_mem_alloc(uword size)
uword unformat_ethernet_interface(unformat_input_t *input, va_list *args)
#define vec_elt(v, i)
Get vector value at index i.
ethernet_interface_t * ethernet_get_interface(ethernet_main_t *em, u32 hw_if_index)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unformat_function_t unformat_vnet_sw_interface_flags
static clib_error_t * vnet_interface_cli_init(vlib_main_t *vm)
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
vnet_sw_interface_t * sw_interfaces
l2_bridge_domain_t * bd_configs
A collection of combined counters.
#define hash_get_mem(h, key)
u32 min_supported_packet_bytes
void vlib_clear_simple_counters(vlib_simple_counter_main_t *cm)
Clear a collection of simple counters.
ip4_main_t ip4_main
Global ip4 main structure.
#define vec_foreach(var, vec)
Vector iterator.
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
vnet_device_class_t * device_classes
clib_error_t * vnet_create_sw_interface(vnet_main_t *vnm, vnet_sw_interface_t *template, u32 *sw_if_index)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
u32 * fib_index_by_sw_if_index
void ip6_sw_interface_enable_disable(u32 sw_if_index, u32 is_enable)
u32 ethernet_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
clib_error_t * vnet_hw_interface_set_class(vnet_main_t *vnm, u32 hw_if_index, u32 hw_class_index)
static uword pool_elts(void *v)
Number of active elements in a pool.