61 u32 hw_if_index, * hw_if_indices = 0;
62 int i, verbose = -1, is_show, show_bond = 0;
64 is_show = strstr (cmd->
path,
"show") != 0;
69 vec_add1 (hw_if_indices, hw_if_index);
72 else if (
unformat (input,
"%u", &hw_if_index))
73 vec_add1 (hw_if_indices, hw_if_index);
75 else if (
unformat (input,
"verbose"))
87 if (verbose < 0) verbose = 0;
99 if (
vec_len (hw_if_indices) == 0)
103 if (verbose < 0) verbose = 1;
111 for (i = 0; i <
vec_len (hw_if_indices); i++)
126 shi = vnet_get_hw_interface(vnm, hw_idx);
127 vlib_cli_output (vm,
"%U\n",
128 format_vnet_hw_interface, vnm, shi, verbose);
135 for (i = 0; i <
vec_len (hw_if_indices); i++)
142 if (dc->clear_counters)
153 .path =
"show hardware-interfaces",
154 .short_help =
"show hardware-interfaces [brief|verbose|detail] [bond] [<if-name1> <if-name2> ...]",
159 .path =
"clear hardware-interfaces",
160 .short_help =
"Clear hardware interfaces statistics",
182 u8 show_addresses = 0;
213 _vec_len (sorted_sis) = 0;
232 u32 fib_index4 = 0, fib_index6 = 0;
250 (vm,
"%U (%s): \n unnumbered, use %U",
273 config->
bvi ?
" bvi shg " :
" shg ", config->
shg);
286 r4 = ip_interface_address_get_address (lm4, ia);
289 vlib_cli_output (vm,
" %U/%d table %d",
290 format_ip4_address, r4,
296 vlib_cli_output (vm,
" %U/%d",
297 format_ip4_address, r4,
306 r6 = ip_interface_address_get_address (lm6, ia);
309 vlib_cli_output (vm,
" %U/%d table %d",
310 format_ip6_address, r6,
316 vlib_cli_output (vm,
" %U/%d",
317 format_ip6_address, r6,
337 .path =
"show interfaces",
338 .short_help =
"show interfaces [address|addr] [<if-name1> <if-name2> ...]",
345 .short_help =
"Interface commands",
349 .path =
"set interface",
350 .short_help =
"Interface commands",
363 int i, j, n_counters;
378 for (j = 0; j < n_counters; j++)
380 for (i = 0; i <
vec_len(my_vnet_mains); i++)
390 for (j = 0; j < n_counters; j++)
392 for (i = 0; i <
vec_len(my_vnet_mains); i++)
404 .path =
"clear interfaces",
405 .short_help =
"Clear interfaces statistics",
473 u32 inner_vlan, outer_vlan;
475 if (
unformat (input,
"any inner-dot1q any")) {
476 template->sub.eth.
flags.two_tags = 1;
477 template->sub.eth.flags.outer_vlan_id_any = 1;
478 template->sub.eth.flags.inner_vlan_id_any = 1;
479 }
else if (
unformat (input,
"any")) {
480 template->sub.eth.flags.one_tag = 1;
481 template->sub.eth.flags.outer_vlan_id_any = 1;
482 }
else if (
unformat (input,
"%d inner-dot1q any", &outer_vlan)) {
483 template->sub.eth.flags.two_tags = 1;
484 template->sub.eth.flags.inner_vlan_id_any = 1;
485 template->sub.eth.outer_vlan_id = outer_vlan;
486 }
else if (
unformat (input,
"%d inner-dot1q %d", &outer_vlan, &inner_vlan)) {
487 template->sub.eth.flags.two_tags = 1;
488 template->sub.eth.outer_vlan_id = outer_vlan;
489 template->sub.eth.inner_vlan_id = inner_vlan;
490 }
else if (
unformat (input,
"%d", &outer_vlan)) {
491 template->sub.eth.flags.one_tag = 1;
492 template->sub.eth.outer_vlan_id = outer_vlan;
500 if (
unformat (input,
"exact-match")) {
501 template->sub.eth.flags.exact_match = 1;
516 u32 hw_if_index, sw_if_index;
518 u32 id, id_min, id_max;
529 memset (&
template, 0,
sizeof (
template));
530 template.sub.eth.raw_flags = 0;
532 if (
unformat (input,
"%d default", &id_min)) {
534 template.sub.eth.flags.default_sub = 1;
535 }
else if (
unformat (input,
"%d untagged", &id_min)) {
537 template.sub.eth.flags.no_tags = 1;
538 template.sub.eth.flags.exact_match = 1;
539 }
else if (
unformat (input,
"%d dot1q", &id_min)) {
543 if (error)
goto done;
544 }
else if (
unformat (input,
"%d dot1ad", &id_min)) {
547 template.sub.eth.flags.dot1ad = 1;
549 if (error)
goto done;
550 }
else if (
unformat (input,
"%d-%d", &id_min, &id_max)) {
551 template.sub.eth.flags.one_tag = 1;
552 template.sub.eth.outer_vlan_id = id_min;
553 template.sub.eth.flags.exact_match = 1;
556 }
else if (
unformat (input,
"%d", &id_min)) {
558 template.sub.eth.flags.one_tag = 1;
559 template.sub.eth.outer_vlan_id = id_min;
560 template.sub.eth.flags.exact_match = 1;
580 0,
"not allowed as %v belong to a BondEthernet interface", hi->
name);
584 for (
id = id_min;
id <= id_max;
id++)
596 clib_warning (
"sup sw_if_index %d, sub id %d already exists\n",
602 *kp = sup_and_sub_key;
606 template.sub.id = id;
608 if (error)
goto done;
621 .path =
"create sub-interface",
622 .short_help =
"create sub-interfaces <nn>[-<nn>] [dot1q|dot1ad|default|untagged]",
659 .path =
"set interface state",
660 .short_help =
"Set interface state",
670 u32 unnumbered_sw_if_index;
671 u32 inherit_from_sw_if_index;
685 vnm, &unnumbered_sw_if_index))
689 if (is_set || is_del)
710 .path =
"set interface unnumbered",
711 .short_help =
"set interface unnumbered [<intfc> use <intfc>][del <intfc>]",
725 u32 hw_if_index, hw_class_index;
752 .path =
"set interface hw-class",
753 .short_help =
"Set interface hardware class",
768 u32 new_dev_instance;
776 if (!
unformat (input,
"%d", &new_dev_instance))
797 .path =
"renumber interface",
798 .short_help =
"renumber interface <if-name> <new-dev-instance>",
832 .path =
"set interface promiscuous",
833 .short_help =
"set interface promiscuous [on | off] <intfc>",
841 u32 hw_if_index, mtu;
854 if (mtu < hi->min_supported_packet_bytes)
856 "must be >= min pkt bytes (%d)", mtu,
876 .path =
"set interface mtu",
877 .short_help =
"set interface mtu <value> <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)
unformat_function_t unformat_hash_string
vnet_interface_main_t interface_main
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 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
uword * sub_interface_sw_if_index_by_id
u32 * fib_index_by_sw_if_index
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
vnet_main_t * vnet_get_main(void)
format_function_t format_vnet_hw_interface
void vlib_clear_combined_counters(vlib_combined_counter_main_t *cm)
#define pool_foreach(VAR, POOL, BODY)
#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)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
always_inline uword pool_elts(void *v)
#define clib_warning(format, args...)
static clib_error_t * set_unnumbered(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
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)
#define pool_elt_at_index(p, i)
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)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static int compare_interface_names(void *a1, void *a2)
uword * hw_interface_class_by_name
#define VNET_HW_INTERFACE_BOND_INFO_SLAVE
always_inline void * clib_mem_alloc(uword size)
#define vec_free(V)
Free vector's memory (no header).
#define ETHERNET_INTERFACE_FLAG_MTU
#define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
always_inline vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
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,...)
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
ip_lookup_main_t lookup_main
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)
always_inline vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
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
#define hash_get_mem(h, key)
u32 min_supported_packet_bytes
void vlib_clear_simple_counters(vlib_simple_counter_main_t *cm)
#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
#define clib_error_return(e, args...)
clib_error_t * vnet_create_sw_interface(vnet_main_t *vnm, vnet_sw_interface_t *template, u32 *sw_if_index)
u32 * fib_index_by_sw_if_index
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)