VPP-328: Add dump call for listing LISP VNIs
Change-Id: I45c054ad638a0e918dddefa4468ff65452949970
Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
diff --git a/vpp-api-test/vat/api_format.c b/vpp-api-test/vat/api_format.c
index f13e983..7f0f9fa 100644
--- a/vpp-api-test/vat/api_format.c
+++ b/vpp-api-test/vat/api_format.c
@@ -2428,7 +2428,33 @@
vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
}
+static void
+ vl_api_lisp_eid_table_vni_details_t_handler
+ (vl_api_lisp_eid_table_vni_details_t * mp)
+{
+ vat_main_t *vam = &vat_main;
+ u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
+ fformat (vam->ofp, "%v\n", line);
+ vec_free (line);
+}
+
+static void
+ vl_api_lisp_eid_table_vni_details_t_handler_json
+ (vl_api_lisp_eid_table_vni_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, "vni", clib_net_to_host_u32 (mp->vni));
+}
static u8 *
format_decap_next (u8 * s, va_list * args)
@@ -3544,6 +3570,7 @@
_(LISP_LOCATOR_DETAILS, lisp_locator_details) \
_(LISP_EID_TABLE_DETAILS, lisp_eid_table_details) \
_(LISP_EID_TABLE_MAP_DETAILS, lisp_eid_table_map_details) \
+_(LISP_EID_TABLE_VNI_DETAILS, lisp_eid_table_vni_details) \
_(LISP_GPE_TUNNEL_DETAILS, lisp_gpe_tunnel_details) \
_(LISP_MAP_RESOLVER_DETAILS, lisp_map_resolver_details) \
_(SHOW_LISP_STATUS_REPLY, show_lisp_status_reply) \
@@ -13117,6 +13144,35 @@
}
static int
+api_lisp_eid_table_vni_dump (vat_main_t * vam)
+{
+ vl_api_lisp_eid_table_vni_dump_t *mp;
+ f64 timeout = ~0;
+
+ if (!vam->json_output)
+ {
+ fformat (vam->ofp, "VNI\n");
+ }
+
+ M (LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_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
get_locator_set (vat_main_t * vam)
{
vl_api_lisp_locator_set_dump_t *mp;
@@ -15652,6 +15708,7 @@
_(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
"[local] | [remote]") \
_(lisp_eid_table_map_dump, "") \
+_(lisp_eid_table_vni_dump, "") \
_(lisp_gpe_tunnel_dump, "") \
_(lisp_map_resolver_dump, "") \
_(show_lisp_status, "") \
diff --git a/vpp/vpp-api/api.c b/vpp/vpp-api/api.c
index 15a7bf4..b10baf0 100644
--- a/vpp/vpp-api/api.c
+++ b/vpp/vpp-api/api.c
@@ -345,6 +345,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) \
_(SHOW_LISP_STATUS, show_lisp_status) \
_(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, \
lisp_add_del_map_request_itr_rlocs) \
@@ -5922,6 +5923,54 @@
}
static void
+send_eid_table_vni (u32 vni, unix_shared_memory_queue_t * q, u32 context)
+{
+ vl_api_lisp_eid_table_vni_details_t *rmp = 0;
+
+ rmp = vl_msg_api_alloc (sizeof (*rmp));
+ 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);
+}
+
+static void
+vl_api_lisp_eid_table_vni_dump_t_handler (vl_api_lisp_eid_table_vni_dump_t *
+ mp)
+{
+ hash_pair_t *p;
+ u32 *vnis = 0;
+ unix_shared_memory_queue_t *q = 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;
+ }
+
+ /* *INDENT-OFF* */
+ hash_foreach_pair (p, lcm->table_id_by_vni,
+ ({
+ hash_set (vnis, p->key, 0);
+ }));
+
+ hash_foreach_pair (p, lcm->bd_id_by_vni,
+ ({
+ hash_set (vnis, p->key, 0);
+ }));
+
+ hash_foreach_pair (p, vnis,
+ ({
+ send_eid_table_vni (p->key, q, mp->context);
+ }));
+ /* *INDENT-ON* */
+
+ hash_free (vnis);
+}
+
+static void
vl_api_show_lisp_status_t_handler (vl_api_show_lisp_status_t * mp)
{
unix_shared_memory_queue_t *q = NULL;
diff --git a/vpp/vpp-api/custom_dump.c b/vpp/vpp-api/custom_dump.c
index db5ea64..4737d3b 100644
--- a/vpp/vpp-api/custom_dump.c
+++ b/vpp/vpp-api/custom_dump.c
@@ -2572,6 +2572,7 @@
#define foreach_custom_print_no_arg_function \
_(lisp_eid_table_map_dump) \
+_(lisp_eid_table_vni_dump) \
_(lisp_map_resolver_dump) \
_(lisp_gpe_tunnel_dump)
@@ -2711,6 +2712,7 @@
_(LISP_ADD_DEL_LOCATOR, lisp_add_del_locator) \
_(LISP_EID_TABLE_DUMP, lisp_eid_table_dump) \
_(LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump) \
+_(LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump) \
_(LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump) \
_(LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump) \
_(LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump) \
diff --git a/vpp/vpp-api/vpe.api b/vpp/vpp-api/vpe.api
index 3b3025d..fb0a414 100644
--- a/vpp/vpp-api/vpe.api
+++ b/vpp/vpp-api/vpe.api
@@ -2881,6 +2881,28 @@
u32 context;
};
+/** \brief Dumps all VNIs used in mappings
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ */
+define lisp_eid_table_vni_dump
+{
+ u32 client_index;
+ u32 context;
+};
+
+/** \brief reply to lisp_eid_table_vni_dump
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param vni - virtual network instance
+ */
+define lisp_eid_table_vni_details
+{
+ u32 client_index;
+ u32 context;
+ u32 vni;
+};
+
define lisp_gpe_tunnel_details
{
u32 context;