diff options
author | Filip Tehlar <ftehlar@cisco.com> | 2016-07-13 13:17:15 +0200 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2016-07-13 19:36:43 +0000 |
commit | 2f653d08f4647905b241508e282a491794a54285 (patch) | |
tree | 6cf109d0276448f682e768b3357a183b799c7ecd | |
parent | ad476c7861d0428766f9bee01f69cd00025a47c0 (diff) |
Add API dump call for vrf/vni mapping to vpp-api-test
Change-Id: I7a028ce9ddf21bd3a7d4991ba1be05e5e74202d6
Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
-rw-r--r-- | vnet/vnet/lisp-cp/control.c | 2 | ||||
-rw-r--r-- | vpp-api-test/vat/api_format.c | 60 | ||||
-rw-r--r-- | vpp/vpp-api/api.c | 24 |
3 files changed, 79 insertions, 7 deletions
diff --git a/vnet/vnet/lisp-cp/control.c b/vnet/vnet/lisp-cp/control.c index 824046cd9cf..7ab336c292a 100644 --- a/vnet/vnet/lisp-cp/control.c +++ b/vnet/vnet/lisp-cp/control.c @@ -601,7 +601,7 @@ vnet_lisp_eid_table_map (u32 vni, u32 vrf, u8 is_add) { if (table_id || vnip) { - clib_warning ("vni %d or vrf %d already used in any vrf/vni " + clib_warning ("vni %d or vrf %d already used in vrf/vni " "mapping!", vni, vrf); return -1; } diff --git a/vpp-api-test/vat/api_format.c b/vpp-api-test/vat/api_format.c index b540f72c8c6..84e9c4f6705 100644 --- a/vpp-api-test/vat/api_format.c +++ b/vpp-api-test/vat/api_format.c @@ -2048,6 +2048,36 @@ vl_api_lisp_local_eid_table_details_t_handler ( } static void +vl_api_lisp_eid_table_map_details_t_handler ( + vl_api_lisp_eid_table_map_details_t *mp) +{ + vat_main_t *vam = &vat_main; + + u8 * line = format(0, "%=10d%=10d", + clib_net_to_host_u32 (mp->vni), + clib_net_to_host_u32 (mp->vrf)); + fformat(vam->ofp, "%v\n", line); + vec_free(line); +} + +static void +vl_api_lisp_eid_table_map_details_t_handler_json ( + vl_api_lisp_eid_table_map_details_t *mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node = NULL; + + if (VAT_JSON_ARRAY != vam->json_tree.type) { + ASSERT(VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array(&vam->json_tree); + } + node = vat_json_array_add(&vam->json_tree); + vat_json_init_object(node); + vat_json_object_add_uint(node, "vrf", clib_net_to_host_u32 (mp->vrf)); + vat_json_object_add_uint(node, "vni", clib_net_to_host_u32 (mp->vni)); +} + +static void vl_api_lisp_local_eid_table_details_t_handler_json ( vl_api_lisp_local_eid_table_details_t *mp) { @@ -2959,6 +2989,7 @@ _(LISP_EID_TABLE_ADD_DEL_MAP_REPLY, lisp_eid_table_add_del_map_reply) \ _(LISP_GPE_ADD_DEL_IFACE_REPLY, lisp_gpe_add_del_iface_reply) \ _(LISP_LOCATOR_SET_DETAILS, lisp_locator_set_details) \ _(LISP_LOCAL_EID_TABLE_DETAILS, lisp_local_eid_table_details) \ +_(LISP_EID_TABLE_MAP_DETAILS, lisp_eid_table_map_details) \ _(LISP_GPE_TUNNEL_DETAILS, lisp_gpe_tunnel_details) \ _(LISP_MAP_RESOLVER_DETAILS, lisp_map_resolver_details) \ _(LISP_ENABLE_DISABLE_STATUS_DETAILS, \ @@ -11193,6 +11224,34 @@ api_lisp_locator_set_dump(vat_main_t *vam) } static int +api_lisp_eid_table_map_dump(vat_main_t *vam) +{ + vl_api_lisp_eid_table_map_dump_t *mp; + f64 timeout = ~0; + + if (!vam->json_output) { + fformat (vam->ofp, "%=10s%=10s\n", "VNI", "VRF"); + } + + M(LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump); + + /* send it... */ + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t * mp; + M(CONTROL_PING, control_ping); + S; + } + /* Wait for a reply... */ + W; + + /* NOTREACHED */ + return 0; +} + +static int api_lisp_local_eid_table_dump(vat_main_t *vam) { unformat_input_t * i = vam->input; @@ -12620,6 +12679,7 @@ _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \ _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \ _(lisp_locator_set_dump, "") \ _(lisp_local_eid_table_dump, "") \ +_(lisp_eid_table_map_dump, "") \ _(lisp_gpe_tunnel_dump, "") \ _(lisp_map_resolver_dump, "") \ _(lisp_enable_disable_status_dump, "") \ diff --git a/vpp/vpp-api/api.c b/vpp/vpp-api/api.c index 9acda74547b..63e0ed25a86 100644 --- a/vpp/vpp-api/api.c +++ b/vpp/vpp-api/api.c @@ -5454,6 +5454,23 @@ vl_api_lisp_map_resolver_dump_t_handler ( } static void +send_eid_table_map_pair (hash_pair_t * p, + unix_shared_memory_queue_t * q, + u32 context) +{ + vl_api_lisp_eid_table_map_details_t * rmp = NULL; + + rmp = vl_msg_api_alloc (sizeof (*rmp)); + 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->vrf = clib_host_to_net_u32 (p->value[0]); + rmp->context = context; + vl_msg_api_send_shmem (q, (u8 *)&rmp); +} + +static void vl_api_lisp_eid_table_map_dump_t_handler ( vl_api_lisp_eid_table_map_dump_t *mp) { @@ -5466,12 +5483,7 @@ vl_api_lisp_eid_table_map_dump_t_handler ( return; } hash_foreach_pair (p, lcm->table_id_by_vni, { - vl_api_lisp_eid_table_map_details_t * rmp = NULL; - memset (rmp, 0, sizeof (*rmp)); - rmp->_vl_msg_id = ntohs(VL_API_LISP_EID_TABLE_MAP_DETAILS); - rmp->vni = p->key; - rmp->vrf = p->value[0]; - rmp->context = mp->context; + send_eid_table_map_pair (p, q, mp->context); }); } |