summaryrefslogtreecommitdiffstats
path: root/vnet
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 /vnet
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>
Diffstat (limited to 'vnet')
-rw-r--r--vnet/vnet/lisp-cp/control.c49
-rw-r--r--vnet/vnet/lisp-cp/lisp_types.c28
2 files changed, 66 insertions, 11 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;
}