X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=vpp%2Fvpp-api%2Fapi.c;h=4ac0afd30269306fffe4fe6dccd48b52ca8ce293;hb=56f32cc3a77d2c7d82e3ee57779abb30e1dd7586;hp=496c577e9dbff666c15f19182c0becc96be48c23;hpb=bbe3362948415a6fcee8246cc2e419240395d5d4;p=vpp.git diff --git a/vpp/vpp-api/api.c b/vpp/vpp-api/api.c index 496c577e9db..4ac0afd3026 100644 --- a/vpp/vpp-api/api.c +++ b/vpp/vpp-api/api.c @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -71,7 +70,6 @@ #include #include #include -#include #include #include #include @@ -83,9 +81,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -98,26 +94,15 @@ #include #endif -#if IPSEC > 0 -#include -#include -#endif /* IPSEC */ -#include - #include #include - #include #include #include - #include #include #include #include - -#include -#include #include #include #include @@ -126,23 +111,18 @@ #include #include #include - #define vl_typedefs /* define message structures */ #include #undef vl_typedefs - #define vl_endianfun /* define message structures */ #include #undef vl_endianfun - /* instantiate all the print functions we know about */ #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) #define vl_printfun #include #undef vl_printfun - #include - #define foreach_vpe_api_msg \ _(WANT_OAM_EVENTS, want_oam_events) \ _(OAM_ADD_DEL, oam_add_del) \ @@ -187,23 +167,11 @@ _(CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table) \ _(CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables) \ _(GET_NODE_INDEX, get_node_index) \ _(ADD_NODE_NEXT, add_node_next) \ -_(L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel) \ -_(L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies) \ -_(L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable) \ -_(L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key) \ -_(SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump) \ _(VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel) \ _(VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump) \ -_(GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel) \ -_(GRE_TUNNEL_DUMP, gre_tunnel_dump) \ _(L2_FIB_CLEAR_TABLE, l2_fib_clear_table) \ _(L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter) \ _(L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite) \ -_(CREATE_VHOST_USER_IF, create_vhost_user_if) \ -_(MODIFY_VHOST_USER_IF, modify_vhost_user_if) \ -_(DELETE_VHOST_USER_IF, delete_vhost_user_if) \ -_(SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump) \ -_(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \ _(SHOW_VERSION, show_version) \ _(L2_FIB_TABLE_DUMP, l2_fib_table_dump) \ _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \ @@ -213,16 +181,6 @@ _(INTERFACE_NAME_RENUMBER, interface_name_renumber) \ _(WANT_IP4_ARP_EVENTS, want_ip4_arp_events) \ _(WANT_IP6_ND_EVENTS, want_ip6_nd_events) \ _(INPUT_ACL_SET_INTERFACE, input_acl_set_interface) \ -_(IPSEC_SPD_ADD_DEL, ipsec_spd_add_del) \ -_(IPSEC_INTERFACE_ADD_DEL_SPD, ipsec_interface_add_del_spd) \ -_(IPSEC_SPD_ADD_DEL_ENTRY, ipsec_spd_add_del_entry) \ -_(IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry) \ -_(IPSEC_SA_SET_KEY, ipsec_sa_set_key) \ -_(IKEV2_PROFILE_ADD_DEL, ikev2_profile_add_del) \ -_(IKEV2_PROFILE_SET_AUTH, ikev2_profile_set_auth) \ -_(IKEV2_PROFILE_SET_ID, ikev2_profile_set_id) \ -_(IKEV2_PROFILE_SET_TS, ikev2_profile_set_ts) \ -_(IKEV2_SET_LOCAL_KEY, ikev2_set_local_key) \ _(DELETE_LOOPBACK, delete_loopback) \ _(BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del) \ _(COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable) \ @@ -268,8 +226,6 @@ _(POLICER_ADD_DEL, policer_add_del) \ _(POLICER_DUMP, policer_dump) \ _(POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface) \ _(POLICER_CLASSIFY_DUMP, policer_classify_dump) \ -_(NETMAP_CREATE, netmap_create) \ -_(NETMAP_DELETE, netmap_delete) \ _(MPLS_TUNNEL_DUMP, mpls_tunnel_dump) \ _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \ _(MPLS_FIB_DUMP, mpls_fib_dump) \ @@ -293,24 +249,15 @@ _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, \ ip_source_and_port_range_check_add_del) \ _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, \ ip_source_and_port_range_check_interface_add_del) \ -_(IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel) \ -_(IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump) \ _(DELETE_SUBIF, delete_subif) \ _(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) \ -_(IPSEC_SPD_DUMP, ipsec_spd_dump) \ -_(FEATURE_ENABLE_DISABLE, feature_enable_disable) \ -_(BFD_UDP_ADD, bfd_udp_add) \ -_(BFD_UDP_DEL, bfd_udp_del) \ -_(BFD_UDP_SESSION_DUMP, bfd_udp_session_dump) \ -_(BFD_SESSION_SET_FLAGS, bfd_session_set_flags) \ -_(WANT_BFD_EVENTS, want_bfd_events) +_(FEATURE_ENABLE_DISABLE, feature_enable_disable) #define QUOTE_(x) #x #define QUOTE(x) QUOTE_(x) - typedef enum { RESOLVE_IP4_ADD_DEL_ROUTE = 1, @@ -347,7 +294,6 @@ vl_api_memclnt_delete_callback (u32 client_index) } pub_sub_handler (oam_events, OAM_EVENTS); -pub_sub_handler (bfd_events, BFD_EVENTS); #define RESOLUTION_EVENT 1 #define RESOLUTION_PENDING_EVENT 2 @@ -1609,27 +1555,6 @@ static void REPLY_MACRO (VL_API_SW_INTERFACE_SET_MPLS_ENABLE_REPLY); } -/* - * WARNING: replicated pending api refactor completion - */ -static void -send_sw_interface_flags_deleted (vpe_api_main_t * am, - unix_shared_memory_queue_t * q, - u32 sw_if_index) -{ - vl_api_sw_interface_set_flags_t *mp; - - mp = vl_msg_api_alloc (sizeof (*mp)); - memset (mp, 0, sizeof (*mp)); - mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_SET_FLAGS); - mp->sw_if_index = ntohl (sw_if_index); - - mp->admin_up_down = 0; - mp->link_up_down = 0; - mp->deleted = 1; - vl_msg_api_send_shmem (q, (u8 *) & mp); -} - void send_oam_event (oam_target_t * t) { @@ -2585,202 +2510,6 @@ static void REPLY_MACRO (VL_API_L2_INTERFACE_VLAN_TAG_REWRITE_REPLY); } -static void -vl_api_create_vhost_user_if_t_handler (vl_api_create_vhost_user_if_t * mp) -{ - int rv = 0; - vl_api_create_vhost_user_if_reply_t *rmp; - u32 sw_if_index = (u32) ~ 0; - vnet_main_t *vnm = vnet_get_main (); - vlib_main_t *vm = vlib_get_main (); - - 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); - - /* Remember an interface tag for the new interface */ - if (rv == 0) - { - /* If a tag was supplied... */ - if (mp->tag[0]) - { - /* Make sure it's a proper C-string */ - mp->tag[ARRAY_LEN (mp->tag) - 1] = 0; - u8 *tag = format (0, "%s%c", mp->tag, 0); - vnet_set_sw_interface_tag (vnm, tag, sw_if_index); - } - } - - /* *INDENT-OFF* */ - REPLY_MACRO2(VL_API_CREATE_VHOST_USER_IF_REPLY, - ({ - rmp->sw_if_index = ntohl (sw_if_index); - })); - /* *INDENT-ON* */ -} - -static void -vl_api_modify_vhost_user_if_t_handler (vl_api_modify_vhost_user_if_t * mp) -{ - int rv = 0; - vl_api_modify_vhost_user_if_reply_t *rmp; - u32 sw_if_index = ntohl (mp->sw_if_index); - - vnet_main_t *vnm = vnet_get_main (); - vlib_main_t *vm = vlib_get_main (); - - 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); -} - -static void -vl_api_delete_vhost_user_if_t_handler (vl_api_delete_vhost_user_if_t * mp) -{ - int rv = 0; - vl_api_delete_vhost_user_if_reply_t *rmp; - vpe_api_main_t *vam = &vpe_api_main; - u32 sw_if_index = ntohl (mp->sw_if_index); - - vnet_main_t *vnm = vnet_get_main (); - vlib_main_t *vm = vlib_get_main (); - - rv = vhost_user_delete_if (vnm, vm, sw_if_index); - - REPLY_MACRO (VL_API_DELETE_VHOST_USER_IF_REPLY); - if (!rv) - { - unix_shared_memory_queue_t *q = - vl_api_client_index_to_input_queue (mp->client_index); - if (!q) - return; - - vnet_clear_sw_interface_tag (vnm, sw_if_index); - send_sw_interface_flags_deleted (vam, q, sw_if_index); - } -} - -static void - vl_api_sw_interface_vhost_user_details_t_handler - (vl_api_sw_interface_vhost_user_details_t * mp) -{ - clib_warning ("BUG"); -} - -static void -send_sw_interface_vhost_user_details (vpe_api_main_t * am, - unix_shared_memory_queue_t * q, - vhost_user_intf_details_t * vui, - u32 context) -{ - vl_api_sw_interface_vhost_user_details_t *mp; - - mp = vl_msg_api_alloc (sizeof (*mp)); - memset (mp, 0, sizeof (*mp)); - mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_VHOST_USER_DETAILS); - mp->sw_if_index = ntohl (vui->sw_if_index); - mp->virtio_net_hdr_sz = ntohl (vui->virtio_net_hdr_sz); - mp->features = clib_net_to_host_u64 (vui->features); - mp->is_server = vui->is_server; - mp->num_regions = ntohl (vui->num_regions); - mp->sock_errno = ntohl (vui->sock_errno); - mp->context = context; - - strncpy ((char *) mp->sock_filename, - (char *) vui->sock_filename, ARRAY_LEN (mp->sock_filename) - 1); - strncpy ((char *) mp->interface_name, - (char *) vui->if_name, ARRAY_LEN (mp->interface_name) - 1); - - vl_msg_api_send_shmem (q, (u8 *) & mp); -} - -static void - vl_api_sw_interface_vhost_user_dump_t_handler - (vl_api_sw_interface_vhost_user_dump_t * mp) -{ - int rv = 0; - vpe_api_main_t *am = &vpe_api_main; - vnet_main_t *vnm = vnet_get_main (); - vlib_main_t *vm = vlib_get_main (); - vhost_user_intf_details_t *ifaces = NULL; - vhost_user_intf_details_t *vuid = NULL; - unix_shared_memory_queue_t *q; - - q = vl_api_client_index_to_input_queue (mp->client_index); - if (q == 0) - return; - - rv = vhost_user_dump_ifs (vnm, vm, &ifaces); - if (rv) - return; - - vec_foreach (vuid, ifaces) - { - send_sw_interface_vhost_user_details (am, q, vuid, mp->context); - } - vec_free (ifaces); -} - -static void -send_sw_if_l2tpv3_tunnel_details (vpe_api_main_t * am, - unix_shared_memory_queue_t * q, - l2t_session_t * s, - l2t_main_t * lm, u32 context) -{ - vl_api_sw_if_l2tpv3_tunnel_details_t *mp; - u8 *if_name = NULL; - vnet_sw_interface_t *si = NULL; - - si = vnet_get_hw_sw_interface (lm->vnet_main, s->hw_if_index); - - if_name = format (if_name, "%U", - format_vnet_sw_interface_name, lm->vnet_main, si); - - mp = vl_msg_api_alloc (sizeof (*mp)); - memset (mp, 0, sizeof (*mp)); - mp->_vl_msg_id = ntohs (VL_API_SW_IF_L2TPV3_TUNNEL_DETAILS); - strncpy ((char *) mp->interface_name, - (char *) if_name, ARRAY_LEN (mp->interface_name) - 1); - mp->sw_if_index = ntohl (si->sw_if_index); - mp->local_session_id = s->local_session_id; - mp->remote_session_id = s->remote_session_id; - mp->local_cookie[0] = s->local_cookie[0]; - mp->local_cookie[1] = s->local_cookie[1]; - mp->remote_cookie = s->remote_cookie; - clib_memcpy (mp->client_address, &s->client_address, - sizeof (s->client_address)); - clib_memcpy (mp->our_address, &s->our_address, sizeof (s->our_address)); - mp->l2_sublayer_present = s->l2_sublayer_present; - mp->context = context; - - vl_msg_api_send_shmem (q, (u8 *) & mp); -} - - -static void -vl_api_sw_if_l2tpv3_tunnel_dump_t_handler (vl_api_sw_if_l2tpv3_tunnel_dump_t * - mp) -{ - vpe_api_main_t *am = &vpe_api_main; - l2t_main_t *lm = &l2t_main; - unix_shared_memory_queue_t *q; - l2t_session_t *session; - - q = vl_api_client_index_to_input_queue (mp->client_index); - if (q == 0) - return; - - /* *INDENT-OFF* */ - pool_foreach (session, lm->sessions, - ({ - send_sw_if_l2tpv3_tunnel_details (am, q, session, lm, mp->context); - })); - /* *INDENT-ON* */ -} - static void vl_api_l2_fib_table_entry_t_handler (vl_api_l2_fib_table_entry_t * mp) { @@ -2984,114 +2713,6 @@ out: /* *INDENT-ON* */ } -static void vl_api_l2tpv3_create_tunnel_t_handler - (vl_api_l2tpv3_create_tunnel_t * mp) -{ - vl_api_l2tpv3_create_tunnel_reply_t *rmp; - l2t_main_t *lm = &l2t_main; - u32 sw_if_index = (u32) ~ 0; - int rv; - - if (mp->is_ipv6 != 1) - { - rv = VNET_API_ERROR_UNIMPLEMENTED; - goto out; - } - - u32 encap_fib_index; - - if (mp->encap_vrf_id != ~0) - { - uword *p; - ip6_main_t *im = &ip6_main; - if (! - (p = - hash_get (im->fib_index_by_table_id, ntohl (mp->encap_vrf_id)))) - { - rv = VNET_API_ERROR_NO_SUCH_FIB; - goto out; - } - encap_fib_index = p[0]; - } - else - { - encap_fib_index = ~0; - } - - rv = create_l2tpv3_ipv6_tunnel (lm, - (ip6_address_t *) mp->client_address, - (ip6_address_t *) mp->our_address, - ntohl (mp->local_session_id), - ntohl (mp->remote_session_id), - clib_net_to_host_u64 (mp->local_cookie), - clib_net_to_host_u64 (mp->remote_cookie), - mp->l2_sublayer_present, - encap_fib_index, &sw_if_index); - -out: - /* *INDENT-OFF* */ - REPLY_MACRO2(VL_API_L2TPV3_CREATE_TUNNEL_REPLY, - ({ - rmp->sw_if_index = ntohl (sw_if_index); - })); - /* *INDENT-ON* */ -} - -static void vl_api_l2tpv3_set_tunnel_cookies_t_handler - (vl_api_l2tpv3_set_tunnel_cookies_t * mp) -{ - vl_api_l2tpv3_set_tunnel_cookies_reply_t *rmp; - l2t_main_t *lm = &l2t_main; - int rv; - - VALIDATE_SW_IF_INDEX (mp); - - rv = l2tpv3_set_tunnel_cookies (lm, ntohl (mp->sw_if_index), - clib_net_to_host_u64 (mp->new_local_cookie), - clib_net_to_host_u64 - (mp->new_remote_cookie)); - - BAD_SW_IF_INDEX_LABEL; - - REPLY_MACRO (VL_API_L2TPV3_SET_TUNNEL_COOKIES_REPLY); -} - -static void vl_api_l2tpv3_interface_enable_disable_t_handler - (vl_api_l2tpv3_interface_enable_disable_t * mp) -{ - int rv; - vnet_main_t *vnm = vnet_get_main (); - vl_api_l2tpv3_interface_enable_disable_reply_t *rmp; - - VALIDATE_SW_IF_INDEX (mp); - - rv = l2tpv3_interface_enable_disable - (vnm, ntohl (mp->sw_if_index), mp->enable_disable); - - BAD_SW_IF_INDEX_LABEL; - - REPLY_MACRO (VL_API_L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY); -} - -static void vl_api_l2tpv3_set_lookup_key_t_handler - (vl_api_l2tpv3_set_lookup_key_t * mp) -{ - int rv = 0; - l2t_main_t *lm = &l2t_main; - vl_api_l2tpv3_set_lookup_key_reply_t *rmp; - - if (mp->key > L2T_LOOKUP_SESSION_ID) - { - rv = VNET_API_ERROR_INVALID_VALUE; - goto out; - } - - lm->lookup_type = mp->key; - -out: - REPLY_MACRO (VL_API_L2TPV3_SET_LOOKUP_KEY_REPLY); -} - static void vl_api_vxlan_add_del_tunnel_t_handler (vl_api_vxlan_add_del_tunnel_t * mp) { @@ -3218,28 +2839,72 @@ static void vl_api_vxlan_tunnel_dump_t_handler } } -static void vl_api_gre_add_del_tunnel_t_handler - (vl_api_gre_add_del_tunnel_t * mp) +static void +vl_api_l2_patch_add_del_t_handler (vl_api_l2_patch_add_del_t * mp) +{ + extern int vnet_l2_patch_add_del (u32 rx_sw_if_index, u32 tx_sw_if_index, + int is_add); + vl_api_l2_patch_add_del_reply_t *rmp; + int vnet_l2_patch_add_del (u32 rx_sw_if_index, u32 tx_sw_if_index, + int is_add); + int rv = 0; + + VALIDATE_RX_SW_IF_INDEX (mp); + VALIDATE_TX_SW_IF_INDEX (mp); + + rv = vnet_l2_patch_add_del (ntohl (mp->rx_sw_if_index), + ntohl (mp->tx_sw_if_index), + (int) (mp->is_add != 0)); + + BAD_RX_SW_IF_INDEX_LABEL; + BAD_TX_SW_IF_INDEX_LABEL; + + REPLY_MACRO (VL_API_L2_PATCH_ADD_DEL_REPLY); +} + +static void + vl_api_vxlan_gpe_add_del_tunnel_t_handler + (vl_api_vxlan_gpe_add_del_tunnel_t * mp) { - vl_api_gre_add_del_tunnel_reply_t *rmp; + vl_api_vxlan_gpe_add_del_tunnel_reply_t *rmp; int rv = 0; - vnet_gre_add_del_tunnel_args_t _a, *a = &_a; - u32 outer_fib_id; + vnet_vxlan_gpe_add_del_tunnel_args_t _a, *a = &_a; + u32 encap_fib_index, decap_fib_index; + u8 protocol; uword *p; ip4_main_t *im = &ip4_main; u32 sw_if_index = ~0; - p = hash_get (im->fib_index_by_table_id, ntohl (mp->outer_fib_id)); + + p = hash_get (im->fib_index_by_table_id, ntohl (mp->encap_vrf_id)); if (!p) { rv = VNET_API_ERROR_NO_SUCH_FIB; goto out; } - outer_fib_id = p[0]; + encap_fib_index = p[0]; + + protocol = mp->protocol; + + /* Interpret decap_vrf_id as an opaque if sending to other-than-ip4-input */ + if (protocol == VXLAN_GPE_INPUT_NEXT_IP4_INPUT) + { + p = hash_get (im->fib_index_by_table_id, ntohl (mp->decap_vrf_id)); + if (!p) + { + rv = VNET_API_ERROR_NO_SUCH_INNER_FIB; + goto out; + } + decap_fib_index = p[0]; + } + else + { + decap_fib_index = ntohl (mp->decap_vrf_id); + } /* Check src & dst are different */ - if ((mp->is_ipv6 && memcmp (mp->src_address, mp->dst_address, 16) == 0) || - (!mp->is_ipv6 && memcmp (mp->src_address, mp->dst_address, 4) == 0)) + if ((mp->is_ipv6 && memcmp (mp->local, mp->remote, 16) == 0) || + (!mp->is_ipv6 && memcmp (mp->local, mp->remote, 4) == 0)) { rv = VNET_API_ERROR_SAME_SRC_DST; goto out; @@ -3247,154 +2912,7 @@ static void vl_api_gre_add_del_tunnel_t_handler memset (a, 0, sizeof (*a)); a->is_add = mp->is_add; - a->teb = mp->teb; - - /* ip addresses sent in network byte order */ - clib_memcpy (&(a->src), mp->src_address, 4); - clib_memcpy (&(a->dst), mp->dst_address, 4); - - a->outer_fib_id = outer_fib_id; - rv = vnet_gre_add_del_tunnel (a, &sw_if_index); - -out: - /* *INDENT-OFF* */ - REPLY_MACRO2(VL_API_GRE_ADD_DEL_TUNNEL_REPLY, - ({ - rmp->sw_if_index = ntohl (sw_if_index); - })); - /* *INDENT-ON* */ -} - -static void send_gre_tunnel_details - (gre_tunnel_t * t, unix_shared_memory_queue_t * q, u32 context) -{ - vl_api_gre_tunnel_details_t *rmp; - ip4_main_t *im = &ip4_main; - - rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); - rmp->_vl_msg_id = ntohs (VL_API_GRE_TUNNEL_DETAILS); - clib_memcpy (rmp->src_address, &(t->tunnel_src), 4); - clib_memcpy (rmp->dst_address, &(t->tunnel_dst), 4); - rmp->outer_fib_id = htonl (im->fibs[t->outer_fib_index].ft_table_id); - rmp->teb = (GRE_TUNNEL_TYPE_TEB == t->type); - rmp->sw_if_index = htonl (t->sw_if_index); - rmp->context = context; - - vl_msg_api_send_shmem (q, (u8 *) & rmp); -} - -static void -vl_api_gre_tunnel_dump_t_handler (vl_api_gre_tunnel_dump_t * mp) -{ - unix_shared_memory_queue_t *q; - gre_main_t *gm = &gre_main; - gre_tunnel_t *t; - u32 sw_if_index; - - q = vl_api_client_index_to_input_queue (mp->client_index); - if (q == 0) - { - return; - } - - sw_if_index = ntohl (mp->sw_if_index); - - if (~0 == sw_if_index) - { - /* *INDENT-OFF* */ - pool_foreach (t, gm->tunnels, - ({ - send_gre_tunnel_details(t, q, mp->context); - })); - /* *INDENT-ON* */ - } - else - { - if ((sw_if_index >= vec_len (gm->tunnel_index_by_sw_if_index)) || - (~0 == gm->tunnel_index_by_sw_if_index[sw_if_index])) - { - return; - } - t = &gm->tunnels[gm->tunnel_index_by_sw_if_index[sw_if_index]]; - send_gre_tunnel_details (t, q, mp->context); - } -} - -static void -vl_api_l2_patch_add_del_t_handler (vl_api_l2_patch_add_del_t * mp) -{ - extern int vnet_l2_patch_add_del (u32 rx_sw_if_index, u32 tx_sw_if_index, - int is_add); - vl_api_l2_patch_add_del_reply_t *rmp; - int vnet_l2_patch_add_del (u32 rx_sw_if_index, u32 tx_sw_if_index, - int is_add); - int rv = 0; - - VALIDATE_RX_SW_IF_INDEX (mp); - VALIDATE_TX_SW_IF_INDEX (mp); - - rv = vnet_l2_patch_add_del (ntohl (mp->rx_sw_if_index), - ntohl (mp->tx_sw_if_index), - (int) (mp->is_add != 0)); - - BAD_RX_SW_IF_INDEX_LABEL; - BAD_TX_SW_IF_INDEX_LABEL; - - REPLY_MACRO (VL_API_L2_PATCH_ADD_DEL_REPLY); -} - -static void - vl_api_vxlan_gpe_add_del_tunnel_t_handler - (vl_api_vxlan_gpe_add_del_tunnel_t * mp) -{ - vl_api_vxlan_gpe_add_del_tunnel_reply_t *rmp; - int rv = 0; - vnet_vxlan_gpe_add_del_tunnel_args_t _a, *a = &_a; - u32 encap_fib_index, decap_fib_index; - u8 protocol; - uword *p; - ip4_main_t *im = &ip4_main; - u32 sw_if_index = ~0; - - - p = hash_get (im->fib_index_by_table_id, ntohl (mp->encap_vrf_id)); - if (!p) - { - rv = VNET_API_ERROR_NO_SUCH_FIB; - goto out; - } - encap_fib_index = p[0]; - - protocol = mp->protocol; - - /* Interpret decap_vrf_id as an opaque if sending to other-than-ip4-input */ - if (protocol == VXLAN_GPE_INPUT_NEXT_IP4_INPUT) - { - p = hash_get (im->fib_index_by_table_id, ntohl (mp->decap_vrf_id)); - if (!p) - { - rv = VNET_API_ERROR_NO_SUCH_INNER_FIB; - goto out; - } - decap_fib_index = p[0]; - } - else - { - decap_fib_index = ntohl (mp->decap_vrf_id); - } - - /* Check src & dst are different */ - if ((mp->is_ipv6 && memcmp (mp->local, mp->remote, 16) == 0) || - (!mp->is_ipv6 && memcmp (mp->local, mp->remote, 4) == 0)) - { - rv = VNET_API_ERROR_SAME_SRC_DST; - goto out; - } - memset (a, 0, sizeof (*a)); - - a->is_add = mp->is_add; - a->is_ip6 = mp->is_ipv6; + a->is_ip6 = mp->is_ipv6; /* ip addresses sent in network byte order */ if (a->is_ip6) { @@ -4999,354 +4517,6 @@ static void vl_api_input_acl_set_interface_t_handler REPLY_MACRO (VL_API_INPUT_ACL_SET_INTERFACE_REPLY); } -static void vl_api_ipsec_spd_add_del_t_handler - (vl_api_ipsec_spd_add_del_t * mp) -{ -#if IPSEC == 0 - clib_warning ("unimplemented"); -#else - - vlib_main_t *vm __attribute__ ((unused)) = vlib_get_main (); - vl_api_ipsec_spd_add_del_reply_t *rmp; - int rv; - -#if DPDK > 0 - rv = ipsec_add_del_spd (vm, ntohl (mp->spd_id), mp->is_add); -#else - rv = VNET_API_ERROR_UNIMPLEMENTED; -#endif - - REPLY_MACRO (VL_API_IPSEC_SPD_ADD_DEL_REPLY); -#endif -} - -static void vl_api_ipsec_interface_add_del_spd_t_handler - (vl_api_ipsec_interface_add_del_spd_t * mp) -{ - vlib_main_t *vm __attribute__ ((unused)) = vlib_get_main (); - vl_api_ipsec_interface_add_del_spd_reply_t *rmp; - int rv; - u32 sw_if_index __attribute__ ((unused)); - u32 spd_id __attribute__ ((unused)); - - sw_if_index = ntohl (mp->sw_if_index); - spd_id = ntohl (mp->spd_id); - - VALIDATE_SW_IF_INDEX (mp); - -#if IPSEC > 0 - rv = ipsec_set_interface_spd (vm, sw_if_index, spd_id, mp->is_add); -#else - rv = VNET_API_ERROR_UNIMPLEMENTED; -#endif - - BAD_SW_IF_INDEX_LABEL; - - REPLY_MACRO (VL_API_IPSEC_INTERFACE_ADD_DEL_SPD_REPLY); -} - -static void vl_api_ipsec_spd_add_del_entry_t_handler - (vl_api_ipsec_spd_add_del_entry_t * mp) -{ - vlib_main_t *vm __attribute__ ((unused)) = vlib_get_main (); - vl_api_ipsec_spd_add_del_entry_reply_t *rmp; - int rv; - -#if IPSEC > 0 - ipsec_policy_t p; - - memset (&p, 0, sizeof (p)); - - p.id = ntohl (mp->spd_id); - p.priority = ntohl (mp->priority); - p.is_outbound = mp->is_outbound; - p.is_ipv6 = mp->is_ipv6; - - if (mp->is_ipv6 || mp->is_ip_any) - { - clib_memcpy (&p.raddr.start, mp->remote_address_start, 16); - clib_memcpy (&p.raddr.stop, mp->remote_address_stop, 16); - clib_memcpy (&p.laddr.start, mp->local_address_start, 16); - clib_memcpy (&p.laddr.stop, mp->local_address_stop, 16); - } - else - { - clib_memcpy (&p.raddr.start.ip4.data, mp->remote_address_start, 4); - clib_memcpy (&p.raddr.stop.ip4.data, mp->remote_address_stop, 4); - clib_memcpy (&p.laddr.start.ip4.data, mp->local_address_start, 4); - clib_memcpy (&p.laddr.stop.ip4.data, mp->local_address_stop, 4); - } - p.protocol = mp->protocol; - p.rport.start = ntohs (mp->remote_port_start); - p.rport.stop = ntohs (mp->remote_port_stop); - p.lport.start = ntohs (mp->local_port_start); - p.lport.stop = ntohs (mp->local_port_stop); - /* policy action resolve unsupported */ - if (mp->policy == IPSEC_POLICY_ACTION_RESOLVE) - { - clib_warning ("unsupported action: 'resolve'"); - rv = VNET_API_ERROR_UNIMPLEMENTED; - goto out; - } - p.policy = mp->policy; - p.sa_id = ntohl (mp->sa_id); - - rv = ipsec_add_del_policy (vm, &p, mp->is_add); - if (rv) - goto out; - - if (mp->is_ip_any) - { - p.is_ipv6 = 1; - rv = ipsec_add_del_policy (vm, &p, mp->is_add); - } -#else - rv = VNET_API_ERROR_UNIMPLEMENTED; - goto out; -#endif - -out: - REPLY_MACRO (VL_API_IPSEC_SPD_ADD_DEL_ENTRY_REPLY); -} - -static void vl_api_ipsec_sad_add_del_entry_t_handler - (vl_api_ipsec_sad_add_del_entry_t * mp) -{ - vlib_main_t *vm __attribute__ ((unused)) = vlib_get_main (); - vl_api_ipsec_sad_add_del_entry_reply_t *rmp; - int rv; -#if IPSEC > 0 - ipsec_sa_t sa; - - memset (&sa, 0, sizeof (sa)); - - sa.id = ntohl (mp->sad_id); - sa.spi = ntohl (mp->spi); - /* security protocol AH unsupported */ - if (mp->protocol == IPSEC_PROTOCOL_AH) - { - clib_warning ("unsupported security protocol 'AH'"); - rv = VNET_API_ERROR_UNIMPLEMENTED; - goto out; - } - sa.protocol = mp->protocol; - /* check for unsupported crypto-alg */ - if (mp->crypto_algorithm < IPSEC_CRYPTO_ALG_AES_CBC_128 || - mp->crypto_algorithm >= IPSEC_CRYPTO_N_ALG) - { - clib_warning ("unsupported crypto-alg: '%U'", format_ipsec_crypto_alg, - mp->crypto_algorithm); - rv = VNET_API_ERROR_UNIMPLEMENTED; - goto out; - } - sa.crypto_alg = mp->crypto_algorithm; - sa.crypto_key_len = mp->crypto_key_length; - clib_memcpy (&sa.crypto_key, mp->crypto_key, sizeof (sa.crypto_key)); - /* check for unsupported integ-alg */ -#if DPDK_CRYPTO==1 - if (mp->integrity_algorithm < IPSEC_INTEG_ALG_NONE || -#else - if (mp->integrity_algorithm < IPSEC_INTEG_ALG_SHA1_96 || -#endif - mp->integrity_algorithm >= IPSEC_INTEG_N_ALG) - { - clib_warning ("unsupported integ-alg: '%U'", format_ipsec_integ_alg, - mp->integrity_algorithm); - rv = VNET_API_ERROR_UNIMPLEMENTED; - goto out; - } - -#if DPDK_CRYPTO==1 - /*Special cases, aes-gcm-128 encryption */ - if (mp->crypto_algorithm == IPSEC_CRYPTO_ALG_AES_GCM_128) - { - if (mp->integrity_algorithm != IPSEC_INTEG_ALG_NONE - && mp->integrity_algorithm != IPSEC_INTEG_ALG_AES_GCM_128) - { - clib_warning - ("unsupported: aes-gcm-128 crypto-alg needs none as integ-alg"); - rv = VNET_API_ERROR_UNIMPLEMENTED; - goto out; - } - else /*set integ-alg internally to aes-gcm-128 */ - mp->integrity_algorithm = IPSEC_INTEG_ALG_AES_GCM_128; - } - else if (mp->integrity_algorithm == IPSEC_INTEG_ALG_AES_GCM_128) - { - clib_warning ("unsupported integ-alg: aes-gcm-128"); - rv = VNET_API_ERROR_UNIMPLEMENTED; - goto out; - } - else if (mp->integrity_algorithm == IPSEC_INTEG_ALG_NONE) - { - clib_warning ("unsupported integ-alg: none"); - rv = VNET_API_ERROR_UNIMPLEMENTED; - goto out; - } -#endif - - sa.integ_alg = mp->integrity_algorithm; - sa.integ_key_len = mp->integrity_key_length; - clib_memcpy (&sa.integ_key, mp->integrity_key, sizeof (sa.integ_key)); - sa.use_esn = mp->use_extended_sequence_number; - sa.is_tunnel = mp->is_tunnel; - sa.is_tunnel_ip6 = mp->is_tunnel_ipv6; - if (sa.is_tunnel_ip6) - { - clib_memcpy (&sa.tunnel_src_addr, mp->tunnel_src_address, 16); - clib_memcpy (&sa.tunnel_dst_addr, mp->tunnel_dst_address, 16); - } - else - { - clib_memcpy (&sa.tunnel_src_addr.ip4.data, mp->tunnel_src_address, 4); - clib_memcpy (&sa.tunnel_dst_addr.ip4.data, mp->tunnel_dst_address, 4); - } - - rv = ipsec_add_del_sa (vm, &sa, mp->is_add); -#else - rv = VNET_API_ERROR_UNIMPLEMENTED; - goto out; -#endif - -out: - REPLY_MACRO (VL_API_IPSEC_SAD_ADD_DEL_ENTRY_REPLY); -} - -static void -vl_api_ikev2_profile_add_del_t_handler (vl_api_ikev2_profile_add_del_t * mp) -{ - vl_api_ikev2_profile_add_del_reply_t *rmp; - int rv = 0; - -#if IPSEC > 0 - vlib_main_t *vm = vlib_get_main (); - clib_error_t *error; - u8 *tmp = format (0, "%s", mp->name); - error = ikev2_add_del_profile (vm, tmp, mp->is_add); - vec_free (tmp); - if (error) - rv = VNET_API_ERROR_UNSPECIFIED; -#else - rv = VNET_API_ERROR_UNIMPLEMENTED; -#endif - - REPLY_MACRO (VL_API_IKEV2_PROFILE_ADD_DEL_REPLY); -} - -static void - vl_api_ikev2_profile_set_auth_t_handler - (vl_api_ikev2_profile_set_auth_t * mp) -{ - vl_api_ikev2_profile_set_auth_reply_t *rmp; - int rv = 0; - -#if IPSEC > 0 - vlib_main_t *vm = vlib_get_main (); - clib_error_t *error; - u8 *tmp = format (0, "%s", mp->name); - u8 *data = vec_new (u8, mp->data_len); - clib_memcpy (data, mp->data, mp->data_len); - error = ikev2_set_profile_auth (vm, tmp, mp->auth_method, data, mp->is_hex); - vec_free (tmp); - vec_free (data); - if (error) - rv = VNET_API_ERROR_UNSPECIFIED; -#else - rv = VNET_API_ERROR_UNIMPLEMENTED; -#endif - - REPLY_MACRO (VL_API_IKEV2_PROFILE_SET_AUTH_REPLY); -} - -static void -vl_api_ikev2_profile_set_id_t_handler (vl_api_ikev2_profile_set_id_t * mp) -{ - vl_api_ikev2_profile_add_del_reply_t *rmp; - int rv = 0; - -#if IPSEC > 0 - vlib_main_t *vm = vlib_get_main (); - clib_error_t *error; - u8 *tmp = format (0, "%s", mp->name); - u8 *data = vec_new (u8, mp->data_len); - clib_memcpy (data, mp->data, mp->data_len); - error = ikev2_set_profile_id (vm, tmp, mp->id_type, data, mp->is_local); - vec_free (tmp); - vec_free (data); - if (error) - rv = VNET_API_ERROR_UNSPECIFIED; -#else - rv = VNET_API_ERROR_UNIMPLEMENTED; -#endif - - REPLY_MACRO (VL_API_IKEV2_PROFILE_SET_ID_REPLY); -} - -static void -vl_api_ikev2_profile_set_ts_t_handler (vl_api_ikev2_profile_set_ts_t * mp) -{ - vl_api_ikev2_profile_set_ts_reply_t *rmp; - int rv = 0; - -#if IPSEC > 0 - vlib_main_t *vm = vlib_get_main (); - clib_error_t *error; - u8 *tmp = format (0, "%s", mp->name); - error = ikev2_set_profile_ts (vm, tmp, mp->proto, mp->start_port, - mp->end_port, (ip4_address_t) mp->start_addr, - (ip4_address_t) mp->end_addr, mp->is_local); - vec_free (tmp); - if (error) - rv = VNET_API_ERROR_UNSPECIFIED; -#else - rv = VNET_API_ERROR_UNIMPLEMENTED; -#endif - - REPLY_MACRO (VL_API_IKEV2_PROFILE_SET_TS_REPLY); -} - -static void -vl_api_ikev2_set_local_key_t_handler (vl_api_ikev2_set_local_key_t * mp) -{ - vl_api_ikev2_profile_set_ts_reply_t *rmp; - int rv = 0; - -#if IPSEC > 0 - vlib_main_t *vm = vlib_get_main (); - clib_error_t *error; - - error = ikev2_set_local_key (vm, mp->key_file); - if (error) - rv = VNET_API_ERROR_UNSPECIFIED; -#else - rv = VNET_API_ERROR_UNIMPLEMENTED; -#endif - - REPLY_MACRO (VL_API_IKEV2_SET_LOCAL_KEY_REPLY); -} - -static void -vl_api_ipsec_sa_set_key_t_handler (vl_api_ipsec_sa_set_key_t * mp) -{ - vlib_main_t *vm __attribute__ ((unused)) = vlib_get_main (); - vl_api_ipsec_sa_set_key_reply_t *rmp; - int rv; -#if IPSEC > 0 - ipsec_sa_t sa; - sa.id = ntohl (mp->sa_id); - sa.crypto_key_len = mp->crypto_key_length; - clib_memcpy (&sa.crypto_key, mp->crypto_key, sizeof (sa.crypto_key)); - sa.integ_key_len = mp->integrity_key_length; - clib_memcpy (&sa.integ_key, mp->integrity_key, sizeof (sa.integ_key)); - - rv = ipsec_set_sa_key (vm, &sa); -#else - rv = VNET_API_ERROR_UNIMPLEMENTED; -#endif - - REPLY_MACRO (VL_API_IPSEC_SA_SET_KEY_REPLY); -} - static void vl_api_cop_interface_enable_disable_t_handler (vl_api_cop_interface_enable_disable_t * mp) { @@ -5665,44 +4835,6 @@ vl_api_policer_classify_dump_t_handler (vl_api_policer_classify_dump_t * mp) } } -static void -vl_api_netmap_create_t_handler (vl_api_netmap_create_t * mp) -{ - vlib_main_t *vm = vlib_get_main (); - vl_api_netmap_create_reply_t *rmp; - int rv = 0; - u8 *if_name = NULL; - - if_name = format (0, "%s", mp->netmap_if_name); - vec_add1 (if_name, 0); - - rv = - netmap_create_if (vm, if_name, mp->use_random_hw_addr ? 0 : mp->hw_addr, - mp->is_pipe, mp->is_master, 0); - - vec_free (if_name); - - REPLY_MACRO (VL_API_NETMAP_CREATE_REPLY); -} - -static void -vl_api_netmap_delete_t_handler (vl_api_netmap_delete_t * mp) -{ - vlib_main_t *vm = vlib_get_main (); - vl_api_netmap_delete_reply_t *rmp; - int rv = 0; - u8 *if_name = NULL; - - if_name = format (0, "%s", mp->netmap_if_name); - vec_add1 (if_name, 0); - - rv = netmap_delete_if (vm, if_name); - - vec_free (if_name); - - REPLY_MACRO (VL_API_NETMAP_DELETE_REPLY); -} - static void vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_fib_details_t * mp) { @@ -6599,97 +5731,6 @@ reply: REPLY_MACRO (VL_API_IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY); } -static void -vl_api_ipsec_gre_add_del_tunnel_t_handler (vl_api_ipsec_gre_add_del_tunnel_t * - mp) -{ - vl_api_ipsec_gre_add_del_tunnel_reply_t *rmp; - int rv = 0; - vnet_ipsec_gre_add_del_tunnel_args_t _a, *a = &_a; - u32 sw_if_index = ~0; - - /* Check src & dst are different */ - if (memcmp (mp->src_address, mp->dst_address, 4) == 0) - { - rv = VNET_API_ERROR_SAME_SRC_DST; - goto out; - } - - memset (a, 0, sizeof (*a)); - - /* ip addresses sent in network byte order */ - clib_memcpy (&(a->src), mp->src_address, 4); - clib_memcpy (&(a->dst), mp->dst_address, 4); - a->is_add = mp->is_add; - a->lsa = ntohl (mp->local_sa_id); - a->rsa = ntohl (mp->remote_sa_id); - - rv = vnet_ipsec_gre_add_del_tunnel (a, &sw_if_index); - -out: - /* *INDENT-OFF* */ - REPLY_MACRO2(VL_API_GRE_ADD_DEL_TUNNEL_REPLY, - ({ - rmp->sw_if_index = ntohl (sw_if_index); - })); - /* *INDENT-ON* */ -} - -static void send_ipsec_gre_tunnel_details - (ipsec_gre_tunnel_t * t, unix_shared_memory_queue_t * q, u32 context) -{ - vl_api_ipsec_gre_tunnel_details_t *rmp; - - rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); - rmp->_vl_msg_id = ntohs (VL_API_IPSEC_GRE_TUNNEL_DETAILS); - clib_memcpy (rmp->src_address, &(t->tunnel_src), 4); - clib_memcpy (rmp->dst_address, &(t->tunnel_dst), 4); - rmp->sw_if_index = htonl (t->sw_if_index); - rmp->local_sa_id = htonl (t->local_sa_id); - rmp->remote_sa_id = htonl (t->remote_sa_id); - rmp->context = context; - - vl_msg_api_send_shmem (q, (u8 *) & rmp); -} - -static void vl_api_ipsec_gre_tunnel_dump_t_handler - (vl_api_ipsec_gre_tunnel_dump_t * mp) -{ - unix_shared_memory_queue_t *q; - ipsec_gre_main_t *igm = &ipsec_gre_main; - ipsec_gre_tunnel_t *t; - u32 sw_if_index; - - q = vl_api_client_index_to_input_queue (mp->client_index); - if (q == 0) - { - return; - } - - sw_if_index = ntohl (mp->sw_if_index); - - if (~0 == sw_if_index) - { - /* *INDENT-OFF* */ - pool_foreach (t, igm->tunnels, - ({ - send_ipsec_gre_tunnel_details(t, q, mp->context); - })); - /* *INDENT-ON* */ - } - else - { - if ((sw_if_index >= vec_len (igm->tunnel_index_by_sw_if_index)) || - (~0 == igm->tunnel_index_by_sw_if_index[sw_if_index])) - { - return; - } - t = &igm->tunnels[igm->tunnel_index_by_sw_if_index[sw_if_index]]; - send_ipsec_gre_tunnel_details (t, q, mp->context); - } -} - static void vl_api_delete_subif_t_handler (vl_api_delete_subif_t * mp) { @@ -6738,162 +5779,6 @@ static void } -static void -vl_api_bfd_udp_add_t_handler (vl_api_bfd_udp_add_t * mp) -{ - vl_api_bfd_udp_add_reply_t *rmp; - int rv; - - VALIDATE_SW_IF_INDEX (mp); - - ip46_address_t local_addr; - memset (&local_addr, 0, sizeof (local_addr)); - ip46_address_t peer_addr; - memset (&peer_addr, 0, sizeof (peer_addr)); - if (mp->is_ipv6) - { - clib_memcpy (&local_addr.ip6, mp->local_addr, sizeof (local_addr.ip6)); - clib_memcpy (&peer_addr.ip6, mp->peer_addr, sizeof (peer_addr.ip6)); - } - else - { - clib_memcpy (&local_addr.ip4, mp->local_addr, sizeof (local_addr.ip4)); - clib_memcpy (&peer_addr.ip4, mp->peer_addr, sizeof (peer_addr.ip4)); - } - - rv = bfd_udp_add_session (clib_net_to_host_u32 (mp->sw_if_index), - clib_net_to_host_u32 (mp->desired_min_tx), - clib_net_to_host_u32 (mp->required_min_rx), - mp->detect_mult, &local_addr, &peer_addr); - - BAD_SW_IF_INDEX_LABEL; - REPLY_MACRO (VL_API_BFD_UDP_ADD_REPLY); -} - -static void -vl_api_bfd_udp_del_t_handler (vl_api_bfd_udp_del_t * mp) -{ - vl_api_bfd_udp_del_reply_t *rmp; - int rv; - - VALIDATE_SW_IF_INDEX (mp); - - ip46_address_t local_addr; - memset (&local_addr, 0, sizeof (local_addr)); - ip46_address_t peer_addr; - memset (&peer_addr, 0, sizeof (peer_addr)); - if (mp->is_ipv6) - { - clib_memcpy (&local_addr.ip6, mp->local_addr, sizeof (local_addr.ip6)); - clib_memcpy (&peer_addr.ip6, mp->peer_addr, sizeof (peer_addr.ip6)); - } - else - { - clib_memcpy (&local_addr.ip4, mp->local_addr, sizeof (local_addr.ip4)); - clib_memcpy (&peer_addr.ip4, mp->peer_addr, sizeof (peer_addr.ip4)); - } - - rv = - bfd_udp_del_session (clib_net_to_host_u32 (mp->sw_if_index), &local_addr, - &peer_addr); - - BAD_SW_IF_INDEX_LABEL; - REPLY_MACRO (VL_API_BFD_UDP_DEL_REPLY); -} - -void -send_bfd_udp_session_details (unix_shared_memory_queue_t * q, u32 context, - bfd_session_t * bs) -{ - if (bs->transport != BFD_TRANSPORT_UDP4 && - bs->transport != BFD_TRANSPORT_UDP6) - { - return; - } - - vl_api_bfd_udp_session_details_t *mp = vl_msg_api_alloc (sizeof (*mp)); - memset (mp, 0, sizeof (*mp)); - mp->_vl_msg_id = ntohs (VL_API_BFD_UDP_SESSION_DETAILS); - mp->context = context; - mp->bs_index = clib_host_to_net_u32 (bs->bs_idx); - mp->state = bs->local_state; - bfd_udp_session_t *bus = &bs->udp; - bfd_udp_key_t *key = &bus->key; - mp->sw_if_index = clib_host_to_net_u32 (key->sw_if_index); - mp->is_ipv6 = !(ip46_address_is_ip4 (&key->local_addr)); - if (mp->is_ipv6) - { - clib_memcpy (mp->local_addr, &key->local_addr, - sizeof (key->local_addr)); - clib_memcpy (mp->peer_addr, &key->peer_addr, sizeof (key->peer_addr)); - } - else - { - clib_memcpy (mp->local_addr, key->local_addr.ip4.data, - sizeof (key->local_addr.ip4.data)); - clib_memcpy (mp->peer_addr, key->peer_addr.ip4.data, - sizeof (key->peer_addr.ip4.data)); - } - - vl_msg_api_send_shmem (q, (u8 *) & mp); -} - -void -bfd_event (bfd_main_t * bm, bfd_session_t * bs) -{ - vpe_api_main_t *vam = &vpe_api_main; - vpe_client_registration_t *reg; - unix_shared_memory_queue_t *q; - /* *INDENT-OFF* */ - pool_foreach (reg, vam->bfd_events_registrations, ({ - q = vl_api_client_index_to_input_queue (reg->client_index); - if (q) - { - switch (bs->transport) - { - case BFD_TRANSPORT_UDP4: - /* fallthrough */ - case BFD_TRANSPORT_UDP6: - send_bfd_udp_session_details (q, 0, bs); - } - } - })); - /* *INDENT-ON* */ -} - -static void -vl_api_bfd_udp_session_dump_t_handler (vl_api_bfd_udp_session_dump_t * mp) -{ - unix_shared_memory_queue_t *q; - - q = vl_api_client_index_to_input_queue (mp->client_index); - - if (q == 0) - return; - - bfd_session_t *bs = NULL; - /* *INDENT-OFF* */ - pool_foreach (bs, bfd_main.sessions, ({ - if (bs->transport == BFD_TRANSPORT_UDP4 || - bs->transport == BFD_TRANSPORT_UDP6) - send_bfd_udp_session_details (q, mp->context, bs); - })); - /* *INDENT-ON* */ -} - -static void -vl_api_bfd_session_set_flags_t_handler (vl_api_bfd_session_set_flags_t * mp) -{ - vl_api_bfd_session_set_flags_reply_t *rmp; - int rv; - - rv = - bfd_session_set_flags (clib_net_to_host_u32 (mp->bs_index), - mp->admin_up_down); - - REPLY_MACRO (VL_API_BFD_SESSION_SET_FLAGS_REPLY); -} - static void vl_api_punt_t_handler (vl_api_punt_t * mp) { @@ -6980,82 +5865,6 @@ vl_api_flow_classify_dump_t_handler (vl_api_flow_classify_dump_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); - - /* *INDENT-OFF* */ - 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);} - )); - /* *INDENT-ON* */ -#else - clib_warning ("unimplemented"); -#endif -} - static void vl_api_feature_enable_disable_t_handler (vl_api_feature_enable_disable_t * mp) {