X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Finterface_format.c;h=e58369a1126bc8e1629571fc7732d834c3e45bb4;hb=2f8d8fa50175bf775f66ff15aff2cf08138ccfbd;hp=b3a30622031f1085ff4cb8c470e66d739b075a26;hpb=7cd468a3d7dee7d6c92f69a0bb7061ae208ec727;p=vpp.git diff --git a/src/vnet/interface_format.c b/src/vnet/interface_format.c index b3a30622031..e58369a1126 100644 --- a/src/vnet/interface_format.c +++ b/src/vnet/interface_format.c @@ -45,7 +45,9 @@ format_vnet_sw_interface_flags (u8 * s, va_list * args) { u32 flags = va_arg (*args, u32); - if (flags & VNET_SW_INTERFACE_FLAG_BOND_SLAVE) + if (flags & VNET_SW_INTERFACE_FLAG_ERROR) + s = format (s, "error"); + else if (flags & VNET_SW_INTERFACE_FLAG_BOND_SLAVE) s = format (s, "bond-slave"); else { @@ -58,6 +60,23 @@ format_vnet_sw_interface_flags (u8 * s, va_list * args) return s; } +u8 * +format_vnet_hw_interface_rx_mode (u8 * s, va_list * args) +{ + vnet_hw_interface_rx_mode mode = va_arg (*args, vnet_hw_interface_rx_mode); + + if (mode == VNET_HW_INTERFACE_RX_MODE_POLLING) + return format (s, "polling"); + + if (mode == VNET_HW_INTERFACE_RX_MODE_INTERRUPT) + return format (s, "interrupt"); + + if (mode == VNET_HW_INTERFACE_RX_MODE_ADAPTIVE) + return format (s, "adaptive"); + + return format (s, "unknown"); +} + u8 * format_vnet_hw_interface (u8 * s, va_list * args) { @@ -66,7 +85,7 @@ format_vnet_hw_interface (u8 * s, va_list * args) vnet_hw_interface_class_t *hw_class; vnet_device_class_t *dev_class; int verbose = va_arg (*args, int); - uword indent; + u32 indent; if (!hi) return format (s, "%=32s%=6s%=8s%s", "Name", "Idx", "Link", "Hardware"); @@ -146,16 +165,22 @@ format_vnet_sw_if_index_name (u8 * s, va_list * args) { vnet_main_t *vnm = va_arg (*args, vnet_main_t *); u32 sw_if_index = va_arg (*args, u32); - return format (s, "%U", - format_vnet_sw_interface_name, vnm, - vnet_get_sw_interface (vnm, sw_if_index)); + vnet_sw_interface_t *si; + + si = vnet_get_sw_interface_safe (vnm, sw_if_index); + + if (NULL == si) + { + return format (s, "DELETED"); + } + return format (s, "%U", format_vnet_sw_interface_name, vnm, si); } u8 * format_vnet_sw_interface_cntrs (u8 * s, vnet_interface_main_t * im, vnet_sw_interface_t * si) { - uword indent, n_printed; + u32 indent, n_printed; int i, j, n_counters; static vnet_main_t **my_vnet_mains; @@ -321,6 +346,7 @@ unformat_vnet_sw_interface (unformat_input_t * input, va_list * args) u32 *result = va_arg (*args, u32 *); vnet_hw_interface_t *hi; u32 hw_if_index, id, id_specified; + u32 sw_if_index; u8 *if_name = 0; uword *p, error = 0; @@ -340,14 +366,17 @@ unformat_vnet_sw_interface (unformat_input_t * input, va_list * args) hi = vnet_get_hw_interface (vnm, hw_if_index); if (!id_specified) { - *result = hi->sw_if_index; + sw_if_index = hi->sw_if_index; } else { if (!(p = hash_get (hi->sub_interface_sw_if_index_by_id, id))) - return 0; - *result = p[0]; + goto done; + sw_if_index = p[0]; } + if (!vnet_sw_interface_is_api_visible (vnm, sw_if_index)) + goto done; + *result = sw_if_index; error = 1; done: vec_free (if_name);