X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Flisp-cp%2Flisp_api.c;h=f1b68d477aed45840cb7c5c3445d478975cc8418;hb=8daa80a4adfd82a19017c2c12554a8a43dddccd7;hp=d91f9907752a8f07bcbaad7f83722c2e87c5296c;hpb=974cdc6faacc49ef393eeea6e4c9643f767d2792;p=vpp.git diff --git a/src/vnet/lisp-cp/lisp_api.c b/src/vnet/lisp-cp/lisp_api.c index d91f9907752..f1b68d477ae 100644 --- a/src/vnet/lisp-cp/lisp_api.c +++ b/src/vnet/lisp-cp/lisp_api.c @@ -128,7 +128,9 @@ vl_api_lisp_add_del_locator_set_t_handler (vl_api_lisp_add_del_locator_set_t * memset (a, 0, sizeof (a[0])); + mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0; locator_name = format (0, "%s", mp->locator_set_name); + vec_terminate_c_string (locator_name); a->name = locator_name; a->is_add = mp->is_add; @@ -182,7 +184,9 @@ vl_api_lisp_add_del_locator_t_handler (vl_api_lisp_add_del_locator_t * mp) locator.local = 1; vec_add1 (locators, locator); + mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0; locator_name = format (0, "%s", mp->locator_set_name); + vec_terminate_c_string (locator_name); a->name = locator_name; a->locators = locators; @@ -248,7 +252,9 @@ vl_api_lisp_add_del_local_eid_t_handler (vl_api_lisp_add_del_local_eid_t * mp) if (rv) goto out; + mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0; name = format (0, "%s", mp->locator_set_name); + vec_terminate_c_string (name); p = hash_get_mem (lcm->locator_set_index_by_name, name); if (!p) { @@ -389,7 +395,9 @@ vl_api_lisp_pitr_set_locator_set_t_handler (vl_api_lisp_pitr_set_locator_set_t int rv = 0; u8 *ls_name = 0; + mp->ls_name[sizeof (mp->ls_name) - 1] = 0; ls_name = format (0, "%s", mp->ls_name); + vec_terminate_c_string (ls_name); rv = vnet_lisp_pitr_set_locator_set (ls_name, mp->is_add); vec_free (ls_name); @@ -445,9 +453,24 @@ vl_api_show_lisp_use_petr_t_handler (vl_api_show_lisp_use_petr_t * mp) /* *INDENT-OFF* */ REPLY_MACRO2 (VL_API_SHOW_LISP_USE_PETR_REPLY, { - rmp->status = status; - gid_address_put (rmp->address, &addr); - rmp->is_ip4 = (gid_address_ip_version (&addr) == IP4); + rmp->status = status; + ip_address_t *ip = &gid_address_ip (&addr); + switch (ip_addr_version (ip)) + { + case IP4: + clib_memcpy (rmp->address, &ip_addr_v4 (ip), + sizeof (ip_addr_v4 (ip))); + break; + + case IP6: + clib_memcpy (rmp->address, &ip_addr_v6 (ip), + sizeof (ip_addr_v6 (ip))); + break; + + default: + ASSERT (0); + } + rmp->is_ip4 = (gid_address_ip_version (&addr) == IP4); }); /* *INDENT-ON* */ } @@ -461,7 +484,9 @@ static void u8 *locator_set_name = NULL; vnet_lisp_add_del_mreq_itr_rloc_args_t _a, *a = &_a; + mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0; locator_set_name = format (0, "%s", mp->locator_set_name); + vec_terminate_c_string (locator_set_name); a->is_add = mp->is_add; a->locator_set_name = locator_set_name; @@ -495,6 +520,7 @@ static void if (!mp->is_add) { vnet_lisp_add_del_adjacency_args_t _a, *a = &_a; + memset (a, 0, sizeof (*a)); gid_address_copy (&a->reid, eid); a->is_add = 0; rv = vnet_lisp_add_del_adjacency (a); @@ -506,8 +532,21 @@ static void /* NOTE: for now this works as a static remote mapping, i.e., * not authoritative and ttl infinite. */ - rv = vnet_lisp_add_del_mapping (eid, rlocs, mp->action, 0, ~0, - mp->is_add, 1 /* is_static */ , 0); + if (mp->is_add) + { + vnet_lisp_add_del_mapping_args_t _m_args, *m_args = &_m_args; + memset (m_args, 0, sizeof (m_args[0])); + gid_address_copy (&m_args->eid, eid); + m_args->action = mp->action; + m_args->is_static = 1; + m_args->ttl = ~0; + m_args->authoritative = 0; + rv = vnet_lisp_add_mapping (m_args, rlocs, NULL, NULL); + } + else + { + rv = vnet_lisp_del_mapping (eid, NULL); + } if (mp->del_all) vnet_lisp_clear_all_remote_adjacencies (); @@ -594,6 +633,7 @@ vl_api_lisp_locator_dump_t_handler (vl_api_lisp_locator_dump_t * mp) /* make sure we get a proper C-string */ mp->ls_name[sizeof (mp->ls_name) - 1] = 0; ls_name = format (0, "%s", mp->ls_name); + vec_terminate_c_string (ls_name); p = hash_get_mem (lcm->locator_set_index_by_name, ls_name); if (!p) goto out; @@ -1233,7 +1273,10 @@ vl_api_show_lisp_pitr_t_handler (vl_api_show_lisp_pitr_t * mp) return; } - if (!lcm->lisp_pitr) + u8 is_enabled = (lcm->flags & LISP_FLAG_PITR_MODE) + && lcm->pitr_map_index != ~0; + + if (!is_enabled) { tmp_str = format (0, "N/A"); } @@ -1256,7 +1299,7 @@ vl_api_show_lisp_pitr_t_handler (vl_api_show_lisp_pitr_t * mp) /* *INDENT-OFF* */ REPLY_MACRO2(VL_API_SHOW_LISP_PITR_REPLY, ({ - rmp->status = lcm->lisp_pitr; + rmp->status = lcm->flags & LISP_FLAG_PITR_MODE; strncpy((char *) rmp->locator_set_name, (char *) tmp_str, ARRAY_LEN(rmp->locator_set_name) - 1); }));