#include <vnet/ipsec-gre/ipsec_gre.h>
#include <vnet/flow/flow_report_classify.h>
#include <vnet/ip/punt.h>
+#include <vnet/feature/feature.h>
#undef BIHASH_TYPE
#undef __included_bihash_template_h__
#include <vnet/l2/l2_fib.h>
#include <vnet/l2/l2_bd.h>
#include <vpp-api/vpe_msg_enum.h>
+#include <vnet/span/span.h>
#include <vnet/fib/ip6_fib.h>
#include <vnet/fib/ip4_fib.h>
_(IPFIX_CLASSIFY_STREAM_DUMP, ipfix_classify_stream_dump) \
_(IPFIX_CLASSIFY_TABLE_ADD_DEL, ipfix_classify_table_add_del) \
_(IPFIX_CLASSIFY_TABLE_DUMP, ipfix_classify_table_dump) \
+_(SW_INTERFACE_SPAN_ENABLE_DISABLE, sw_interface_span_enable_disable) \
+_(SW_INTERFACE_SPAN_DUMP, sw_interface_span_dump) \
_(GET_NEXT_INDEX, get_next_index) \
_(PG_CREATE_INTERFACE, pg_create_interface) \
_(PG_CAPTURE, pg_capture) \
_(L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite) \
_(PUNT, punt) \
_(FLOW_CLASSIFY_SET_INTERFACE, flow_classify_set_interface) \
-_(FLOW_CLASSIFY_DUMP, flow_classify_dump)
+_(FLOW_CLASSIFY_DUMP, flow_classify_dump) \
+_(IPSEC_SPD_DUMP, ipsec_spd_dump) \
+_(IP_FIB_DUMP, ip_fib_dump) \
+_(IP_FIB_DETAILS, ip_fib_details) \
+_(IP6_FIB_DUMP, ip6_fib_dump) \
+_(IP6_FIB_DETAILS, ip6_fib_details) \
+_(FEATURE_ENABLE_DISABLE, feature_enable_disable)
#define QUOTE_(x) #x
#define QUOTE(x) QUOTE_(x)
}
dpo_set (&dpo, DPO_CLASSIFY, dproto,
- classify_dpo_create (prefix->fp_proto,
+ classify_dpo_create (dproto,
ntohl (classify_table_index)));
}
else
static void
vl_api_sw_interface_set_vpath_t_handler (vl_api_sw_interface_set_vpath_t * mp)
{
- vlib_main_t *vm = vlib_get_main ();
- ip4_main_t *im4 = &ip4_main;
- ip6_main_t *im6 = &ip6_main;
vl_api_sw_interface_set_vpath_reply_t *rmp;
int rv = 0;
- u32 ci;
u32 sw_if_index = ntohl (mp->sw_if_index);
- ip4_main_t *ip4m = &ip4_main;
- ip6_main_t *ip6m = &ip6_main;
- ip_lookup_main_t *ip4lm = &ip4m->lookup_main;
- ip_lookup_main_t *ip6lm = &ip6m->lookup_main;
- ip_config_main_t *rx_cm4u =
- &ip4lm->feature_config_mains[VNET_IP_RX_UNICAST_FEAT];
- ip_config_main_t *rx_cm4m =
- &ip4lm->feature_config_mains[VNET_IP_RX_MULTICAST_FEAT];
- ip_config_main_t *rx_cm6u =
- &ip6lm->feature_config_mains[VNET_IP_RX_UNICAST_FEAT];
- ip_config_main_t *rx_cm6m =
- &ip6lm->feature_config_mains[VNET_IP_RX_MULTICAST_FEAT];
VALIDATE_SW_IF_INDEX (mp);
l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_VPATH, mp->enable);
- if (mp->enable)
- {
- ci = rx_cm4u->config_index_by_sw_if_index[sw_if_index]; //IP4 unicast
- ci = vnet_config_add_feature (vm, &rx_cm4u->config_main,
- ci,
- im4->ip4_unicast_rx_feature_vpath, 0, 0);
- rx_cm4u->config_index_by_sw_if_index[sw_if_index] = ci;
- ci = rx_cm4m->config_index_by_sw_if_index[sw_if_index]; //IP4 mcast
- ci = vnet_config_add_feature (vm, &rx_cm4m->config_main,
- ci,
- im4->ip4_multicast_rx_feature_vpath,
- 0, 0);
- rx_cm4m->config_index_by_sw_if_index[sw_if_index] = ci;
- ci = rx_cm6u->config_index_by_sw_if_index[sw_if_index]; //IP6 unicast
- ci = vnet_config_add_feature (vm, &rx_cm6u->config_main,
- ci,
- im6->ip6_unicast_rx_feature_vpath, 0, 0);
- rx_cm6u->config_index_by_sw_if_index[sw_if_index] = ci;
- ci = rx_cm6m->config_index_by_sw_if_index[sw_if_index]; //IP6 mcast
- ci = vnet_config_add_feature (vm, &rx_cm6m->config_main,
- ci,
- im6->ip6_multicast_rx_feature_vpath,
- 0, 0);
- rx_cm6m->config_index_by_sw_if_index[sw_if_index] = ci;
- }
- else
- {
- ci = rx_cm4u->config_index_by_sw_if_index[sw_if_index]; //IP4 unicast
- ci = vnet_config_del_feature (vm, &rx_cm4u->config_main,
- ci,
- im4->ip4_unicast_rx_feature_vpath, 0, 0);
- rx_cm4u->config_index_by_sw_if_index[sw_if_index] = ci;
- ci = rx_cm4m->config_index_by_sw_if_index[sw_if_index]; //IP4 mcast
- ci = vnet_config_del_feature (vm, &rx_cm4m->config_main,
- ci,
- im4->ip4_multicast_rx_feature_vpath,
- 0, 0);
- rx_cm4m->config_index_by_sw_if_index[sw_if_index] = ci;
- ci = rx_cm6u->config_index_by_sw_if_index[sw_if_index]; //IP6 unicast
- ci = vnet_config_del_feature (vm, &rx_cm6u->config_main,
- ci,
- im6->ip6_unicast_rx_feature_vpath, 0, 0);
- rx_cm6u->config_index_by_sw_if_index[sw_if_index] = ci;
- ci = rx_cm6m->config_index_by_sw_if_index[sw_if_index]; //IP6 mcast
- ci = vnet_config_del_feature (vm, &rx_cm6m->config_main,
- ci,
- im6->ip6_multicast_rx_feature_vpath,
- 0, 0);
- rx_cm6m->config_index_by_sw_if_index[sw_if_index] = ci;
- }
+ vnet_feature_enable_disable ("ip4-unicast", "vpath-input-ip4",
+ sw_if_index, mp->enable, 0, 0);
+ vnet_feature_enable_disable ("ip4-multicast", "vpath-input-ip4",
+ sw_if_index, mp->enable, 0, 0);
+ vnet_feature_enable_disable ("ip6-unicast", "vpath-input-ip6",
+ sw_if_index, mp->enable, 0, 0);
+ vnet_feature_enable_disable ("ip6-multicast", "vpath-input-ip6",
+ sw_if_index, mp->enable, 0, 0);
BAD_SW_IF_INDEX_LABEL;
vl_api_dhcp_proxy_config_reply_t *rmp;
int rv = -1;
-#if 0 // $$$$ FIXME
rv = dhcpv6_proxy_set_server_2 ((ip6_address_t *) (&mp->dhcp_server),
(ip6_address_t *) (&mp->dhcp_src_address),
(u32) ntohl (mp->rx_vrf_id),
(u32) ntohl (mp->server_vrf_id),
(int) mp->insert_circuit_id,
(int) (mp->is_add == 0));
-#else
- rv = VNET_API_ERROR_UNIMPLEMENTED;
-#endif
REPLY_MACRO (VL_API_DHCP_PROXY_CONFIG_2_REPLY);
}
_(skip_n_vectors) \
_(match_n_vectors) \
_(next_table_index) \
-_(miss_next_index)
+_(miss_next_index) \
+_(current_data_flag) \
+_(current_data_offset)
static void vl_api_classify_add_del_table_t_handler
(vl_api_classify_add_del_table_t * mp)
#undef _
/* The underlying API fails silently, on purpose, so check here */
- if (mp->is_add == 0)
- if (pool_is_free_index (cm->tables, table_index))
- {
- rv = VNET_API_ERROR_NO_SUCH_TABLE;
- goto out;
- }
+ if (mp->is_add == 0) /* delete */
+ {
+ if (pool_is_free_index (cm->tables, table_index))
+ {
+ rv = VNET_API_ERROR_NO_SUCH_TABLE;
+ goto out;
+ }
+ }
+ else /* add or update */
+ {
+ if (table_index != ~0 && pool_is_free_index (cm->tables, table_index))
+ table_index = ~0;
+ }
rv = vnet_classify_add_del_table
(cm, mp->mask, nbuckets, memory_size,
skip_n_vectors, match_n_vectors,
- next_table_index, miss_next_index, &table_index, mp->is_add);
+ next_table_index, miss_next_index, &table_index,
+ current_data_flag, current_data_offset, mp->is_add);
out:
/* *INDENT-OFF* */
vnet_classify_main_t *cm = &vnet_classify_main;
vl_api_classify_add_del_session_reply_t *rmp;
int rv;
- u32 table_index, hit_next_index, opaque_index;
+ u32 table_index, hit_next_index, opaque_index, metadata;
i32 advance;
+ u8 action;
table_index = ntohl (mp->table_index);
hit_next_index = ntohl (mp->hit_next_index);
opaque_index = ntohl (mp->opaque_index);
advance = ntohl (mp->advance);
+ action = mp->action;
+ metadata = ntohl (mp->metadata);
rv = vnet_classify_add_del_session
(cm, table_index, mp->match, hit_next_index, opaque_index,
- advance, mp->is_add);
+ advance, action, metadata, mp->is_add);
REPLY_MACRO (VL_API_CLASSIFY_ADD_DEL_SESSION_REPLY);
}
vnet_main_t *vnm = vnet_get_main ();
vlib_main_t *vm = vlib_get_main ();
-#if DPDK > 0 && DPDK_VHOST_USER
- rv = dpdk_vhost_user_create_if (
-#else
- rv = vhost_user_create_if (
-#endif
- vnm, vm, (char *) mp->sock_filename,
- mp->is_server, &sw_if_index, (u64) ~ 0,
- mp->renumber, ntohl (mp->custom_dev_instance),
- (mp->use_custom_mac) ? mp->mac_address : NULL);
+ rv = vhost_user_create_if (vnm, vm, (char *) mp->sock_filename,
+ mp->is_server, &sw_if_index, (u64) ~ 0,
+ mp->renumber, ntohl (mp->custom_dev_instance),
+ (mp->use_custom_mac) ? mp->mac_address : NULL);
/* *INDENT-OFF* */
REPLY_MACRO2(VL_API_CREATE_VHOST_USER_IF_REPLY,
vnet_main_t *vnm = vnet_get_main ();
vlib_main_t *vm = vlib_get_main ();
-#if DPDK > 0 && DPDK_VHOST_USER
- rv = dpdk_vhost_user_modify_if (
-#else
- rv = vhost_user_modify_if (
-#endif
- vnm, vm, (char *) mp->sock_filename,
- mp->is_server, sw_if_index, (u64) ~ 0,
- mp->renumber, ntohl (mp->custom_dev_instance));
+ rv = vhost_user_modify_if (vnm, vm, (char *) mp->sock_filename,
+ mp->is_server, sw_if_index, (u64) ~ 0,
+ mp->renumber, ntohl (mp->custom_dev_instance));
REPLY_MACRO (VL_API_MODIFY_VHOST_USER_IF_REPLY);
}
vnet_main_t *vnm = vnet_get_main ();
vlib_main_t *vm = vlib_get_main ();
-#if DPDK > 0 && DPDK_VHOST_USER
- rv = dpdk_vhost_user_delete_if (vnm, vm, sw_if_index);
-#else
rv = vhost_user_delete_if (vnm, vm, sw_if_index);
-#endif
REPLY_MACRO (VL_API_DELETE_VHOST_USER_IF_REPLY);
if (!rv)
if (q == 0)
return;
-#if DPDK > 0 && DPDK_VHOST_USER
- rv = dpdk_vhost_user_dump_ifs (vnm, vm, &ifaces);
-#else
rv = vhost_user_dump_ifs (vnm, vm, &ifaces);
-#endif
if (rv)
return;
else
{
u32 *tp = (u32 *) mp->ip;
- *tp = ntohl (*(u32 *) ip);
+ *tp = *(u32 *) ip;
}
mp->prefix_length = prefix_length;
mp->context = context;
vl_api_vxlan_tunnel_details_t *rmp;
ip4_main_t *im4 = &ip4_main;
ip6_main_t *im6 = &ip6_main;
- u8 is_ipv6 = !(t->flags & VXLAN_TUNNEL_IS_IPV4);
+ u8 is_ipv6 = !ip46_address_is_ip4 (&t->dst);
rmp = vl_msg_api_alloc (sizeof (*rmp));
memset (rmp, 0, sizeof (*rmp));
rmp->encap_vrf_id = htonl (im4->fibs[t->encap_fib_index].ft_table_id);
}
rmp->vni = htonl (t->vni);
- rmp->decap_next_index = htonl (t->decap_next_index);
+ /* decap_next_index is deprecated, hard code to l2-input */
+ rmp->decap_next_index = htonl (VXLAN_INPUT_NEXT_L2_INPUT);
rmp->sw_if_index = htonl (t->sw_if_index);
rmp->is_ipv6 = is_ipv6;
rmp->context = context;
/* Ignoring the profile id as currently a single profile
* is supported */
- error = ip6_ioam_enable (mp->trace_enable, mp->pow_enable, mp->trace_ppc);
+ error = ip6_ioam_enable (mp->trace_enable, mp->pot_enable,
+ mp->seqno, mp->analyse);
if (error)
{
clib_error_report (error);
clib_warning ("BUG");
}
+static void
+vl_api_mpls_fib_details_t_endian (vl_api_mpls_fib_details_t * mp)
+{
+ clib_warning ("BUG");
+}
+
+static void
+vl_api_mpls_fib_details_t_print (vl_api_mpls_fib_details_t * mp)
+{
+ clib_warning ("BUG");
+}
+
+
+static void
+copy_fib_next_hop (fib_route_path_encode_t * api_rpath,
+ vl_api_fib_path_t * fp)
+{
+ int is_ip4;
+
+ if (api_rpath->rpath.frp_proto == FIB_PROTOCOL_IP4)
+ fp->afi = IP46_TYPE_IP4;
+ else if (api_rpath->rpath.frp_proto == FIB_PROTOCOL_IP6)
+ fp->afi = IP46_TYPE_IP6;
+ else
+ {
+ is_ip4 = ip46_address_is_ip4 (&api_rpath->rpath.frp_addr);
+ if (is_ip4)
+ fp->afi = IP46_TYPE_IP4;
+ else
+ fp->afi = IP46_TYPE_IP6;
+ }
+ if (fp->afi == IP46_TYPE_IP4)
+ memcpy (fp->next_hop, &api_rpath->rpath.frp_addr.ip4,
+ sizeof (api_rpath->rpath.frp_addr.ip4));
+ else
+ memcpy (fp->next_hop, &api_rpath->rpath.frp_addr.ip6,
+ sizeof (api_rpath->rpath.frp_addr.ip6));
+}
+
static void
send_mpls_fib_details (vpe_api_main_t * am,
unix_shared_memory_queue_t * q,
- u32 table_id, u32 label, u32 eos, u32 context)
+ u32 table_id, u32 label, u32 eos,
+ fib_route_path_encode_t * api_rpaths, u32 context)
{
vl_api_mpls_fib_details_t *mp;
+ fib_route_path_encode_t *api_rpath;
+ vl_api_fib_path_t *fp;
+ int path_count;
- mp = vl_msg_api_alloc (sizeof (*mp));
+ path_count = vec_len (api_rpaths);
+ mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
+ if (!mp)
+ return;
memset (mp, 0, sizeof (*mp));
mp->_vl_msg_id = ntohs (VL_API_MPLS_FIB_DETAILS);
mp->context = context;
mp->eos_bit = eos;
mp->label = htonl (label);
+ mp->count = htonl (path_count);
+ fp = mp->path;
+ vec_foreach (api_rpath, api_rpaths)
+ {
+ memset (fp, 0, sizeof (*fp));
+ fp->weight = htonl (api_rpath->rpath.frp_weight);
+ fp->sw_if_index = htonl (api_rpath->rpath.frp_sw_if_index);
+ copy_fib_next_hop (api_rpath, fp);
+ fp++;
+ }
+
vl_msg_api_send_shmem (q, (u8 *) & mp);
}
mpls_label_t key;
fib_prefix_t pfx;
u32 fib_index;
+ fib_route_path_encode_t *api_rpaths;
q = vl_api_client_index_to_input_queue (mp->client_index);
if (q == 0)
{
fib_entry_get_prefix(*lfeip, &pfx);
fib_index = fib_entry_get_fib_index(*lfeip);
-
fib_table = fib_table_get(fib_index, pfx.fp_proto);
-
+ api_rpaths = NULL;
+ fib_entry_encode(*lfeip, &api_rpaths);
send_mpls_fib_details (am, q,
fib_table->ft_table_id,
pfx.fp_label,
pfx.fp_eos,
+ api_rpaths,
mp->context);
+ vec_free(api_rpaths);
+ }
+
+ vec_free (lfeis);
+}
+
+static void
+vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
+{
+ clib_warning ("BUG");
+}
+
+static void
+vl_api_ip_fib_details_t_endian (vl_api_ip_fib_details_t * mp)
+{
+ clib_warning ("BUG");
+}
+
+static void
+vl_api_ip_fib_details_t_print (vl_api_ip_fib_details_t * mp)
+{
+ clib_warning ("BUG");
+}
+
+static void
+send_ip_fib_details (vpe_api_main_t * am,
+ unix_shared_memory_queue_t * q,
+ u32 table_id, fib_prefix_t *pfx,
+ fib_route_path_encode_t *api_rpaths, u32 context)
+{
+ vl_api_ip_fib_details_t *mp;
+ fib_route_path_encode_t *api_rpath;
+ vl_api_fib_path_t *fp;
+ int path_count;
+
+ path_count = vec_len(api_rpaths);
+ mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
+ if (!mp)
+ return;
+ memset (mp, 0, sizeof (*mp));
+ mp->_vl_msg_id = ntohs (VL_API_IP_FIB_DETAILS);
+ mp->context = context;
+
+ mp->table_id = htonl (table_id);
+ mp->address_length = pfx->fp_len;
+ memcpy(mp->address, &pfx->fp_addr.ip4, sizeof(pfx->fp_addr.ip4));
+
+ mp->count = htonl (path_count);
+ fp = mp->path;
+ vec_foreach(api_rpath, api_rpaths)
+ {
+ memset (fp, 0, sizeof (*fp));
+ switch (api_rpath->dpo.dpoi_type)
+ {
+ case DPO_RECEIVE:
+ fp->is_local = true;
+ break;
+ case DPO_DROP:
+ fp->is_drop = true;
+ break;
+ case DPO_IP_NULL:
+ switch (api_rpath->dpo.dpoi_index)
+ {
+ case IP_NULL_ACTION_NONE:
+ fp->is_drop = true;
+ break;
+ case IP_NULL_ACTION_SEND_ICMP_UNREACH:
+ fp->is_unreach = true;
+ break;
+ case IP_NULL_ACTION_SEND_ICMP_PROHIBIT:
+ fp->is_prohibit = true;
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ fp->weight = htonl(api_rpath->rpath.frp_weight);
+ fp->sw_if_index = htonl(api_rpath->rpath.frp_sw_if_index);
+ copy_fib_next_hop (api_rpath, fp);
+ fp++;
+ }
+
+ vl_msg_api_send_shmem (q, (u8 *) & mp);
+}
+
+static void
+vl_api_ip_fib_dump_t_handler (vl_api_ip_fib_dump_t * mp)
+{
+ vpe_api_main_t *am = &vpe_api_main;
+ unix_shared_memory_queue_t *q;
+ ip4_main_t *im = &ip4_main;
+ fib_table_t *fib_table;
+ fib_node_index_t lfei, *lfeip, *lfeis = NULL;
+ mpls_label_t key;
+ fib_prefix_t pfx;
+ u32 fib_index;
+ fib_route_path_encode_t *api_rpaths;
+ int i;
+
+ q = vl_api_client_index_to_input_queue (mp->client_index);
+ if (q == 0)
+ return;
+
+ /* *INDENT-OFF* */
+ pool_foreach (fib_table, im->fibs,
+ ({
+ for (i = 0; i < ARRAY_LEN (fib_table->v4.fib_entry_by_dst_address); i++)
+ {
+ hash_foreach(key, lfei, fib_table->v4.fib_entry_by_dst_address[i],
+ ({
+ vec_add1(lfeis, lfei);
+ }));
+ }
+ }));
+
+ vec_sort_with_function(lfeis, fib_entry_cmp_for_sort);
+
+ vec_foreach(lfeip, lfeis)
+ {
+ fib_entry_get_prefix(*lfeip, &pfx);
+ fib_index = fib_entry_get_fib_index(*lfeip);
+ fib_table = fib_table_get(fib_index, pfx.fp_proto);
+ api_rpaths = NULL;
+ fib_entry_encode(*lfeip, &api_rpaths);
+ send_ip_fib_details (am, q,
+ fib_table->ft_table_id,
+ &pfx,
+ api_rpaths,
+ mp->context);
+ vec_free(api_rpaths);
}
vec_free (lfeis);
}
+static void
+vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
+{
+ clib_warning ("BUG");
+}
+
+static void
+vl_api_ip6_fib_details_t_endian (vl_api_ip6_fib_details_t * mp)
+{
+ clib_warning ("BUG");
+}
+
+static void
+vl_api_ip6_fib_details_t_print (vl_api_ip6_fib_details_t * mp)
+{
+ clib_warning ("BUG");
+}
+
+static void
+send_ip6_fib_details (vpe_api_main_t * am,
+ unix_shared_memory_queue_t * q,
+ u32 table_id, fib_prefix_t *pfx,
+ fib_route_path_encode_t *api_rpaths, u32 context)
+{
+ vl_api_ip6_fib_details_t *mp;
+ fib_route_path_encode_t *api_rpath;
+ vl_api_fib_path_t *fp;
+ int path_count;
+
+ path_count = vec_len(api_rpaths);
+ mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
+ if (!mp)
+ return;
+ memset (mp, 0, sizeof (*mp));
+ mp->_vl_msg_id = ntohs (VL_API_IP6_FIB_DETAILS);
+ mp->context = context;
+
+ mp->table_id = htonl (table_id);
+ mp->address_length = pfx->fp_len;
+ memcpy(mp->address, &pfx->fp_addr.ip6, sizeof(pfx->fp_addr.ip6));
+
+ mp->count = htonl (path_count);
+ fp = mp->path;
+ vec_foreach(api_rpath, api_rpaths)
+ {
+ memset (fp, 0, sizeof (*fp));
+ switch (api_rpath->dpo.dpoi_type)
+ {
+ case DPO_RECEIVE:
+ fp->is_local = true;
+ break;
+ case DPO_DROP:
+ fp->is_drop = true;
+ break;
+ case DPO_IP_NULL:
+ switch (api_rpath->dpo.dpoi_index)
+ {
+ case IP_NULL_DPO_ACTION_NUM+IP_NULL_ACTION_NONE:
+ fp->is_drop = true;
+ break;
+ case IP_NULL_DPO_ACTION_NUM+IP_NULL_ACTION_SEND_ICMP_UNREACH:
+ fp->is_unreach = true;
+ break;
+ case IP_NULL_DPO_ACTION_NUM+IP_NULL_ACTION_SEND_ICMP_PROHIBIT:
+ fp->is_prohibit = true;
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ fp->weight = htonl(api_rpath->rpath.frp_weight);
+ fp->sw_if_index = htonl(api_rpath->rpath.frp_sw_if_index);
+ copy_fib_next_hop (api_rpath, fp);
+ fp++;
+ }
+
+ vl_msg_api_send_shmem (q, (u8 *) & mp);
+}
+
+typedef struct apt_ip6_fib_show_ctx_t_ {
+ u32 fib_index;
+ fib_node_index_t *entries;
+} api_ip6_fib_show_ctx_t;
+
+static void
+api_ip6_fib_table_put_entries (clib_bihash_kv_24_8_t * kvp,
+ void *arg)
+{
+ api_ip6_fib_show_ctx_t *ctx = arg;
+
+ if ((kvp->key[2] >> 32) == ctx->fib_index)
+ {
+ vec_add1(ctx->entries, kvp->value);
+ }
+}
+
+static void
+api_ip6_fib_table_get_all (unix_shared_memory_queue_t *q,
+ vl_api_ip6_fib_dump_t *mp,
+ fib_table_t *fib_table)
+{
+ vpe_api_main_t *am = &vpe_api_main;
+ ip6_main_t *im6 = &ip6_main;
+ ip6_fib_t *fib = &fib_table->v6;
+ fib_node_index_t *fib_entry_index;
+ api_ip6_fib_show_ctx_t ctx = {
+ .fib_index = fib->index,
+ .entries = NULL,
+ };
+ fib_route_path_encode_t *api_rpaths;
+ fib_prefix_t pfx;
+
+ BV(clib_bihash_foreach_key_value_pair)
+ ((BVT(clib_bihash) *) &im6->ip6_table[IP6_FIB_TABLE_NON_FWDING].ip6_hash,
+ api_ip6_fib_table_put_entries,
+ &ctx);
+
+ vec_sort_with_function(ctx.entries, fib_entry_cmp_for_sort);
+
+ vec_foreach(fib_entry_index, ctx.entries)
+ {
+ fib_entry_get_prefix(*fib_entry_index, &pfx);
+ api_rpaths = NULL;
+ fib_entry_encode(*fib_entry_index, &api_rpaths);
+ send_ip6_fib_details (am, q,
+ fib_table->ft_table_id,
+ &pfx,
+ api_rpaths,
+ mp->context);
+ vec_free(api_rpaths);
+ }
+
+ vec_free(ctx.entries);
+}
+
+static void
+vl_api_ip6_fib_dump_t_handler (vl_api_ip6_fib_dump_t * mp)
+{
+ unix_shared_memory_queue_t *q;
+ ip6_main_t *im6 = &ip6_main;
+ fib_table_t *fib_table;
+
+ q = vl_api_client_index_to_input_queue (mp->client_index);
+ if (q == 0)
+ return;
+
+ /* *INDENT-OFF* */
+ pool_foreach (fib_table, im6->fibs,
+ ({
+ api_ip6_fib_table_get_all(q, mp, fib_table);
+ }));
+}
+
static void
vl_api_mpls_fib_encap_details_t_handler (vl_api_mpls_fib_encap_details_t * mp)
{
send_ipfix_classify_table_details (i, q, mp->context);
}
+static void
+ vl_api_sw_interface_span_enable_disable_t_handler
+ (vl_api_sw_interface_span_enable_disable_t * mp)
+{
+ vl_api_sw_interface_span_enable_disable_reply_t *rmp;
+ int rv;
+
+ vlib_main_t *vm = vlib_get_main ();
+
+ rv = span_add_delete_entry (vm, ntohl (mp->sw_if_index_from),
+ ntohl (mp->sw_if_index_to), mp->enable);
+
+ REPLY_MACRO (VL_API_SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY);
+}
+
+static void
+vl_api_sw_interface_span_dump_t_handler (vl_api_sw_interface_span_dump_t * mp)
+{
+
+ unix_shared_memory_queue_t *q;
+ vl_api_sw_interface_span_details_t *rmp;
+ span_main_t *sm = &span_main;
+ u32 src_sw_if_index = 0, *dst_sw_if_index;
+
+ q = vl_api_client_index_to_input_queue (mp->client_index);
+ if (!q)
+ return;
+
+ vec_foreach (dst_sw_if_index, sm->dst_by_src_sw_if_index)
+ {
+ if (*dst_sw_if_index > 0)
+ {
+ rmp = vl_msg_api_alloc (sizeof (*rmp));
+ memset (rmp, 0, sizeof (*rmp));
+ rmp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_SPAN_DETAILS);
+ rmp->context = mp->context;
+
+ rmp->sw_if_index_from = htonl (src_sw_if_index);
+ rmp->sw_if_index_to = htonl (*dst_sw_if_index);
+
+ vl_msg_api_send_shmem (q, (u8 *) & rmp);
+ }
+ src_sw_if_index++;
+ }
+}
+
static void
vl_api_pg_create_interface_t_handler (vl_api_pg_create_interface_t * mp)
{
}
}
+static void
+send_ipsec_spd_details (ipsec_policy_t * p, unix_shared_memory_queue_t * q,
+ u32 context)
+{
+ vl_api_ipsec_spd_details_t *mp;
+
+ mp = vl_msg_api_alloc (sizeof (*mp));
+ memset (mp, 0, sizeof (*mp));
+ mp->_vl_msg_id = ntohs (VL_API_IPSEC_SPD_DETAILS);
+ mp->context = context;
+
+ mp->spd_id = htonl (p->id);
+ mp->priority = htonl (p->priority);
+ mp->is_outbound = p->is_outbound;
+ mp->is_ipv6 = p->is_ipv6;
+ if (p->is_ipv6)
+ {
+ memcpy (mp->local_start_addr, &p->laddr.start.ip6, 16);
+ memcpy (mp->local_stop_addr, &p->laddr.stop.ip6, 16);
+ memcpy (mp->remote_start_addr, &p->raddr.start.ip6, 16);
+ memcpy (mp->remote_stop_addr, &p->raddr.stop.ip6, 16);
+ }
+ else
+ {
+ memcpy (mp->local_start_addr, &p->laddr.start.ip4, 4);
+ memcpy (mp->local_stop_addr, &p->laddr.stop.ip4, 4);
+ memcpy (mp->remote_start_addr, &p->raddr.start.ip4, 4);
+ memcpy (mp->remote_stop_addr, &p->raddr.stop.ip4, 4);
+ }
+ mp->local_start_port = htons (p->lport.start);
+ mp->local_stop_port = htons (p->lport.stop);
+ mp->remote_start_port = htons (p->rport.start);
+ mp->remote_stop_port = htons (p->rport.stop);
+ mp->protocol = p->protocol;
+ mp->policy = p->policy;
+ mp->sa_id = htonl (p->sa_id);
+ mp->bytes = clib_host_to_net_u64 (p->counter.bytes);
+ mp->packets = clib_host_to_net_u64 (p->counter.packets);
+
+ vl_msg_api_send_shmem (q, (u8 *) & mp);
+}
+
+static void
+vl_api_ipsec_spd_dump_t_handler (vl_api_ipsec_spd_dump_t * mp)
+{
+ unix_shared_memory_queue_t *q;
+ ipsec_main_t *im = &ipsec_main;
+ ipsec_policy_t *policy;
+ ipsec_spd_t *spd;
+ uword *p;
+ u32 spd_index;
+#if IPSEC > 0
+ q = vl_api_client_index_to_input_queue (mp->client_index);
+ if (q == 0)
+ return;
+
+ p = hash_get (im->spd_index_by_spd_id, ntohl (mp->spd_id));
+ if (!p)
+ return;
+
+ spd_index = p[0];
+ spd = pool_elt_at_index (im->spds, spd_index);
+
+ pool_foreach (policy, spd->policies, (
+ {
+ if (mp->sa_id == ~(0)
+ || ntohl (mp->sa_id) ==
+ policy->sa_id)
+ send_ipsec_spd_details (policy, q,
+ mp->context);}
+ ));
+#else
+ clib_warning ("unimplemented");
+#endif
+}
+
+static void
+vl_api_feature_enable_disable_t_handler (vl_api_feature_enable_disable_t * mp)
+{
+ vl_api_feature_enable_disable_reply_t *rmp;
+ int rv = 0;
+
+ u8 *arc_name = format (0, "%s%c", mp->arc_name, 0);
+ u8 *feature_name = format (0, "%s%c", mp->feature_name, 0);
+
+ vnet_feature_registration_t *reg;
+ reg =
+ vnet_get_feature_reg ((const char *) arc_name,
+ (const char *) feature_name);
+ if (reg == 0)
+ rv = VNET_API_ERROR_INVALID_VALUE;
+ else
+ {
+ u32 sw_if_index;
+ clib_error_t *error = 0;
+
+ sw_if_index = ntohl (mp->sw_if_index);
+ if (reg->enable_disable_cb)
+ error = reg->enable_disable_cb (sw_if_index, mp->enable);
+ if (!error)
+ vnet_feature_enable_disable ((const char *) arc_name,
+ (const char *) feature_name,
+ sw_if_index, mp->enable, 0, 0);
+ else
+ {
+ clib_error_report (error);
+ rv = VNET_API_ERROR_CANNOT_ENABLE_DISABLE_FEATURE;
+ }
+ }
+
+ vec_free (feature_name);
+ vec_free (arc_name);
+
+ REPLY_MACRO (VL_API_FEATURE_ENABLE_DISABLE_REPLY);
+}
+
#define BOUNCE_HANDLER(nn) \
static void vl_api_##nn##_t_handler ( \
vl_api_##nn##_t *mp) \
vl_msg_api_free (mp); \
}
+static void setup_message_id_table (api_main_t * am);
+
/*
* vpe_api_hookup
* Add vpe's API message handlers to the table.
* added the client registration handlers.
* See .../open-repo/vlib/memclnt_vlib.c:memclnt_process()
*/
-
static clib_error_t *
vpe_api_hookup (vlib_main_t * vm)
{
am->is_mp_safe[VL_API_IP_ADD_DEL_ROUTE] = 1;
am->is_mp_safe[VL_API_GET_NODE_GRAPH] = 1;
+ /*
+ * Set up the (msg_name, crc, message-id) table
+ */
+ setup_message_id_table (am);
+
return 0;
}
return (void *) &unformat_vnet_sw_interface;
}
-#undef vl_api_version
-#define vl_api_version(n,v) static u32 vpe_api_version = v;
-#include <vpp-api/vpe.api.h>
-#undef vl_api_version
-
-int
-vl_msg_api_version_check (vl_api_memclnt_create_t * mp)
-{
- if (clib_host_to_net_u32 (mp->api_versions[0]) != vpe_api_version)
- {
- clib_warning ("vpe API mismatch: 0x%08x instead of 0x%08x",
- clib_host_to_net_u32 (mp->api_versions[0]),
- vpe_api_version);
- return -1;
- }
- return 0;
-}
-
static u8 *
format_arp_event (u8 * s, va_list * args)
{
};
/* *INDENT-ON* */
+#define vl_msg_name_crc_list
+#include <vpp-api/vpe_all_api_h.h>
+#undef vl_msg_name_crc_list
+
+static void
+setup_message_id_table (api_main_t * am)
+{
+#define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
+ foreach_vl_msg_name_crc_memclnt;
+ foreach_vl_msg_name_crc_vpe;
+#undef _
+}
+
+
/*
* fd.io coding-style-patch-verification: ON
*