diff options
author | Filip Tehlar <ftehlar@cisco.com> | 2016-09-23 10:00:52 +0200 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2016-10-12 13:24:03 +0000 |
commit | 69a9b76d648a108e0a7fad4404b218ebdd6a8ea5 (patch) | |
tree | f42dedb675f6e10852c436a0e60abc24172cd9b1 /vpp | |
parent | 75fc854da7e92502581d83e31306b9912d3c53ff (diff) |
VPP-362 Implement dumping of LISP adjacencies
Change-Id: Ieea56f3bf9e749878d9f2b35d39d9f7a9cdabde4
Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
Diffstat (limited to 'vpp')
-rw-r--r-- | vpp/vpp-api/api.c | 84 | ||||
-rw-r--r-- | vpp/vpp-api/custom_dump.c | 12 | ||||
-rw-r--r-- | vpp/vpp-api/vpe.api | 43 |
3 files changed, 138 insertions, 1 deletions
diff --git a/vpp/vpp-api/api.c b/vpp/vpp-api/api.c index 0ef6966a..84e4d5d5 100644 --- a/vpp/vpp-api/api.c +++ b/vpp/vpp-api/api.c @@ -170,16 +170,31 @@ do { \ #define REPLY_MACRO3(t, n, body) \ do { \ unix_shared_memory_queue_t * q; \ + u8 is_error = 0; \ rv = vl_msg_api_pd_handler (mp, rv); \ q = vl_api_client_index_to_input_queue (mp->client_index); \ if (!q) \ return; \ \ rmp = vl_msg_api_alloc (sizeof (*rmp) + n); \ + if (!rmp) \ + { \ + /* if there isn't enough memory, try to allocate */ \ + /* some at least for returning an error */ \ + rmp = vl_msg_api_alloc (sizeof (*rmp)); \ + if (!rmp) \ + return; \ + \ + memset (rmp, 0, sizeof (*rmp)); \ + rv = VNET_API_ERROR_TABLE_TOO_BIG; \ + is_error = 1; \ + } \ + \ rmp->_vl_msg_id = ntohs((t)); \ rmp->context = mp->context; \ rmp->retval = ntohl(rv); \ - do {body;} while (0); \ + if (!is_error) \ + do {body;} while (0); \ vl_msg_api_send_shmem (q, (u8 *)&rmp); \ } while(0); @@ -380,6 +395,7 @@ _(LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump) \ _(LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump) \ _(LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump) \ _(LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump) \ +_(LISP_ADJACENCIES_GET, lisp_adjacencies_get) \ _(SHOW_LISP_STATUS, show_lisp_status) \ _(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, \ lisp_add_del_map_request_itr_rlocs) \ @@ -6014,6 +6030,72 @@ send_eid_table_vni (u32 vni, unix_shared_memory_queue_t * q, u32 context) } static void +lisp_adjacency_copy (vl_api_lisp_adjacency_t * dst, lisp_adjacency_t * adjs) +{ + lisp_adjacency_t *adj; + vl_api_lisp_adjacency_t a; + u32 i, n = vec_len (adjs); + + for (i = 0; i < n; i++) + { + adj = vec_elt_at_index (adjs, i); + 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) + { + a.eid_type = 0; /* ipv4 type */ + clib_memcpy (a.reid, &gid_address_ip (&adj->reid), 4); + clib_memcpy (a.leid, &gid_address_ip (&adj->leid), 4); + } + else + { + a.eid_type = 1; /* ipv6 type */ + clib_memcpy (a.reid, &gid_address_ip (&adj->reid), 16); + clib_memcpy (a.leid, &gid_address_ip (&adj->leid), 16); + } + break; + case GID_ADDR_MAC: + a.eid_type = 2; /* l2 mac type */ + mac_copy (a.reid, gid_address_mac (&adj->reid)); + mac_copy (a.leid, gid_address_mac (&adj->leid)); + break; + default: + ASSERT (0); + } + dst[i] = a; + } +} + +static void +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); + + /* *INDENT-OFF* */ + REPLY_MACRO3 (VL_API_LISP_ADJACENCIES_GET_REPLY, size, + { + rmp->count = clib_host_to_net_u32 (vec_len (adjs)); + lisp_adjacency_copy (rmp->adjacencies, adjs); + }); + /* *INDENT-ON* */ + + vec_free (adjs); +} + +static void vl_api_lisp_eid_table_vni_dump_t_handler (vl_api_lisp_eid_table_vni_dump_t * mp) { diff --git a/vpp/vpp-api/custom_dump.c b/vpp/vpp-api/custom_dump.c index 096c1aa8..887c9fc7 100644 --- a/vpp/vpp-api/custom_dump.c +++ b/vpp/vpp-api/custom_dump.c @@ -2698,6 +2698,17 @@ static void *vl_api_lisp_eid_table_dump_t_print FINISH; } +static void *vl_api_lisp_adjacencies_get_t_print + (vl_api_lisp_adjacencies_get_t * mp, void *handle) +{ + u8 *s; + + s = format (0, "SCRIPT: lisp_adjacencies_get "); + s = format (s, "vni %d", clib_net_to_host_u32 (mp->vni)); + + FINISH; +} + static void *vl_api_lisp_eid_table_map_dump_t_print (vl_api_lisp_eid_table_map_dump_t * mp, void *handle) { @@ -2989,6 +3000,7 @@ _(LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump) \ _(LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump) \ _(LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump) \ _(LISP_LOCATOR_DUMP, lisp_locator_dump) \ +_(LISP_ADJACENCIES_GET, lisp_adjacencies_get) \ _(IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel) \ _(IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump) \ _(DELETE_SUBIF, delete_subif) \ diff --git a/vpp/vpp-api/vpe.api b/vpp/vpp-api/vpe.api index a48d345a..0fe9d200 100644 --- a/vpp/vpp-api/vpe.api +++ b/vpp/vpp-api/vpe.api @@ -2946,6 +2946,49 @@ define lisp_eid_table_dump u8 filter; }; +/** \brief LISP adjacency + @param eid_type - + 0 : ipv4 + 1 : ipv6 + 2 : mac + @param reid - remote EID + @param leid - local EID + @param reid_prefix_len - remote EID IP prefix length + @param leid_prefix_len - local EID IP prefix length + */ +typeonly manual_print manual_endian define lisp_adjacency +{ + u8 eid_type; + u8 reid[16]; + u8 leid[16]; + u8 reid_prefix_len; + u8 leid_prefix_len; +}; + +/** \brief LISP adjacency reply + @param count - number of adjacencies + @param adjacencies - array of adjacencies + */ +manual_endian manual_print define lisp_adjacencies_get_reply +{ + u32 context; + i32 retval; + u32 count; + vl_api_lisp_adjacency_t adjacencies[count]; +}; + +/** \brief Request for LISP adjacencies + @param client_index - opaque cookie to identify the sender + @param context - sender context, to match reply w/ request + @param vni - filter adjacencies by VNI + */ +define lisp_adjacencies_get +{ + u32 client_index; + u32 context; + u32 vni; +}; + /** \brief Shows relationship between vni and vrf/bd @param dp_table - VRF index or bridge domain index @param vni - vitual network instance |