VPP-448 Fix LISP APIs using binary data
* use zero length array in LISP API to avoid confusion
* add missing LISP data structure definitions in API documentation
* fix wrong memory allocation in VAT
Change-Id: I9b5e656a071fc24cb698c164db953c09b66deeeb
Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
diff --git a/vpp-api-test/vat/api_format.c b/vpp-api-test/vat/api_format.c
index 27c80d9..4b1d41f 100644
--- a/vpp-api-test/vat/api_format.c
+++ b/vpp-api-test/vat/api_format.c
@@ -11870,6 +11870,7 @@
u8 locator_set_name_set = 0;
ls_locator_t locator, *locators = 0;
u32 sw_if_index, priority, weight;
+ u32 data_len = 0;
/* Parse args required to build the message */
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
@@ -11918,8 +11919,10 @@
}
vec_add1 (locator_set_name, 0);
+ data_len = sizeof (ls_locator_t) * vec_len (locators);
+
/* Construct the API message */
- M (LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set);
+ M2 (LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set, data_len);
mp->is_add = is_add;
clib_memcpy (mp->locator_set_name, locator_set_name,
@@ -11928,8 +11931,7 @@
mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
if (locators)
- clib_memcpy (mp->locators, locators,
- (sizeof (ls_locator_t) * vec_len (locators)));
+ clib_memcpy (mp->locators, locators, data_len);
vec_free (locators);
/* send it... */
@@ -12667,7 +12669,7 @@
lisp_eid_vat_t _eid, *eid = &_eid;
lisp_eid_vat_t _seid, *seid = &_seid;
u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
- u32 action = ~0, p, w;
+ u32 action = ~0, p, w, data_len;
ip4_address_t rloc4;
ip6_address_t rloc6;
rloc_t *rlocs = 0, rloc, *curr_rloc = 0;
@@ -12749,7 +12751,9 @@
return -99;
}
- M (LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping);
+ data_len = vec_len (rlocs) * sizeof (rloc_t);
+
+ M2 (LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping, data_len);
mp->is_add = is_add;
mp->vni = htonl (vni);
mp->action = (u8) action;
@@ -12762,7 +12766,7 @@
lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
- clib_memcpy (mp->rlocs, rlocs, (sizeof (rloc_t) * vec_len (rlocs)));
+ clib_memcpy (mp->rlocs, rlocs, data_len);
vec_free (rlocs);
/* send it... */