X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvat%2Fapi_format.c;h=69a57ab3d33552260657619c7bfbb295683de1bf;hb=5281a9029;hp=fe1a87f573e4a741a1c448ffa5d2d6cef1d66582;hpb=097fa66b986f06281f603767d321ab13ab6c88c3;p=vpp.git diff --git a/src/vat/api_format.c b/src/vat/api_format.c index fe1a87f573e..69a57ab3d33 100644 --- a/src/vat/api_format.c +++ b/src/vat/api_format.c @@ -58,7 +58,6 @@ #include "vat/json_format.h" #include #include -#include #include #include @@ -86,6 +85,9 @@ #define __plugin_msg_base 0 #include +void vl_api_set_elog_main (elog_main_t * m); +int vl_api_set_elog_trace_api_messages (int enable); + #if VPP_API_TEST_BUILTIN == 0 #include @@ -165,7 +167,8 @@ errmsg (char *fmt, ...) if (vam->ifp != stdin) fformat (vam->ofp, "%s(%d): \n", vam->current_file, vam->input_line_number); - fformat (vam->ofp, (char *) s); + else + fformat (vam->ofp, "%s\n", (char *) s); fflush (vam->ofp); } #endif @@ -738,9 +741,9 @@ increment_v6_address (vl_api_ip6_address_t * i) static void increment_address (vl_api_address_t * a) { - if (a->af == ADDRESS_IP4) + if (clib_net_to_host_u32 (a->af) == ADDRESS_IP4) increment_v4_address (&a->un.ip4); - else if (a->af == ADDRESS_IP6) + else if (clib_net_to_host_u32 (a->af) == ADDRESS_IP6) increment_v6_address (&a->un.ip6); } @@ -789,8 +792,8 @@ static void vat_json_object_add_prefix (vat_json_node_t * node, const vl_api_prefix_t * prefix) { - vat_json_object_add_uint (node, "address_length", prefix->address_length); - vat_json_object_add_address (node, "prefix", &prefix->address); + vat_json_object_add_uint (node, "len", prefix->len); + vat_json_object_add_address (node, "address", &prefix->address); } static void vl_api_create_loopback_reply_t_handler @@ -1352,9 +1355,8 @@ static void vl_api_show_version_reply_t_handler p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t); s = vl_api_from_api_to_vec ((vl_api_string_t *) p); - vec_free (s); - errmsg ("build directory: %v\n", s); + vec_free (s); } vam->retval = retval; vam->result_ready = 1; @@ -2665,7 +2667,7 @@ static void vl_api_ip_address_details_t_handler address = vec_elt_at_index (addresses, vec_len (addresses) - 1); clib_memcpy (&address->ip, &mp->prefix.address.un, sizeof (address->ip)); - address->prefix_length = mp->prefix.address_length; + address->prefix_length = mp->prefix.len; #undef addresses } @@ -5084,41 +5086,6 @@ static void vl_api_policer_classify_details_t_handler_json vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index)); } -static void vl_api_ipsec_gre_tunnel_add_del_reply_t_handler - (vl_api_ipsec_gre_tunnel_add_del_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - i32 retval = ntohl (mp->retval); - if (vam->async_mode) - { - vam->async_errors += (retval < 0); - } - else - { - vam->retval = retval; - vam->sw_if_index = ntohl (mp->sw_if_index); - vam->result_ready = 1; - } - vam->regenerate_interface_table = 1; -} - -static void vl_api_ipsec_gre_tunnel_add_del_reply_t_handler_json - (vl_api_ipsec_gre_tunnel_add_del_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t node; - - vat_json_init_object (&node); - vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); - vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index)); - - vat_json_print (vam->ofp, &node); - vat_json_free (&node); - - vam->retval = ntohl (mp->retval); - vam->result_ready = 1; -} - static void vl_api_flow_classify_details_t_handler (vl_api_flow_classify_details_t * mp) { @@ -5599,8 +5566,6 @@ _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \ ip_source_and_port_range_check_add_del_reply) \ _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \ ip_source_and_port_range_check_interface_add_del_reply) \ -_(IPSEC_GRE_TUNNEL_ADD_DEL_REPLY, ipsec_gre_tunnel_add_del_reply) \ -_(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \ _(DELETE_SUBIF_REPLY, delete_subif_reply) \ _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \ _(SET_PUNT_REPLY, set_punt_reply) \ @@ -7337,11 +7302,11 @@ api_bd_ip_mac_add_del (vat_main_t * vam) M (BD_IP_MAC_ADD_DEL, mp); - mp->bd_id = ntohl (bd_id); + mp->entry.bd_id = ntohl (bd_id); mp->is_add = is_add; - clib_memcpy (&mp->ip, &ip, sizeof (ip)); - clib_memcpy (&mp->mac, &mac, sizeof (mac)); + clib_memcpy (&mp->entry.ip, &ip, sizeof (ip)); + clib_memcpy (&mp->entry.mac, &mac, sizeof (mac)); S (mp); W (ret); @@ -7386,21 +7351,12 @@ static void vl_api_bd_ip_mac_details_t_handler (vl_api_bd_ip_mac_details_t * mp) { vat_main_t *vam = &vat_main; - u8 *ip = 0; - - if (!mp->is_ipv6) - ip = - format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address); - else - ip = - format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address); print (vam->ofp, - "\n%-5d %-7s %-20U %-30s", - ntohl (mp->bd_id), mp->is_ipv6 ? "ip6" : "ip4", - format_ethernet_address, mp->mac_address, ip); - - vec_free (ip); + "\n%-5d %U %U", + ntohl (mp->entry.bd_id), + format_vl_api_mac_address, mp->entry.mac, + format_vl_api_address, &mp->entry.ip); } static void vl_api_bd_ip_mac_details_t_handler_json @@ -7417,19 +7373,13 @@ static void vl_api_bd_ip_mac_details_t_handler_json node = vat_json_array_add (&vam->json_tree); vat_json_init_object (node); - vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id)); - vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6); + vat_json_object_add_uint (node, "bd_id", ntohl (mp->entry.bd_id)); vat_json_object_add_string_copy (node, "mac_address", - format (0, "%U", format_ethernet_address, - &mp->mac_address)); + format (0, "%U", format_vl_api_mac_address, + &mp->entry.mac)); u8 *ip = 0; - if (!mp->is_ipv6) - ip = - format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address); - else - ip = - format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address); + ip = format (0, "%U", format_vl_api_address, &mp->entry.ip); vat_json_object_add_string_copy (node, "ip_address", ip); vec_free (ip); } @@ -7481,6 +7431,7 @@ api_tap_create_v2 (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_tap_create_v2_t *mp; +#define TAP_FLAG_GSO (1 << 0) u8 mac_address[6]; u8 random_mac = 1; u32 id = ~0; @@ -7497,6 +7448,9 @@ api_tap_create_v2 (vat_main_t * vam) ip6_address_t host_ip6_gw; u8 host_ip6_gw_set = 0; u32 host_ip6_prefix_len = 0; + u8 host_mtu_set = 0; + u32 host_mtu_size = 0; + u32 tap_flags = 0; int ret; u32 rx_ring_sz = 0, tx_ring_sz = 0; @@ -7536,6 +7490,12 @@ api_tap_create_v2 (vat_main_t * vam) ; else if (unformat (i, "tx-ring-size %d", &tx_ring_sz)) ; + else if (unformat (i, "host-mtu-size %d", &host_mtu_size)) + host_mtu_set = 1; + else if (unformat (i, "no-gso")) + tap_flags &= ~TAP_FLAG_GSO; + else if (unformat (i, "gso")) + tap_flags |= TAP_FLAG_GSO; else break; } @@ -7585,6 +7545,11 @@ api_tap_create_v2 (vat_main_t * vam) errmsg ("tx ring size must be 32768 or lower. "); return -99; } + if (host_mtu_set && (host_mtu_size < 64 || host_mtu_size > 65355)) + { + errmsg ("host MTU size must be in between 64 and 65355. "); + return -99; + } /* Construct the API message */ M (TAP_CREATE_V2, mp); @@ -7598,6 +7563,9 @@ api_tap_create_v2 (vat_main_t * vam) mp->host_ip6_addr_set = host_ip6_prefix_len != 0; mp->rx_ring_sz = ntohs (rx_ring_sz); mp->tx_ring_sz = ntohs (tx_ring_sz); + mp->host_mtu_set = host_mtu_set; + mp->host_mtu_size = ntohl (host_mtu_size); + mp->tap_flags = ntohl (tap_flags); if (random_mac == 0) clib_memcpy (mp->mac_address, mac_address, 6); @@ -7801,6 +7769,7 @@ api_bond_create (vat_main_t * vam) u8 lb; u8 mode_is_set = 0; u32 id = ~0; + u8 numa_only = 0; clib_memset (mac_address, 0, sizeof (mac_address)); lb = BOND_LB_L2; @@ -7816,6 +7785,8 @@ api_bond_create (vat_main_t * vam) else if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address)) custom_mac = 1; + else if (unformat (i, "numa-only")) + numa_only = 1; else if (unformat (i, "id %u", &id)) ; else @@ -7836,6 +7807,7 @@ api_bond_create (vat_main_t * vam) mp->mode = mode; mp->lb = lb; mp->id = htonl (id); + mp->numa_only = numa_only; if (custom_mac) clib_memcpy (mp->mac_address, mac_address, 6); @@ -18957,7 +18929,7 @@ static void vl_api_mpls_route_details_t_handler (vl_api_mpls_route_details_t * mp) { vat_main_t *vam = &vat_main; - int count = ntohl (mp->mr_route.mr_n_paths); + int count = (int) clib_net_to_host_u32 (mp->mr_route.mr_n_paths); vl_api_fib_path_t *fp; int i; @@ -18977,7 +18949,7 @@ static void vl_api_mpls_route_details_t_handler_json (vl_api_mpls_route_details_t * mp) { vat_main_t *vam = &vat_main; - int count = ntohl (mp->mr_route.mr_n_paths); + int count = (int) clib_host_to_net_u32 (mp->mr_route.mr_n_paths); vat_json_node_t *node = NULL; vl_api_fib_path_t *fp; int i; @@ -19237,8 +19209,7 @@ vl_api_ip_route_details_t_handler (vl_api_ip_route_details_t * mp) print (vam->ofp, "table-id %d, prefix %U/%d", ntohl (mp->route.table_id), - format_ip46_address, - mp->route.prefix.address, mp->route.prefix.address_length); + format_ip46_address, mp->route.prefix.address, mp->route.prefix.len); for (i = 0; i < count; i++) { fp = &mp->route.paths[i]; @@ -19278,8 +19249,7 @@ static void vl_api_ip_route_details_t_handler_json clib_memcpy (&ip4, &mp->route.prefix.address.un.ip4, sizeof (ip4)); vat_json_object_add_ip4 (node, "prefix", ip4); } - vat_json_object_add_uint (node, "mask_length", - mp->route.prefix.address_length); + vat_json_object_add_uint (node, "mask_length", mp->route.prefix.len); vat_json_object_add_uint (node, "path_count", count); for (i = 0; i < count; i++) { @@ -20086,52 +20056,6 @@ api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam) return ret; } -static int -api_ipsec_gre_tunnel_add_del (vat_main_t * vam) -{ - unformat_input_t *i = vam->input; - vl_api_ipsec_gre_tunnel_add_del_t *mp; - u32 local_sa_id = 0; - u32 remote_sa_id = 0; - vl_api_ip4_address_t src_address; - vl_api_ip4_address_t dst_address; - u8 is_add = 1; - int ret; - - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) - { - if (unformat (i, "local_sa %d", &local_sa_id)) - ; - else if (unformat (i, "remote_sa %d", &remote_sa_id)) - ; - else - if (unformat (i, "src %U", unformat_vl_api_ip4_address, &src_address)) - ; - else - if (unformat (i, "dst %U", unformat_vl_api_ip4_address, &dst_address)) - ; - else if (unformat (i, "del")) - is_add = 0; - else - { - clib_warning ("parse error '%U'", format_unformat_error, i); - return -99; - } - } - - M (IPSEC_GRE_TUNNEL_ADD_DEL, mp); - - mp->tunnel.local_sa_id = ntohl (local_sa_id); - mp->tunnel.remote_sa_id = ntohl (remote_sa_id); - clib_memcpy (mp->tunnel.src, &src_address, sizeof (src_address)); - clib_memcpy (mp->tunnel.dst, &dst_address, sizeof (dst_address)); - mp->is_add = is_add; - - S (mp); - W (ret); - return ret; -} - static int api_set_punt (vat_main_t * vam) { @@ -20173,99 +20097,6 @@ api_set_punt (vat_main_t * vam) return ret; } -static void vl_api_ipsec_gre_tunnel_details_t_handler - (vl_api_ipsec_gre_tunnel_details_t * mp) -{ - vat_main_t *vam = &vat_main; - - print (vam->ofp, "%11d%15U%15U%14d%14d", - ntohl (mp->tunnel.sw_if_index), - format_vl_api_ip4_address, mp->tunnel.src, - format_vl_api_ip4_address, mp->tunnel.dst, - ntohl (mp->tunnel.local_sa_id), ntohl (mp->tunnel.remote_sa_id)); -} - -static void -vat_json_object_add_vl_api_ip4 (vat_json_node_t * node, - const char *name, - const vl_api_ip4_address_t addr) -{ - struct in_addr ip4; - - clib_memcpy (&ip4, addr, sizeof (ip4)); - vat_json_object_add_ip4 (node, name, ip4); -} - -static void vl_api_ipsec_gre_tunnel_details_t_handler_json - (vl_api_ipsec_gre_tunnel_details_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t *node = NULL; - - if (VAT_JSON_ARRAY != vam->json_tree.type) - { - ASSERT (VAT_JSON_NONE == vam->json_tree.type); - vat_json_init_array (&vam->json_tree); - } - node = vat_json_array_add (&vam->json_tree); - - vat_json_init_object (node); - vat_json_object_add_uint (node, "sw_if_index", - ntohl (mp->tunnel.sw_if_index)); - vat_json_object_add_vl_api_ip4 (node, "src", mp->tunnel.src); - vat_json_object_add_vl_api_ip4 (node, "src", mp->tunnel.dst); - vat_json_object_add_uint (node, "local_sa_id", - ntohl (mp->tunnel.local_sa_id)); - vat_json_object_add_uint (node, "remote_sa_id", - ntohl (mp->tunnel.remote_sa_id)); -} - -static int -api_ipsec_gre_tunnel_dump (vat_main_t * vam) -{ - unformat_input_t *i = vam->input; - vl_api_ipsec_gre_tunnel_dump_t *mp; - vl_api_control_ping_t *mp_ping; - u32 sw_if_index; - u8 sw_if_index_set = 0; - int ret; - - /* Parse args required to build the message */ - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) - { - if (unformat (i, "sw_if_index %d", &sw_if_index)) - sw_if_index_set = 1; - else - break; - } - - if (sw_if_index_set == 0) - { - sw_if_index = ~0; - } - - if (!vam->json_output) - { - print (vam->ofp, "%11s%15s%15s%14s%14s", - "sw_if_index", "src_address", "dst_address", - "local_sa_id", "remote_sa_id"); - } - - /* Get list of gre-tunnel interfaces */ - M (IPSEC_GRE_TUNNEL_DUMP, mp); - - mp->sw_if_index = htonl (sw_if_index); - - S (mp); - - /* Use a control ping for synchronization */ - MPING (CONTROL_PING, mp_ping); - S (mp_ping); - - W (ret); - return ret; -} - static int api_delete_subif (vat_main_t * vam) { @@ -21485,7 +21316,7 @@ api_ip_container_proxy_add_del (vat_main_t * vam) else break; } - if (sw_if_index == ~0 || pfx.address_length == 0) + if (sw_if_index == ~0 || pfx.len == 0) { errmsg ("address and sw_if_index must be set"); return -99; @@ -21542,8 +21373,8 @@ api_qos_record_enable_disable (vat_main_t * vam) M (QOS_RECORD_ENABLE_DISABLE, mp); - mp->sw_if_index = ntohl (sw_if_index); - mp->input_source = qs; + mp->record.sw_if_index = ntohl (sw_if_index); + mp->record.input_source = qs; mp->enable = enable; S (mp); @@ -21579,6 +21410,98 @@ comment (vat_main_t * vam) return 0; } +static int +elog_save (vat_main_t * vam) +{ +#if VPP_API_TEST_BUILTIN == 0 + elog_main_t *em = &vam->elog_main; + unformat_input_t *i = vam->input; + char *file, *chroot_file; + clib_error_t *error; + + if (!unformat (i, "%s", &file)) + { + errmsg ("expected file name, got `%U'", format_unformat_error, i); + return 0; + } + + /* It's fairly hard to get "../oopsie" through unformat; just in case */ + if (strstr (file, "..") || index (file, '/')) + { + errmsg ("illegal characters in filename '%s'", file); + return 0; + } + + chroot_file = (char *) format (0, "/tmp/%s%c", file, 0); + + vec_free (file); + + errmsg ("Saving %wd of %wd events to %s", + elog_n_events_in_buffer (em), + elog_buffer_capacity (em), chroot_file); + + error = elog_write_file (em, chroot_file, 1 /* flush ring */ ); + vec_free (chroot_file); + + if (error) + clib_error_report (error); +#else + errmsg ("Use the vpp event loger..."); +#endif + + return 0; +} + +static int +elog_setup (vat_main_t * vam) +{ +#if VPP_API_TEST_BUILTIN == 0 + elog_main_t *em = &vam->elog_main; + unformat_input_t *i = vam->input; + u32 nevents = 128 << 10; + + (void) unformat (i, "nevents %d", &nevents); + + elog_init (em, nevents); + vl_api_set_elog_main (em); + vl_api_set_elog_trace_api_messages (1); + errmsg ("Event logger initialized with %u events", nevents); +#else + errmsg ("Use the vpp event loger..."); +#endif + return 0; +} + +static int +elog_enable (vat_main_t * vam) +{ +#if VPP_API_TEST_BUILTIN == 0 + elog_main_t *em = &vam->elog_main; + + elog_enable_disable (em, 1 /* enable */ ); + vl_api_set_elog_trace_api_messages (1); + errmsg ("Event logger enabled..."); +#else + errmsg ("Use the vpp event loger..."); +#endif + return 0; +} + +static int +elog_disable (vat_main_t * vam) +{ +#if VPP_API_TEST_BUILTIN == 0 + elog_main_t *em = &vam->elog_main; + + elog_enable_disable (em, 0 /* enable */ ); + vl_api_set_elog_trace_api_messages (1); + errmsg ("Event logger disabled..."); +#else + errmsg ("Use the vpp event loger..."); +#endif + return 0; +} + static int statseg (vat_main_t * vam) { @@ -22034,7 +21957,7 @@ _(l2_flags, \ _(bridge_flags, \ "bd_id [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \ _(tap_create_v2, \ - "id [hw-addr ] [host-ns ] [rx-ring-size [tx-ring-size ]") \ + "id [hw-addr ] [host-ns ] [rx-ring-size [tx-ring-size ] [host-mtu-size ] [gso | no-gso]") \ _(tap_delete_v2, \ " | sw_if_index ") \ _(sw_interface_tap_v2_dump, "") \ @@ -22409,9 +22332,6 @@ _(ip_source_and_port_range_check_add_del, \ _(ip_source_and_port_range_check_interface_add_del, \ " | sw_if_index [tcp-out-vrf ] [tcp-in-vrf ]" \ "[udp-in-vrf ] [udp-out-vrf ]") \ -_(ipsec_gre_tunnel_add_del, \ - "src dst local_sa remote_sa [del]") \ -_(ipsec_gre_tunnel_dump, "[sw_if_index ]") \ _(delete_subif," | sw_if_index ") \ _(l2_interface_pbb_tag_rewrite, \ " | sw_if_index \n" \ @@ -22466,6 +22386,10 @@ _(dump_ipv6_table, "usage: dump_ipv6_table") \ _(dump_macro_table, "usage: dump_macro_table ") \ _(dump_node_table, "usage: dump_node_table") \ _(dump_msg_api_table, "usage: dump_msg_api_table") \ +_(elog_setup, "usage: elog_setup [nevents, default 128K]") \ +_(elog_disable, "usage: elog_disable") \ +_(elog_enable, "usage: elog_enable") \ +_(elog_save, "usage: elog_save ") \ _(get_msg_id, "usage: get_msg_id name_and_crc") \ _(echo, "usage: echo ") \ _(exec, "usage: exec ") \