From 3e53fc56645f4b99d014031995bd00d16c051a9b Mon Sep 17 00:00:00 2001 From: Andrej Kozemcak Date: Mon, 9 May 2016 10:52:16 +0200 Subject: ONE-11: Fix bugs in LISP API - check input variables - in locator_set dump, add support for remote locator_set Change-Id: Ib10028e83fead358f820ae45c71b6ca4dfbe2f1e Signed-off-by: Andrej Kozemcak --- vpp/api/api.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++------- vpp/api/vpe.api | 4 ++++ 2 files changed, 52 insertions(+), 7 deletions(-) (limited to 'vpp') diff --git a/vpp/api/api.c b/vpp/api/api.c index 4809a6e5318..9bf4d3c957a 100644 --- a/vpp/api/api.c +++ b/vpp/api/api.c @@ -4910,24 +4910,54 @@ vl_api_lisp_gpe_add_del_iface_t_handler( REPLY_MACRO(VL_API_LISP_GPE_ADD_DEL_IFACE_REPLY); } +static void +send_lisp_locator_set_details_set_address +(vl_api_lisp_locator_set_details_t *rmp, + gid_address_t *gid_address) +{ + ip_prefix_t *ip_addr; + + if (gid_address_type(gid_address) != GID_ADDR_IP_PREFIX) { + return; + } + + ip_addr = &gid_address_ippref(gid_address); + rmp->prefix_len = ip_prefix_len(ip_addr); + rmp->is_ipv6 = ip_prefix_version(ip_addr); + ip_address_copy_addr(rmp->ip_address, &ip_prefix_addr(ip_addr)); +} + static void send_lisp_locator_set_details (lisp_cp_main_t *lcm, locator_set_t *lsit, unix_shared_memory_queue_t *q, - u32 context) + u32 context, + u32 index) { vl_api_lisp_locator_set_details_t *rmp; locator_t *loc = NULL; u32 * locit = NULL; + u8 * str = NULL; vec_foreach (locit, lsit->locator_indices) { loc = pool_elt_at_index (lcm->locator_pool, locit[0]); rmp = vl_msg_api_alloc (sizeof (*rmp)); memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs(VL_API_LISP_LOCATOR_SET_DETAILS); - strncpy((char *) rmp->locator_set_name, - (char *) lsit->name, ARRAY_LEN(rmp->locator_set_name) - 1); - rmp->sw_if_index = htonl(loc->sw_if_index); + rmp->local = lsit->local; + if (lsit->local) { + ASSERT(lsit->name != NULL); + strncpy((char *) rmp->locator_set_name, + (char *) lsit->name, ARRAY_LEN(rmp->locator_set_name) - 1); + rmp->sw_if_index = htonl(loc->sw_if_index); + } else { + str = format(0, "remote-%d", index); + strncpy((char *) rmp->locator_set_name, (char *) str, + ARRAY_LEN(rmp->locator_set_name) - 1); + send_lisp_locator_set_details_set_address(rmp, &loc->address); + + vec_free(str); + } rmp->priority = loc->priority; rmp->weight = loc->weight; rmp->context = context; @@ -4942,15 +4972,17 @@ vl_api_lisp_locator_set_dump_t_handler (vl_api_lisp_locator_set_dump_t *mp) unix_shared_memory_queue_t * q = NULL; lisp_cp_main_t * lcm = vnet_lisp_cp_get_main(); locator_set_t * lsit = NULL; + u32 index; q = vl_api_client_index_to_input_queue (mp->client_index); if (q == 0) { return; } + index = 0; pool_foreach (lsit, lcm->locator_set_pool, ({ - send_lisp_locator_set_details(lcm, lsit, q, mp->context); + send_lisp_locator_set_details(lcm, lsit, q, mp->context, index++); })); } @@ -4964,6 +4996,7 @@ send_lisp_local_eid_table_details (mapping_t *mapit, locator_set_t *ls = NULL; gid_address_t *gid = NULL; ip_prefix_t *ip_prefix = NULL; + u8 * str = NULL; u8 type = ~0; ls = pool_elt_at_index (lcm->locator_set_pool, @@ -4981,8 +5014,16 @@ send_lisp_local_eid_table_details (mapping_t *mapit, rmp = vl_msg_api_alloc (sizeof (*rmp)); memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs(VL_API_LISP_LOCAL_EID_TABLE_DETAILS); - strncpy((char *) rmp->locator_set_name, - (char *) ls->name, ARRAY_LEN(rmp->locator_set_name) - 1); + if (ls->local) { + ASSERT(ls->name != NULL); + strncpy((char *) rmp->locator_set_name, + (char *) ls->name, ARRAY_LEN(rmp->locator_set_name) - 1); + } else { + str = format(0, "remote-%d", mapit->locator_set_index); + strncpy((char *) rmp->locator_set_name, (char *) str, + ARRAY_LEN(rmp->locator_set_name) - 1); + vec_free(str); + } switch (ip_prefix_version(ip_prefix)) { case IP4: diff --git a/vpp/api/vpe.api b/vpp/api/vpe.api index bef6ffb4dd0..8b5b21ca02c 100644 --- a/vpp/api/vpe.api +++ b/vpp/api/vpe.api @@ -2373,8 +2373,12 @@ define lisp_gpe_add_del_iface_reply { */ manual_java define lisp_locator_set_details { u32 context; + u8 local; u8 locator_set_name[64]; u32 sw_if_index; + u8 is_ipv6; + u8 ip_address[16]; + u8 prefix_len; u8 priority; u8 weight; }; -- cgit 1.2.3-korg