aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2016-08-24 11:28:02 +0200
committerFlorin Coras <florin.coras@gmail.com>2016-08-25 12:49:37 +0000
commit50a4e1429477e41848b1cdb632aab20cb8154386 (patch)
tree21f68eab2e1261481f070794842bdf789a2d4075
parent082b39dc6764c883bdda647c610065b506d4ba2d (diff)
VPP-328: Add dump call for listing LISP VNIs
Change-Id: I45c054ad638a0e918dddefa4468ff65452949970 Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
-rw-r--r--vpp-api-test/vat/api_format.c57
-rw-r--r--vpp/vpp-api/api.c49
-rw-r--r--vpp/vpp-api/custom_dump.c2
-rw-r--r--vpp/vpp-api/vpe.api22
4 files changed, 130 insertions, 0 deletions
diff --git a/vpp-api-test/vat/api_format.c b/vpp-api-test/vat/api_format.c
index f13e983c450..7f0f9fa7f20 100644
--- a/vpp-api-test/vat/api_format.c
+++ b/vpp-api-test/vat/api_format.c
@@ -2428,7 +2428,33 @@ static void
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_SET_DETAILS, lisp_locator_set_details) \
_(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 @@ api_lisp_eid_table_map_dump (vat_main_t * vam)
}
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_locator_set_dump, "[locator-set-index <ls-index> | " \
_(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 15a7bf416ed..b10baf08628 100644
--- a/vpp/vpp-api/api.c
+++ b/vpp/vpp-api/api.c
@@ -345,6 +345,7 @@ _(LISP_EID_TABLE_DUMP, lisp_eid_table_dump) \
_(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 @@ vl_api_lisp_eid_table_map_dump_t_handler (vl_api_lisp_eid_table_map_dump_t *
}
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 db5ea646150..4737d3b2126 100644
--- a/vpp/vpp-api/custom_dump.c
+++ b/vpp/vpp-api/custom_dump.c
@@ -2572,6 +2572,7 @@ static void *vl_api_ipsec_gre_tunnel_dump_t_print
#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_MAP_RESOLVER, lisp_add_del_map_resolver) \
_(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 3b3025d487d..fb0a4145c00 100644
--- a/vpp/vpp-api/vpe.api
+++ b/vpp/vpp-api/vpe.api
@@ -2881,6 +2881,28 @@ define lisp_eid_table_map_dump
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;