summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2016-06-22 09:18:12 +0200
committerFlorin Coras <florin.coras@gmail.com>2016-06-24 15:57:17 +0000
commitb0ccf03b6e1d29b473e092d42768ced9f2ae8508 (patch)
tree35580808508877fce2f88b05071228b4fcf166f7
parentfa42e25c4e498c57e15ebb0ded56502a61b7dc08 (diff)
Reformat output of lisp eid-table show command.
Example output: DBGvpp# sh lisp eid EID type locators [100] 6.0.2.0/24 local(ls1) host-intervpp1 [200] 6.0.2.0/24 local(ls2) host-intervpp1 [100] 6.0.4.0/24 remote 6.0.3.2 [200] 6.0.99.0/24 local(ls3) local0 host-intervpp1 [0] 6.0.0.0/16 remote Change-Id: I69200bf7636167bce931def88828503a75496f4b Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
-rw-r--r--vnet/vnet/lisp-cp/control.c64
-rw-r--r--vnet/vnet/lisp-cp/lisp_types.c4
-rw-r--r--vnet/vnet/lisp-cp/lisp_types.h9
3 files changed, 66 insertions, 11 deletions
diff --git a/vnet/vnet/lisp-cp/control.c b/vnet/vnet/lisp-cp/control.c
index 8b3d25f8dfa..1e3b98ff5c6 100644
--- a/vnet/vnet/lisp-cp/control.c
+++ b/vnet/vnet/lisp-cp/control.c
@@ -891,32 +891,74 @@ VLIB_CLI_COMMAND (lisp_pitr_set_locator_set_command) = {
.function = lisp_pitr_set_locator_set_command_fn,
};
+
+static u8 *
+format_eid_entry (u8 * s, va_list * args)
+{
+ vnet_main_t * vnm = va_arg (*args, vnet_main_t *);
+ lisp_cp_main_t * lcm = va_arg (*args, lisp_cp_main_t *);
+ gid_address_t * gid = va_arg (*args, gid_address_t *);
+ locator_set_t * ls = va_arg (*args, locator_set_t *);
+ u32 * loc_index;
+ u8 first_line = 1;
+ u8 * loc;
+
+ u8 * type = ls->local ? format(0, "local(%s)", ls->name)
+ : format(0, "remote");
+
+ if (vec_len (ls->locator_indices) == 0)
+ {
+ s = format (s, "%-35U%-20s", format_gid_address, gid, type);
+ }
+ else
+ {
+ vec_foreach (loc_index, ls->locator_indices)
+ {
+ locator_t * l = pool_elt_at_index (lcm->locator_pool, loc_index[0]);
+ if (l->local)
+ loc = format (0, "%U", format_vnet_sw_if_index_name, vnm,
+ l->sw_if_index);
+ else
+ loc = format (0, "%U", format_ip_address,
+ &gid_address_ip (&l->address));
+
+ if (first_line)
+ {
+ s = format (s, "%-35U%-20s%-v\n", format_gid_address,
+ gid, type, loc);
+ first_line = 0;
+ }
+ else
+ s = format (s, "%55s%v\n", "", loc);
+ }
+ }
+ return s;
+}
+
static clib_error_t *
-lisp_show_local_eid_table_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
+lisp_show_eid_table_command_fn (vlib_main_t * vm,
+ unformat_input_t * input,
+ vlib_cli_command_t * cmd)
{
lisp_cp_main_t * lcm = vnet_lisp_cp_get_main();
mapping_t * mapit;
- vlib_cli_output (vm, "%=30s%=16s", "EID", "Locator");
+ vlib_cli_output (vm, "%-35s%-20s%-s", "EID", "type", "locators");
pool_foreach (mapit, lcm->mapping_pool,
({
- u8 * msg = 0;
locator_set_t * ls = pool_elt_at_index (lcm->locator_set_pool,
mapit->locator_set_index);
- vlib_cli_output (vm, "%-30U%16v", format_gid_address, &mapit->eid,
- ls->name);
- vec_free (msg);
+ vlib_cli_output (vm, "%U", format_eid_entry, lcm->vnet_main,
+ lcm, &mapit->eid, ls);
}));
return 0;
}
-VLIB_CLI_COMMAND (lisp_cp_show_local_eid_table_command) = {
+VLIB_CLI_COMMAND (lisp_cp_show_eid_table_command) = {
.path = "show lisp eid-table",
- .short_help = "Shows local EID table",
- .function = lisp_show_local_eid_table_command_fn,
+ .short_help = "Shows EID table",
+ .function = lisp_show_eid_table_command_fn,
};
/* cleans locator to locator-set data and removes locators not part of
diff --git a/vnet/vnet/lisp-cp/lisp_types.c b/vnet/vnet/lisp-cp/lisp_types.c
index f0debc61a00..11e252aac54 100644
--- a/vnet/vnet/lisp-cp/lisp_types.c
+++ b/vnet/vnet/lisp-cp/lisp_types.c
@@ -160,6 +160,10 @@ format_gid_address (u8 * s, va_list * args)
case GID_ADDR_IP_PREFIX:
return format (s, "[%d] %U", gid_address_vni(a), format_ip_prefix,
&gid_address_ippref(a));
+ case GID_ADDR_SRC_DST:
+ return format (s, "[%d] %U|%U", gid_address_vni(a),
+ format_ip_prefix, &gid_address_sd_source_pref(a),
+ format_ip_prefix, &gid_address_sd_dest_pref(a));
default:
clib_warning("Can't format gid type %d", type);
return 0;
diff --git a/vnet/vnet/lisp-cp/lisp_types.h b/vnet/vnet/lisp-cp/lisp_types.h
index 235d4701d46..709d415deca 100644
--- a/vnet/vnet/lisp-cp/lisp_types.h
+++ b/vnet/vnet/lisp-cp/lisp_types.h
@@ -64,6 +64,7 @@ typedef enum
GID_ADDR_IP_PREFIX,
GID_ADDR_LCAF,
GID_ADDR_MAC,
+ GID_ADDR_SRC_DST,
GID_ADDR_NO_ADDRESS,
GID_ADDR_TYPES
} gid_address_type_t;
@@ -87,6 +88,10 @@ typedef struct
struct _gid_address_t *dst;
} source_dest_t;
+#define SD_CAST (source_dest_t *)
+#define sd_dst_gid(_a) (SD_CAST _a)->dst
+#define sd_src_gid(_a) (SD_CAST _a)->src
+
typedef struct
{
u8 vni_mask_len;
@@ -172,6 +177,10 @@ u32 gid_address_parse (u8 * offset, gid_address_t *a);
#define gid_address_mac(_a) (_a)->mac
#define gid_address_vni(_a) (_a)->vni
#define gid_address_vni_mask(_a) (_a)->vni_mask
+#define gid_address_sd_dest_pref(_a) \
+ gid_address_ippref(sd_dst_gid(_a))
+#define gid_address_sd_source_pref(_a) \
+ gid_address_ippref(sd_src_gid(_a))
/* 'sub'address functions */
#define foreach_gid_address_type_fcns \