aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2017-01-13 14:13:09 +0100
committerFlorin Coras <florin.coras@gmail.com>2017-01-13 15:52:36 +0000
commitc3af7bf104919be668d696fc1ac05893712dae06 (patch)
treecdf40ecc1960e833ef5e06eac8298ab128f0516d /src/vnet
parent67e7fcb181c2eeeb14f3bd9f88a3c5ee4dc51a17 (diff)
LISP: Fix gpe API
Change-Id: Iba076fc13e3f870c49fc5ca971dc7b8799188a27 Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/lisp-gpe/lisp_gpe.api54
-rw-r--r--src/vnet/lisp-gpe/lisp_gpe.c45
-rw-r--r--src/vnet/lisp-gpe/lisp_gpe_api.c113
-rw-r--r--src/vnet/lisp-gpe/lisp_gpe_fwd_entry.c2
4 files changed, 79 insertions, 135 deletions
diff --git a/src/vnet/lisp-gpe/lisp_gpe.api b/src/vnet/lisp-gpe/lisp_gpe.api
index 3956b97d6a1..2a79becee48 100644
--- a/src/vnet/lisp-gpe/lisp_gpe.api
+++ b/src/vnet/lisp-gpe/lisp_gpe.api
@@ -13,6 +13,18 @@
* limitations under the License.
*/
+/** \brief LISP locator structure
+ @param is_ip4 - whether addr is IPv4 or v6
+ @param weight - locator weight
+ @param addr - IPv4/6 address
+*/
+typeonly manual_print manual_endian define lisp_gpe_locator
+{
+ u8 is_ip4;
+ u8 weight;
+ u8 addr[16];
+};
+
/** \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
@@ -27,12 +39,11 @@
@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
@param action - negative action when 0 locators configured
+ @param loc_num - number of locators
+ @param locs - array of remote locators
*/
-define lisp_gpe_add_del_fwd_entry
+manual_print manual_endian define lisp_gpe_add_del_fwd_entry
{
u32 client_index;
u32 context;
@@ -44,10 +55,9 @@ define lisp_gpe_add_del_fwd_entry
u8 lcl_len;
u32 vni;
u32 dp_table;
- u32 loc_num;
- u8 lcl_locs[loc_num];
- u8 rmt_locs[loc_num];
u8 action;
+ u32 loc_num;
+ vl_api_lisp_gpe_locator_t locs[loc_num];
};
/** \brief Reply for gpe_fwd_entry add/del
@@ -107,37 +117,9 @@ define lisp_gpe_add_del_iface_reply
i32 retval;
};
-define lisp_gpe_tunnel_details
-{
- u32 context;
- u32 tunnels;
- u8 is_ipv6;
- u8 source_ip[16];
- u8 destination_ip[16];
- u32 encap_fib_id;
- u32 decap_fib_id;
- u32 dcap_next;
- u8 lisp_ver;
- u8 next_protocol;
- u8 flags;
- u8 ver_res;
- u8 res;
- u32 iid;
-};
-
-/** \brief Request for gpe tunnel summary status
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- */
-define lisp_gpe_tunnel_dump
-{
- u32 client_index;
- u32 context;
-};
-
/*
* Local Variables:
* eval: (c-set-style "gnu")
* End:
*/
- \ No newline at end of file
+
diff --git a/src/vnet/lisp-gpe/lisp_gpe.c b/src/vnet/lisp-gpe/lisp_gpe.c
index fbda8687c3b..3fd78c6a1cd 100644
--- a/src/vnet/lisp-gpe/lisp_gpe.c
+++ b/src/vnet/lisp-gpe/lisp_gpe.c
@@ -38,11 +38,15 @@ lisp_gpe_add_del_fwd_entry_command_fn (vlib_main_t * vm,
ip_address_t lloc, rloc;
clib_error_t *error = 0;
gid_address_t _reid, *reid = &_reid, _leid, *leid = &_leid;
- u8 reid_set = 0, leid_set = 0, is_negative = 0, vrf_set = 0, vni_set = 0;
- u32 vni, vrf, action = ~0, p, w;
+ u8 reid_set = 0, leid_set = 0, is_negative = 0, dp_table_set = 0,
+ vni_set = 0;
+ u32 vni = 0, dp_table = 0, action = ~0, w;
locator_pair_t pair, *pairs = 0;
int rv;
+ memset (leid, 0, sizeof (*leid));
+ memset (reid, 0, sizeof (*reid));
+
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
@@ -67,46 +71,46 @@ lisp_gpe_add_del_fwd_entry_command_fn (vlib_main_t * vm,
gid_address_vni (reid) = vni;
vni_set = 1;
}
- else if (unformat (line_input, "vrf %u", &vrf))
+ else if (unformat (line_input, "vrf %u", &dp_table))
{
- vrf_set = 1;
+ dp_table_set = 1;
}
- else if (unformat (line_input, "bd %u", &vrf))
+ else if (unformat (line_input, "bd %u", &dp_table))
{
- vrf_set = 1;
+ dp_table_set = 1;
}
else if (unformat (line_input, "negative action %U",
unformat_negative_mapping_action, &action))
{
is_negative = 1;
}
- else if (unformat (line_input, "loc-pair %U %U p %d w %d",
+ else if (unformat (line_input, "loc-pair %U %U w %d",
unformat_ip_address, &lloc,
- unformat_ip_address, &rloc, &p, &w))
+ unformat_ip_address, &rloc, &w))
{
pair.lcl_loc = lloc;
pair.rmt_loc = rloc;
- pair.priority = p;
pair.weight = w;
vec_add1 (pairs, pair);
}
else
{
error = unformat_parse_error (line_input);
+ vlib_cli_output (vm, "parse error: '%U'",
+ format_unformat_error, line_input);
goto done;
}
}
- unformat_free (line_input);
- if (!vni_set || !vrf_set)
+ if (!vni_set || !dp_table_set)
{
- error = clib_error_return (0, "vni and vrf must be set!");
+ vlib_cli_output (vm, "vni and vrf/bd must be set!");
goto done;
}
if (!reid_set)
{
- error = clib_error_return (0, "remote eid must be set!");
+ vlib_cli_output (vm, "remote eid must be set!");
goto done;
}
@@ -114,7 +118,7 @@ lisp_gpe_add_del_fwd_entry_command_fn (vlib_main_t * vm,
{
if (~0 == action)
{
- error = clib_error_return (0, "no action set for negative tunnel!");
+ vlib_cli_output (vm, "no action set for negative tunnel!");
goto done;
}
}
@@ -122,7 +126,7 @@ lisp_gpe_add_del_fwd_entry_command_fn (vlib_main_t * vm,
{
if (vec_len (pairs) == 0)
{
- error = clib_error_return (0, "expected ip4/ip6 locators.");
+ vlib_cli_output (vm, "expected ip4/ip6 locators");
goto done;
}
}
@@ -142,7 +146,7 @@ lisp_gpe_add_del_fwd_entry_command_fn (vlib_main_t * vm,
a->is_add = is_add;
a->is_negative = is_negative;
a->vni = vni;
- a->table_id = vrf;
+ a->table_id = dp_table;
gid_address_copy (&a->lcl_eid, leid);
gid_address_copy (&a->rmt_eid, reid);
a->locator_pairs = pairs;
@@ -150,11 +154,12 @@ lisp_gpe_add_del_fwd_entry_command_fn (vlib_main_t * vm,
rv = vnet_lisp_gpe_add_del_fwd_entry (a, 0);
if (0 != rv)
{
- error = clib_error_return (0, "failed to %s gpe tunnel!",
- is_add ? "add" : "delete");
+ vlib_cli_output (vm, "failed to %s gpe tunnel!",
+ is_add ? "add" : "delete");
}
done:
+ unformat_free (line_input);
vec_free (pairs);
return error;
}
@@ -162,8 +167,8 @@ done:
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (lisp_gpe_add_del_fwd_entry_command, static) = {
.path = "lisp gpe entry",
- .short_help = "lisp gpe entry add/del vni <vni> vrf <vrf> [leid <leid>]"
- "reid <reid> [loc-pair <lloc> <rloc> p <priority> w <weight>] "
+ .short_help = "lisp gpe entry add/del vni <vni> vrf/bd <id> [leid <leid>]"
+ "reid <reid> [loc-pair <lloc> <rloc> w <weight>] "
"[negative action <action>]",
.function = lisp_gpe_add_del_fwd_entry_command_fn,
};
diff --git a/src/vnet/lisp-gpe/lisp_gpe_api.c b/src/vnet/lisp-gpe/lisp_gpe_api.c
index 176ded501cd..93b6053203e 100644
--- a/src/vnet/lisp-gpe/lisp_gpe_api.c
+++ b/src/vnet/lisp-gpe/lisp_gpe_api.c
@@ -28,6 +28,11 @@
#include <vnet/vnet_msg_enum.h>
+#define vl_api_lisp_gpe_locator_pair_t_endian vl_noop_handler
+#define vl_api_lisp_gpe_locator_pair_t_print vl_noop_handler
+#define vl_api_lisp_gpe_add_del_fwd_entry_t_endian vl_noop_handler
+#define vl_api_lisp_gpe_add_del_fwd_entry_t_print vl_noop_handler
+
#define vl_typedefs /* define message structures */
#include <vnet/vnet_all_api_h.h>
#undef vl_typedefs
@@ -47,43 +52,33 @@
#define foreach_vpe_api_msg \
_(LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry) \
_(LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable) \
-_(LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface) \
-_(LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump)
-
-/** Used for transferring locators via VPP API */
-/* *INDENT-OFF* */
-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;
-/* *INDENT-ON* */
+_(LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface)
static locator_pair_t *
-unformat_lisp_loc_pairs (void *lcl_locs, void *rmt_locs, u32 rloc_num)
+unformat_lisp_loc_pairs (void *locs, u32 rloc_num)
{
u32 i;
- locator_pair_t *pairs = 0, pair;
- rloc_t *r;
+ locator_pair_t *pairs = 0, pair, *p;
+ vl_api_lisp_gpe_locator_t *r;
for (i = 0; i < rloc_num; i++)
{
/* local locator */
- r = &((rloc_t *) lcl_locs)[i];
- memset (&pair.lcl_loc, 0, sizeof (pair.lcl_loc));
+ r = &((vl_api_lisp_gpe_locator_t *) locs)[i];
+ memset (&pair, 0, sizeof (pair));
ip_address_set (&pair.lcl_loc, &r->addr, r->is_ip4 ? IP4 : IP6);
- /* remote locators */
- r = &((rloc_t *) rmt_locs)[i];
- memset (&pair.rmt_loc, 0, sizeof (pair.rmt_loc));
- ip_address_set (&pair.rmt_loc, &r->addr, r->is_ip4 ? IP4 : IP6);
-
- pair.priority = r->priority;
pair.weight = r->weight;
-
vec_add1 (pairs, pair);
}
+
+ for (i = rloc_num; i < rloc_num * 2; i++)
+ {
+ /* remote locators */
+ r = &((vl_api_lisp_gpe_locator_t *) locs)[i];
+ p = &pairs[i - rloc_num];
+ ip_address_set (&p->rmt_loc, &r->addr, r->is_ip4 ? IP4 : IP6);
+ }
return pairs;
}
@@ -120,6 +115,15 @@ unformat_lisp_eid_api (gid_address_t * dst, u32 vni, u8 type, void *src,
}
static void
+ lisp_gpe_add_del_fwd_entry_t_net_to_host
+ (vl_api_lisp_gpe_add_del_fwd_entry_t * mp)
+{
+ mp->vni = clib_net_to_host_u32 (mp->vni);
+ mp->dp_table = clib_net_to_host_u32 (mp->dp_table);
+ mp->loc_num = clib_net_to_host_u32 (mp->loc_num);
+}
+
+static void
vl_api_lisp_gpe_add_del_fwd_entry_t_handler
(vl_api_lisp_gpe_add_del_fwd_entry_t * mp)
{
@@ -128,6 +132,7 @@ static void
locator_pair_t *pairs = 0;
int rv = 0;
+ lisp_gpe_add_del_fwd_entry_t_net_to_host (mp);
memset (a, 0, sizeof (a[0]));
rv = unformat_lisp_eid_api (&a->rmt_eid, mp->vni, mp->eid_type,
@@ -135,7 +140,12 @@ static void
rv |= unformat_lisp_eid_api (&a->lcl_eid, mp->vni, mp->eid_type,
mp->lcl_eid, mp->lcl_len);
- pairs = unformat_lisp_loc_pairs (mp->lcl_locs, mp->rmt_locs, mp->loc_num);
+ if (mp->loc_num % 2 != 0)
+ {
+ rv = -1;
+ goto send_reply;
+ }
+ pairs = unformat_lisp_loc_pairs (mp->locs, mp->loc_num / 2);
if (rv || 0 == pairs)
goto send_reply;
@@ -198,59 +208,6 @@ vl_api_lisp_gpe_add_del_iface_t_handler (vl_api_lisp_gpe_add_del_iface_t * mp)
REPLY_MACRO (VL_API_LISP_GPE_ADD_DEL_IFACE_REPLY);
}
-static void
-send_lisp_gpe_fwd_entry_details (lisp_gpe_fwd_entry_t * lfe,
- unix_shared_memory_queue_t * q, u32 context)
-{
- vl_api_lisp_gpe_tunnel_details_t *rmp;
- lisp_gpe_main_t *lgm = &lisp_gpe_main;
-
- rmp = vl_msg_api_alloc (sizeof (*rmp));
- memset (rmp, 0, sizeof (*rmp));
- rmp->_vl_msg_id = ntohs (VL_API_LISP_GPE_TUNNEL_DETAILS);
-
- rmp->tunnels = lfe - lgm->lisp_fwd_entry_pool;
-
- rmp->is_ipv6 = ip_prefix_version (&(lfe->key->rmt.ippref)) == IP6 ? 1 : 0;
- ip_address_copy_addr (rmp->source_ip,
- &ip_prefix_addr (&(lfe->key->rmt.ippref)));
- ip_address_copy_addr (rmp->destination_ip,
- &ip_prefix_addr (&(lfe->key->rmt.ippref)));
-
- rmp->encap_fib_id = htonl (0);
- rmp->decap_fib_id = htonl (lfe->eid_fib_index);
- rmp->iid = htonl (lfe->key->vni);
- rmp->context = context;
-
- vl_msg_api_send_shmem (q, (u8 *) & rmp);
-}
-
-static void
-vl_api_lisp_gpe_tunnel_dump_t_handler (vl_api_lisp_gpe_tunnel_dump_t * mp)
-{
- unix_shared_memory_queue_t *q = NULL;
- lisp_gpe_main_t *lgm = &lisp_gpe_main;
- lisp_gpe_fwd_entry_t *lfe = NULL;
-
- if (pool_elts (lgm->lisp_fwd_entry_pool) == 0)
- {
- return;
- }
-
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (q == 0)
- {
- return;
- }
-
- /* *INDENT-OFF* */
- pool_foreach(lfe, lgm->lisp_fwd_entry_pool,
- ({
- send_lisp_gpe_fwd_entry_details(lfe, q, mp->context);
- }));
- /* *INDENT-ON* */
-}
-
/*
* lisp_gpe_api_hookup
* Add vpe's API message handlers to the table.
diff --git a/src/vnet/lisp-gpe/lisp_gpe_fwd_entry.c b/src/vnet/lisp-gpe/lisp_gpe_fwd_entry.c
index 26a93a87b9d..e05f0e01bee 100644
--- a/src/vnet/lisp-gpe/lisp_gpe_fwd_entry.c
+++ b/src/vnet/lisp-gpe/lisp_gpe_fwd_entry.c
@@ -913,7 +913,7 @@ format_lisp_fwd_path (u8 * s, va_list ap)
{
lisp_fwd_path_t *lfp = va_arg (ap, lisp_fwd_path_t *);
- s = format (s, "priority:%d weight:%d ", lfp->priority, lfp->weight);
+ s = format (s, "weight:%d ", lfp->weight);
s = format (s, "adj:[%U]\n",
format_lisp_gpe_adjacency,
lisp_gpe_adjacency_get (lfp->lisp_adj),