X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Flisp-cp%2Fone_api.c;h=724e58df8393c4113124a3a1f8eaa13f6d9653ce;hb=d5a65db98d66c66b03b057ac568be05f2456f73c;hp=d0a9309b368403ad3ffc251e2bf3a09dca7ced9f;hpb=974cdc6faacc49ef393eeea6e4c9643f767d2792;p=vpp.git diff --git a/src/vnet/lisp-cp/one_api.c b/src/vnet/lisp-cp/one_api.c index d0a9309b368..724e58df839 100644 --- a/src/vnet/lisp-cp/one_api.c +++ b/src/vnet/lisp-cp/one_api.c @@ -42,6 +42,11 @@ #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_api_one_l2_arp_entry_t_endian vl_noop_handler +#define vl_api_one_l2_arp_entry_t_print vl_noop_handler +#define vl_api_one_add_del_l2_arp_entry vl_noop_handler +#define vl_api_one_l2_arp_bd_get vl_noop_handler + #define vl_typedefs /* define message structures */ #include #undef vl_typedefs @@ -58,6 +63,21 @@ #include +#define REPLY_DETAILS(t, body) \ +do { \ + unix_shared_memory_queue_t * q; \ + 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)); \ + rmp->_vl_msg_id = ntohs((t)); \ + rmp->context = mp->context; \ + do {body;} while (0); \ + vl_msg_api_send_shmem (q, (u8 *)&rmp); \ +} while(0); + #define foreach_vpe_api_msg \ _(ONE_ADD_DEL_LOCATOR_SET, one_add_del_locator_set) \ _(ONE_ADD_DEL_LOCATOR, one_add_del_locator) \ @@ -90,6 +110,14 @@ _(SHOW_ONE_PITR, show_one_pitr) \ _(SHOW_ONE_MAP_REQUEST_MODE, show_one_map_request_mode) \ _(ONE_USE_PETR, one_use_petr) \ _(SHOW_ONE_USE_PETR, show_one_use_petr) \ +_(SHOW_ONE_STATS_ENABLE_DISABLE, show_one_stats_enable_disable) \ +_(ONE_STATS_ENABLE_DISABLE, one_stats_enable_disable) \ +_(ONE_STATS_DUMP, one_stats_dump) \ +_(ONE_STATS_FLUSH, one_stats_flush) \ +_(ONE_L2_ARP_BD_GET, one_l2_arp_bd_get) \ +_(ONE_L2_ARP_ENTRIES_GET, one_l2_arp_entries_get) \ +_(ONE_ADD_DEL_L2_ARP_ENTRY, one_add_del_l2_arp_entry) \ + static locator_t * unformat_one_locs (vl_api_one_remote_locator_t * rmt_locs, u32 rloc_num) @@ -444,9 +472,24 @@ vl_api_show_one_use_petr_t_handler (vl_api_show_one_use_petr_t * mp) /* *INDENT-OFF* */ REPLY_MACRO2 (VL_API_SHOW_ONE_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* */ } @@ -738,6 +781,9 @@ send_one_eid_table_details (mapping_t * mapit, u8 *mac = 0; ip_prefix_t *ip_prefix = NULL; + if (mapit->pitr_set) + return; + switch (filter) { case 0: /* all mappings */ @@ -1256,6 +1302,173 @@ vl_api_show_one_pitr_t_handler (vl_api_show_one_pitr_t * mp) /* *INDENT-ON* */ } +static void + vl_api_show_one_stats_enable_disable_t_handler + (vl_api_show_one_stats_enable_disable_t * mp) +{ + vl_api_show_one_stats_enable_disable_reply_t *rmp = NULL; + vnet_api_error_t rv = 0; + + /* *INDENT-OFF* */ + REPLY_MACRO2 (VL_API_SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, + ({ + rmp->is_en = vnet_lisp_stats_enable_disable_state (); + })); + /* *INDENT-ON* */ +} + +static void + vl_api_one_stats_enable_disable_t_handler + (vl_api_one_stats_enable_disable_t * mp) +{ + vl_api_one_enable_disable_reply_t *rmp = NULL; + + vnet_api_error_t rv = vnet_lisp_stats_enable_disable (mp->is_en); + REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY); +} + +static void +lisp_fid_addr_to_api (fid_address_t * fid, u8 * dst, u8 * api_eid_type, + u8 * prefix_length) +{ + switch (fid_addr_type (fid)) + { + case FID_ADDR_IP_PREF: + *prefix_length = fid_addr_prefix_length (fid); + if (fid_addr_ip_version (fid) == IP4) + { + *api_eid_type = 0; /* ipv4 type */ + clib_memcpy (dst, &fid_addr_ippref (fid), 4); + } + else + { + *api_eid_type = 1; /* ipv6 type */ + clib_memcpy (dst, &fid_addr_ippref (fid), 16); + } + break; + case FID_ADDR_MAC: + *api_eid_type = 2; /* l2 mac type */ + mac_copy (dst, fid_addr_mac (fid)); + break; + default: + ASSERT (0); + } +} + +static void +vl_api_one_stats_flush_t_handler (vl_api_one_stats_flush_t * mp) +{ + vl_api_one_stats_flush_reply_t *rmp; + u8 rv; + + rv = vnet_lisp_flush_stats (); + REPLY_MACRO (VL_API_ONE_STATS_FLUSH_REPLY); +} + +static void +vl_api_one_stats_dump_t_handler (vl_api_one_stats_dump_t * mp) +{ + vl_api_one_stats_details_t *rmp; + lisp_api_stats_t *stats, *stat; + u8 rv = 0; + + stats = vnet_lisp_get_stats (); + vec_foreach (stat, stats) + { + /* *INDENT-OFF* */ + REPLY_DETAILS (VL_API_ONE_STATS_DETAILS, + ({ + lisp_fid_addr_to_api (&stat->deid, rmp->deid, &rmp->eid_type, + &rmp->deid_pref_len); + lisp_fid_addr_to_api (&stat->seid, rmp->seid, &rmp->eid_type, + &rmp->seid_pref_len); + rmp->vni = clib_host_to_net_u32 (stat->vni); + + rmp->is_ip4 = ip_addr_version (&stat->rmt_rloc) == IP4 ? 1 : 0; + ip_address_copy_addr (rmp->rloc, &stat->rmt_rloc); + ip_address_copy_addr (rmp->lloc, &stat->loc_rloc); + + rmp->pkt_count = clib_host_to_net_u32 (stat->counters.packets); + rmp->bytes = clib_host_to_net_u32 (stat->counters.bytes); + })); + /* *INDENT-ON* */ + } +} + +static void + vl_api_one_add_del_l2_arp_entry_t_handler + (vl_api_one_add_del_l2_arp_entry_t * mp) +{ + vl_api_one_add_del_l2_arp_entry_reply_t *rmp; + int rv = 0; + gid_address_t _arp, *arp = &_arp; + memset (arp, 0, sizeof (*arp)); + + gid_address_type (arp) = GID_ADDR_ARP; + gid_address_arp_bd (arp) = clib_net_to_host_u32 (mp->bd); + + /* vpp keeps ip4 addresses in network byte order */ + clib_memcpy (&gid_address_arp_ip4 (arp), &mp->ip4, 4); + + rv = vnet_lisp_add_del_l2_arp_entry (arp, mp->mac, mp->is_add); + + REPLY_MACRO (VL_API_ONE_ADD_DEL_L2_ARP_ENTRY_REPLY); +} + +static void +vl_api_one_l2_arp_bd_get_t_handler (vl_api_one_l2_arp_bd_get_t * mp) +{ + vl_api_one_l2_arp_bd_get_reply_t *rmp; + int rv = 0; + u32 i = 0; + hash_pair_t *p; + + u32 *bds = vnet_lisp_l2_arp_bds_get (); + u32 size = hash_elts (bds) * sizeof (u32); + + /* *INDENT-OFF* */ + REPLY_MACRO4 (VL_API_ONE_L2_ARP_BD_GET_REPLY, size, + { + rmp->count = clib_host_to_net_u32 (hash_elts (bds)); + hash_foreach_pair (p, bds, + ({ + rmp->bridge_domains[i++] = clib_host_to_net_u32 (p->key); + })); + }); + /* *INDENT-ON* */ + + hash_free (bds); +} + +static void +vl_api_one_l2_arp_entries_get_t_handler (vl_api_one_l2_arp_entries_get_t * mp) +{ + vl_api_one_l2_arp_entries_get_reply_t *rmp; + lisp_api_l2_arp_entry_t *entries = 0, *e; + u32 i = 0; + int rv = 0; + + u32 bd = clib_net_to_host_u32 (mp->bd); + + entries = vnet_lisp_l2_arp_entries_get_by_bd (bd); + u32 size = vec_len (entries) * sizeof (u32); + + /* *INDENT-OFF* */ + REPLY_MACRO4 (VL_API_ONE_L2_ARP_ENTRIES_GET_REPLY, size, + { + rmp->count = clib_host_to_net_u32 (vec_len (entries)); + vec_foreach (e, entries) + { + mac_copy (rmp->entries[i].mac, e->mac); + rmp->entries[i].ip4 = e->ip4; + i++; + } + }); + /* *INDENT-ON* */ + + vec_free (entries); +} + /* * one_api_hookup * Add vpe's API message handlers to the table.