X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvpp%2Fapi%2Fapi.c;h=673ffe5618cbf43d43805659ad6bd4dbdf2337f2;hb=b64e4e2af314e1b2bc074b12ede50ad6d96c37c0;hp=a8f471e864e7a38b0e31755c4c22b0d0cb508b38;hpb=a1a093d4e46e38503332a97ad216f80053a15f2b;p=vpp.git diff --git a/src/vpp/api/api.c b/src/vpp/api/api.c index a8f471e864e..673ffe5618c 100644 --- a/src/vpp/api/api.c +++ b/src/vpp/api/api.c @@ -61,8 +61,6 @@ #include #include #include -#include -#include #include #include #include @@ -109,7 +107,6 @@ _(OAM_ADD_DEL, oam_add_del) \ _(IS_ADDRESS_REACHABLE, is_address_reachable) \ _(SW_INTERFACE_SET_MPLS_ENABLE, sw_interface_set_mpls_enable) \ _(SW_INTERFACE_SET_VPATH, sw_interface_set_vpath) \ -_(SW_INTERFACE_SET_VXLAN_BYPASS, sw_interface_set_vxlan_bypass) \ _(SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect) \ _(SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge) \ _(CREATE_VLAN_SUBIF, create_vlan_subif) \ @@ -119,6 +116,7 @@ _(PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable) \ _(VNET_GET_SUMMARY_STATS, vnet_get_summary_stats) \ _(RESET_FIB, reset_fib) \ _(CREATE_LOOPBACK, create_loopback) \ +_(CREATE_LOOPBACK_INSTANCE, create_loopback_instance) \ _(CONTROL_PING, control_ping) \ _(CLI_REQUEST, cli_request) \ _(CLI_INBAND, cli_inband) \ @@ -166,8 +164,8 @@ static int arp_change_delete_callback (u32 pool_index, u8 * notused); static int nd_change_delete_callback (u32 pool_index, u8 * notused); /* Clean up all registrations belonging to the indicated client */ -int -vl_api_memclnt_delete_callback (u32 client_index) +static clib_error_t * +memclnt_delete_callback (u32 client_index) { vpe_api_main_t *vam = &vpe_api_main; vpe_client_registration_t *rp; @@ -188,6 +186,8 @@ vl_api_memclnt_delete_callback (u32 client_index) return 0; } +VL_MSG_API_REAPER_FUNCTION (memclnt_delete_callback); + pub_sub_handler (oam_events, OAM_EVENTS); #define RESOLUTION_EVENT 1 @@ -373,29 +373,6 @@ vl_api_sw_interface_set_vpath_t_handler (vl_api_sw_interface_set_vpath_t * mp) REPLY_MACRO (VL_API_SW_INTERFACE_SET_VPATH_REPLY); } -static void - vl_api_sw_interface_set_vxlan_bypass_t_handler - (vl_api_sw_interface_set_vxlan_bypass_t * mp) -{ - vl_api_sw_interface_set_vxlan_bypass_reply_t *rmp; - int rv = 0; - u32 sw_if_index = ntohl (mp->sw_if_index); - - VALIDATE_SW_IF_INDEX (mp); - - if (mp->is_ipv6) - { - /* not yet implemented */ - } - else - vnet_feature_enable_disable ("ip4-unicast", "ip4-vxlan-bypass", - sw_if_index, mp->enable, 0, 0); - - BAD_SW_IF_INDEX_LABEL; - - REPLY_MACRO (VL_API_SW_INTERFACE_SET_VXLAN_BYPASS_REPLY); -} - static void vl_api_sw_interface_set_l2_xconnect_t_handler (vl_api_sw_interface_set_l2_xconnect_t * mp) @@ -492,7 +469,7 @@ vl_api_create_vlan_subif_t_handler (vl_api_create_vlan_subif_t * mp) { vl_api_create_vlan_subif_reply_t *rmp; vnet_main_t *vnm = vnet_get_main (); - u32 hw_if_index, sw_if_index = (u32) ~ 0; + u32 sw_if_index = (u32) ~ 0; vnet_hw_interface_t *hi; int rv = 0; u32 id; @@ -506,8 +483,13 @@ vl_api_create_vlan_subif_t_handler (vl_api_create_vlan_subif_t * mp) VALIDATE_SW_IF_INDEX (mp); - hw_if_index = ntohl (mp->sw_if_index); - hi = vnet_get_hw_interface (vnm, hw_if_index); + hi = vnet_get_sup_hw_interface (vnm, ntohl (mp->sw_if_index)); + + if (hi->bond_info == VNET_HW_INTERFACE_BOND_INFO_SLAVE) + { + rv = VNET_API_ERROR_BOND_SLAVE_NOT_ALLOWED; + goto out; + } id = ntohl (mp->vlan_id); if (id == 0 || id > 4095) @@ -1047,7 +1029,7 @@ vl_api_create_loopback_t_handler (vl_api_create_loopback_t * mp) u32 sw_if_index; int rv; - rv = vnet_create_loopback_interface (&sw_if_index, mp->mac_address); + rv = vnet_create_loopback_interface (&sw_if_index, mp->mac_address, 0, 0); /* *INDENT-OFF* */ REPLY_MACRO2(VL_API_CREATE_LOOPBACK_REPLY, @@ -1057,6 +1039,26 @@ vl_api_create_loopback_t_handler (vl_api_create_loopback_t * mp) /* *INDENT-ON* */ } +static void vl_api_create_loopback_instance_t_handler + (vl_api_create_loopback_instance_t * mp) +{ + vl_api_create_loopback_instance_reply_t *rmp; + u32 sw_if_index; + u8 is_specified = mp->is_specified; + u32 user_instance = ntohl (mp->user_instance); + int rv; + + rv = vnet_create_loopback_interface (&sw_if_index, mp->mac_address, + is_specified, user_instance); + + /* *INDENT-OFF* */ + REPLY_MACRO2(VL_API_CREATE_LOOPBACK_INSTANCE_REPLY, + ({ + rmp->sw_if_index = ntohl (sw_if_index); + })); + /* *INDENT-ON* */ +} + static void vl_api_delete_loopback_t_handler (vl_api_delete_loopback_t * mp) { @@ -1432,39 +1434,6 @@ out: /* *INDENT-ON* */ } -static void send_vxlan_tunnel_details - (vxlan_tunnel_t * t, unix_shared_memory_queue_t * q, u32 context) -{ - vl_api_vxlan_tunnel_details_t *rmp; - ip4_main_t *im4 = &ip4_main; - ip6_main_t *im6 = &ip6_main; - u8 is_ipv6 = !ip46_address_is_ip4 (&t->dst); - - rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); - rmp->_vl_msg_id = ntohs (VL_API_VXLAN_TUNNEL_DETAILS); - if (is_ipv6) - { - memcpy (rmp->src_address, t->src.ip6.as_u8, 16); - memcpy (rmp->dst_address, t->dst.ip6.as_u8, 16); - rmp->encap_vrf_id = htonl (im6->fibs[t->encap_fib_index].ft_table_id); - } - else - { - memcpy (rmp->src_address, t->src.ip4.as_u8, 4); - memcpy (rmp->dst_address, t->dst.ip4.as_u8, 4); - rmp->encap_vrf_id = htonl (im4->fibs[t->encap_fib_index].ft_table_id); - } - rmp->mcast_sw_if_index = htonl (t->mcast_sw_if_index); - rmp->vni = htonl (t->vni); - rmp->decap_next_index = htonl (t->decap_next_index); - rmp->sw_if_index = htonl (t->sw_if_index); - rmp->is_ipv6 = is_ipv6; - rmp->context = context; - - vl_msg_api_send_shmem (q, (u8 *) & rmp); -} - static void vl_api_l2_patch_add_del_t_handler (vl_api_l2_patch_add_del_t * mp) { @@ -1488,40 +1457,6 @@ vl_api_l2_patch_add_del_t_handler (vl_api_l2_patch_add_del_t * mp) REPLY_MACRO (VL_API_L2_PATCH_ADD_DEL_REPLY); } -static void send_vxlan_gpe_tunnel_details - (vxlan_gpe_tunnel_t * t, unix_shared_memory_queue_t * q, u32 context) -{ - vl_api_vxlan_gpe_tunnel_details_t *rmp; - ip4_main_t *im4 = &ip4_main; - ip6_main_t *im6 = &ip6_main; - u8 is_ipv6 = !(t->flags & VXLAN_GPE_TUNNEL_IS_IPV4); - - rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); - rmp->_vl_msg_id = ntohs (VL_API_VXLAN_GPE_TUNNEL_DETAILS); - if (is_ipv6) - { - memcpy (rmp->local, &(t->local.ip6), 16); - memcpy (rmp->remote, &(t->remote.ip6), 16); - rmp->encap_vrf_id = htonl (im6->fibs[t->encap_fib_index].ft_table_id); - rmp->decap_vrf_id = htonl (im6->fibs[t->decap_fib_index].ft_table_id); - } - else - { - memcpy (rmp->local, &(t->local.ip4), 4); - memcpy (rmp->remote, &(t->remote.ip4), 4); - rmp->encap_vrf_id = htonl (im4->fibs[t->encap_fib_index].ft_table_id); - rmp->decap_vrf_id = htonl (im4->fibs[t->decap_fib_index].ft_table_id); - } - rmp->vni = htonl (t->vni); - rmp->protocol = t->protocol; - rmp->sw_if_index = htonl (t->sw_if_index); - rmp->is_ipv6 = is_ipv6; - rmp->context = context; - - vl_msg_api_send_shmem (q, (u8 *) & rmp); -} - static void vl_api_interface_name_renumber_t_handler (vl_api_interface_name_renumber_t * mp) @@ -1560,7 +1495,7 @@ arp_change_data_callback (u32 pool_index, u8 * new_mac, } else { /* same mac */ - if (sw_if_index == event->sw_if_index && + if (sw_if_index == ntohl(event->sw_if_index) && (!event->mac_ip || /* for BD case, also check IP address with 10 sec timeout */ (address == event->address && @@ -1570,7 +1505,7 @@ arp_change_data_callback (u32 pool_index, u8 * new_mac, /* *INDENT-ON* */ arp_event_last_time = now; - event->sw_if_index = sw_if_index; + event->sw_if_index = htonl (sw_if_index); if (event->mac_ip) event->address = address; return 0; @@ -1598,7 +1533,7 @@ nd_change_data_callback (u32 pool_index, u8 * new_mac, } else { /* same mac */ - if (sw_if_index == event->sw_if_index && + if (sw_if_index == ntohl(event->sw_if_index) && (!event->mac_ip || /* for BD case, also check IP address with 10 sec timeout */ (ip6_address_is_equal (address, @@ -1609,7 +1544,7 @@ nd_change_data_callback (u32 pool_index, u8 * new_mac, /* *INDENT-ON* */ nd_event_last_time = now; - event->sw_if_index = sw_if_index; + event->sw_if_index = htonl (sw_if_index); if (event->mac_ip) clib_memcpy (event->address, address, sizeof (event->address)); return 0; @@ -2178,7 +2113,6 @@ vpe_api_hookup (vlib_main_t * vm) am->api_trace_cfg[VL_API_CLASSIFY_ADD_DEL_TABLE].size += 5 * sizeof (u32x4); am->api_trace_cfg[VL_API_CLASSIFY_ADD_DEL_SESSION].size += 5 * sizeof (u32x4); - am->api_trace_cfg[VL_API_VXLAN_ADD_DEL_TUNNEL].size += 16 * sizeof (u32); /* * Thread-safe API messages @@ -2211,7 +2145,6 @@ vpe_api_init (vlib_main_t * vm) am->oam_events_registration_hash = hash_create (0, sizeof (uword)); am->bfd_events_registration_hash = hash_create (0, sizeof (uword)); - vl_api_init (vm); vl_set_memory_region_name ("/vpe-api"); vl_enable_disable_memory_api (vm, 1 /* enable it */ );