X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Flisp-cp%2Flisp_api.c;h=4ef4d18f44ab806f4da635e83303e34a39ec3a33;hb=07063b8ea;hp=d3fc4627c5f823222db8c37feb9190d4cafaed73;hpb=7cd468a3d7dee7d6c92f69a0bb7061ae208ec727;p=vpp.git diff --git a/src/vnet/lisp-cp/lisp_api.c b/src/vnet/lisp-cp/lisp_api.c index d3fc4627c5f..4ef4d18f44a 100644 --- a/src/vnet/lisp-cp/lisp_api.c +++ b/src/vnet/lisp-cp/lisp_api.c @@ -27,6 +27,17 @@ #include + +#define vl_api_lisp_add_del_locator_set_t_endian vl_noop_handler +#define vl_api_lisp_add_del_locator_set_t_print vl_noop_handler +#define vl_api_lisp_add_del_remote_mapping_t_endian vl_noop_handler +#define vl_api_lisp_add_del_remote_mapping_t_print vl_noop_handler + +#define vl_api_one_add_del_locator_set_t_endian vl_noop_handler +#define vl_api_one_add_del_locator_set_t_print vl_noop_handler +#define vl_api_one_add_del_remote_mapping_t_endian vl_noop_handler +#define vl_api_one_add_del_remote_mapping_t_print vl_noop_handler + #define vl_typedefs /* define message structures */ #include #undef vl_typedefs @@ -73,39 +84,23 @@ _(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) \ _(SHOW_LISP_MAP_REQUEST_MODE, show_lisp_map_request_mode) \ - -/** Used for transferring locators via VPP API */ -/* *INDENT-OFF* */ -typedef CLIB_PACKED (struct { - u8 is_ip4; /**< is locator an IPv4 address */ - u8 priority; /**< locator priority */ - u8 weight; /**< locator weight */ - u8 addr[16]; /**< IPv4/IPv6 address */ -}) rloc_t; -/* *INDENT-ON* */ - -/** Used for transferring locators via VPP API */ -/* *INDENT-OFF* */ -typedef CLIB_PACKED (struct { - u32 sw_if_index; /**< locator sw_if_index */ - u8 priority; /**< locator priority */ - u8 weight; /**< locator weight */ -}) ls_locator_t; -/* *INDENT-ON* */ +_(LISP_USE_PETR, lisp_use_petr) \ +_(SHOW_LISP_USE_PETR, show_lisp_use_petr) \ static locator_t * -unformat_lisp_locs (void *rmt_locs, u32 rloc_num) +unformat_lisp_locs (vl_api_remote_locator_t * rmt_locs, u32 rloc_num) { u32 i; locator_t *locs = 0, loc; - rloc_t *r; + vl_api_remote_locator_t *r; for (i = 0; i < rloc_num; i++) { /* remote locators */ - r = &((rloc_t *) rmt_locs)[i]; - memset (&loc, 0, sizeof (loc)); - gid_address_ip_set (&loc.address, &r->addr, r->is_ip4 ? IP4 : IP6); + r = &rmt_locs[i]; + clib_memset (&loc, 0, sizeof (loc)); + gid_address_ip_set (&loc.address, &r->addr, + r->is_ip4 ? AF_IP4 : AF_IP6); loc.priority = r->priority; loc.weight = r->weight; @@ -123,24 +118,26 @@ vl_api_lisp_add_del_locator_set_t_handler (vl_api_lisp_add_del_locator_set_t * int rv = 0; vnet_lisp_add_del_locator_set_args_t _a, *a = &_a; locator_t locator; - ls_locator_t *ls_loc; + vl_api_local_locator_t *ls_loc; u32 ls_index = ~0, locator_num; u8 *locator_name = NULL; int i; - memset (a, 0, sizeof (a[0])); + clib_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; a->local = 1; locator_num = clib_net_to_host_u32 (mp->locator_num); - memset (&locator, 0, sizeof (locator)); + clib_memset (&locator, 0, sizeof (locator)); for (i = 0; i < locator_num; i++) { - ls_loc = &((ls_locator_t *) mp->locators)[i]; + ls_loc = &mp->locators[i]; VALIDATE_SW_IF_INDEX (ls_loc); locator.sw_if_index = htonl (ls_loc->sw_if_index); @@ -175,8 +172,8 @@ vl_api_lisp_add_del_locator_t_handler (vl_api_lisp_add_del_locator_t * mp) u32 ls_index = ~0; u8 *locator_name = NULL; - memset (&locator, 0, sizeof (locator)); - memset (a, 0, sizeof (a[0])); + clib_memset (&locator, 0, sizeof (locator)); + clib_memset (a, 0, sizeof (a[0])); locator.sw_if_index = ntohl (mp->sw_if_index); locator.priority = mp->priority; @@ -184,7 +181,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; @@ -207,13 +206,13 @@ unformat_lisp_eid_api (gid_address_t * dst, u32 vni, u8 type, void *src, { case 0: /* ipv4 */ gid_address_type (dst) = GID_ADDR_IP_PREFIX; - gid_address_ip_set (dst, src, IP4); + gid_address_ip_set (dst, src, AF_IP4); gid_address_ippref_len (dst) = len; ip_prefix_normalize (&gid_address_ippref (dst)); break; case 1: /* ipv6 */ gid_address_type (dst) = GID_ADDR_IP_PREFIX; - gid_address_ip_set (dst, src, IP6); + gid_address_ip_set (dst, src, AF_IP6); gid_address_ippref_len (dst) = len; ip_prefix_normalize (&gid_address_ippref (dst)); break; @@ -242,15 +241,17 @@ vl_api_lisp_add_del_local_eid_t_handler (vl_api_lisp_add_del_local_eid_t * mp) u32 locator_set_index = ~0, map_index = ~0; vnet_lisp_add_del_mapping_args_t _a, *a = &_a; u8 *name = NULL, *key = NULL; - memset (a, 0, sizeof (a[0])); - memset (eid, 0, sizeof (eid[0])); + clib_memset (a, 0, sizeof (a[0])); + clib_memset (eid, 0, sizeof (eid[0])); rv = unformat_lisp_eid_api (eid, clib_net_to_host_u32 (mp->vni), mp->eid_type, mp->eid, mp->prefix_len); 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) { @@ -299,9 +300,9 @@ vl_api_lisp_add_del_map_server_t_handler (vl_api_lisp_add_del_map_server_t int rv = 0; ip_address_t addr; - memset (&addr, 0, sizeof (addr)); + clib_memset (&addr, 0, sizeof (addr)); - ip_address_set (&addr, mp->ip_address, mp->is_ipv6 ? IP6 : IP4); + ip_address_set (&addr, mp->ip_address, mp->is_ipv6 ? AF_IP6 : AF_IP4); rv = vnet_lisp_add_del_map_server (&addr, mp->is_add); REPLY_MACRO (VL_API_LISP_ADD_DEL_MAP_SERVER_REPLY); @@ -315,10 +316,10 @@ vl_api_lisp_add_del_map_resolver_t_handler (vl_api_lisp_add_del_map_resolver_t int rv = 0; vnet_lisp_add_del_map_resolver_args_t _a, *a = &_a; - memset (a, 0, sizeof (a[0])); + clib_memset (a, 0, sizeof (a[0])); a->is_add = mp->is_add; - ip_address_set (&a->address, mp->ip_address, mp->is_ipv6 ? IP6 : IP4); + ip_address_set (&a->address, mp->ip_address, mp->is_ipv6 ? AF_IP6 : AF_IP4); rv = vnet_lisp_add_del_map_resolver (a); @@ -391,13 +392,79 @@ 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); REPLY_MACRO (VL_API_LISP_PITR_SET_LOCATOR_SET_REPLY); } +static void +vl_api_lisp_use_petr_t_handler (vl_api_lisp_use_petr_t * mp) +{ + vl_api_lisp_use_petr_reply_t *rmp; + int rv = 0; + ip_address_t addr; + + ip_address_set (&addr, &mp->address, mp->is_ip4 ? AF_IP4 : AF_IP6); + rv = vnet_lisp_use_petr (&addr, mp->is_add); + + REPLY_MACRO (VL_API_LISP_USE_PETR_REPLY); +} + +static void +vl_api_show_lisp_use_petr_t_handler (vl_api_show_lisp_use_petr_t * mp) +{ + vl_api_show_lisp_use_petr_reply_t *rmp = NULL; + lisp_cp_main_t *lcm = vnet_lisp_cp_get_main (); + mapping_t *m; + locator_set_t *ls = 0; + int rv = 0; + locator_t *loc = 0; + u8 status = 0; + gid_address_t addr; + + clib_memset (&addr, 0, sizeof (addr)); + status = lcm->flags & LISP_FLAG_USE_PETR; + if (status) + { + m = pool_elt_at_index (lcm->mapping_pool, lcm->petr_map_index); + if (~0 != m->locator_set_index) + { + ls = + pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index); + loc = pool_elt_at_index (lcm->locator_pool, ls->locator_indices[0]); + gid_address_copy (&addr, &loc->address); + } + } + + /* *INDENT-OFF* */ + REPLY_MACRO2 (VL_API_SHOW_LISP_USE_PETR_REPLY, + { + rmp->status = status; + ip_address_t *ip = &gid_address_ip (&addr); + switch (ip_addr_version (ip)) + { + case AF_IP4: + clib_memcpy (rmp->address, &ip_addr_v4 (ip), + sizeof (ip_addr_v4 (ip))); + break; + + case AF_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) == AF_IP4); + }); + /* *INDENT-ON* */ +} + static void vl_api_lisp_add_del_map_request_itr_rlocs_t_handler (vl_api_lisp_add_del_map_request_itr_rlocs_t * mp) @@ -407,7 +474,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; @@ -429,7 +498,7 @@ static void gid_address_t _eid, *eid = &_eid; u32 rloc_num = clib_net_to_host_u32 (mp->rloc_num); - memset (eid, 0, sizeof (eid[0])); + clib_memset (eid, 0, sizeof (eid[0])); rv = unformat_lisp_eid_api (eid, clib_net_to_host_u32 (mp->vni), mp->eid_type, mp->eid, mp->eid_len); @@ -441,6 +510,7 @@ static void if (!mp->is_add) { vnet_lisp_add_del_adjacency_args_t _a, *a = &_a; + clib_memset (a, 0, sizeof (*a)); gid_address_copy (&a->reid, eid); a->is_add = 0; rv = vnet_lisp_add_del_adjacency (a); @@ -452,8 +522,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; + clib_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 (); @@ -471,7 +554,7 @@ vl_api_lisp_add_del_adjacency_t_handler (vl_api_lisp_add_del_adjacency_t * mp) vnet_lisp_add_del_adjacency_args_t _a, *a = &_a; int rv = 0; - memset (a, 0, sizeof (a[0])); + clib_memset (a, 0, sizeof (a[0])); rv = unformat_lisp_eid_api (&a->leid, clib_net_to_host_u32 (mp->vni), mp->eid_type, mp->leid, mp->leid_len); @@ -490,13 +573,13 @@ send_reply: static void send_lisp_locator_details (lisp_cp_main_t * lcm, - locator_t * loc, - unix_shared_memory_queue_t * q, u32 context) + locator_t * loc, vl_api_registration_t * reg, + u32 context) { vl_api_lisp_locator_details_t *rmp; rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_LISP_LOCATOR_DETAILS); rmp->context = context; @@ -513,25 +596,23 @@ send_lisp_locator_details (lisp_cp_main_t * lcm, rmp->priority = loc->priority; rmp->weight = loc->weight; - vl_msg_api_send_shmem (q, (u8 *) & rmp); + vl_api_send_msg (reg, (u8 *) rmp); } static void vl_api_lisp_locator_dump_t_handler (vl_api_lisp_locator_dump_t * mp) { u8 *ls_name = 0; - unix_shared_memory_queue_t *q = 0; + vl_api_registration_t *reg = 0; lisp_cp_main_t *lcm = vnet_lisp_cp_get_main (); locator_set_t *lsit = 0; locator_t *loc = 0; u32 ls_index = ~0, *locit = 0; uword *p = 0; - q = vl_api_client_index_to_input_queue (mp->client_index); - if (q == 0) - { - return; - } + reg = vl_api_client_index_to_registration (mp->client_index); + if (!reg) + return; if (mp->is_index_set) ls_index = htonl (mp->ls_index); @@ -540,6 +621,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; @@ -554,7 +636,7 @@ vl_api_lisp_locator_dump_t_handler (vl_api_lisp_locator_dump_t * mp) vec_foreach (locit, lsit->locator_indices) { loc = pool_elt_at_index (lcm->locator_pool, locit[0]); - send_lisp_locator_details (lcm, loc, q, mp->context); + send_lisp_locator_details (lcm, loc, reg, mp->context); }; out: vec_free (ls_name); @@ -563,14 +645,14 @@ out: 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 ls_index) + vl_api_registration_t * reg, u32 context, + u32 ls_index) { vl_api_lisp_locator_set_details_t *rmp; u8 *str = 0; rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_LISP_LOCATOR_SET_DETAILS); rmp->context = context; @@ -588,22 +670,20 @@ send_lisp_locator_set_details (lisp_cp_main_t * lcm, vec_free (str); } - vl_msg_api_send_shmem (q, (u8 *) & rmp); + vl_api_send_msg (reg, (u8 *) rmp); } static void vl_api_lisp_locator_set_dump_t_handler (vl_api_lisp_locator_set_dump_t * mp) { - unix_shared_memory_queue_t *q = NULL; + vl_api_registration_t *reg; lisp_cp_main_t *lcm = vnet_lisp_cp_get_main (); locator_set_t *lsit = NULL; u8 filter; - q = vl_api_client_index_to_input_queue (mp->client_index); - if (q == 0) - { - return; - } + reg = vl_api_client_index_to_registration (mp->client_index); + if (!reg) + return; filter = mp->filter; /* *INDENT-OFF* */ @@ -614,7 +694,7 @@ vl_api_lisp_locator_set_dump_t_handler (vl_api_lisp_locator_set_dump_t * mp) { continue; } - send_lisp_locator_set_details (lcm, lsit, q, mp->context, + send_lisp_locator_set_details (lcm, lsit, reg, mp->context, lsit - lcm->locator_set_pool); })); /* *INDENT-ON* */ @@ -629,7 +709,7 @@ lisp_fid_put_api (u8 * dst, fid_address_t * src, u8 * prefix_length) switch (fid_addr_type (src)) { case FID_ADDR_IP_PREF: - if (ip_prefix_version (ippref) == IP4) + if (ip_prefix_version (ippref) == AF_IP4) clib_memcpy (dst, &ip_prefix_v4 (ippref), 4); else clib_memcpy (dst, &ip_prefix_v6 (ippref), 16); @@ -656,15 +736,17 @@ fid_type_to_api_type (fid_address_t * fid) { case FID_ADDR_IP_PREF: ippref = &fid_addr_ippref (fid); - if (ip_prefix_version (ippref) == IP4) + if (ip_prefix_version (ippref) == AF_IP4) return 0; - else if (ip_prefix_version (ippref) == IP6) + else if (ip_prefix_version (ippref) == AF_IP6) return 1; else return ~0; case FID_ADDR_MAC: return 2; + case FID_ADDR_NSH: + return 3; } return ~0; @@ -672,8 +754,8 @@ fid_type_to_api_type (fid_address_t * fid) static void send_lisp_eid_table_details (mapping_t * mapit, - unix_shared_memory_queue_t * q, - u32 context, u8 filter) + vl_api_registration_t * reg, u32 context, + u8 filter) { fid_address_t *fid; lisp_cp_main_t *lcm = vnet_lisp_cp_get_main (); @@ -701,12 +783,16 @@ send_lisp_eid_table_details (mapping_t * mapit, return; } + /* don't send PITR generated mapping */ + if (mapit->pitr_set) + return; + gid = &mapit->eid; ip_prefix = &gid_address_ippref (gid); mac = gid_address_mac (gid); rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_LISP_EID_TABLE_DETAILS); ls = pool_elt_at_index (lcm->locator_set_pool, mapit->locator_set_index); @@ -733,7 +819,7 @@ send_lisp_eid_table_details (mapping_t * mapit, break; case GID_ADDR_IP_PREFIX: rmp->eid_prefix_len = ip_prefix_len (ip_prefix); - if (ip_prefix_version (ip_prefix) == IP4) + if (ip_prefix_version (ip_prefix) == AF_IP4) { rmp->eid_type = 0; /* ipv4 type */ clib_memcpy (rmp->eid, &ip_prefix_v4 (ip_prefix), @@ -757,27 +843,25 @@ send_lisp_eid_table_details (mapping_t * mapit, rmp->vni = clib_host_to_net_u32 (gid_address_vni (gid)); rmp->key_id = clib_host_to_net_u16 (mapit->key_id); memcpy (rmp->key, mapit->key, vec_len (mapit->key)); - vl_msg_api_send_shmem (q, (u8 *) & rmp); + vl_api_send_msg (reg, (u8 *) rmp); } static void vl_api_lisp_eid_table_dump_t_handler (vl_api_lisp_eid_table_dump_t * mp) { u32 mi; - unix_shared_memory_queue_t *q = NULL; + vl_api_registration_t *reg; lisp_cp_main_t *lcm = vnet_lisp_cp_get_main (); mapping_t *mapit = NULL; gid_address_t _eid, *eid = &_eid; - q = vl_api_client_index_to_input_queue (mp->client_index); - if (q == 0) - { - return; - } + reg = vl_api_client_index_to_registration (mp->client_index); + if (!reg) + return; if (mp->eid_set) { - memset (eid, 0, sizeof (*eid)); + clib_memset (eid, 0, sizeof (*eid)); unformat_lisp_eid_api (eid, clib_net_to_host_u32 (mp->vni), mp->eid_type, mp->eid, mp->prefix_length); @@ -787,7 +871,7 @@ vl_api_lisp_eid_table_dump_t_handler (vl_api_lisp_eid_table_dump_t * mp) return; mapit = pool_elt_at_index (lcm->mapping_pool, mi); - send_lisp_eid_table_details (mapit, q, mp->context, + send_lisp_eid_table_details (mapit, reg, mp->context, 0 /* ignore filter */ ); } else @@ -795,7 +879,7 @@ vl_api_lisp_eid_table_dump_t_handler (vl_api_lisp_eid_table_dump_t * mp) /* *INDENT-OFF* */ pool_foreach (mapit, lcm->mapping_pool, ({ - send_lisp_eid_table_details(mapit, q, mp->context, + send_lisp_eid_table_details(mapit, reg, mp->context, mp->filter); })); /* *INDENT-ON* */ @@ -803,24 +887,24 @@ vl_api_lisp_eid_table_dump_t_handler (vl_api_lisp_eid_table_dump_t * mp) } static void -send_lisp_map_server_details (ip_address_t * ip, - unix_shared_memory_queue_t * q, u32 context) +send_lisp_map_server_details (ip_address_t * ip, vl_api_registration_t * reg, + u32 context) { vl_api_lisp_map_server_details_t *rmp = NULL; rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_LISP_MAP_SERVER_DETAILS); switch (ip_addr_version (ip)) { - case IP4: + case AF_IP4: rmp->is_ipv6 = 0; clib_memcpy (rmp->ip_address, &ip_addr_v4 (ip), sizeof (ip_addr_v4 (ip))); break; - case IP6: + case AF_IP6: rmp->is_ipv6 = 1; clib_memcpy (rmp->ip_address, &ip_addr_v6 (ip), sizeof (ip_addr_v6 (ip))); @@ -831,47 +915,45 @@ send_lisp_map_server_details (ip_address_t * ip, } rmp->context = context; - vl_msg_api_send_shmem (q, (u8 *) & rmp); + vl_api_send_msg (reg, (u8 *) rmp); } static void vl_api_lisp_map_server_dump_t_handler (vl_api_lisp_map_server_dump_t * mp) { - unix_shared_memory_queue_t *q = NULL; + vl_api_registration_t *reg; lisp_cp_main_t *lcm = vnet_lisp_cp_get_main (); lisp_msmr_t *mr; - q = vl_api_client_index_to_input_queue (mp->client_index); - if (q == 0) - { - return; - } + reg = vl_api_client_index_to_registration (mp->client_index); + if (!reg) + return; vec_foreach (mr, lcm->map_servers) { - send_lisp_map_server_details (&mr->address, q, mp->context); + send_lisp_map_server_details (&mr->address, reg, mp->context); } } static void send_lisp_map_resolver_details (ip_address_t * ip, - unix_shared_memory_queue_t * q, u32 context) + vl_api_registration_t * reg, u32 context) { vl_api_lisp_map_resolver_details_t *rmp = NULL; rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_LISP_MAP_RESOLVER_DETAILS); switch (ip_addr_version (ip)) { - case IP4: + case AF_IP4: rmp->is_ipv6 = 0; clib_memcpy (rmp->ip_address, &ip_addr_v4 (ip), sizeof (ip_addr_v4 (ip))); break; - case IP6: + case AF_IP6: rmp->is_ipv6 = 1; clib_memcpy (rmp->ip_address, &ip_addr_v6 (ip), sizeof (ip_addr_v6 (ip))); @@ -882,58 +964,54 @@ send_lisp_map_resolver_details (ip_address_t * ip, } rmp->context = context; - vl_msg_api_send_shmem (q, (u8 *) & rmp); + vl_api_send_msg (reg, (u8 *) rmp); } static void vl_api_lisp_map_resolver_dump_t_handler (vl_api_lisp_map_resolver_dump_t * mp) { - unix_shared_memory_queue_t *q = NULL; + vl_api_registration_t *reg; lisp_cp_main_t *lcm = vnet_lisp_cp_get_main (); lisp_msmr_t *mr; - q = vl_api_client_index_to_input_queue (mp->client_index); - if (q == 0) - { - return; - } + reg = vl_api_client_index_to_registration (mp->client_index); + if (!reg) + return; vec_foreach (mr, lcm->map_resolvers) { - send_lisp_map_resolver_details (&mr->address, q, mp->context); + send_lisp_map_resolver_details (&mr->address, reg, mp->context); } } static void -send_eid_table_map_pair (hash_pair_t * p, - unix_shared_memory_queue_t * q, u32 context) +send_eid_table_map_pair (hash_pair_t * p, vl_api_registration_t * reg, + u32 context) { vl_api_lisp_eid_table_map_details_t *rmp = NULL; rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_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->dp_table = clib_host_to_net_u32 (p->value[0]); rmp->context = context; - vl_msg_api_send_shmem (q, (u8 *) & rmp); + vl_api_send_msg (reg, (u8 *) rmp); } static void vl_api_lisp_eid_table_map_dump_t_handler (vl_api_lisp_eid_table_map_dump_t * mp) { - unix_shared_memory_queue_t *q = NULL; + vl_api_registration_t *reg; lisp_cp_main_t *lcm = vnet_lisp_cp_get_main (); hash_pair_t *p; uword *vni_table = 0; - q = vl_api_client_index_to_input_queue (mp->client_index); - if (q == 0) - { - return; - } + reg = vl_api_client_index_to_registration (mp->client_index); + if (!reg) + return; if (mp->is_l2) { @@ -947,22 +1025,22 @@ vl_api_lisp_eid_table_map_dump_t_handler (vl_api_lisp_eid_table_map_dump_t * /* *INDENT-OFF* */ hash_foreach_pair (p, vni_table, ({ - send_eid_table_map_pair (p, q, mp->context); + send_eid_table_map_pair (p, reg, mp->context); })); /* *INDENT-ON* */ } static void -send_eid_table_vni (u32 vni, unix_shared_memory_queue_t * q, u32 context) +send_eid_table_vni (u32 vni, vl_api_registration_t * reg, u32 context) { vl_api_lisp_eid_table_vni_details_t *rmp = 0; rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_LISP_EID_TABLE_VNI_DETAILS); rmp->context = context; rmp->vni = clib_host_to_net_u32 (vni); - vl_msg_api_send_shmem (q, (u8 *) & rmp); + vl_api_send_msg (reg, (u8 *) rmp); } static void @@ -975,14 +1053,14 @@ lisp_adjacency_copy (vl_api_lisp_adjacency_t * dst, lisp_adjacency_t * adjs) for (i = 0; i < n; i++) { adj = vec_elt_at_index (adjs, i); - memset (&a, 0, sizeof (a)); + clib_memset (&a, 0, sizeof (a)); switch (gid_address_type (&adj->reid)) { case GID_ADDR_IP_PREFIX: a.reid_prefix_len = gid_address_ippref_len (&adj->reid); a.leid_prefix_len = gid_address_ippref_len (&adj->leid); - if (gid_address_ip_version (&adj->reid) == IP4) + if (gid_address_ip_version (&adj->reid) == AF_IP4) { a.eid_type = 0; /* ipv4 type */ clib_memcpy (a.reid, &gid_address_ip (&adj->reid), 4); @@ -1043,12 +1121,11 @@ vl_api_lisp_adjacencies_get_t_handler (vl_api_lisp_adjacencies_get_t * mp) vl_api_lisp_adjacencies_get_reply_t *rmp = 0; lisp_adjacency_t *adjs = 0; int rv = 0; - vl_api_lisp_adjacency_t a; u32 size = ~0; u32 vni = clib_net_to_host_u32 (mp->vni); adjs = vnet_lisp_adjacencies_get_by_vni (vni); - size = vec_len (adjs) * sizeof (a); + size = vec_len (adjs) * sizeof (vl_api_lisp_adjacency_t); /* *INDENT-OFF* */ REPLY_MACRO4 (VL_API_LISP_ADJACENCIES_GET_REPLY, size, @@ -1067,14 +1144,12 @@ vl_api_lisp_eid_table_vni_dump_t_handler (vl_api_lisp_eid_table_vni_dump_t * { hash_pair_t *p; u32 *vnis = 0; - unix_shared_memory_queue_t *q = 0; + vl_api_registration_t *reg = 0; lisp_cp_main_t *lcm = vnet_lisp_cp_get_main (); - q = vl_api_client_index_to_input_queue (mp->client_index); - if (q == 0) - { - return; - } + reg = vl_api_client_index_to_registration (mp->client_index); + if (!reg) + return; /* *INDENT-OFF* */ hash_foreach_pair (p, lcm->table_id_by_vni, @@ -1089,7 +1164,7 @@ vl_api_lisp_eid_table_vni_dump_t_handler (vl_api_lisp_eid_table_vni_dump_t * hash_foreach_pair (p, vnis, ({ - send_eid_table_vni (p->key, q, mp->context); + send_eid_table_vni (p->key, reg, mp->context); })); /* *INDENT-ON* */ @@ -1099,16 +1174,9 @@ vl_api_lisp_eid_table_vni_dump_t_handler (vl_api_lisp_eid_table_vni_dump_t * static void vl_api_show_lisp_status_t_handler (vl_api_show_lisp_status_t * mp) { - unix_shared_memory_queue_t *q = NULL; vl_api_show_lisp_status_reply_t *rmp = NULL; int rv = 0; - q = vl_api_client_index_to_input_queue (mp->client_index); - if (q == 0) - { - return; - } - /* *INDENT-OFF* */ REPLY_MACRO2(VL_API_SHOW_LISP_STATUS_REPLY, ({ @@ -1122,19 +1190,12 @@ static void vl_api_lisp_get_map_request_itr_rlocs_t_handler (vl_api_lisp_get_map_request_itr_rlocs_t * mp) { - unix_shared_memory_queue_t *q = NULL; vl_api_lisp_get_map_request_itr_rlocs_reply_t *rmp = NULL; lisp_cp_main_t *lcm = vnet_lisp_cp_get_main (); locator_set_t *loc_set = 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->mreq_itr_rlocs) { tmp_str = format (0, " "); @@ -1160,7 +1221,6 @@ static void 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; @@ -1168,13 +1228,10 @@ vl_api_show_lisp_pitr_t_handler (vl_api_show_lisp_pitr_t * mp) u8 *tmp_str = 0; int rv = 0; - q = vl_api_client_index_to_input_queue (mp->client_index); - if (q == 0) - { - return; - } + u8 is_enabled = (lcm->flags & LISP_FLAG_PITR_MODE) + && lcm->pitr_map_index != ~0; - if (!lcm->lisp_pitr) + if (!is_enabled) { tmp_str = format (0, "N/A"); } @@ -1197,7 +1254,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); })); @@ -1207,7 +1264,7 @@ vl_api_show_lisp_pitr_t_handler (vl_api_show_lisp_pitr_t * mp) /* * lisp_api_hookup * Add vpe's API message handlers to the table. - * vlib has alread mapped shared memory and + * vlib has already mapped shared memory and * added the client registration handlers. * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process() */ @@ -1226,7 +1283,7 @@ setup_message_id_table (api_main_t * am) static clib_error_t * lisp_api_hookup (vlib_main_t * vm) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); #define _(N,n) \ vl_msg_api_set_handlers(VL_API_##N, #n, \