#include <vnet/span/span.h>
#include <vnet/policer/policer.h>
#include <vnet/policer/police.h>
+#include <vnet/mfib/mfib_types.h>
#include "vat/json_format.h"
return 1;
}
+static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
+static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
+static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
+static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
+
+uword
+unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
+{
+ mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
+ mfib_itf_attribute_t attr;
+
+ old = *iflags;
+ FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
+ {
+ if (unformat (input, mfib_itf_flag_long_names[attr]))
+ *iflags |= (1 << attr);
+ }
+ FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
+ {
+ if (unformat (input, mfib_itf_flag_names[attr]))
+ *iflags |= (1 << attr);
+ }
+
+ return (old == *iflags ? 0 : 1);
+}
+
+uword
+unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
+{
+ mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
+ mfib_entry_attribute_t attr;
+
+ old = *eflags;
+ FOR_EACH_MFIB_ATTRIBUTE (attr)
+ {
+ if (unformat (input, mfib_flag_long_names[attr]))
+ *eflags |= (1 << attr);
+ }
+ FOR_EACH_MFIB_ATTRIBUTE (attr)
+ {
+ if (unformat (input, mfib_flag_names[attr]))
+ *eflags |= (1 << attr);
+ }
+
+ return (old == *eflags ? 0 : 1);
+}
+
#if (VPP_API_TEST_BUILTIN==0)
u8 *
format_ip4_address (u8 * s, va_list * args)
vec_free (s);
}
+static void
+api_lisp_gpe_fwd_entry_net_to_host (vl_api_lisp_gpe_fwd_entry_t * e)
+{
+ e->dp_table = clib_net_to_host_u32 (e->dp_table);
+ e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
+}
+
+static void
+ lisp_gpe_fwd_entries_get_reply_t_net_to_host
+ (vl_api_lisp_gpe_fwd_entries_get_reply_t * mp)
+{
+ u32 i;
+
+ mp->count = clib_net_to_host_u32 (mp->count);
+ for (i = 0; i < mp->count; i++)
+ {
+ api_lisp_gpe_fwd_entry_net_to_host (&mp->entries[i]);
+ }
+}
+
+static void
+ vl_api_lisp_gpe_fwd_entry_path_details_t_handler
+ (vl_api_lisp_gpe_fwd_entry_path_details_t * mp)
+{
+ vat_main_t *vam = &vat_main;
+ u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
+
+ if (mp->lcl_loc.is_ip4)
+ format_ip_address_fcn = format_ip4_address;
+ else
+ format_ip_address_fcn = format_ip6_address;
+
+ print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
+ format_ip_address_fcn, &mp->lcl_loc,
+ format_ip_address_fcn, &mp->rmt_loc);
+}
+
+static void
+lisp_fill_locator_node (vat_json_node_t * n, vl_api_lisp_gpe_locator_t * loc)
+{
+ struct in6_addr ip6;
+ struct in_addr ip4;
+
+ if (loc->is_ip4)
+ {
+ clib_memcpy (&ip4, loc->addr, sizeof (ip4));
+ vat_json_object_add_ip4 (n, "address", ip4);
+ }
+ else
+ {
+ clib_memcpy (&ip6, loc->addr, sizeof (ip6));
+ vat_json_object_add_ip6 (n, "address", ip6);
+ }
+ vat_json_object_add_uint (n, "weight", loc->weight);
+}
+
+static void
+ vl_api_lisp_gpe_fwd_entry_path_details_t_handler_json
+ (vl_api_lisp_gpe_fwd_entry_path_details_t * mp)
+{
+ vat_main_t *vam = &vat_main;
+ vat_json_node_t *node = NULL;
+ vat_json_node_t *loc_node;
+
+ if (VAT_JSON_ARRAY != vam->json_tree.type)
+ {
+ ASSERT (VAT_JSON_NONE == vam->json_tree.type);
+ vat_json_init_array (&vam->json_tree);
+ }
+ node = vat_json_array_add (&vam->json_tree);
+ vat_json_init_object (node);
+
+ loc_node = vat_json_object_add (node, "local_locator");
+ vat_json_init_object (loc_node);
+ lisp_fill_locator_node (loc_node, &mp->lcl_loc);
+
+ loc_node = vat_json_object_add (node, "remote_locator");
+ vat_json_init_object (loc_node);
+ lisp_fill_locator_node (loc_node, &mp->rmt_loc);
+}
+
+static void
+ vl_api_lisp_gpe_fwd_entries_get_reply_t_handler
+ (vl_api_lisp_gpe_fwd_entries_get_reply_t * mp)
+{
+ vat_main_t *vam = &vat_main;
+ u32 i;
+ int retval = clib_net_to_host_u32 (mp->retval);
+ vl_api_lisp_gpe_fwd_entry_t *e;
+
+ if (retval)
+ goto end;
+
+ lisp_gpe_fwd_entries_get_reply_t_net_to_host (mp);
+
+ for (i = 0; i < mp->count; i++)
+ {
+ e = &mp->entries[i];
+ print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
+ format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
+ format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
+ }
+
+end:
+ vam->retval = retval;
+ vam->result_ready = 1;
+}
+
+static void
+ vl_api_lisp_gpe_fwd_entries_get_reply_t_handler_json
+ (vl_api_lisp_gpe_fwd_entries_get_reply_t * mp)
+{
+ u8 *s = 0;
+ vat_main_t *vam = &vat_main;
+ vat_json_node_t *e = 0, root;
+ u32 i;
+ int retval = clib_net_to_host_u32 (mp->retval);
+ vl_api_lisp_gpe_fwd_entry_t *fwd;
+
+ if (retval)
+ goto end;
+
+ lisp_gpe_fwd_entries_get_reply_t_net_to_host (mp);
+ vat_json_init_array (&root);
+
+ for (i = 0; i < mp->count; i++)
+ {
+ e = vat_json_array_add (&root);
+ fwd = &mp->entries[i];
+
+ vat_json_init_object (e);
+ vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
+ vat_json_object_add_int (e, "dp_table", fwd->dp_table);
+
+ s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
+ fwd->leid_prefix_len);
+ vec_add1 (s, 0);
+ vat_json_object_add_string_copy (e, "leid", s);
+ vec_free (s);
+
+ s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
+ fwd->reid_prefix_len);
+ vec_add1 (s, 0);
+ vat_json_object_add_string_copy (e, "reid", s);
+ vec_free (s);
+ }
+
+ vat_json_print (vam->ofp, &root);
+ vat_json_free (&root);
+
+end:
+ vam->retval = retval;
+ vam->result_ready = 1;
+}
+
static void
vl_api_lisp_adjacencies_get_reply_t_handler
(vl_api_lisp_adjacencies_get_reply_t * mp)
_(sw_interface_set_l2_xconnect_reply) \
_(l2fib_add_del_reply) \
_(ip_add_del_route_reply) \
+_(ip_mroute_add_del_reply) \
_(mpls_route_add_del_reply) \
_(mpls_ip_bind_unbind_reply) \
_(proxy_arp_add_del_reply) \
_(TAP_DELETE_REPLY, tap_delete_reply) \
_(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
_(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
+_(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
_(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
_(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
_(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
_(LISP_MAP_RESOLVER_DETAILS, lisp_map_resolver_details) \
_(LISP_MAP_SERVER_DETAILS, lisp_map_server_details) \
_(LISP_ADJACENCIES_GET_REPLY, lisp_adjacencies_get_reply) \
+_(LISP_GPE_FWD_ENTRIES_GET_REPLY, lisp_gpe_fwd_entries_get_reply) \
+_(LISP_GPE_FWD_ENTRY_PATH_DETAILS, \
+ lisp_gpe_fwd_entry_path_details) \
_(SHOW_LISP_STATUS_REPLY, show_lisp_status_reply) \
_(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
lisp_add_del_map_request_itr_rlocs_reply) \
f64 timeout;
u32 sw_if_index = 0;
u8 sw_if_index_set = 0;
- u8 is_enable = 0;
+ u8 is_enable = 1;
u8 is_ipv6 = 0;
/* Parse args required to build the message */
return (vam->retval);
}
+static int
+api_ip_mroute_add_del (vat_main_t * vam)
+{
+ unformat_input_t *i = vam->input;
+ vl_api_ip_mroute_add_del_t *mp;
+ f64 timeout;
+ u32 sw_if_index = ~0, vrf_id = 0;
+ u8 is_ipv6 = 0;
+ u8 is_local = 0;
+ u8 create_vrf_if_needed = 0;
+ u8 is_add = 1;
+ u8 address_set = 0;
+ u32 grp_address_length = 0;
+ ip4_address_t v4_grp_address, v4_src_address;
+ ip6_address_t v6_grp_address, v6_src_address;
+ mfib_itf_flags_t iflags = 0;
+ mfib_entry_flags_t eflags = 0;
+
+ /* Parse args required to build the message */
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (i, "sw_if_index %d", &sw_if_index))
+ ;
+ else if (unformat (i, "%U %U",
+ unformat_ip4_address, &v4_src_address,
+ unformat_ip4_address, &v4_grp_address))
+ {
+ grp_address_length = 64;
+ address_set = 1;
+ is_ipv6 = 0;
+ }
+ else if (unformat (i, "%U %U",
+ unformat_ip6_address, &v6_src_address,
+ unformat_ip6_address, &v6_grp_address))
+ {
+ grp_address_length = 256;
+ address_set = 1;
+ is_ipv6 = 1;
+ }
+ else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
+ {
+ memset (&v4_src_address, 0, sizeof (v4_src_address));
+ grp_address_length = 32;
+ address_set = 1;
+ is_ipv6 = 0;
+ }
+ else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
+ {
+ memset (&v6_src_address, 0, sizeof (v6_src_address));
+ grp_address_length = 128;
+ address_set = 1;
+ is_ipv6 = 1;
+ }
+ else if (unformat (i, "/%d", &grp_address_length))
+ ;
+ else if (unformat (i, "local"))
+ {
+ is_local = 1;
+ }
+ else if (unformat (i, "del"))
+ is_add = 0;
+ else if (unformat (i, "add"))
+ is_add = 1;
+ else if (unformat (i, "vrf %d", &vrf_id))
+ ;
+ else if (unformat (i, "create-vrf"))
+ create_vrf_if_needed = 1;
+ else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
+ ;
+ else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
+ ;
+ else
+ {
+ clib_warning ("parse error '%U'", format_unformat_error, i);
+ return -99;
+ }
+ }
+
+ if (address_set == 0)
+ {
+ errmsg ("missing addresses\n");
+ return -99;
+ }
+
+ /* Construct the API message */
+ M (IP_MROUTE_ADD_DEL, ip_mroute_add_del);
+
+ mp->next_hop_sw_if_index = ntohl (sw_if_index);
+ mp->table_id = ntohl (vrf_id);
+ mp->create_vrf_if_needed = create_vrf_if_needed;
+
+ mp->is_add = is_add;
+ mp->is_ipv6 = is_ipv6;
+ mp->is_local = is_local;
+ mp->itf_flags = ntohl (iflags);
+ mp->entry_flags = ntohl (eflags);
+ mp->grp_address_length = grp_address_length;
+ mp->grp_address_length = ntohs (mp->grp_address_length);
+
+ if (is_ipv6)
+ {
+ clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
+ clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
+ }
+ else
+ {
+ clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
+ clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
+
+ }
+
+ /* send it... */
+ S;
+ /* Wait for a reply... */
+ W;
+}
+
static int
api_mpls_route_add_del (vat_main_t * vam)
{
if (unformat
(i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
{
-#if DPDK_CRYPTO==1
- if (integ_alg < IPSEC_INTEG_ALG_NONE ||
-#else
if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
-#endif
integ_alg >= IPSEC_INTEG_N_ALG)
{
clib_warning ("unsupported integ-alg: '%U'",
}
-#if DPDK_CRYPTO==1
- /*Special cases, aes-gcm-128 encryption */
- if (crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_128)
- {
- if (integ_alg != IPSEC_INTEG_ALG_NONE
- && integ_alg != IPSEC_INTEG_ALG_AES_GCM_128)
- {
- clib_warning
- ("unsupported: aes-gcm-128 crypto-alg needs none as integ-alg");
- return -99;
- }
- else /*set integ-alg internally to aes-gcm-128 */
- integ_alg = IPSEC_INTEG_ALG_AES_GCM_128;
- }
- else if (integ_alg == IPSEC_INTEG_ALG_AES_GCM_128)
- {
- clib_warning ("unsupported integ-alg: aes-gcm-128");
- return -99;
- }
- else if (integ_alg == IPSEC_INTEG_ALG_NONE)
- {
- clib_warning ("unsupported integ-alg: none");
- return -99;
- }
-#endif
-
-
M (IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry);
mp->sad_id = ntohl (sad_id);
return 0;
}
+static int
+api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
+{
+ unformat_input_t *i = vam->input;
+ vl_api_lisp_gpe_fwd_entries_get_t *mp;
+ f64 timeout = ~0;
+ u8 vni_set = 0;
+ u32 vni = ~0;
+
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (i, "vni %d", &vni))
+ {
+ vni_set = 1;
+ }
+ else
+ {
+ errmsg ("parse error '%U'", format_unformat_error, i);
+ return -99;
+ }
+ }
+
+ if (!vni_set)
+ {
+ errmsg ("vni not set!");
+ return -99;
+ }
+
+ if (!vam->json_output)
+ {
+ print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
+ "leid", "reid");
+ }
+
+ M (LISP_GPE_FWD_ENTRIES_GET, lisp_gpe_fwd_entries_get);
+ mp->vni = clib_host_to_net_u32 (vni);
+
+ /* send it... */
+ S;
+
+ /* Wait for a reply... */
+ W;
+
+ /* NOTREACHED */
+ return 0;
+}
+
+#define vl_api_lisp_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
+#define vl_api_lisp_gpe_fwd_entries_get_reply_t_print vl_noop_handler
+#define vl_api_lisp_gpe_fwd_entry_path_details_t_endian vl_noop_handler
+#define vl_api_lisp_gpe_fwd_entry_path_details_t_print vl_noop_handler
+
static int
api_lisp_adjacencies_get (vat_main_t * vam)
{
return 0;
}
+static int
+api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
+{
+ vl_api_lisp_gpe_fwd_entry_path_dump_t *mp;
+ f64 timeout = ~0;
+ unformat_input_t *i = vam->input;
+ u32 fwd_entry_index = ~0;
+
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (i, "index %d", &fwd_entry_index))
+ ;
+ else
+ break;
+ }
+
+ if (~0 == fwd_entry_index)
+ {
+ errmsg ("no index specified!");
+ return -99;
+ }
+
+ if (!vam->json_output)
+ {
+ print (vam->ofp, "first line");
+ }
+
+ M (LISP_GPE_FWD_ENTRY_PATH_DUMP, lisp_gpe_fwd_entry_path_dump);
+
+ /* send it... */
+ S;
+ /* Use a control ping for synchronization */
+ {
+ vl_api_control_ping_t *mp;
+ M (CONTROL_PING, control_ping);
+ S;
+ }
+ /* Wait for a reply... */
+ W;
+
+ /* NOTREACHED */
+ return 0;
+}
+
static int
api_lisp_get_map_request_itr_rlocs (vat_main_t * vam)
{
vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
- vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
+ if (0 != sw_if_to_name)
+ {
+ vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
+ }
vat_json_object_add_uint (node, "state", mp->state);
}
_(sw_interface_set_vpath, \
"<intfc> | sw_if_index <id> enable | disable") \
_(sw_interface_set_vxlan_bypass, \
- "<intfc> | sw_if_index <id> [ip4 | ip6] enable | disable") \
+ "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
_(sw_interface_set_l2_xconnect, \
"rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
"enable | disable") \
"[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
"[weight <n>] [drop] [local] [classify <n>] [del]\n" \
"[multipath] [count <n>]") \
+_(ip_mroute_add_del, \
+ "<src> <grp>/<mask> [table-id <n>]\n" \
+ "[<intfc> | sw_if_index <id>] [local] [del]") \
_(mpls_route_add_del, \
"<label> <eos> via <addr> [table-id <n>]\n" \
"[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
_(lisp_map_resolver_dump, "") \
_(lisp_map_server_dump, "") \
_(lisp_adjacencies_get, "vni <vni>") \
+_(lisp_gpe_fwd_entries_get, "vni <vni>") \
+_(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
_(show_lisp_rloc_probe_state, "") \
_(show_lisp_map_register_state, "") \
_(show_lisp_status, "") \