X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvat%2Fapi_format.c;h=4f20ea823612796d409fbb137f849fc4a156ee08;hb=7866c45;hp=e8d6bd5b1c18970d7cc6fd28ef4ce7eb1dcd461a;hpb=c42fc05bfbb26fd11fe92ac9d11587660a817ac1;p=vpp.git diff --git a/src/vat/api_format.c b/src/vat/api_format.c index e8d6bd5b1c1..4f20ea82361 100644 --- a/src/vat/api_format.c +++ b/src/vat/api_format.c @@ -19,7 +19,6 @@ #include #include -#include #include #include #include @@ -88,9 +87,9 @@ vl (void *p) int vat_socket_connect (vat_main_t * vam) { - return vl_socket_client_connect - (&vam->socket_client_main, (char *) vam->socket_name, - "vpp_api_test(s)", 0 /* default socket rx, tx buffer */ ); + vam->socket_client_main = &socket_client_main; + return vl_socket_client_connect ((char *) vam->socket_name, "vpp_api_test", + 0 /* default socket rx, tx buffer */ ); } #else /* vpp built-in case, we don't do sockets... */ int @@ -99,10 +98,23 @@ vat_socket_connect (vat_main_t * vam) return 0; } -void -vl_socket_client_read_reply (socket_client_main_t * scm) +int +vl_socket_client_read (int wait) +{ + return -1; +}; + +int +vl_socket_client_write () { + return -1; }; + +void * +vl_socket_client_msg_alloc (int nbytes) +{ + return 0; +} #endif @@ -1464,7 +1476,8 @@ static void vl_api_control_ping_reply_t_handler vam->retval = retval; vam->result_ready = 1; } - vam->socket_client_main.control_pings_outstanding--; + if (vam->socket_client_main) + vam->socket_client_main->control_pings_outstanding--; } static void vl_api_control_ping_reply_t_handler_json @@ -1970,6 +1983,7 @@ static void vl_api_vxlan_add_del_tunnel_reply_t_handler vam->sw_if_index = ntohl (mp->sw_if_index); vam->result_ready = 1; } + vam->regenerate_interface_table = 1; } static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json @@ -2038,6 +2052,7 @@ static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler vam->sw_if_index = ntohl (mp->sw_if_index); vam->result_ready = 1; } + vam->regenerate_interface_table = 1; } static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json @@ -2106,6 +2121,7 @@ static void vl_api_create_vhost_user_if_reply_t_handler vam->sw_if_index = ntohl (mp->sw_if_index); vam->result_ready = 1; } + vam->regenerate_interface_table = 1; } static void vl_api_create_vhost_user_if_reply_t_handler_json @@ -2186,10 +2202,10 @@ static void vl_api_memfd_segment_create_reply_t_handler #if VPP_API_TEST_BUILTIN == 0 vat_main_t *vam = &vat_main; api_main_t *am = &api_main; - socket_client_main_t *scm = &vam->socket_client_main; + socket_client_main_t *scm = vam->socket_client_main; int my_fd = -1; clib_error_t *error; - memfd_private_t memfd; + ssvm_private_t memfd; i32 retval = ntohl (mp->retval); if (retval == 0) @@ -2207,7 +2223,7 @@ static void vl_api_memfd_segment_create_reply_t_handler vam->client_index_invalid = 1; /* Note: this closes memfd.fd */ - retval = memfd_slave_init (&memfd); + retval = ssvm_slave_init_memfd (&memfd); if (retval) clib_warning ("WARNING: segment map returned %d", retval); @@ -2224,8 +2240,7 @@ static void vl_api_memfd_segment_create_reply_t_handler 32 /* input_queue_length */ ); vam->vl_input_queue = am->shmem_hdr->vl_input_queue; - vl_socket_client_enable_disable (&vam->socket_client_main, - 0 /* disable socket */ ); + vl_socket_client_enable_disable (0 /* disable socket */ ); } out: @@ -5149,6 +5164,7 @@ static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler vam->sw_if_index = ntohl (mp->sw_if_index); vam->result_ready = 1; } + vam->regenerate_interface_table = 1; } static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json @@ -6316,73 +6332,12 @@ api_sw_interface_dump (vat_main_t * vam) /* recreate the interface name hash table */ vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword)); - /* Get list of ethernets */ - M (SW_INTERFACE_DUMP, mp); - mp->name_filter_valid = 1; - strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1); - S (mp); - - /* and local / loopback interfaces */ - M (SW_INTERFACE_DUMP, mp); - mp->name_filter_valid = 1; - strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1); - S (mp); - - /* and packet-generator interfaces */ - M (SW_INTERFACE_DUMP, mp); - mp->name_filter_valid = 1; - strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1); - S (mp); - - /* and vxlan-gpe tunnel interfaces */ - M (SW_INTERFACE_DUMP, mp); - mp->name_filter_valid = 1; - strncpy ((char *) mp->name_filter, "vxlan_gpe", - sizeof (mp->name_filter) - 1); - S (mp); - - /* and vxlan tunnel interfaces */ - M (SW_INTERFACE_DUMP, mp); - mp->name_filter_valid = 1; - strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1); - S (mp); - - /* and geneve tunnel interfaces */ - M (SW_INTERFACE_DUMP, mp); - mp->name_filter_valid = 1; - strncpy ((char *) mp->name_filter, "geneve", sizeof (mp->name_filter) - 1); - S (mp); - - /* and host (af_packet) interfaces */ - M (SW_INTERFACE_DUMP, mp); - mp->name_filter_valid = 1; - strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1); - S (mp); - - /* and l2tpv3 tunnel interfaces */ - M (SW_INTERFACE_DUMP, mp); - mp->name_filter_valid = 1; - strncpy ((char *) mp->name_filter, "l2tpv3_tunnel", - sizeof (mp->name_filter) - 1); - S (mp); - - /* and GRE tunnel interfaces */ - M (SW_INTERFACE_DUMP, mp); - mp->name_filter_valid = 1; - strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1); - S (mp); - - /* and LISP-GPE interfaces */ - M (SW_INTERFACE_DUMP, mp); - mp->name_filter_valid = 1; - strncpy ((char *) mp->name_filter, "lisp_gpe", - sizeof (mp->name_filter) - 1); - S (mp); - - /* and IPSEC tunnel interfaces */ + /* + * Ask for all interface names. Otherwise, the epic catalog of + * name filters becomes ridiculously long, and vat ends up needing + * to be taught about new interface types. + */ M (SW_INTERFACE_DUMP, mp); - mp->name_filter_valid = 1; - strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1); S (mp); /* Use a control ping for synchronization */ @@ -7817,8 +7772,12 @@ api_tap_create_v2 (vat_main_t * vam) u8 host_mac_addr_set = 0; u8 *host_bridge = 0; ip4_address_t host_ip4_addr; + ip4_address_t host_ip4_gw; + u8 host_ip4_gw_set = 0; u32 host_ip4_prefix_len = 0; ip6_address_t host_ip6_addr; + ip6_address_t host_ip6_gw; + u8 host_ip6_gw_set = 0; u32 host_ip6_prefix_len = 0; int ret; int rx_ring_sz = 0, tx_ring_sz = 0; @@ -7849,6 +7808,12 @@ api_tap_create_v2 (vat_main_t * vam) else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address, &host_ip6_addr, &host_ip6_prefix_len)) ; + else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address, + &host_ip4_gw)) + host_ip4_gw_set = 1; + else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address, + &host_ip6_gw)) + host_ip6_gw_set = 1; else if (unformat (i, "rx-ring-size %d", &rx_ring_sz)) ; else if (unformat (i, "tx-ring-size %d", &tx_ring_sz)) @@ -7930,7 +7895,10 @@ api_tap_create_v2 (vat_main_t * vam) clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4); if (host_ip4_prefix_len) clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16); - + if (host_ip4_gw_set) + clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4); + if (host_ip6_gw_set) + clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16); vec_free (host_ns); vec_free (host_if_name); @@ -12439,8 +12407,20 @@ static void vl_api_sw_interface_tap_v2_details_t_handler { vat_main_t *vam = &vat_main; - print (vam->ofp, "%-16s %d", - mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index)); + u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr, + mp->host_ip4_prefix_len); + u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr, + mp->host_ip6_prefix_len); + + print (vam->ofp, + "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s", + mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id), + ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz), + format_ethernet_address, mp->host_mac_addr, mp->host_namespace, + mp->host_bridge, ip4, ip6); + + vec_free (ip4); + vec_free (ip6); } static void vl_api_sw_interface_tap_v2_details_t_handler_json @@ -12457,8 +12437,26 @@ static void vl_api_sw_interface_tap_v2_details_t_handler_json node = vat_json_array_add (&vam->json_tree); vat_json_init_object (node); + vat_json_object_add_uint (node, "id", ntohl (mp->id)); vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index)); vat_json_object_add_string_copy (node, "dev_name", mp->dev_name); + vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz)); + vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz)); + vat_json_object_add_string_copy (node, "host_mac_addr", + format (0, "%U", format_ethernet_address, + &mp->host_mac_addr)); + vat_json_object_add_string_copy (node, "host_namespace", + mp->host_namespace); + vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge); + vat_json_object_add_string_copy (node, "host_ip4_addr", + format (0, "%U/%d", format_ip4_address, + mp->host_ip4_addr, + mp->host_ip4_prefix_len)); + vat_json_object_add_string_copy (node, "host_ip6_addr", + format (0, "%U/%d", format_ip6_address, + mp->host_ip6_addr, + mp->host_ip6_prefix_len)); + } static int @@ -12468,7 +12466,12 @@ api_sw_interface_tap_v2_dump (vat_main_t * vam) vl_api_control_ping_t *mp_ping; int ret; - print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index"); + print (vam->ofp, + "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s", + "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz", + "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr", + "host_ip6_addr"); + /* Get list of tap interfaces */ M (SW_INTERFACE_TAP_V2_DUMP, mp); S (mp); @@ -21830,6 +21833,46 @@ api_memfd_segment_create (vat_main_t * vam) #endif } +static int +api_sock_init_shm (vat_main_t * vam) +{ +#if VPP_API_TEST_BUILTIN == 0 + unformat_input_t *i = vam->input; + vl_api_shm_elem_config_t *config = 0; + u64 size = 64 << 20; + int rv; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "size %U", unformat_memory_size, &size)) + ; + else + break; + } + + /* Try customized config to see if it works */ + vec_validate (config, 3); + config[0].type = VL_API_VLIB_RING; + config[0].count = 256; + config[0].size = 256; + config[1].type = VL_API_CLIENT_RING; + config[1].count = 256; + config[1].size = 1024; + config[2].type = VL_API_CLIENT_RING; + config[2].count = 8; + config[2].size = 4096; + config[3].type = VL_API_QUEUE; + config[3].count = 256; + config[3].size = sizeof (uword); + rv = vl_socket_client_init_shm (config); + if (!rv) + vam->client_index_invalid = 1; + return rv; +#else + return -99; +#endif +} + static int api_dns_enable_disable (vat_main_t * vam) { @@ -22483,7 +22526,7 @@ get_msg_id (vat_main_t * vam) if (unformat (vam->input, "%s", &name_and_crc)) { - message_index = vl_api_get_msg_index (name_and_crc); + message_index = vl_msg_api_get_msg_index (name_and_crc); if (message_index == ~0) { print (vam->ofp, " '%s' not found", name_and_crc); @@ -23058,6 +23101,7 @@ _(sw_interface_set_lldp, " | sw_if_index [port-desc ]\n " [mgmt-ip4 ] [mgmt-ip6 ] [mgmt-oid ] [disable]") \ _(tcp_configure_src_addresses, "first-last [vrf ]") \ _(memfd_segment_create,"size ") \ +_(sock_init_shm, "size ") \ _(app_namespace_add_del, "[add] id secret sw_if_index ")\ _(dns_enable_disable, "[enable][disable]") \ _(dns_name_server_add_del, " [del]") \