aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2017-05-18 14:23:32 +0200
committerFlorin Coras <florin.coras@gmail.com>2017-05-22 15:23:32 +0000
commit0eb874e7fd34d74edd0619674561995ddf3b20ae (patch)
tree7b116403bdc425a64e0042e2aa479a72080c9972 /src
parentaade2c5a703b7d68fb2532e30bf84ab05e2ad152 (diff)
LISP-GPE: add dump call for VNIs in use
Change-Id: I394af7c1ac9fd0177ff5d298e4008245df54b436 Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/vat/api_format.c75
-rw-r--r--src/vnet/lisp-gpe/lisp_gpe.api16
-rw-r--r--src/vnet/lisp-gpe/lisp_gpe.h1
-rw-r--r--src/vnet/lisp-gpe/lisp_gpe_api.c33
-rw-r--r--src/vnet/lisp-gpe/lisp_gpe_fwd_entry.c23
-rw-r--r--src/vnet/lisp-gpe/lisp_gpe_fwd_entry.h2
6 files changed, 149 insertions, 1 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 22a91666102..aac59bb8bc0 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -2956,6 +2956,7 @@ api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
{
e->dp_table = clib_net_to_host_u32 (e->dp_table);
e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
+ e->vni = clib_net_to_host_u32 (e->vni);
}
static void
@@ -3131,6 +3132,8 @@ static void
vat_json_init_object (e);
vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
vat_json_object_add_int (e, "dp_table", fwd->dp_table);
+ vat_json_object_add_int (e, "vni", fwd->vni);
+ vat_json_object_add_int (e, "action", fwd->action);
s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
fwd->leid_prefix_len);
@@ -3154,6 +3157,53 @@ end:
}
static void
+ vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
+ (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
+{
+ vat_main_t *vam = &vat_main;
+ u32 i, n;
+ int retval = clib_net_to_host_u32 (mp->retval);
+
+ if (retval)
+ goto end;
+
+ n = clib_net_to_host_u32 (mp->count);
+
+ for (i = 0; i < n; i++)
+ print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
+
+end:
+ vam->retval = retval;
+ vam->result_ready = 1;
+}
+
+static void
+ vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
+ (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
+{
+ vat_main_t *vam = &vat_main;
+ vat_json_node_t root;
+ u32 i, n;
+ int retval = clib_net_to_host_u32 (mp->retval);
+
+ if (retval)
+ goto end;
+
+ n = clib_net_to_host_u32 (mp->count);
+ vat_json_init_array (&root);
+
+ for (i = 0; i < n; i++)
+ vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
+
+ vat_json_print (vam->ofp, &root);
+ vat_json_free (&root);
+
+end:
+ vam->retval = retval;
+ vam->result_ready = 1;
+}
+
+static void
vl_api_one_adjacencies_get_reply_t_handler
(vl_api_one_adjacencies_get_reply_t * mp)
{
@@ -4494,6 +4544,7 @@ _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
_(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
_(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
_(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
+_(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
_(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
_(GPE_FWD_ENTRY_PATH_DETAILS, \
gpe_fwd_entry_path_details) \
@@ -15900,6 +15951,8 @@ api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
return ret;
}
+#define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
+#define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
#define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
#define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
#define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
@@ -15952,6 +16005,27 @@ api_one_adjacencies_get (vat_main_t * vam)
#define api_lisp_adjacencies_get api_one_adjacencies_get
static int
+api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
+{
+ vl_api_gpe_fwd_entry_vnis_get_t *mp;
+ int ret;
+
+ if (!vam->json_output)
+ {
+ print (vam->ofp, "VNIs");
+ }
+
+ M (GPE_FWD_ENTRY_VNIS_GET, mp);
+
+ /* send it... */
+ S (mp);
+
+ /* Wait for a reply... */
+ W (ret);
+ return ret;
+}
+
+static int
api_one_map_server_dump (vat_main_t * vam)
{
vl_api_one_map_server_dump_t *mp;
@@ -19087,6 +19161,7 @@ _(lisp_eid_table_map_dump, "l2|l3") \
_(lisp_map_resolver_dump, "") \
_(lisp_map_server_dump, "") \
_(lisp_adjacencies_get, "vni <vni>") \
+_(gpe_fwd_entry_vnis_get, "") \
_(lisp_gpe_fwd_entries_get, "vni <vni>") \
_(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
_(gpe_set_encap_mode, "lisp|vxlan") \
diff --git a/src/vnet/lisp-gpe/lisp_gpe.api b/src/vnet/lisp-gpe/lisp_gpe.api
index f79d18c1a60..7af153355b7 100644
--- a/src/vnet/lisp-gpe/lisp_gpe.api
+++ b/src/vnet/lisp-gpe/lisp_gpe.api
@@ -87,6 +87,20 @@ autoreply define gpe_add_del_iface
u32 vni;
};
+define gpe_fwd_entry_vnis_get
+{
+ u32 client_index;
+ u32 context;
+};
+
+manual_print manual_endian define gpe_fwd_entry_vnis_get_reply
+{
+ u32 context;
+ i32 retval;
+ u32 count;
+ u32 vnis[count];
+};
+
define gpe_fwd_entries_get
{
u32 client_index;
@@ -103,6 +117,8 @@ typeonly manual_print manual_endian define gpe_fwd_entry
u8 reid_prefix_len;
u8 leid[16];
u8 reid[16];
+ u32 vni;
+ u8 action;
};
manual_print manual_endian define gpe_fwd_entries_get_reply
diff --git a/src/vnet/lisp-gpe/lisp_gpe.h b/src/vnet/lisp-gpe/lisp_gpe.h
index 38d76997ce3..d86a225f5f8 100644
--- a/src/vnet/lisp-gpe/lisp_gpe.h
+++ b/src/vnet/lisp-gpe/lisp_gpe.h
@@ -271,6 +271,7 @@ typedef struct
u32 fwd_entry_index;
u32 dp_table;
u32 vni;
+ u8 action;
dp_address_t leid;
dp_address_t reid;
} lisp_api_gpe_fwd_entry_t;
diff --git a/src/vnet/lisp-gpe/lisp_gpe_api.c b/src/vnet/lisp-gpe/lisp_gpe_api.c
index f6bd5440a6d..9edffa18ad4 100644
--- a/src/vnet/lisp-gpe/lisp_gpe_api.c
+++ b/src/vnet/lisp-gpe/lisp_gpe_api.c
@@ -57,6 +57,7 @@ _(GPE_FWD_ENTRIES_GET, gpe_fwd_entries_get) \
_(GPE_FWD_ENTRY_PATH_DUMP, gpe_fwd_entry_path_dump) \
_(GPE_ENABLE_DISABLE, gpe_enable_disable) \
_(GPE_ADD_DEL_IFACE, gpe_add_del_iface) \
+_(GPE_FWD_ENTRY_VNIS_GET, gpe_fwd_entry_vnis_get) \
_(GPE_SET_ENCAP_MODE, gpe_set_encap_mode) \
_(GPE_GET_ENCAP_MODE, gpe_get_encap_mode)
@@ -200,6 +201,8 @@ gpe_fwd_entries_copy (vl_api_gpe_fwd_entry_t * dst,
memset (dst, 0, sizeof (*dst));
dst[i].dp_table = src->dp_table;
dst[i].fwd_entry_index = src->fwd_entry_index;
+ dst[i].vni = src->vni;
+ dst[i].action = src->action;
switch (fid_addr_type (&e->leid))
{
case FID_ADDR_IP_PREF:
@@ -242,6 +245,7 @@ gpe_entry_t_host_to_net (vl_api_gpe_fwd_entry_t * e)
{
e->fwd_entry_index = clib_host_to_net_u32 (e->fwd_entry_index);
e->dp_table = clib_host_to_net_u32 (e->dp_table);
+ e->vni = clib_host_to_net_u32 (e->vni);
}
static void
@@ -260,6 +264,31 @@ static void
}
static void
+vl_api_gpe_fwd_entry_vnis_get_t_handler (vl_api_gpe_fwd_entry_vnis_get_t * mp)
+{
+ vl_api_gpe_fwd_entry_vnis_get_reply_t *rmp = 0;
+ hash_pair_t *p;
+ u32 i = 0;
+ int rv = 0;
+
+ u32 *vnis = vnet_lisp_gpe_get_fwd_entry_vnis ();
+ u32 size = hash_elts (vnis) * sizeof (u32);
+
+ /* *INDENT-OFF* */
+ REPLY_MACRO4 (VL_API_GPE_FWD_ENTRY_VNIS_GET_REPLY, size,
+ {
+ rmp->count = clib_host_to_net_u32 (hash_elts (vnis));
+ hash_foreach_pair (p, vnis,
+ ({
+ rmp->vnis[i++] = clib_host_to_net_u32 (p->key);
+ }));
+ });
+ /* *INDENT-ON* */
+
+ hash_free (vnis);
+}
+
+static void
vl_api_gpe_fwd_entries_get_t_handler (vl_api_gpe_fwd_entries_get_t * mp)
{
lisp_api_gpe_fwd_entry_t *e;
@@ -315,7 +344,7 @@ vl_api_gpe_add_del_fwd_entry_t_handler (vl_api_gpe_add_del_fwd_entry_t * mp)
}
pairs = unformat_gpe_loc_pairs (mp->locs, mp->loc_num / 2);
- if (rv || 0 == pairs)
+ if (rv)
goto send_reply;
a->is_add = mp->is_add;
@@ -323,6 +352,8 @@ vl_api_gpe_add_del_fwd_entry_t_handler (vl_api_gpe_add_del_fwd_entry_t * mp)
a->dp_table = mp->dp_table;
a->vni = mp->vni;
a->action = mp->action;
+ if (mp->loc_num == 0)
+ a->is_negative = 1;
rv = vnet_lisp_gpe_add_del_fwd_entry (a, 0);
vec_free (pairs);
diff --git a/src/vnet/lisp-gpe/lisp_gpe_fwd_entry.c b/src/vnet/lisp-gpe/lisp_gpe_fwd_entry.c
index 6d400f75489..1c34e6e4eee 100644
--- a/src/vnet/lisp-gpe/lisp_gpe_fwd_entry.c
+++ b/src/vnet/lisp-gpe/lisp_gpe_fwd_entry.c
@@ -495,6 +495,10 @@ add_ip_fwd_entry (lisp_gpe_main_t * lgm,
{
lisp_gpe_fwd_entry_mk_paths (lfe, a);
}
+ else
+ {
+ lfe->action = a->action;
+ }
create_fib_entries (lfe);
return (0);
@@ -1438,6 +1442,23 @@ lisp_gpe_fwd_entry_init (vlib_main_t * vm)
return (error);
}
+u32 *
+vnet_lisp_gpe_get_fwd_entry_vnis (void)
+{
+ lisp_gpe_main_t *lgm = vnet_lisp_gpe_get_main ();
+ lisp_gpe_fwd_entry_t *lfe;
+ u32 *vnis = 0;
+
+ /* *INDENT-OFF* */
+ pool_foreach (lfe, lgm->lisp_fwd_entry_pool,
+ ({
+ hash_set (vnis, lfe->key->vni, 0);
+ }));
+ /* *INDENT-ON* */
+
+ return vnis;
+}
+
lisp_api_gpe_fwd_entry_t *
vnet_lisp_gpe_fwd_entries_get_by_vni (u32 vni)
{
@@ -1453,6 +1474,8 @@ vnet_lisp_gpe_fwd_entries_get_by_vni (u32 vni)
memset (&e, 0, sizeof (e));
e.dp_table = lfe->eid_table_id;
e.vni = lfe->key->vni;
+ if (lfe->type == LISP_GPE_FWD_ENTRY_TYPE_NEGATIVE)
+ e.action = lfe->action;
e.fwd_entry_index = lfe - lgm->lisp_fwd_entry_pool;
memcpy (&e.reid, &lfe->key->rmt, sizeof (e.reid));
memcpy (&e.leid, &lfe->key->lcl, sizeof (e.leid));
diff --git a/src/vnet/lisp-gpe/lisp_gpe_fwd_entry.h b/src/vnet/lisp-gpe/lisp_gpe_fwd_entry.h
index b9d9c98359b..1580351611c 100644
--- a/src/vnet/lisp-gpe/lisp_gpe_fwd_entry.h
+++ b/src/vnet/lisp-gpe/lisp_gpe_fwd_entry.h
@@ -217,6 +217,8 @@ vnet_lisp_gpe_del_fwd_counters (vnet_lisp_gpe_add_del_fwd_entry_args_t * a,
extern void
vnet_lisp_gpe_add_fwd_counters (vnet_lisp_gpe_add_del_fwd_entry_args_t * a,
u32 fwd_entry_index);
+extern u32 *vnet_lisp_gpe_get_fwd_entry_vnis (void);
+
#endif
/*