aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2017-06-14 14:39:42 +0200
committerFlorin Coras <florin.coras@gmail.com>2017-06-15 21:31:59 +0000
commitb4243aaa7ac53075a3d02e4e1fed4435250e8078 (patch)
tree71a878905105c72eea73f0449bce0a4f59cce400 /src
parent779c3e3a632f887a7249a5cae8cce6eeacb67e3f (diff)
Add VAT handlers for LISP-GPE API
Change-Id: Id1139533c41cabef48394b5d79750608e0b74179 Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/vat/api_format.c199
-rw-r--r--src/vnet/lisp-gpe/lisp_gpe.c7
-rw-r--r--src/vnet/lisp-gpe/lisp_gpe_api.c28
3 files changed, 223 insertions, 11 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 766624a0fe4..d31b301e0ed 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -3184,6 +3184,77 @@ end:
}
static void
+ vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
+ (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
+{
+ vat_main_t *vam = &vat_main;
+ u32 i, n;
+ int retval = clib_net_to_host_u32 (mp->retval);
+ vl_api_gpe_native_fwd_rpath_t *r;
+
+ if (retval)
+ goto end;
+
+ n = clib_net_to_host_u32 (mp->count);
+
+ for (i = 0; i < n; i++)
+ {
+ r = &mp->entries[i];
+ print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
+ clib_net_to_host_u32 (r->fib_index),
+ clib_net_to_host_u32 (r->nh_sw_if_index),
+ r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
+ }
+
+end:
+ vam->retval = retval;
+ vam->result_ready = 1;
+}
+
+static void
+ vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
+ (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
+{
+ vat_main_t *vam = &vat_main;
+ vat_json_node_t root, *e;
+ u32 i, n;
+ int retval = clib_net_to_host_u32 (mp->retval);
+ vl_api_gpe_native_fwd_rpath_t *r;
+ u8 *s;
+
+ if (retval)
+ goto end;
+
+ n = clib_net_to_host_u32 (mp->count);
+ vat_json_init_array (&root);
+
+ for (i = 0; i < n; i++)
+ {
+ e = vat_json_array_add (&root);
+ vat_json_init_object (e);
+ r = &mp->entries[i];
+ s =
+ format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
+ r->nh_addr);
+ vec_add1 (s, 0);
+ vat_json_object_add_string_copy (e, "ip4", s);
+ vec_free (s);
+
+ vat_json_object_add_uint (e, "fib_index",
+ clib_net_to_host_u32 (r->fib_index));
+ vat_json_object_add_uint (e, "nh_sw_if_index",
+ clib_net_to_host_u32 (r->nh_sw_if_index));
+ }
+
+ vat_json_print (vam->ofp, &root);
+ vat_json_free (&root);
+
+end:
+ vam->retval = retval;
+ vam->result_ready = 1;
+}
+
+static void
vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
(vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
{
@@ -4506,6 +4577,7 @@ _(one_stats_flush_reply) \
_(gpe_enable_disable_reply) \
_(gpe_set_encap_mode_reply) \
_(gpe_add_del_iface_reply) \
+_(gpe_add_del_native_fwd_rpath_reply) \
_(vxlan_gpe_add_del_tunnel_reply) \
_(af_packet_delete_reply) \
_(policer_classify_set_interface_reply) \
@@ -4745,6 +4817,9 @@ _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
_(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
_(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
_(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
+_(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
+_(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
+ gpe_add_del_native_fwd_rpath_reply) \
_(GPE_FWD_ENTRY_PATH_DETAILS, \
gpe_fwd_entry_path_details) \
_(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
@@ -16324,6 +16399,8 @@ api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
return ret;
}
+#define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
+#define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
#define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
#define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
#define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
@@ -16378,6 +16455,50 @@ api_one_adjacencies_get (vat_main_t * vam)
#define api_lisp_adjacencies_get api_one_adjacencies_get
static int
+api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
+{
+ unformat_input_t *i = vam->input;
+ vl_api_gpe_native_fwd_rpaths_get_t *mp;
+ int ret;
+ u8 ip_family_set = 0, is_ip4 = 1;
+
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (i, "ip4"))
+ {
+ ip_family_set = 1;
+ is_ip4 = 1;
+ }
+ else if (unformat (i, "ip6"))
+ {
+ ip_family_set = 1;
+ is_ip4 = 0;
+ }
+ else
+ {
+ errmsg ("parse error '%U'", format_unformat_error, i);
+ return -99;
+ }
+ }
+
+ if (!ip_family_set)
+ {
+ errmsg ("ip family not set!");
+ return -99;
+ }
+
+ M (GPE_NATIVE_FWD_RPATHS_GET, mp);
+ mp->is_ip4 = is_ip4;
+
+ /* send it... */
+ S (mp);
+
+ /* Wait for a reply... */
+ W (ret);
+ return ret;
+}
+
+static int
api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
{
vl_api_gpe_fwd_entry_vnis_get_t *mp;
@@ -16399,6 +16520,81 @@ api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
}
static int
+api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
+{
+ unformat_input_t *i = vam->input;
+ vl_api_gpe_add_del_native_fwd_rpath_t *mp;
+ int ret = 0;
+ u8 is_add = 1, ip_set = 0, is_ip4 = 1;
+ struct in_addr ip4;
+ struct in6_addr ip6;
+ u32 table_id = 0, nh_sw_if_index = ~0;
+
+ memset (&ip4, 0, sizeof (ip4));
+ memset (&ip6, 0, sizeof (ip6));
+
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (i, "del"))
+ is_add = 0;
+ else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
+ api_unformat_sw_if_index, vam, &nh_sw_if_index))
+ {
+ ip_set = 1;
+ is_ip4 = 1;
+ }
+ else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
+ api_unformat_sw_if_index, vam, &nh_sw_if_index))
+ {
+ ip_set = 1;
+ is_ip4 = 0;
+ }
+ else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
+ {
+ ip_set = 1;
+ is_ip4 = 1;
+ nh_sw_if_index = ~0;
+ }
+ else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
+ {
+ ip_set = 1;
+ is_ip4 = 0;
+ nh_sw_if_index = ~0;
+ }
+ else if (unformat (i, "table %d", &table_id))
+ ;
+ else
+ {
+ errmsg ("parse error '%U'", format_unformat_error, i);
+ return -99;
+ }
+ }
+
+ if (!ip_set)
+ {
+ errmsg ("nh addr not set!");
+ return -99;
+ }
+
+ M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
+ mp->is_add = is_add;
+ mp->table_id = clib_host_to_net_u32 (table_id);
+ mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
+ mp->is_ip4 = is_ip4;
+ if (is_ip4)
+ clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
+ else
+ clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
+
+ /* send it... */
+ S (mp);
+
+ /* Wait for a reply... */
+ W (ret);
+ return ret;
+}
+
+static int
api_one_map_server_dump (vat_main_t * vam)
{
vl_api_one_map_server_dump_t *mp;
@@ -19633,6 +19829,9 @@ _(lisp_map_resolver_dump, "") \
_(lisp_map_server_dump, "") \
_(lisp_adjacencies_get, "vni <vni>") \
_(gpe_fwd_entry_vnis_get, "") \
+_(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
+_(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
+ "[table <table-id>]") \
_(lisp_gpe_fwd_entries_get, "vni <vni>") \
_(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
_(gpe_set_encap_mode, "lisp|vxlan") \
diff --git a/src/vnet/lisp-gpe/lisp_gpe.c b/src/vnet/lisp-gpe/lisp_gpe.c
index ea6c143d917..d274818d46f 100644
--- a/src/vnet/lisp-gpe/lisp_gpe.c
+++ b/src/vnet/lisp-gpe/lisp_gpe.c
@@ -404,8 +404,9 @@ gpe_show_native_fwd_rpath_command_fn (vlib_main_t * vm,
vec_foreach (rpath, lgm->native_fwd_rpath[IP4])
{
vlib_cli_output (vm, "nh: %U fib_index %u sw_if_index %u",
- format_ip46_address, &rpath->frp_addr, 1,
- rpath->frp_fib_index, rpath->frp_sw_if_index);
+ format_ip46_address, &rpath->frp_addr,
+ IP46_TYPE_IP4, rpath->frp_fib_index,
+ rpath->frp_sw_if_index);
}
}
if (vec_len (lgm->native_fwd_rpath[IP6]))
@@ -413,7 +414,7 @@ gpe_show_native_fwd_rpath_command_fn (vlib_main_t * vm,
vec_foreach (rpath, lgm->native_fwd_rpath[IP6])
{
vlib_cli_output (vm, "nh: %U fib_index %u sw_if_index %u",
- format_ip46_address, &rpath->frp_addr, 1,
+ format_ip46_address, &rpath->frp_addr, IP46_TYPE_IP6,
rpath->frp_fib_index, rpath->frp_sw_if_index);
}
}
diff --git a/src/vnet/lisp-gpe/lisp_gpe_api.c b/src/vnet/lisp-gpe/lisp_gpe_api.c
index cb18b4bb980..f026e8b08e8 100644
--- a/src/vnet/lisp-gpe/lisp_gpe_api.c
+++ b/src/vnet/lisp-gpe/lisp_gpe_api.c
@@ -441,26 +441,33 @@ static void
vl_api_gpe_add_del_native_fwd_rpath_t_handler
(vl_api_gpe_add_del_native_fwd_rpath_t * mp)
{
- vl_api_gpe_add_del_fwd_entry_reply_t *rmp;
+ vl_api_gpe_add_del_native_fwd_rpath_reply_t *rmp;
vnet_gpe_native_fwd_rpath_args_t _a, *a = &_a;
int rv = 0;
memset (a, 0, sizeof (a[0]));
if (mp->is_ip4)
- clib_memcpy (&a->rpath.frp_addr, mp->nh_addr, sizeof (ip4_address_t));
+ clib_memcpy (&a->rpath.frp_addr.ip4, mp->nh_addr, sizeof (ip4_address_t));
else
- clib_memcpy (&a->rpath.frp_addr, mp->nh_addr, sizeof (ip6_address_t));
+ clib_memcpy (&a->rpath.frp_addr.ip6, mp->nh_addr, sizeof (ip6_address_t));
a->is_add = mp->is_add;
a->rpath.frp_proto = mp->is_ip4 ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6;
a->rpath.frp_fib_index = fib_table_find (a->rpath.frp_proto,
clib_net_to_host_u32
(mp->table_id));
+ if (~0 == a->rpath.frp_fib_index)
+ {
+ rv = VNET_API_ERROR_INVALID_VALUE;
+ goto done;
+ }
+
a->rpath.frp_sw_if_index = clib_net_to_host_u32 (mp->nh_sw_if_index);
a->rpath.frp_weight = 1;
rv = vnet_gpe_add_del_native_fwd_rpath (a);
+done:
REPLY_MACRO (VL_API_GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY);
}
@@ -477,8 +484,11 @@ gpe_native_fwd_rpaths_copy (vl_api_gpe_native_fwd_rpath_t * dst,
dst[i].fib_index = e->frp_fib_index;
dst[i].nh_sw_if_index = e->frp_sw_if_index;
dst[i].is_ip4 = is_ip4;
- clib_memcpy (&dst[i].nh_addr, &e->frp_addr,
- is_ip4 ? sizeof (ip4_address_t) : sizeof (ip6_address_t));
+ if (is_ip4)
+ clib_memcpy (&dst[i].nh_addr, &e->frp_addr.ip4, sizeof (ip4_address_t));
+ else
+ clib_memcpy (&dst[i].nh_addr, &e->frp_addr.ip6, sizeof (ip6_address_t));
+ i++;
}
}
@@ -513,15 +523,17 @@ vl_api_gpe_native_fwd_rpaths_get_t_handler (vl_api_gpe_native_fwd_rpaths_get_t
u32 size = 0;
int rv = 0;
- size = vec_len (lgm->native_fwd_rpath[mp->is_ip4])
+ u8 rpath_index = mp->is_ip4 ? 0 : 1;
+
+ size = vec_len (lgm->native_fwd_rpath[rpath_index])
* sizeof (vl_api_gpe_native_fwd_rpath_t);
/* *INDENT-OFF* */
REPLY_MACRO4 (VL_API_GPE_NATIVE_FWD_RPATHS_GET_REPLY, size,
{
- rmp->count = vec_len (lgm->native_fwd_rpath[mp->is_ip4]);
+ rmp->count = vec_len (lgm->native_fwd_rpath[rpath_index]);
gpe_native_fwd_rpaths_copy (rmp->entries,
- lgm->native_fwd_rpath[mp->is_ip4],
+ lgm->native_fwd_rpath[rpath_index],
mp->is_ip4);
gpe_native_fwd_rpaths_get_reply_t_host_to_net (rmp);
});