summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2016-08-27 08:40:26 +0200
committerFlorin Coras <florin.coras@gmail.com>2016-08-30 10:30:59 +0000
commitc00617b13ccda0cfbd9ea248342643f728b0087f (patch)
tree1c056121bc316f6b6345dd6353152cb61441140b
parented47b4cd4e1793ba9b3974f3026e8161d3b598a4 (diff)
VPP-353: Fully support LISP negative mappings in API
Change-Id: I71943fb4ae2a2f71bcf1ad73512812edf96c06da Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
-rw-r--r--vpp-api-test/vat/api_format.c58
-rw-r--r--vpp-api-test/vat/vat.h1
-rw-r--r--vpp/vpp-api/api.c18
-rw-r--r--vpp/vpp-api/vpe.api5
4 files changed, 49 insertions, 33 deletions
diff --git a/vpp-api-test/vat/api_format.c b/vpp-api-test/vat/api_format.c
index 3d90cae7f83..d0b1dd01efe 100644
--- a/vpp-api-test/vat/api_format.c
+++ b/vpp-api-test/vat/api_format.c
@@ -2361,40 +2361,37 @@ static void
}
static void
-vl_api_lisp_eid_table_details_t_handler (vl_api_lisp_eid_table_details_t * mp)
+add_lisp_eid_table_entry (vat_main_t * vam,
+ vl_api_lisp_eid_table_details_t * mp)
{
- vat_main_t *vam = &vat_main;
eid_table_t eid_table;
memset (&eid_table, 0, sizeof (eid_table));
eid_table.is_local = mp->is_local;
- eid_table.locator_set_index = mp->locator_set_index;
+ eid_table.locator_set_index = clib_net_to_host_u32 (mp->locator_set_index);
eid_table.eid_type = mp->eid_type;
- eid_table.vni = mp->vni;
+ eid_table.vni = clib_net_to_host_u32 (mp->vni);
eid_table.eid_prefix_len = mp->eid_prefix_len;
- eid_table.ttl = mp->ttl;
+ eid_table.ttl = clib_net_to_host_u32 (mp->ttl);
+ eid_table.action = mp->action;
eid_table.authoritative = mp->authoritative;
clib_memcpy (eid_table.eid, mp->eid, sizeof (eid_table.eid));
vec_add1 (vam->eid_tables, eid_table);
}
static void
+vl_api_lisp_eid_table_details_t_handler (vl_api_lisp_eid_table_details_t * mp)
+{
+ vat_main_t *vam = &vat_main;
+ add_lisp_eid_table_entry (vam, mp);
+}
+
+static void
vl_api_lisp_eid_table_details_t_handler_json (vl_api_lisp_eid_table_details_t
* mp)
{
vat_main_t *vam = &vat_main;
- eid_table_t eid_table;
-
- memset (&eid_table, 0, sizeof (eid_table));
- eid_table.is_local = mp->is_local;
- eid_table.locator_set_index = mp->locator_set_index;
- eid_table.eid_type = mp->eid_type;
- eid_table.vni = mp->vni;
- eid_table.eid_prefix_len = mp->eid_prefix_len;
- eid_table.ttl = mp->ttl;
- eid_table.authoritative = mp->authoritative;
- clib_memcpy (eid_table.eid, mp->eid, sizeof (eid_table.eid));
- vec_add1 (vam->eid_tables, eid_table);
+ add_lisp_eid_table_entry (vam, mp);
}
static void
@@ -13247,13 +13244,11 @@ format_eid_for_eid_table (vat_main_t * vam, u8 * str, eid_table_t * eid_table,
case 1:
format_eid = (eid_table->eid_type ? format_ip6_address :
format_ip4_address);
- str = format (0, "[%d] %U/%d",
- clib_net_to_host_u32 (eid_table->vni),
+ str = format (0, "[%d] %U/%d", eid_table->vni,
format_eid, eid_table->eid, eid_table->eid_prefix_len);
break;
case 2:
- str = format (0, "[%d] %U",
- clib_net_to_host_u32 (eid_table->vni),
+ str = format (0, "[%d] %U", eid_table->vni,
format_ethernet_address, eid_table->eid);
break;
default:
@@ -13308,6 +13303,11 @@ format_locator_for_eid_table (vat_main_t * vam, u8 * str,
ASSERT (vam != NULL);
ASSERT (eid_table != NULL);
+ if (~0 == eid_table->locator_set_index)
+ {
+ return format (0, "action: %d\n", eid_table->action);
+ }
+
vec_foreach (loc, vam->locator_msg)
{
if (!first_line)
@@ -13366,13 +13366,17 @@ print_lisp_eid_table_dump (vat_main_t * vam)
vec_foreach (eid_table, vam->eid_tables)
{
- ret = lisp_locator_dump_send_msg (vam, eid_table->locator_set_index, 0);
- if (ret)
+ if (~0 != eid_table->locator_set_index)
{
- vec_free (vam->locator_msg);
- clean_locator_set_message (vam);
- vec_free (vam->eid_tables);
- return ret;
+ ret = lisp_locator_dump_send_msg (vam, eid_table->locator_set_index,
+ 0);
+ if (ret)
+ {
+ vec_free (vam->locator_msg);
+ clean_locator_set_message (vam);
+ vec_free (vam->eid_tables);
+ return ret;
+ }
}
tmp_str2 = format_eid_for_eid_table (vam, tmp_str2, eid_table, &ret);
diff --git a/vpp-api-test/vat/vat.h b/vpp-api-test/vat/vat.h
index b0ab883764b..311b9c72d24 100644
--- a/vpp-api-test/vat/vat.h
+++ b/vpp-api-test/vat/vat.h
@@ -117,6 +117,7 @@ typedef struct
u32 vni;
u8 eid[16];
u8 eid_prefix_len;
+ u8 action;
u32 ttl;
u8 authoritative;
} eid_table_t;
diff --git a/vpp/vpp-api/api.c b/vpp/vpp-api/api.c
index 8bf6d306102..fb44aaa8371 100644
--- a/vpp/vpp-api/api.c
+++ b/vpp/vpp-api/api.c
@@ -5480,6 +5480,7 @@ static void
vl_api_lisp_add_del_remote_mapping_reply_t *rmp;
int rv = 0;
gid_address_t _eid, *eid = &_eid;
+ u32 rloc_num = clib_net_to_host_u32 (mp->rloc_num);
memset (eid, 0, sizeof (eid[0]));
@@ -5488,9 +5489,7 @@ static void
if (rv)
goto send_reply;
- rlocs = unformat_lisp_locs (mp->rlocs, clib_net_to_host_u32 (mp->rloc_num));
- if (0 == rlocs)
- goto send_reply;
+ rlocs = unformat_lisp_locs (mp->rlocs, rloc_num);
if (!mp->is_add)
{
@@ -5672,6 +5671,8 @@ send_lisp_eid_table_details (mapping_t * mapit,
unix_shared_memory_queue_t * q,
u32 context, u8 filter)
{
+ lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
+ locator_set_t *ls = 0;
vl_api_lisp_eid_table_details_t *rmp = NULL;
gid_address_t *gid = NULL;
u8 *mac = 0;
@@ -5702,9 +5703,16 @@ send_lisp_eid_table_details (mapping_t * mapit,
rmp = vl_msg_api_alloc (sizeof (*rmp));
memset (rmp, 0, sizeof (*rmp));
rmp->_vl_msg_id = ntohs (VL_API_LISP_EID_TABLE_DETAILS);
- rmp->locator_set_index = mapit->locator_set_index;
+
+ ls = pool_elt_at_index (lcm->locator_set_pool, mapit->locator_set_index);
+ if (vec_len (ls->locator_indices) == 0)
+ rmp->locator_set_index = ~0;
+ else
+ rmp->locator_set_index = clib_host_to_net_u32 (mapit->locator_set_index);
+
rmp->is_local = mapit->local;
- rmp->ttl = mapit->ttl;
+ rmp->ttl = clib_host_to_net_u32 (mapit->ttl);
+ rmp->action = mapit->action;
rmp->authoritative = mapit->authoritative;
switch (gid_address_type (gid))
diff --git a/vpp/vpp-api/vpe.api b/vpp/vpp-api/vpe.api
index 1143c436d81..a2a7be4542e 100644
--- a/vpp/vpp-api/vpe.api
+++ b/vpp/vpp-api/vpe.api
@@ -2803,7 +2803,9 @@ define lisp_locator_set_dump
/** \brief Dump lisp eid-table
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
- @param locator_set_index - index of locator_set
+ @param locator_set_index - index of locator_set, if ~0 then the mapping
+ is negative
+ @param action - negative map request action
@param is_local - local if non-zero, else remote
@param eid_type:
0 : ipv4
@@ -2820,6 +2822,7 @@ define lisp_eid_table_details
{
u32 context;
u32 locator_set_index;
+ u8 action;
u8 is_local;
u8 eid_type;
u32 vni;