summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2016-07-04 11:43:11 +0200
committerFilip Tehlar <ftehlar@cisco.com>2016-07-07 08:13:47 +0200
commit1b1ee4f2e550d2cf98e5e5f718ad5543389c8c37 (patch)
treef1be22d0f6929819f7a7ca9cb5b775ce175dc635
parent137c7c612641b5056bc20e64e8ef75df0c775629 (diff)
Add an option to dump details about specific LISP EID in API/CLI
Change-Id: Ie5e6751fd791e7ca728522632332abe442a1a75b Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
-rw-r--r--vnet/vnet/lisp-cp/control.c49
-rw-r--r--vnet/vnet/lisp-cp/lisp_types.c28
-rw-r--r--vpp-api-test/vat/api_format.c49
-rw-r--r--vpp/vpp-api/api.c33
-rw-r--r--vpp/vpp-api/vpe.api15
5 files changed, 162 insertions, 12 deletions
diff --git a/vnet/vnet/lisp-cp/control.c b/vnet/vnet/lisp-cp/control.c
index 00317cd871e..53e8a75b4d6 100644
--- a/vnet/vnet/lisp-cp/control.c
+++ b/vnet/vnet/lisp-cp/control.c
@@ -1391,15 +1391,50 @@ lisp_show_eid_table_command_fn (vlib_main_t * vm,
{
lisp_cp_main_t * lcm = vnet_lisp_cp_get_main();
mapping_t * mapit;
+ unformat_input_t _line_input, * line_input = &_line_input;
+ u32 mi;
+ gid_address_t eid;
+ u8 print_all = 1;
+
+ memset (&eid, 0, sizeof(eid));
+
+ /* Get a line of input. */
+ if (!unformat_user (input, unformat_line_input, line_input))
+ return 0;
+
+ while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (line_input, "eid %U", unformat_gid_address, &eid))
+ print_all = 0;
+ else
+ return clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ }
vlib_cli_output (vm, "%-35s%-20s%-s", "EID", "type", "locators");
- pool_foreach (mapit, lcm->mapping_pool,
- ({
- locator_set_t * ls = pool_elt_at_index (lcm->locator_set_pool,
- mapit->locator_set_index);
- vlib_cli_output (vm, "%U", format_eid_entry, lcm->vnet_main,
- lcm, &mapit->eid, ls);
- }));
+
+ if (print_all)
+ {
+ pool_foreach (mapit, lcm->mapping_pool,
+ ({
+ locator_set_t * ls = pool_elt_at_index (lcm->locator_set_pool,
+ mapit->locator_set_index);
+ vlib_cli_output (vm, "%U", format_eid_entry, lcm->vnet_main,
+ lcm, &mapit->eid, ls);
+ }));
+ }
+ else
+ {
+ mi = gid_dictionary_lookup (&lcm->mapping_index_by_gid, &eid);
+ if ((u32)~0 == mi)
+ return 0;
+
+ mapit = pool_elt_at_index (lcm->mapping_pool, mi);
+ locator_set_t * ls = pool_elt_at_index (lcm->locator_set_pool,
+ mapit->locator_set_index);
+ vlib_cli_output (vm, "%U", format_eid_entry, lcm->vnet_main,
+ lcm, &mapit->eid, ls);
+ }
return 0;
}
diff --git a/vnet/vnet/lisp-cp/lisp_types.c b/vnet/vnet/lisp-cp/lisp_types.c
index 25a8271e929..62900ec795c 100644
--- a/vnet/vnet/lisp-cp/lisp_types.c
+++ b/vnet/vnet/lisp-cp/lisp_types.c
@@ -192,11 +192,31 @@ format_gid_address (u8 * s, va_list * args)
uword
unformat_gid_address (unformat_input_t * input, va_list * args)
{
+ u32 vni;
gid_address_t * a = va_arg(*args, gid_address_t *);
- if (unformat (input, "%U", unformat_ip_prefix, &gid_address_ippref(a)))
- gid_address_type(a) = GID_ADDR_IP_PREFIX;
- else
- return 0;
+ u8 mac[6] = {0};
+ ip_prefix_t ippref;
+
+ memset (&ippref, 0, sizeof (ippref));
+ memset (a, 0, sizeof (a[0]));
+
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (input, "%U", unformat_ip_prefix, &ippref))
+ {
+ clib_memcpy (&gid_address_ippref(a), &ippref, sizeof (ippref));
+ gid_address_type(a) = GID_ADDR_IP_PREFIX;
+ }
+ else if (unformat (input, "%U", unformat_mac_address, mac))
+ {
+ clib_memcpy (gid_address_mac(a), mac, sizeof (mac));
+ gid_address_type(a) = GID_ADDR_MAC;
+ }
+ else if (unformat (input, "[%d]", &vni))
+ gid_address_vni(a) = vni;
+ else
+ return 0;
+ }
return 1;
}
diff --git a/vpp-api-test/vat/api_format.c b/vpp-api-test/vat/api_format.c
index 8c6cb66fea7..fea24684c6a 100644
--- a/vpp-api-test/vat/api_format.c
+++ b/vpp-api-test/vat/api_format.c
@@ -10966,8 +10966,34 @@ api_lisp_locator_set_dump(vat_main_t *vam)
static int
api_lisp_local_eid_table_dump(vat_main_t *vam)
{
+ unformat_input_t * i = vam->input;
vl_api_lisp_local_eid_table_dump_t *mp;
f64 timeout = ~0;
+ struct in_addr ip4;
+ struct in6_addr ip6;
+ u8 mac[6];
+ u8 eid_type = ~0, eid_set;
+ u32 prefix_length = ~0, t, vni = 0;
+
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) {
+ if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t)) {
+ eid_set = 1;
+ eid_type = 0;
+ prefix_length = t;
+ } else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t)) {
+ eid_set = 1;
+ eid_type = 1;
+ prefix_length = t;
+ } else if (unformat (i, "eid %U", unformat_ethernet_address, mac)) {
+ eid_set = 1;
+ eid_type = 2;
+ } else if (unformat (i, "vni %d", &t))
+ vni = t;
+ else {
+ errmsg ("parse error '%U'", format_unformat_error, i);
+ return -99;
+ }
+ }
if (!vam->json_output) {
fformat(vam->ofp, "%=20s%=30s\n",
@@ -10975,6 +11001,29 @@ api_lisp_local_eid_table_dump(vat_main_t *vam)
}
M(LISP_LOCAL_EID_TABLE_DUMP, lisp_local_eid_table_dump);
+
+ if (eid_set) {
+ mp->eid_set = 1;
+ mp->vni = htonl (vni);
+ mp->eid_type = eid_type;
+ switch (eid_type) {
+ case 0:
+ mp->prefix_length = prefix_length;
+ clib_memcpy (mp->eid, &ip4, sizeof (ip4));
+ break;
+ case 1:
+ mp->prefix_length = prefix_length;
+ clib_memcpy (mp->eid, &ip6, sizeof (ip6));
+ break;
+ case 2:
+ clib_memcpy (mp->eid, mac, sizeof (mac));
+ break;
+ default:
+ errmsg ("unknown EID type %d!", eid_type);
+ return -99;
+ }
+ }
+
/* send it... */
S;
diff --git a/vpp/vpp-api/api.c b/vpp/vpp-api/api.c
index 58f7aeff5fd..767b9d5dfd8 100644
--- a/vpp/vpp-api/api.c
+++ b/vpp/vpp-api/api.c
@@ -5337,19 +5337,50 @@ static void
vl_api_lisp_local_eid_table_dump_t_handler (
vl_api_lisp_local_eid_table_dump_t *mp)
{
+ u32 mi;
unix_shared_memory_queue_t * q = NULL;
lisp_cp_main_t * lcm = vnet_lisp_cp_get_main();
mapping_t * mapit = NULL;
+ gid_address_t _eid, * eid = &_eid;
q = vl_api_client_index_to_input_queue (mp->client_index);
if (q == 0) {
return;
}
- pool_foreach (mapit, lcm->mapping_pool,
+ if (mp->eid_set) {
+ memset (eid, 0, sizeof (*eid));
+ gid_address_vni(eid) = ntohl(mp->vni);
+ switch (mp->eid_type) {
+ case 0:
+ gid_address_type(eid) = GID_ADDR_IP_PREFIX;
+ gid_address_ippref_len(eid) = mp->prefix_length;
+ gid_address_ip_version(eid) = IP4;
+ clib_memcpy (&gid_address_ippref(eid), mp->eid, 4);
+ break;
+ case 1:
+ gid_address_type(eid) = GID_ADDR_IP_PREFIX;
+ gid_address_ippref_len(eid) = mp->prefix_length;
+ gid_address_ip_version(eid) = IP6;
+ clib_memcpy (&gid_address_ippref(eid), mp->eid, 16);
+ break;
+ case 2:
+ gid_address_type(eid) = GID_ADDR_MAC;
+ clib_memcpy (gid_address_mac(eid), mp->eid, 6);
+ break;
+ }
+ mi = gid_dictionary_lookup (&lcm->mapping_index_by_gid, eid);
+ if ((u32)~0 == mi)
+ return;
+
+ mapit = pool_elt_at_index (lcm->mapping_pool, mi);
+ send_lisp_local_eid_table_details(mapit, q, mp->context);
+ } else {
+ pool_foreach (mapit, lcm->mapping_pool,
({
send_lisp_local_eid_table_details(mapit, q, mp->context);
}));
+ }
}
static void
diff --git a/vpp/vpp-api/vpe.api b/vpp/vpp-api/vpe.api
index 9057de9d139..bf13efb8d49 100644
--- a/vpp/vpp-api/vpe.api
+++ b/vpp/vpp-api/vpe.api
@@ -2542,10 +2542,25 @@ manual_java define lisp_local_eid_table_details {
/** \brief Request for local eid table summary status
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
+ @param eid_set - if non-zero request info about specific mapping
+ @param vni - virtual network instance; valid only if eid_set != 0
+ @param prefix_length - prefix length if EID is IP address;
+ valid only if eid_set != 0
+ @param eid_type - EID type; valid only if eid_set != 0
+ Supported values:
+ 0: EID is IPv4
+ 1: EID is IPv6
+ 2: EID is ethernet address
+ @param eid - endpoint identifier
*/
define lisp_local_eid_table_dump {
u32 client_index;
u32 context;
+ u8 eid_set;
+ u8 prefix_length;
+ u32 vni;
+ u8 eid_type;
+ u8 eid[16];
};
/** \brief Shows relationship between vni and vrf