summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrej Kozemcak <akozemca@cisco.com>2016-07-27 10:33:38 +0200
committerFlorin Coras <florin.coras@gmail.com>2016-07-27 13:23:24 +0000
commita8691754d2f7cdd960c3d8dc5fbff6367e9c36b8 (patch)
treeb1715a03db89657278630c21b6e4363a905e55e4
parent683d3ee1b136060ef38290b6ab3a21c9a4730c4f (diff)
VAT add_locator_set api support multiple locators
Change-Id: I22df3d4407bd7fdd953783f00605380a2d6fb46e Signed-off-by: Andrej Kozemcak <akozemca@cisco.com>
-rw-r--r--vnet/vnet/lisp-cp/control.c13
-rw-r--r--vpp-api-test/vat/api_format.c33
-rw-r--r--vpp/vpp-api/api.c27
-rw-r--r--vpp/vpp-api/vpe.api2
4 files changed, 70 insertions, 5 deletions
diff --git a/vnet/vnet/lisp-cp/control.c b/vnet/vnet/lisp-cp/control.c
index 78e730f5a5d..fb4c8397d2d 100644
--- a/vnet/vnet/lisp-cp/control.c
+++ b/vnet/vnet/lisp-cp/control.c
@@ -1562,8 +1562,8 @@ is_locator_in_locator_set (lisp_cp_main_t * lcm, locator_set_t * ls,
vec_foreach(locit, ls->locator_indices)
{
itloc = pool_elt_at_index(lcm->locator_pool, locit[0]);
- if (itloc->sw_if_index == loc->sw_if_index ||
- !gid_address_cmp(&itloc->address, &loc->address))
+ if ((ls->local && itloc->sw_if_index == loc->sw_if_index) ||
+ (!ls->local && !gid_address_cmp(&itloc->address, &loc->address)))
{
clib_warning("Duplicate locator");
return VNET_API_ERROR_VALUE_EXIST;
@@ -2099,7 +2099,14 @@ lisp_cp_show_locator_sets_command_fn (vlib_main_t * vm,
({
u8 * msg = 0;
int next_line = 0;
- msg = format (msg, "%=16v", lsit->name);
+ if (lsit->local)
+ {
+ msg = format (msg, "%=16v", lsit->name);
+ }
+ else
+ {
+ msg = format (msg, "%=16s", "remote");
+ }
vec_foreach (locit, lsit->locator_indices)
{
if (next_line)
diff --git a/vpp-api-test/vat/api_format.c b/vpp-api-test/vat/api_format.c
index 3b2c91cf449..a2200660798 100644
--- a/vpp-api-test/vat/api_format.c
+++ b/vpp-api-test/vat/api_format.c
@@ -10488,6 +10488,14 @@ static int api_get_node_graph (vat_main_t * vam)
W;
}
+/** Used for transferring locators via VPP API */
+typedef CLIB_PACKED(struct
+{
+ u32 sw_if_index; /**< locator sw_if_index */
+ u8 priority; /**< locator priority */
+ u8 weight; /**< locator weight */
+}) ls_locator_t;
+
static int
api_lisp_add_del_locator_set(vat_main_t * vam)
{
@@ -10497,6 +10505,8 @@ api_lisp_add_del_locator_set(vat_main_t * vam)
u8 is_add = 1;
u8 *locator_set_name = NULL;
u8 locator_set_name_set = 0;
+ ls_locator_t locator, * locators = 0;
+ u32 sw_if_index, priority, weight;
/* Parse args required to build the message */
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {
@@ -10504,18 +10514,32 @@ api_lisp_add_del_locator_set(vat_main_t * vam)
is_add = 0;
} else if (unformat(input, "locator-set %s", &locator_set_name)) {
locator_set_name_set = 1;
+ } else if (unformat(input, "sw_if_index %u p %u w %u",
+ &sw_if_index, &priority, &weight)) {
+ locator.sw_if_index = htonl(sw_if_index);
+ locator.priority = priority;
+ locator.weight = weight;
+ vec_add1(locators, locator);
+ } else if (unformat(input, "iface %U p %u w %u", unformat_sw_if_index,
+ vam, &sw_if_index, &priority, &weight)) {
+ locator.sw_if_index = htonl(sw_if_index);
+ locator.priority = priority;
+ locator.weight = weight;
+ vec_add1(locators, locator);
} else
break;
}
if (locator_set_name_set == 0) {
errmsg ("missing locator-set name");
+ vec_free(locators);
return -99;
}
if (vec_len(locator_set_name) > 64) {
errmsg ("locator-set name too long\n");
vec_free(locator_set_name);
+ vec_free(locators);
return -99;
}
vec_add1(locator_set_name, 0);
@@ -10528,6 +10552,11 @@ api_lisp_add_del_locator_set(vat_main_t * vam)
vec_len(locator_set_name));
vec_free(locator_set_name);
+ mp->locator_num = vec_len (locators);
+ clib_memcpy (mp->locators, locators,
+ (sizeof (ls_locator_t) * vec_len (locators)));
+ vec_free (locators);
+
/* send it... */
S;
@@ -13147,7 +13176,9 @@ _(trace_profile_add, "id <nn> trace-type <0x1f|0x3|0x9|0x11|0x19> " \
_(trace_profile_apply, "id <nn> <ip6-address>/<width>" \
" vrf_id <nn> add | pop | none") \
_(trace_profile_del, "") \
-_(lisp_add_del_locator_set, "locator-set <locator_name> [del]") \
+_(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
+ " sw_if_index <sw_if_index> p <priority> " \
+ "w <weight>] [del]") \
_(lisp_add_del_locator, "locator-set <locator_name> " \
"iface <intf> | sw_if_index <sw_if_index> " \
"p <priority> w <weight> [del]") \
diff --git a/vpp/vpp-api/api.c b/vpp/vpp-api/api.c
index 822b9906c15..076d16a30f3 100644
--- a/vpp/vpp-api/api.c
+++ b/vpp/vpp-api/api.c
@@ -4777,27 +4777,52 @@ static void vl_api_vxlan_gpe_tunnel_dump_t_handler
}
}
+/** Used for transferring locators via VPP API */
+typedef CLIB_PACKED(struct
+{
+ u32 sw_if_index; /**< locator sw_if_index */
+ u8 priority; /**< locator priority */
+ u8 weight; /**< locator weight */
+}) ls_locator_t;
+
static void
vl_api_lisp_add_del_locator_set_t_handler(vl_api_lisp_add_del_locator_set_t *mp)
{
vl_api_lisp_add_del_locator_set_reply_t *rmp;
int rv = 0;
vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
+ locator_t locator;
+ ls_locator_t *ls_loc;
u32 ls_index = ~0;
u8 *locator_name = NULL;
+ int i;
memset(a, 0, sizeof(a[0]));
locator_name = format(0, "%s", mp->locator_set_name);
a->name = locator_name;
- a->locators = NULL;
a->is_add = mp->is_add;
a->local = 1;
+ memset(&locator, 0, sizeof(locator));
+ for (i = 0; i < mp->locator_num; i++) {
+ ls_loc = &((ls_locator_t *) mp->locators)[i];
+ VALIDATE_SW_IF_INDEX(ls_loc);
+
+ locator.sw_if_index = htonl(ls_loc->sw_if_index);
+ locator.priority = ls_loc->priority;
+ locator.weight = ls_loc->weight;
+ locator.local = 1;
+ vec_add1(a->locators, locator);
+ }
+
rv = vnet_lisp_add_del_locator_set(a, &ls_index);
+ BAD_SW_IF_INDEX_LABEL;
+
vec_free(locator_name);
+ vec_free(a->locators);
REPLY_MACRO(VL_API_LISP_ADD_DEL_LOCATOR_SET_REPLY);
}
diff --git a/vpp/vpp-api/vpe.api b/vpp/vpp-api/vpe.api
index 4571c92df4d..6aa221388c4 100644
--- a/vpp/vpp-api/vpe.api
+++ b/vpp/vpp-api/vpe.api
@@ -2163,6 +2163,8 @@ define lisp_add_del_locator_set {
u32 context;
u8 is_add;
u8 locator_set_name[64];
+ u32 locator_num;
+ u8 locators[0];
};
/** \brief Reply for locator_set add/del