aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2016-07-07 15:40:36 +0200
committerFlorin Coras <florin.coras@gmail.com>2016-07-08 14:15:37 +0000
commit4d5cabde54f847bccd365c64682e428aead30550 (patch)
tree141d2eec6d5037689248da577db868f39afa38b9
parentbbae375ca20df350b26bb97cbe63835661379457 (diff)
Add locator prority and weight to LISP API
Change-Id: Ifa9bcd9a9c5dbda00ff8096909ccbc822445b8cb Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
-rw-r--r--vnet/vnet/lisp-cp/control.c25
-rw-r--r--vpp-api-test/vat/api_format.c42
-rw-r--r--vpp/vpp-api/api.c12
3 files changed, 57 insertions, 22 deletions
diff --git a/vnet/vnet/lisp-cp/control.c b/vnet/vnet/lisp-cp/control.c
index f536560e..c4cdaa98 100644
--- a/vnet/vnet/lisp-cp/control.c
+++ b/vnet/vnet/lisp-cp/control.c
@@ -918,14 +918,14 @@ lisp_add_del_remote_mapping_command_fn (vlib_main_t * vm,
clib_error_t * error = 0;
unformat_input_t _line_input, * line_input = &_line_input;
u8 is_add = 1, del_all = 0;
- locator_t rloc, * rlocs = 0;
+ locator_t rloc, * rlocs = 0, * curr_rloc = 0;
ip_prefix_t * deid_ippref, * seid_ippref;
gid_address_t seid, deid;
u8 * dmac = gid_address_mac (&deid);
u8 * smac = gid_address_mac (&seid);
u8 deid_set = 0, seid_set = 0;
u8 * s = 0;
- u32 vni, action = ~0;
+ u32 vni, action = ~0, p, w;
int rv;
/* Get a line of input. */
@@ -976,8 +976,22 @@ lisp_add_del_remote_mapping_command_fn (vlib_main_t * vm,
gid_address_type (&seid) = GID_ADDR_MAC;
seid_set = 1;
}
- else if (unformat (line_input, "rloc %U", unformat_ip_address, &rloc.address))
- vec_add1 (rlocs, rloc);
+ else if (unformat (line_input, "p %d w %d", &p, &w))
+ {
+ if (!curr_rloc)
+ {
+ clib_warning ("No RLOC configured for setting priority/weight!");
+ goto done;
+ }
+ curr_rloc->priority = p;
+ curr_rloc->weight = w;
+ }
+ else if (unformat (line_input, "rloc %U", unformat_ip_address,
+ &rloc.address))
+ {
+ vec_add1 (rlocs, rloc);
+ curr_rloc = &rlocs[vec_len (rlocs) - 1];
+ }
else if (unformat (line_input, "action %s", &s))
{
if (!strcmp ((char *)s, "no-action"))
@@ -1062,6 +1076,7 @@ lisp_add_del_remote_mapping_command_fn (vlib_main_t * vm,
clib_warning("failed to %s remote mapping!", is_add ? "add" : "delete");
done:
+ vec_free (rlocs);
unformat_free (line_input);
if (s)
vec_free (s);
@@ -2073,7 +2088,7 @@ lisp_cp_show_locator_sets_command_fn (vlib_main_t * vm,
loc->weight);
else
msg = format (msg, "%16U%16d%16d\n", format_ip_address,
- gid_address_ip(&loc->address), loc->priority,
+ &gid_address_ip(&loc->address), loc->priority,
loc->weight);
next_line = 1;
}
diff --git a/vpp-api-test/vat/api_format.c b/vpp-api-test/vat/api_format.c
index 5ba7fbf2..5e2b3275 100644
--- a/vpp-api-test/vat/api_format.c
+++ b/vpp-api-test/vat/api_format.c
@@ -10533,6 +10533,8 @@ api_lisp_enable_disable (vat_main_t * vam)
typedef CLIB_PACKED(struct
{
u8 is_ip4; /**< is locator an IPv4 address? */
+ u8 priority; /**< locator priority */
+ u8 weight; /**< locator weight */
u8 addr[16]; /**< IPv4/IPv6 address */
}) rloc_t;
@@ -10655,8 +10657,8 @@ api_lisp_add_del_remote_mapping (vat_main_t * vam)
u8 deid_type, seid_type;
u32 seid_len = 0, deid_len = 0, len;
u8 is_add = 1, del_all = 0;
- u32 action = ~0;
- rloc_t * rlocs = 0, rloc;
+ u32 action = ~0, p, w;
+ rloc_t * rlocs = 0, rloc, * curr_rloc = 0;
seid_type = deid_type = (u8)~0;
@@ -10692,14 +10694,23 @@ api_lisp_add_del_remote_mapping (vat_main_t * vam)
seid_type = 2; /* mac */
} else if (unformat(input, "vni %d", &vni)) {
;
+ } else if (unformat(input, "p %d w %d", &p, &w)) {
+ if (!curr_rloc) {
+ errmsg ("No RLOC configured for setting priority/weight!");
+ return -99;
+ }
+ curr_rloc->priority = p;
+ curr_rloc->weight = w;
} else if (unformat(input, "rloc %U", unformat_ip4_address, &rloc4)) {
rloc.is_ip4 = 1;
clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
vec_add1 (rlocs, rloc);
+ curr_rloc = &rlocs[vec_len (rlocs) - 1];
} else if (unformat(input, "rloc %U", unformat_ip6_address, &rloc6)) {
rloc.is_ip4 = 0;
clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
vec_add1 (rlocs, rloc);
+ curr_rloc = &rlocs[vec_len (rlocs) - 1];
} else if (unformat(input, "action %d", &action)) {
;
} else {
@@ -10786,10 +10797,9 @@ api_lisp_add_del_adjacency (vat_main_t * vam)
u8 deid_type, seid_type;
u32 seid_len = 0, deid_len = 0, len;
u8 is_add = 1;
- u32 action = ~0;
- rloc_t * rlocs = 0, rloc;
+ u32 action = ~0, p, w;
+ rloc_t * rlocs = 0, rloc, * curr_rloc = 0;
- memset(mp, 0, sizeof(mp[0]));
seid_type = deid_type = (u8)~0;
/* Parse args required to build the message */
@@ -10822,18 +10832,27 @@ api_lisp_add_del_adjacency (vat_main_t * vam)
seid_type = 2; /* mac */
} else if (unformat(input, "vni %d", &vni)) {
;
+ } else if (unformat(input, "p %d w %d", &p, &w)) {
+ if (!curr_rloc) {
+ errmsg ("No RLOC configured for setting priority/weight!");
+ return -99;
+ }
+ curr_rloc->priority = p;
+ curr_rloc->weight = w;
} else if (unformat(input, "rloc %U", unformat_ip4_address, &rloc4)) {
rloc.is_ip4 = 1;
clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
vec_add1 (rlocs, rloc);
+ curr_rloc = &rlocs[vec_len (rlocs) - 1];
} else if (unformat(input, "rloc %U", unformat_ip6_address, &rloc6)) {
rloc.is_ip4 = 0;
clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
vec_add1 (rlocs, rloc);
+ curr_rloc = &rlocs[vec_len (rlocs) - 1];
} else if (unformat(input, "action %d", &action)) {
;
} else {
- clib_warning ("parse error '%U'", format_unformat_error, input);
+ errmsg ("parse error '%U'", format_unformat_error, input);
return -99;
}
}
@@ -12429,11 +12448,12 @@ _(lisp_gpe_enable_disable, "enable|disable") \
_(lisp_enable_disable, "enable|disable") \
_(lisp_gpe_add_del_iface, "up|down") \
_(lisp_add_del_remote_mapping, "add|del vni <vni> deid <dest-eid> seid" \
- " <src-eid> rloc <locator> " \
- "[rloc <loc> ... ] action <action>") \
-_(lisp_add_del_adjacency, "add|del vni <vni> deid <dest-eid> seid" \
- " <src-eid> rloc <locator> " \
- "[rloc <loc> ... ] action <action>") \
+ " <src-eid> rloc <locator> p <prio> " \
+ "w <weight> [rloc <loc> ... ] " \
+ "action <action>") \
+_(lisp_add_del_adjacency, "add|del vni <vni> deid <dest-eid> seid " \
+ "<src-eid> rloc <locator> p <prio> w <weight>"\
+ "[rloc <loc> ... ] action <action>") \
_(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
_(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
_(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
diff --git a/vpp/vpp-api/api.c b/vpp/vpp-api/api.c
index 330222fb..f7338af5 100644
--- a/vpp/vpp-api/api.c
+++ b/vpp/vpp-api/api.c
@@ -5013,6 +5013,8 @@ vl_api_lisp_add_del_map_request_itr_rlocs_t_handler
typedef CLIB_PACKED(struct
{
u8 is_ip4; /**< is locator an IPv4 address */
+ u8 priority; /**< locator priority */
+ u8 weight; /**< locator weight */
u8 addr[16]; /**< IPv4/IPv6 address */
}) rloc_t;
@@ -5090,9 +5092,8 @@ vl_api_lisp_add_del_remote_mapping_t_handler (
r->is_ip4 ? IP4 : IP6);
gid_address_ippref_len(&rloc.address) = r->is_ip4 ? 32: 128;
gid_address_type(&rloc.address) = GID_ADDR_IP_PREFIX;
- /* TODO fix API to pass priority and weight */
- rloc.priority = 1;
- rloc.weight = 1;
+ rloc.priority = r->priority;
+ rloc.weight = r->weight;
vec_add1 (rlocs, rloc);
}
@@ -5184,9 +5185,8 @@ vl_api_lisp_add_del_adjacency_t_handler (
r->is_ip4 ? IP4 : IP6);
gid_address_ippref_len(&rloc.address) = r->is_ip4 ? 32: 128;
gid_address_type(&rloc.address) = GID_ADDR_IP_PREFIX;
- /* TODO fix API to pass priority and weight */
- rloc.priority = 1;
- rloc.weight = 1;
+ rloc.priority = r->priority;
+ rloc.weight = r->weight;
vec_add1 (a->locators, rloc);
}