X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=vpp%2Fvpp-api%2Fapi.c;h=91ec833e7b03f8d860098d3257c96adc89f71f98;hb=9e6ed6e2e1b8af46a317f9448da2bca8d8c5395d;hp=f7338af5db1e48849227f8d58f5bf0c53c1d2cad;hpb=4d5cabde54f847bccd365c64682e428aead30550;p=vpp.git diff --git a/vpp/vpp-api/api.c b/vpp/vpp-api/api.c index f7338af5db1..91ec833e7b0 100644 --- a/vpp/vpp-api/api.c +++ b/vpp/vpp-api/api.c @@ -347,6 +347,7 @@ _(LISP_ENABLE_DISABLE_STATUS_DUMP, \ _(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, \ lisp_add_del_map_request_itr_rlocs) \ _(LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs) \ +_(SHOW_LISP_PITR, show_lisp_pitr) \ _(SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del) \ _(AF_PACKET_CREATE, af_packet_create) \ _(AF_PACKET_DELETE, af_packet_delete) \ @@ -368,7 +369,11 @@ _(CLASSIFY_TABLE_INFO,classify_table_info) \ _(CLASSIFY_SESSION_DUMP,classify_session_dump) \ _(CLASSIFY_SESSION_DETAILS,classify_session_details) \ _(IPFIX_ENABLE,ipfix_enable) \ -_(IPFIX_DUMP,ipfix_dump) +_(IPFIX_DUMP,ipfix_dump) \ +_(GET_NEXT_INDEX, get_next_index) \ +_(PG_CREATE_INTERFACE, pg_create_interface) \ +_(PG_CAPTURE, pg_capture) \ +_(PG_ENABLE_DISABLE, pg_enable_disable) #define QUOTE_(x) #x #define QUOTE(x) QUOTE_(x) @@ -4243,6 +4248,48 @@ static void vl_api_get_node_index_t_handler })) } +static void vl_api_get_next_index_t_handler +(vl_api_get_next_index_t * mp) +{ + vlib_main_t * vm = vlib_get_main(); + vl_api_get_next_index_reply_t * rmp; + vlib_node_t * node, * next_node; + int rv = 0; + u32 next_node_index = ~0, next_index = ~0; + uword * p; + + node = vlib_get_node_by_name (vm, mp->node_name); + + if (node == 0) { + rv = VNET_API_ERROR_NO_SUCH_NODE; + goto out; + } + + next_node = vlib_get_node_by_name (vm, mp->next_name); + + if (next_node == 0) { + rv = VNET_API_ERROR_NO_SUCH_NODE2; + goto out; + } + else + next_node_index = next_node->index; + + p = hash_get (node->next_slot_by_node, next_node_index); + + if (p == 0) { + rv = VNET_API_ERROR_NO_SUCH_ENTRY; + goto out; + } + else + next_index = p[0]; + + out: + REPLY_MACRO2(VL_API_GET_NEXT_INDEX_REPLY, + ({ + rmp->next_index = ntohl(next_index); + })); +} + static void vl_api_add_node_next_t_handler (vl_api_add_node_next_t * mp) { @@ -4286,6 +4333,20 @@ static void vl_api_l2tpv3_create_tunnel_t_handler goto out; } + u32 encap_fib_index; + + if (mp->encap_vrf_id != ~0) { + uword *p; + ip6_main_t *im = &ip6_main; + if (!(p = hash_get (im->fib_index_by_table_id, ntohl(mp->encap_vrf_id)))) { + rv = VNET_API_ERROR_NO_SUCH_FIB; + goto out; + } + encap_fib_index = p[0]; + } else { + encap_fib_index = ~0; + } + rv = create_l2tpv3_ipv6_tunnel (lm, (ip6_address_t *) mp->client_address, (ip6_address_t *) mp->our_address, @@ -4294,6 +4355,7 @@ static void vl_api_l2tpv3_create_tunnel_t_handler clib_net_to_host_u64(mp->local_cookie), clib_net_to_host_u64(mp->remote_cookie), mp->l2_sublayer_present, + encap_fib_index, &sw_if_index); out: @@ -5097,29 +5159,24 @@ vl_api_lisp_add_del_remote_mapping_t_handler ( vec_add1 (rlocs, rloc); } - /* TODO Uncomment once https://gerrit.fd.io/r/#/c/1802 is merged and CSIT - * is switched to lisp_add_del_adjacency */ -// if (!mp->is_add) { -// vnet_lisp_add_del_adjacency_args_t _a, * a = &_a; -// gid_address_copy(&a->deid, deid); -// a->is_add = 0; -// rv = vnet_lisp_add_del_adjacency (a); -// } else { -// /* NOTE: for now this works as a static remote mapping, i.e., -// * not authoritative and ttl infinite. */ -// rv = vnet_lisp_add_del_mapping (deid, rlocs, mp->action, 0, ~0, -// mp->is_add, 0); -// } - - /* TODO: remove once the above is merged */ - vnet_lisp_add_del_adjacency_args_t _a, * a = &_a; - a->is_add = mp->is_add; - a->authoritative = 0; - a->action = mp->action; - a->locators = rlocs; - gid_address_copy(&a->seid, seid); - gid_address_copy(&a->deid, deid); - rv = vnet_lisp_add_del_adjacency (a); + if (!mp->is_add) { + vnet_lisp_add_del_adjacency_args_t _a, * a = &_a; + gid_address_copy(&a->deid, deid); + a->is_add = 0; + rv = vnet_lisp_add_del_adjacency (a); + } else { + /* NOTE: for now this works as a static remote mapping, i.e., + * not authoritative and ttl infinite. */ + rv = vnet_lisp_add_del_mapping (deid, rlocs, mp->action, 0, ~0, + mp->is_add, 0); + + /* TODO remove once CSIT switched to lisp_add_del_adjacency */ + vnet_lisp_add_del_adjacency_args_t _a, * a = &_a; + gid_address_copy(&a->seid, seid); + gid_address_copy(&a->deid, deid); + a->is_add = 1; + vnet_lisp_add_del_adjacency (a); + } if (mp->del_all) vnet_lisp_clear_all_remote_adjacencies (); @@ -5133,8 +5190,6 @@ static void vl_api_lisp_add_del_adjacency_t_handler ( vl_api_lisp_add_del_adjacency_t *mp) { - u32 i; - locator_t rloc; vl_api_lisp_add_del_adjacency_reply_t * rmp; vnet_lisp_add_del_adjacency_args_t _a, * a = &_a; @@ -5178,29 +5233,9 @@ vl_api_lisp_add_del_adjacency_t_handler ( goto send_reply; } - for (i = 0; i < mp->rloc_num; i++) { - rloc_t * r = &((rloc_t *) mp->rlocs)[i]; - memset(&rloc, 0, sizeof(rloc)); - ip_address_set(&gid_address_ip(&rloc.address), &r->addr, - r->is_ip4 ? IP4 : IP6); - gid_address_ippref_len(&rloc.address) = r->is_ip4 ? 32: 128; - gid_address_type(&rloc.address) = GID_ADDR_IP_PREFIX; - rloc.priority = r->priority; - rloc.weight = r->weight; - vec_add1 (a->locators, rloc); - } - - a->action = mp->action; a->is_add = mp->is_add; - - /* NOTE: the remote mapping is static, i.e., not authoritative and - * ttl is infinite. */ - a->authoritative = 0; - a->ttl = ~0; - rv = vnet_lisp_add_del_adjacency (a); - vec_free (a->locators); send_reply: REPLY_MACRO(VL_API_LISP_ADD_DEL_ADJACENCY_REPLY); } @@ -5480,6 +5515,23 @@ vl_api_lisp_map_resolver_dump_t_handler ( } +static void +send_eid_table_map_pair (hash_pair_t * p, + unix_shared_memory_queue_t * q, + u32 context) +{ + vl_api_lisp_eid_table_map_details_t * rmp = NULL; + + rmp = vl_msg_api_alloc (sizeof (*rmp)); + memset (rmp, 0, sizeof (*rmp)); + rmp->_vl_msg_id = ntohs(VL_API_LISP_EID_TABLE_MAP_DETAILS); + + rmp->vni = clib_host_to_net_u32 (p->key); + rmp->vrf = clib_host_to_net_u32 (p->value[0]); + rmp->context = context; + vl_msg_api_send_shmem (q, (u8 *)&rmp); +} + static void vl_api_lisp_eid_table_map_dump_t_handler ( vl_api_lisp_eid_table_map_dump_t *mp) @@ -5493,12 +5545,7 @@ vl_api_lisp_eid_table_map_dump_t_handler ( return; } hash_foreach_pair (p, lcm->table_id_by_vni, { - vl_api_lisp_eid_table_map_details_t * rmp = NULL; - memset (rmp, 0, sizeof (*rmp)); - rmp->_vl_msg_id = ntohs(VL_API_LISP_EID_TABLE_MAP_DETAILS); - rmp->vni = p->key; - rmp->vrf = p->value[0]; - rmp->context = mp->context; + send_eid_table_map_pair (p, q, mp->context); }); } @@ -5565,6 +5612,43 @@ vl_api_lisp_get_map_request_itr_rlocs_t_handler ( vec_free(tmp_str); } +static void +vl_api_show_lisp_pitr_t_handler (vl_api_show_lisp_pitr_t * mp) +{ + unix_shared_memory_queue_t * q = NULL; + vl_api_show_lisp_pitr_reply_t * rmp = NULL; + lisp_cp_main_t * lcm = vnet_lisp_cp_get_main(); + mapping_t * m; + locator_set_t * ls = 0; + u8 * tmp_str = 0; + int rv = 0; + + q = vl_api_client_index_to_input_queue (mp->client_index); + if (q == 0) { + return; + } + + if (~0 == lcm->pitr_map_index) { + tmp_str = format(0, "N/A"); + } else { + m = pool_elt_at_index (lcm->mapping_pool, lcm->pitr_map_index); + if (~0 != m->locator_set_index) { + ls = pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index); + tmp_str = format(0, "%s", ls->name); + } else { + tmp_str = format(0, "N/A"); + } + } + vec_add1(tmp_str, 0); + + REPLY_MACRO2(VL_API_SHOW_LISP_PITR_REPLY, + ({ + rmp->status = lcm->lisp_pitr; + strncpy((char *) rmp->locator_set_name, (char *) tmp_str, + ARRAY_LEN(rmp->locator_set_name) - 1); + })); +} + static void vl_api_interface_name_renumber_t_handler (vl_api_interface_name_renumber_t *mp) { @@ -5746,7 +5830,7 @@ static void vl_api_ipsec_spd_add_del_entry_t_handler p.is_outbound = mp->is_outbound; p.is_ipv6 = mp->is_ipv6; - if (mp->is_ipv6) { + if (mp->is_ipv6 || mp->is_ip_any) { clib_memcpy(&p.raddr.start, mp->remote_address_start, 16); clib_memcpy(&p.raddr.stop, mp->remote_address_stop, 16); clib_memcpy(&p.laddr.start, mp->local_address_start, 16); @@ -6355,6 +6439,12 @@ vl_api_policer_add_del_t_handler cfg.rb.kbps.eir_kbps = mp->eir; cfg.rb.kbps.cb_bytes = mp->cb; cfg.rb.kbps.eb_bytes = mp->eb; + cfg.conform_action.action_type = mp->conform_action_type; + cfg.conform_action.dscp = mp->conform_dscp; + cfg.exceed_action.action_type = mp->exceed_action_type; + cfg.exceed_action.dscp = mp->exceed_dscp; + cfg.violate_action.action_type = mp->violate_action_type; + cfg.violate_action.dscp = mp->violate_dscp; error = policer_add_del(vm, name, &cfg, mp->is_add); @@ -6384,6 +6474,12 @@ send_policer_details (u8 *name, mp->rate_type = config->rate_type; mp->round_type = config->rnd_type; mp->type = config->rfc; + mp->conform_action_type = config->conform_action.action_type; + mp->conform_dscp = config->conform_action.dscp; + mp->exceed_action_type = config->exceed_action.action_type; + mp->exceed_dscp = config->exceed_action.dscp; + mp->violate_action_type = config->violate_action.action_type; + mp->violate_dscp = config->violate_action.dscp; mp->single_rate = templ->single_rate ? 1 : 0; mp->color_aware = templ->color_aware ? 1 : 0; mp->scale = htonl(templ->scale); @@ -7036,8 +7132,8 @@ static void vl_api_ipfix_enable_t_handler (vl_api_ipfix_enable_t *mp) collector_port = ntohs(mp->collector_port); if (collector_port == (u16)~0) collector_port = UDP_DST_PORT_ipfix; - memcpy(src.data, mp->src_address, sizeof(src.data)); - fib_id = ntohl(mp->vrf_id); + memcpy(src.data, mp->src_address, sizeof(src.data)); + fib_id = ntohl(mp->vrf_id); ip4_main_t * im = &ip4_main; uword * p = hash_get (im->fib_index_by_table_id, fib_id); @@ -7119,6 +7215,86 @@ static void vl_api_ipfix_dump_t_handler (vl_api_ipfix_dump_t *mp) vl_msg_api_send_shmem (q, (u8 *)&rmp); } +static void vl_api_pg_create_interface_t_handler (vl_api_pg_create_interface_t *mp) +{ + vl_api_pg_create_interface_reply_t *rmp; + int rv = 0; + + pg_main_t * pg = &pg_main; + u32 sw_if_index = pg_interface_add_or_get (pg, ntohl(mp->interface_id)); + + REPLY_MACRO2(VL_API_PG_CREATE_INTERFACE_REPLY, + ({ + rmp->sw_if_index = ntohl(sw_if_index); + })); +} + +static void vl_api_pg_capture_t_handler (vl_api_pg_capture_t *mp) +{ + vl_api_pg_capture_reply_t *rmp; + int rv = 0; + + vnet_main_t * vnm = vnet_get_main(); + vnet_interface_main_t * im = &vnm->interface_main; + vnet_hw_interface_t * hi = 0; + + u8 * intf_name = format (0, "pg%d", ntohl(mp->interface_id), 0); + u32 hw_if_index = ~0; + uword * p = hash_get_mem (im->hw_interface_by_name, intf_name); + if (p) + hw_if_index = *p; + vec_free (intf_name); + + if (hw_if_index != ~0) { + pg_capture_args_t _a, *a=&_a; + + u32 len = ntohl(mp->pcap_name_length); + u8 * pcap_file_name = vec_new(u8, len); + clib_memcpy(pcap_file_name, mp->pcap_file_name, len); + + hi = vnet_get_sup_hw_interface (vnm, hw_if_index); + a->hw_if_index = hw_if_index; + a->dev_instance = hi->dev_instance; + a->is_enabled = mp->is_enabled; + a->pcap_file_name = pcap_file_name; + a->count = ntohl(mp->count); + + clib_error_t * e = pg_capture (a); + if (e) { + clib_error_report(e); + rv = VNET_API_ERROR_CANNOT_CREATE_PCAP_FILE; + } + + vec_free (pcap_file_name); + } + REPLY_MACRO(VL_API_PG_CAPTURE_REPLY); +} + +static void vl_api_pg_enable_disable_t_handler (vl_api_pg_enable_disable_t *mp) +{ + vl_api_pg_enable_disable_reply_t *rmp; + int rv = 0; + + pg_main_t * pg = &pg_main; + u32 stream_index = ~0; + + int is_enable = mp->is_enabled != 0; + u32 len = ntohl(mp->stream_name_length)-1; + + if (len>0) { + u8 * stream_name = vec_new(u8, len); + clib_memcpy(stream_name, mp->stream_name, len); + uword * p = hash_get_mem (pg->stream_index_by_name, stream_name); + if (p) + stream_index = *p; + vec_free(stream_name); + } + + pg_enable_disable (stream_index, is_enable); + + REPLY_MACRO(VL_API_PG_ENABLE_DISABLE_REPLY); +} + #define BOUNCE_HANDLER(nn) \ static void vl_api_##nn##_t_handler ( \ vl_api_##nn##_t *mp) \