summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vnet/vnet/lisp-cp/lisp_types.c6
-rw-r--r--vnet/vnet/lisp-cp/lisp_types.h1
-rw-r--r--vnet/vnet/lisp-gpe/lisp_gpe.h3
-rw-r--r--vpp-api-test/vat/api_format.c344
-rw-r--r--vpp/vpp-api/api.c312
-rw-r--r--vpp/vpp-api/vpe.api40
6 files changed, 298 insertions, 408 deletions
diff --git a/vnet/vnet/lisp-cp/lisp_types.c b/vnet/vnet/lisp-cp/lisp_types.c
index 196010e2556..e62edb93875 100644
--- a/vnet/vnet/lisp-cp/lisp_types.c
+++ b/vnet/vnet/lisp-cp/lisp_types.c
@@ -955,6 +955,12 @@ gid_address_parse (u8 * offset, gid_address_t *a)
return len;
}
+void
+gid_address_ip_set(gid_address_t * dst, void * src, u8 version)
+{
+ ip_address_set (&gid_address_ip(dst), src, version);
+}
+
int
no_addr_cmp (void * a1, void * a2)
{
diff --git a/vnet/vnet/lisp-cp/lisp_types.h b/vnet/vnet/lisp-cp/lisp_types.h
index 4d4a6b1112c..b1b4b9db3f0 100644
--- a/vnet/vnet/lisp-cp/lisp_types.h
+++ b/vnet/vnet/lisp-cp/lisp_types.h
@@ -171,6 +171,7 @@ u8 gid_address_len (gid_address_t *a);
void * gid_address_cast (gid_address_t * gid, gid_address_type_t type);
void gid_address_copy(gid_address_t * dst, gid_address_t * src);
u32 gid_address_parse (u8 * offset, gid_address_t *a);
+void gid_address_ip_set(gid_address_t * dst, void * src, u8 version);
#define gid_address_type(_a) (_a)->type
#define gid_address_ippref(_a) (_a)->ippref
diff --git a/vnet/vnet/lisp-gpe/lisp_gpe.h b/vnet/vnet/lisp-gpe/lisp_gpe.h
index fd7a1143cbd..c3f024229e3 100644
--- a/vnet/vnet/lisp-gpe/lisp_gpe.h
+++ b/vnet/vnet/lisp-gpe/lisp_gpe.h
@@ -264,6 +264,9 @@ typedef struct
{
u32 table_id;
u16 bd_id;
+
+ /* generic access */
+ u32 dp_table;
};
} vnet_lisp_gpe_add_del_fwd_entry_args_t;
diff --git a/vpp-api-test/vat/api_format.c b/vpp-api-test/vat/api_format.c
index a79a5cce28b..3590a076d85 100644
--- a/vpp-api-test/vat/api_format.c
+++ b/vpp-api-test/vat/api_format.c
@@ -10579,6 +10579,58 @@ static int api_get_node_graph (vat_main_t * vam)
W;
}
+/** Used for parsing LISP eids */
+typedef CLIB_PACKED(struct{
+ u8 addr[16]; /**< eid address */
+ u32 len; /**< prefix length if IP */
+ u8 type; /**< type of eid */
+}) lisp_eid_vat_t;
+
+static uword
+unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
+{
+ lisp_eid_vat_t * a = va_arg(*args, lisp_eid_vat_t *);
+
+ memset(a, 0, sizeof(a[0]));
+
+ if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len)) {
+ a->type = 0; /* ipv4 type */
+ } else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr,
+ &a->len)) {
+ a->type = 1; /* ipv6 type */
+ } else if (unformat (input, "%U", unformat_ethernet_address, a->addr)) {
+ a->type = 2; /* mac type */
+ } else {
+ return 0;
+ }
+
+ if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128)) {
+ return 0;
+ }
+
+ return 1;
+}
+
+static int
+lisp_eid_size_vat (u8 type)
+{
+ switch (type) {
+ case 0:
+ return 4;
+ case 1:
+ return 16;
+ case 2:
+ return 6;
+ }
+ return 0;
+}
+
+static void
+lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
+{
+ clib_memcpy(dst, eid, lisp_eid_size_vat(type));
+}
+
/** Used for transferring locators via VPP API */
typedef CLIB_PACKED(struct
{
@@ -10761,15 +10813,9 @@ api_lisp_add_del_local_eid(vat_main_t * vam)
vl_api_lisp_add_del_local_eid_t *mp;
f64 timeout = ~0;
u8 is_add = 1;
- u8 eidv4_set = 0;
- u8 eidv6_set = 0;
- u8 eid_type = (u8)~0;
- ip4_address_t eidv4;
- ip6_address_t eidv6;
- u8 mac[6] = {0};
- u32 tmp_eid_lenght = ~0;
- u8 eid_lenght = ~0;
- u8 *locator_set_name = NULL;
+ u8 eid_set = 0;
+ lisp_eid_vat_t _eid, *eid = &_eid;
+ u8 *locator_set_name = 0;
u8 locator_set_name_set = 0;
u32 vni = 0;
@@ -10779,18 +10825,8 @@ api_lisp_add_del_local_eid(vat_main_t * vam)
is_add = 0;
} else if (unformat(input, "vni %d", &vni)) {
;
- } else if (unformat(input, "eid %U/%d", unformat_ip4_address,
- &eidv4, &tmp_eid_lenght)) {
- eid_lenght = tmp_eid_lenght;
- eidv4_set = 1;
- eid_type = 0; /* ipv4 type */
- } else if (unformat(input, "eid %U/%d", unformat_ip6_address,
- &eidv6, &tmp_eid_lenght)) {
- eid_lenght = tmp_eid_lenght;
- eidv6_set = 1;
- eid_type = 1; /* ipv6 type */
- } else if (unformat(input, "eid %U", unformat_ethernet_address, mac)) {
- eid_type = 2; /* mac type */
+ } else if (unformat(input, "eid %U", unformat_lisp_eid_vat, eid)) {
+ eid_set = 1;
} else if (unformat(input, "locator-set %s", &locator_set_name)) {
locator_set_name_set = 1;
} else
@@ -10802,7 +10838,7 @@ api_lisp_add_del_local_eid(vat_main_t * vam)
return -99;
}
- if ((u8)~0 == eid_type) {
+ if (0 == eid_set) {
errmsg ("EID address not set!");
vec_free(locator_set_name);
return -99;
@@ -10815,44 +10851,17 @@ api_lisp_add_del_local_eid(vat_main_t * vam)
}
vec_add1(locator_set_name, 0);
- if (eidv4_set && eidv6_set) {
- errmsg ("both eid v4 and v6 addresses set\n");
- vec_free(locator_set_name);
- return -99;
- }
-
- if (eidv4_set && eid_lenght > 32) {
- errmsg ("eid prefix to big\n");
- vec_free(locator_set_name);
- return -99;
- }
-
- if (eidv6_set && eid_lenght > 128) {
- errmsg ("eid prefix to big\n");
- vec_free(locator_set_name);
- return -99;
- }
-
/* Construct the API message */
M(LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid);
mp->is_add = is_add;
- switch (eid_type) {
- case 0: /* ipv4 */
- clib_memcpy (mp->eid, &eidv4, sizeof(eidv4));
- break;
- case 1: /* ipv6 */
- clib_memcpy (mp->eid, &eidv6, sizeof(eidv6));
- break;
- case 2: /* mac */
- clib_memcpy (mp->eid, mac, 6);
- break;
- }
- mp->eid_type = eid_type;
- mp->prefix_len = eid_lenght;
+ lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
+ mp->eid_type = eid->type;
+ mp->prefix_len = eid->len;
mp->vni = clib_host_to_net_u32(vni);
clib_memcpy(mp->locator_set_name, locator_set_name,
vec_len(locator_set_name));
+
vec_free(locator_set_name);
/* send it... */
@@ -10865,6 +10874,15 @@ api_lisp_add_del_local_eid(vat_main_t * vam)
return 0;
}
+/** Used for transferring locators via VPP API */
+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;
+
static int
api_lisp_gpe_add_del_fwd_entry(vat_main_t * vam)
{
@@ -10872,69 +10890,62 @@ api_lisp_gpe_add_del_fwd_entry(vat_main_t * vam)
vl_api_lisp_gpe_add_del_fwd_entry_t *mp;
f64 timeout = ~0;
u8 is_add = 1;
- u8 eidv4_set = 0, slocv4_set = 0, dlocv4_set = 0;
- u8 eidv6_set = 0, slocv6_set = 0, dlocv6_set = 0;
- ip4_address_t eidv4, slocv4, dlocv4;
- ip6_address_t eidv6, slocv6, dlocv6;
- u32 tmp_eid_lenght = ~0;
- u8 eid_lenght = ~0;
+ lisp_eid_vat_t _rmt_eid, * rmt_eid = &_rmt_eid;
+ lisp_eid_vat_t _lcl_eid, * lcl_eid = &_lcl_eid;
+ u8 rmt_eid_set = 0, lcl_eid_set = 0;
+ u32 action = ~0, p, w;
+ ip4_address_t rmt_rloc4, lcl_rloc4;
+ ip6_address_t rmt_rloc6, lcl_rloc6;
+ rloc_t * rmt_locs = 0, * lcl_locs = 0, rloc, * curr_rloc = 0;
/* Parse args required to build the message */
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {
if (unformat(input, "del")) {
is_add = 0;
- } else if (unformat(input, "eid %U/%d", unformat_ip4_address,
- &eidv4, &tmp_eid_lenght)) {
- eid_lenght = tmp_eid_lenght;
- eidv4_set = 1;
- } else if (unformat(input, "eid %U/%d", unformat_ip6_address,
- &eidv6, &tmp_eid_lenght)) {
- eid_lenght = tmp_eid_lenght;
- eidv6_set = 1;
- } else if (unformat(input, "sloc %U", unformat_ip4_address, &slocv4)) {
- slocv4_set = 1;
- } else if (unformat(input, "sloc %U", unformat_ip6_address, &slocv6)) {
- slocv6_set = 1;
- } else if (unformat(input, "dloc %U", unformat_ip4_address, &dlocv4)) {
- dlocv4_set = 1;
- } else if (unformat(input, "dloc %U", unformat_ip6_address, &dlocv6)) {
- dlocv6_set = 1;
- } else
- break;
- }
-
- if (eidv4_set && eidv6_set) {
- errmsg ("both eid v4 and v6 addresses set\n");
- return -99;
- }
-
- if (!eidv4_set && !eidv6_set) {
- errmsg ("eid addresses not set\n");
- return -99;
- }
-
- if (slocv4_set && slocv6_set) {
- errmsg ("both source v4 and v6 addresses set\n");
- return -99;
- }
-
- if (!slocv4_set && !slocv6_set) {
- errmsg ("source addresses not set\n");
- return -99;
- }
-
- if (dlocv4_set && dlocv6_set) {
- errmsg ("both destination v4 and v6 addresses set\n");
- return -99;
+ } else if (unformat(input, "rmt_eid %U", unformat_lisp_eid_vat,
+ rmt_eid)) {
+ rmt_eid_set = 1;
+ } else if (unformat(input, "lcl_eid %U", unformat_lisp_eid_vat,
+ lcl_eid)) {
+ lcl_eid_set = 1;
+ } 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, "loc-pair %U %U", unformat_ip4_address,
+ &lcl_rloc4, unformat_ip4_address, &rmt_rloc4)) {
+ rloc.is_ip4 = 1;
+ clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
+ vec_add1 (lcl_locs, rloc);
+ clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
+ vec_add1 (rmt_locs, rloc);
+ curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
+ } else if (unformat(input, "loc-pair %U", unformat_ip6_address,
+ &lcl_rloc6, unformat_ip6_address, &rmt_rloc6)) {
+ rloc.is_ip4 = 0;
+ clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
+ vec_add1 (lcl_locs, rloc);
+ clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
+ vec_add1 (rmt_locs, rloc);
+ curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
+ } else if (unformat(input, "action %d", &action)) {
+ ;
+ } else {
+ clib_warning ("parse error '%U'", format_unformat_error, input);
+ return -99;
+ }
}
- if (dlocv4_set && dlocv6_set) {
- errmsg ("destination addresses not set\n");
+ if (!rmt_eid_set) {
+ errmsg ("remote eid addresses not set\n");
return -99;
}
- if (!(slocv4_set == dlocv4_set && slocv6_set == dlocv6_set)) {
- errmsg ("mixing type of source and destination address\n");
+ if (lcl_eid_set && rmt_eid->type != lcl_eid->type) {
+ errmsg ("eid types don't match\n");
return -99;
}
@@ -10942,23 +10953,19 @@ api_lisp_gpe_add_del_fwd_entry(vat_main_t * vam)
M(LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry);
mp->is_add = is_add;
- if (eidv6_set) {
- mp->eid_is_ipv6 = 1;
- clib_memcpy(mp->eid_ip_address, &eidv6, sizeof(eidv6));
- } else {
- mp->eid_is_ipv6 = 0;
- clib_memcpy(mp->eid_ip_address, &eidv4, sizeof(eidv4));
- }
- mp->eid_prefix_len = eid_lenght;
- if (slocv6_set) {
- mp->address_is_ipv6 = 1;
- clib_memcpy(mp->source_ip_address, &slocv6, sizeof(slocv6));
- clib_memcpy(mp->destination_ip_address, &dlocv6, sizeof(dlocv6));
- } else {
- mp->address_is_ipv6 = 0;
- clib_memcpy(mp->source_ip_address, &slocv4, sizeof(slocv4));
- clib_memcpy(mp->destination_ip_address, &dlocv4, sizeof(dlocv4));
- }
+ lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
+ lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
+ mp->eid_type = rmt_eid->type;
+ mp->rmt_len = rmt_eid->len;
+ mp->lcl_len = lcl_eid->len;
+
+ mp->loc_num = vec_len (rmt_locs);
+ clib_memcpy (mp->lcl_locs, lcl_locs,
+ (sizeof(rloc_t) * vec_len(lcl_locs)));
+ clib_memcpy (mp->rmt_locs, rmt_locs,
+ (sizeof(rloc_t) * vec_len(rmt_locs)));
+ vec_free(lcl_locs);
+ vec_free(rmt_locs);
/* send it... */
S;
@@ -11113,15 +11120,6 @@ api_lisp_enable_disable (vat_main_t * vam)
return 0;
}
-/** Used for transferring locators via VPP API */
-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;
-
/**
* Enable/disable LISP proxy ITR.
*
@@ -11260,18 +11258,14 @@ api_lisp_add_del_remote_mapping (vat_main_t * vam)
f64 timeout = ~0;
u32 vni = 0;
//TODO: seid need remove
- ip4_address_t seid4, eid4, rloc4;
- ip6_address_t seid6, eid6, rloc6;
- u8 eid_mac[6] = {0};
- u8 seid_mac[6] = {0};
- u8 eid_type;
- u32 eid_len = 0, len;
- u8 is_add = 1, del_all = 0;
+ lisp_eid_vat_t _eid, * eid = &_eid;
+ lisp_eid_vat_t _seid, * seid = &_seid;
+ u8 is_add = 1, del_all = 0, eid_set = 0;
u32 action = ~0, p, w;
+ ip4_address_t rloc4;
+ ip6_address_t rloc6;
rloc_t * rlocs = 0, rloc, * curr_rloc = 0;
- eid_type = (u8)~0;
-
/* Parse args required to build the message */
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {
if (unformat(input, "del-all")) {
@@ -11280,34 +11274,10 @@ api_lisp_add_del_remote_mapping (vat_main_t * vam)
is_add = 0;
} else if (unformat(input, "add")) {
is_add = 1;
- } else if (unformat(input, "deid %U/%d", unformat_ip4_address,
- &eid4, &len)) {
- eid_type = 0; /* ipv4 */
- if (32 < len) {
- clib_warning ("Deid prefix length to big, %d!", len);
- return -99;
- }
- eid_len = len;
- } else if (unformat(input, "deid %U/%d", unformat_ip6_address,
- &eid6, &len)) {
- eid_type = 1; /* ipv6 */
- if (128 < len) {
- clib_warning ("Deid prefix length to big, %d!", len);
- return -99;
- }
- eid_len = len;
- } else if (unformat(input, "deid %U", unformat_ethernet_address,
- eid_mac)) {
- eid_type = 2; /* mac */
+ } else if (unformat(input, "deid %U", unformat_lisp_eid_vat, eid)) {
+ eid_set = 1;
+ } else if (unformat(input, "seid %U", unformat_lisp_eid_vat, &seid)) {
//TODO: Need remove, but first must be remove from CSIT test
- } else if (unformat(input, "seid %U/%d", unformat_ip4_address,
- &seid4, &len)) {
- } else if (unformat(input, "seid %U/%d", unformat_ip6_address,
- &seid6, &len)) {
- ;
- } else if (unformat(input, "seid %U", unformat_ethernet_address,
- seid_mac)) {
- ;
} else if (unformat(input, "vni %d", &vni)) {
;
} else if (unformat(input, "p %d w %d", &p, &w)) {
@@ -11335,7 +11305,7 @@ api_lisp_add_del_remote_mapping (vat_main_t * vam)
}
}
- if ((u8)~0 == eid_type) {
+ if (0 == eid_set) {
errmsg ("missing params!");
return -99;
}
@@ -11350,24 +11320,10 @@ api_lisp_add_del_remote_mapping (vat_main_t * vam)
mp->is_add = is_add;
mp->vni = htonl (vni);
mp->action = (u8) action;
- mp->eid_len = eid_len;
+ mp->eid_len = eid->len;
mp->del_all = del_all;
- mp->eid_type = eid_type;
-
- switch (mp->eid_type) {
- case 0:
- clib_memcpy (mp->eid, &eid4, sizeof (eid4));
- break;
- case 1:
- clib_memcpy (mp->eid, &eid6, sizeof (eid6));
- break;
- case 2:
- clib_memcpy (mp->eid, eid_mac, 6);
- break;
- default:
- errmsg ("unknown EID type %d!", mp->eid_type);
- return 0;
- }
+ mp->eid_type = eid->type;
+ lisp_eid_put_vat(mp->eid, eid->addr, eid->type);
mp->rloc_num = vec_len (rlocs);
clib_memcpy (mp->rlocs, rlocs, (sizeof (rloc_t) * vec_len (rlocs)));
@@ -11494,9 +11450,8 @@ api_lisp_gpe_add_del_iface(vat_main_t * vam)
unformat_input_t * input = vam->input;
vl_api_lisp_gpe_add_del_iface_t *mp;
f64 timeout = ~0;
- u8 is_set = 0;
- u8 is_add = 1;
- u32 table_id, vni;
+ u8 is_set = 0, is_add = 1, is_l2 = 0;
+ u32 dp_table, vni;
/* Parse args required to build the message */
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {
@@ -11506,8 +11461,10 @@ api_lisp_gpe_add_del_iface(vat_main_t * vam)
} else if (unformat(input, "down")) {
is_set = 1;
is_add = 0;
- } else if (unformat(input, "table_id %d", &table_id)) {
+ } else if (unformat(input, "table_id %d", &dp_table)) {
;
+ } else if (unformat(input, "bd_id %d", &dp_table)) {
+ is_l2 = 1;
} else if (unformat(input, "vni %d", &vni)) {
;
} else
@@ -11523,7 +11480,8 @@ api_lisp_gpe_add_del_iface(vat_main_t * vam)
M(LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface);
mp->is_add = is_add;
- mp->table_id = table_id;
+ mp->dp_table = dp_table;
+ mp->is_l2 = is_l2;
mp->vni = vni;
/* send it... */
@@ -14121,8 +14079,8 @@ _(lisp_add_del_locator, "locator-set <locator_name> " \
_(lisp_add_del_local_eid,"vni <vni> eid " \
"<ipv4|ipv6>/<prefix> | <L2 address> " \
"locator-set <locator_name> [del]") \
-_(lisp_gpe_add_del_fwd_entry, "eid <ip4|6-addr>/<prefix> " \
- "sloc <ip4/6-addr> dloc <ip4|6-addr> [del]") \
+_(lisp_gpe_add_del_fwd_entry, "rmt_eid <eid> [lcl_eid <eid>] vni <vni>" \
+ "dp_table <table> loc-pair <lcl_loc> <rmt_loc> ... [del]") \
_(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
_(lisp_gpe_enable_disable, "enable|disable") \
_(lisp_enable_disable, "enable|disable") \
diff --git a/vpp/vpp-api/api.c b/vpp/vpp-api/api.c
index 3f48a7ef2ec..2f076c0b407 100644
--- a/vpp/vpp-api/api.c
+++ b/vpp/vpp-api/api.c
@@ -4880,6 +4880,38 @@ vl_api_lisp_add_del_locator_t_handler(
REPLY_MACRO(VL_API_LISP_ADD_DEL_LOCATOR_REPLY);
}
+static int
+unformat_lisp_eid_api (gid_address_t * dst, u32 vni, u8 type, void * src,
+ u8 len)
+{
+ switch (type)
+ {
+ case 0: /* ipv4 */
+ gid_address_type(dst) = GID_ADDR_IP_PREFIX;
+ gid_address_ip_set (dst, src, IP4);
+ gid_address_ippref_len(dst) = len;
+ ip_prefix_normalize (&gid_address_ippref(dst));
+ break;
+ case 1: /* ipv6 */
+ gid_address_type(dst) = GID_ADDR_IP_PREFIX;
+ gid_address_ip_set (dst, src, IP6);
+ gid_address_ippref_len(dst) = len;
+ ip_prefix_normalize (&gid_address_ippref(dst));
+ break;
+ case 2: /* l2 mac */
+ gid_address_type(dst) = GID_ADDR_MAC;
+ clib_memcpy (&gid_address_mac(dst), src, 6);
+ break;
+ default:
+ /* unknown type */
+ return VNET_API_ERROR_INVALID_VALUE;
+ }
+
+ gid_address_vni (dst) = vni;
+
+ return 0;
+}
+
static void
vl_api_lisp_add_del_local_eid_t_handler(
vl_api_lisp_add_del_local_eid_t *mp)
@@ -4887,42 +4919,18 @@ vl_api_lisp_add_del_local_eid_t_handler(
vl_api_lisp_add_del_local_eid_reply_t *rmp;
lisp_cp_main_t * lcm = vnet_lisp_cp_get_main();
int rv = 0;
- ip_prefix_t *prefp = NULL;
- ip_address_t *ip_eid = NULL;
- gid_address_t eid;
- u8 * mac = gid_address_mac (&eid);
+ gid_address_t _eid, * eid = &_eid;
uword * p = NULL;
u32 locator_set_index = ~0, map_index = ~0;
vnet_lisp_add_del_mapping_args_t _a, *a = &_a;
u8 *name = NULL;
memset (a, 0, sizeof (a[0]));
- memset (&eid, 0, sizeof (eid));
-
- prefp = &gid_address_ippref(&eid);
- ip_eid = &ip_prefix_addr(prefp);
+ memset (eid, 0, sizeof (eid[0]));
- switch (mp->eid_type)
- {
- case 0: /* ipv4*/
- gid_address_type (&eid) = GID_ADDR_IP_PREFIX;
- ip_address_set(ip_eid, mp->eid, IP4);
- ip_prefix_len(prefp) = mp->prefix_len;
- ip_prefix_normalize(prefp);
- break;
- case 1: /* ipv6 */
- gid_address_type (&eid) = GID_ADDR_IP_PREFIX;
- ip_address_set(ip_eid, mp->eid, IP6);
- ip_prefix_len(prefp) = mp->prefix_len;
- ip_prefix_normalize(prefp);
- break;
- case 2: /* l2 mac */
- gid_address_type (&eid) = GID_ADDR_MAC;
- clib_memcpy(mac, mp->eid, 6);
- break;
- default:
- rv = VNET_API_ERROR_INVALID_EID_TYPE;
- goto out;
- }
+ rv = unformat_lisp_eid_api (eid, clib_net_to_host_u32 (mp->vni),
+ mp->eid_type, mp->eid, mp->prefix_len);
+ if (rv)
+ goto out;
name = format(0, "%s", mp->locator_set_name);
p = hash_get_mem(lcm->locator_set_index_by_name, name);
@@ -4932,10 +4940,9 @@ vl_api_lisp_add_del_local_eid_t_handler(
}
locator_set_index = p[0];
- /* XXX treat batch configuration */
+ /* XXX treat batch configuration */
a->is_add = mp->is_add;
- gid_address_vni (&eid) = clib_net_to_host_u32 (mp->vni);
- gid_address_copy (&a->eid, &eid);
+ gid_address_copy (&a->eid, eid);
a->locator_set_index = locator_set_index;
a->local = 1;
rv = vnet_lisp_add_del_local_mapping(a, &map_index);
@@ -4959,46 +4966,32 @@ vl_api_lisp_eid_table_add_del_map_t_handler(
REPLY_MACRO(VL_API_LISP_EID_TABLE_ADD_DEL_MAP_REPLY)
}
-static void
-lisp_gpe_add_del_fwd_entry_set_address(
- vl_api_lisp_gpe_add_del_fwd_entry_t *mp,
- ip_address_t *slocator,
- ip_address_t *dlocator,
- gid_address_t *eid)
-{
- ip_address_t *ip_eid = NULL;
- ip_prefix_t *prefp = NULL;
-
- prefp = &gid_address_ippref(eid);
- ip_eid = &ip_prefix_addr(prefp);
-
- if (mp->eid_is_ipv6) {
- clib_memcpy(&ip_addr_v6(ip_eid), mp->eid_ip_address,
- sizeof(ip_addr_v6(ip_eid)));
- ip_addr_version(ip_eid) = IP6;
- } else {
- clib_memcpy(&ip_addr_v4(ip_eid), mp->eid_ip_address,
- sizeof(ip_addr_v4(ip_eid)));
- ip_addr_version(ip_eid) = IP4;
- }
- ip_prefix_len(prefp) = mp->eid_prefix_len;
- ip_prefix_normalize(prefp);
-
- if (mp->address_is_ipv6) {
- clib_memcpy(&ip_addr_v6(slocator), mp->source_ip_address,
- sizeof(ip_addr_v6(slocator)));
- ip_addr_version(slocator) = IP6;
- clib_memcpy(&ip_addr_v6(dlocator), mp->destination_ip_address,
- sizeof(ip_addr_v6(dlocator)));
- ip_addr_version(dlocator) = IP6;
- } else {
- clib_memcpy(&ip_addr_v4(slocator), mp->source_ip_address,
- sizeof(ip_addr_v4(slocator)));
- ip_addr_version(slocator) = IP4;
- clib_memcpy(&ip_addr_v4(dlocator), mp->destination_ip_address,
- sizeof(ip_addr_v4(dlocator)));
- ip_addr_version(dlocator) = IP4;
- }
+/** Used for transferring locators via VPP API */
+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;
+
+static locator_t *
+unformat_lisp_locs (void * data, u32 rloc_num)
+{
+ u32 i;
+ locator_t rloc, * rlocs = 0;
+
+ for (i = 0; i < rloc_num; i++) {
+ rloc_t * r = &((rloc_t *) data)[i];
+ memset(&rloc, 0, sizeof(rloc));
+ gid_address_ip_set (&rloc.address, &r->addr, 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;
+ rloc.priority = r->priority;
+ rloc.weight = r->weight;
+ vec_add1 (rlocs, rloc);
+ }
+ return rlocs;
}
static void
@@ -5007,20 +5000,31 @@ vl_api_lisp_gpe_add_del_fwd_entry_t_handler(
{
vl_api_lisp_gpe_add_del_fwd_entry_reply_t *rmp;
int rv = 0;
- ip_address_t slocator, dlocator;
- gid_address_t eid;
- vnet_lisp_gpe_add_del_fwd_entry_args_t a;
+ vnet_lisp_gpe_add_del_fwd_entry_args_t _a, * a = &_a;
+ locator_t * lcl_locs = 0, * rmt_locs = 0;
+
+ memset (a, 0, sizeof(a[0]));
+
+ rv = unformat_lisp_eid_api (&a->rmt_eid, mp->vni, mp->eid_type,
+ mp->rmt_eid, mp->rmt_len);
+ rv |= unformat_lisp_eid_api (&a->lcl_eid, mp->vni, mp->eid_type,
+ mp->lcl_eid, mp->lcl_len);
- lisp_gpe_add_del_fwd_entry_set_address(mp, &slocator, &dlocator, &eid);
+ lcl_locs = unformat_lisp_locs (mp->lcl_locs, mp->loc_num);
+ rmt_locs = unformat_lisp_locs (mp->rmt_locs, mp->loc_num);
- memset (&a, 0, sizeof(a));
+ if (rv || 0 == lcl_locs || 0 == lcl_locs)
+ goto send_reply;
- a.is_add = mp->is_add;
- a.rmt_eid = eid;
- a.lcl_loc = slocator;
- a.rmt_loc = dlocator;
- rv = vnet_lisp_gpe_add_del_fwd_entry (&a, 0);
+ a->is_add = mp->is_add;
+ a->lcl_loc = gid_address_ip(&lcl_locs[0].address); /* TODO support more */
+ a->rmt_loc = gid_address_ip(&rmt_locs[0].address);
+ a->dp_table = mp->dp_table;
+ a->vni = mp->vni;
+ rv = vnet_lisp_gpe_add_del_fwd_entry (a, 0);
+
+send_reply:
REPLY_MACRO(VL_API_LISP_GPE_ADD_DEL_FWD_ENTRY_REPLY);
}
@@ -5030,21 +5034,12 @@ vl_api_lisp_add_del_map_resolver_t_handler(
{
vl_api_lisp_add_del_map_resolver_reply_t *rmp;
int rv = 0;
- ip_address_t *ip_addr = NULL;
vnet_lisp_add_del_map_resolver_args_t _a, * a = &_a;
- a->is_add = mp->is_add;
- ip_addr = &a->address;
+ memset(a, 0, sizeof(a[0]));
- if (mp->is_ipv6) {
- clib_memcpy(&ip_addr_v6(ip_addr), mp->ip_address,
- sizeof(ip_addr_v6(ip_addr)));
- ip_addr_version(ip_addr) = IP6;
- } else {
- clib_memcpy(&ip_addr_v4(ip_addr), mp->ip_address,
- sizeof(ip_addr_v4(ip_addr)));
- ip_addr_version(ip_addr) = IP4;
- }
+ a->is_add = mp->is_add;
+ ip_address_set (&a->address, mp->ip_address, mp->is_ipv6 ? IP6 : IP4);
rv = vnet_lisp_add_del_map_resolver (a);
@@ -5085,8 +5080,9 @@ vl_api_lisp_gpe_add_del_iface_t_handler(
vnet_lisp_gpe_add_del_iface_args_t _a, * a = &_a;
a->is_add = mp->is_add;
- a->table_id = mp->table_id;
+ a->dp_table = mp->dp_table;
a->vni = mp->vni;
+ a->is_l2 = mp->is_l2;
rv = vnet_lisp_gpe_add_del_iface (a, 0);
REPLY_MACRO(VL_API_LISP_GPE_ADD_DEL_IFACE_REPLY);
@@ -5128,64 +5124,25 @@ vl_api_lisp_add_del_map_request_itr_rlocs_t_handler
REPLY_MACRO(VL_API_LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY);
}
-/** Used for transferring locators via VPP API */
-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;
-
static void
vl_api_lisp_add_del_remote_mapping_t_handler (
vl_api_lisp_add_del_remote_mapping_t *mp)
{
- u32 i;
- locator_t rloc, * rlocs = 0;
+ locator_t * rlocs = 0;
vl_api_lisp_add_del_remote_mapping_reply_t * rmp;
int rv = 0;
gid_address_t _eid, * eid = &_eid;
- ip_prefix_t * eid_pref = &gid_address_ippref(eid);
memset (eid, 0, sizeof (eid[0]));
- ip_address_t * eid_addr = &ip_prefix_addr(eid_pref);
- ip_prefix_len(eid_pref) = mp->eid_len;
- u8 * eid_mac = gid_address_mac (eid);
- gid_address_vni (eid) = ntohl (mp->vni);
- switch (mp->eid_type)
- {
- case 0: /* ipv4 */
- gid_address_type(eid) = GID_ADDR_IP_PREFIX;
- ip_address_set (eid_addr, mp->eid, IP4);
- ip_prefix_normalize (eid_pref);
- break;
- case 1: /* ipv6 */
- gid_address_type(eid) = GID_ADDR_IP_PREFIX;
- ip_address_set (eid_addr, mp->eid, IP6);
- ip_prefix_normalize (eid_pref);
- break;
- case 2: /* l2 mac */
- gid_address_type(eid) = GID_ADDR_MAC;
- clib_memcpy (eid_mac, mp->eid, 6);
- break;
- default:
- rv = VNET_API_ERROR_INVALID_EID_TYPE;
- goto send_reply;
- }
+ rv = unformat_lisp_eid_api (eid, clib_net_to_host_u32 (mp->vni),
+ mp->eid_type, mp->eid, mp->eid_len);
+ if (rv)
+ goto send_reply;
- for (i = 0; i < mp->rloc_num; i++) {
- rloc_t * r = &((rloc_t *) mp->rlocs)[i];
- memset(&rloc, 0, sizeof(rloc));
- ip_address_set(&gid_address_ip(&rloc.address), &r->addr,
- 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;
- rloc.priority = r->priority;
- rloc.weight = r->weight;
- vec_add1 (rlocs, rloc);
- }
+ rlocs = unformat_lisp_locs (mp->rlocs, mp->rloc_num);
+ if (0 == rlocs)
+ goto send_reply;
if (!mp->is_add) {
vnet_lisp_add_del_adjacency_args_t _a, * a = &_a;
@@ -5221,46 +5178,13 @@ vl_api_lisp_add_del_adjacency_t_handler (
int rv = 0;
memset(a, 0, sizeof(a[0]));
- ip_prefix_t * seid_pref = &gid_address_ippref(&a->seid);
- ip_prefix_t * deid_pref = &gid_address_ippref(&a->deid);
+ rv = unformat_lisp_eid_api (&a->seid, clib_net_to_host_u32 (mp->vni),
+ mp->eid_type, mp->seid, mp->seid_len);
+ rv |= unformat_lisp_eid_api (&a->deid, clib_net_to_host_u32 (mp->vni),
+ mp->eid_type, mp->deid, mp->deid_len);
- ip_address_t * seid_addr = &ip_prefix_addr(seid_pref);
- ip_address_t * deid_addr = &ip_prefix_addr(deid_pref);
- ip_prefix_len(seid_pref) = mp->seid_len;
- ip_prefix_len(deid_pref) = mp->deid_len;
- u8 * seid_mac = gid_address_mac (&a->seid);
- u8 * deid_mac = gid_address_mac (&a->deid);
- gid_address_vni(&a->seid) = ntohl (mp->vni);
- gid_address_vni(&a->deid) = ntohl (mp->vni);
-
- switch (mp->eid_type)
- {
- case 0: /* ipv4 */
- gid_address_type(&a->seid) = GID_ADDR_IP_PREFIX;
- gid_address_type(&a->deid) = GID_ADDR_IP_PREFIX;
- ip_address_set (seid_addr, mp->seid, IP4);
- ip_address_set (deid_addr, mp->deid, IP4);
- ip_prefix_normalize (seid_pref);
- ip_prefix_normalize (deid_pref);
- break;
- case 1: /* ipv6 */
- gid_address_type(&a->seid) = GID_ADDR_IP_PREFIX;
- gid_address_type(&a->deid) = GID_ADDR_IP_PREFIX;
- ip_address_set (seid_addr, mp->seid, IP6);
- ip_address_set (deid_addr, mp->deid, IP6);
- ip_prefix_normalize (seid_pref);
- ip_prefix_normalize (deid_pref);
- break;
- case 2: /* l2 mac */
- gid_address_type(&a->seid) = GID_ADDR_MAC;
- gid_address_type(&a->deid) = GID_ADDR_MAC;
- clib_memcpy (seid_mac, mp->seid, 6);
- clib_memcpy (deid_mac, mp->deid, 6);
- break;
- default:
- rv = VNET_API_ERROR_INVALID_EID_TYPE;
- goto send_reply;
- }
+ if (rv)
+ goto send_reply;
a->is_add = mp->is_add;
rv = vnet_lisp_add_del_adjacency (a);
@@ -5476,25 +5400,11 @@ vl_api_lisp_eid_table_dump_t_handler (
if (mp->eid_set) {
memset (eid, 0, sizeof (*eid));
- gid_address_vni(eid) = ntohl(mp->vni);
- switch (mp->eid_type) {
- case 0:
- gid_address_type(eid) = GID_ADDR_IP_PREFIX;
- gid_address_ippref_len(eid) = mp->prefix_length;
- gid_address_ip_version(eid) = IP4;
- clib_memcpy (&gid_address_ippref(eid), mp->eid, 4);
- break;
- case 1:
- gid_address_type(eid) = GID_ADDR_IP_PREFIX;
- gid_address_ippref_len(eid) = mp->prefix_length;
- gid_address_ip_version(eid) = IP6;
- clib_memcpy (&gid_address_ippref(eid), mp->eid, 16);
- break;
- case 2:
- gid_address_type(eid) = GID_ADDR_MAC;
- clib_memcpy (gid_address_mac(eid), mp->eid, 6);
- break;
- }
+
+ unformat_lisp_eid_api (eid, mp->eid_type,
+ clib_net_to_host_u32 (mp->vni), mp->eid,
+ mp->prefix_length);
+
mi = gid_dictionary_lookup (&lcm->mapping_index_by_gid, eid);
if ((u32)~0 == mi)
return;
diff --git a/vpp/vpp-api/vpe.api b/vpp/vpp-api/vpe.api
index 50cfe2adf67..67e742e7155 100644
--- a/vpp/vpp-api/vpe.api
+++ b/vpp/vpp-api/vpe.api
@@ -2261,27 +2261,38 @@ define lisp_add_del_local_eid_reply {
i32 retval;
};
-/** \brief add or delete lisp gpe maptunel
+/** \brief add or delete lisp gpe tunnel
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@param is_add - add address if non-zero, else delete
- @param eid_is_ipv6 - if non-zero the address is ipv6, else ipv4
- @param eid_ip_address - array of address bytes
- @param eid_prefix_len - prefix len
- @param address_is_ipv6 - if non-zero the address is ipv6, else ipv4
- @param source_ip_address - array of address bytes
- @param destination_ip_address - array of address bytes
+ @param eid_type -
+ 0 : ipv4
+ 1 : ipv6
+ 2 : mac
+ @param rmt_eid - remote eid
+ @param lcl_eid - local eid
+ @param rmt_len - remote prefix len
+ @param lcl_len - local prefix len
+ @param vni - virtual network identifier
+ @param dp_table - vrf/bridge domain id
+ @param loc_num - number of locators
+ @param lcl_locs - array of local locators
+ @param rmt_locs - array of remote locators
*/
define lisp_gpe_add_del_fwd_entry {
u32 client_index;
u32 context;
u8 is_add;
- u8 eid_is_ipv6;
- u8 eid_ip_address[16];
- u8 eid_prefix_len;
- u8 address_is_ipv6;
- u8 source_ip_address[16];
- u8 destination_ip_address[16];
+ u8 eid_type;
+ u8 rmt_eid[16];
+ u8 lcl_eid[16];
+ u8 rmt_len;
+ u8 lcl_len;
+ u32 vni;
+ u32 dp_table;
+ u32 loc_num;
+ u8 lcl_locs[loc_num];
+ u8 rmt_locs[loc_num];
};
/** \brief Reply for gpe_fwd_entry add/del
@@ -2366,7 +2377,8 @@ define lisp_gpe_add_del_iface {
u32 client_index;
u32 context;
u8 is_add;
- u32 table_id;
+ u8 is_l2;
+ u32 dp_table;
u32 vni;
};