X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvpp%2Fapi%2Fapi.c;h=16d512259acc44ad20a49943af632907b6c7ae39;hb=5d73eecd63018db69b10bf56adeec9cc5cf92790;hp=8df404061314bf6f3c626b78891fa75ddcac8fc0;hpb=1bd01099a6512b6119bbf337b36222a6f0770d49;p=vpp.git diff --git a/src/vpp/api/api.c b/src/vpp/api/api.c index 8df40406131..16d512259ac 100644 --- a/src/vpp/api/api.c +++ b/src/vpp/api/api.c @@ -53,7 +53,7 @@ #include #include #if WITH_LIBSSL > 0 -#include +#include #endif #include #include @@ -158,7 +158,7 @@ typedef enum } resolve_t; static vlib_node_registration_t vpe_resolver_process_node; -vpe_api_main_t vpe_api_main; +extern vpe_api_main_t vpe_api_main; static int arp_change_delete_callback (u32 pool_index, u8 * notused); static int nd_change_delete_callback (u32 pool_index, u8 * notused); @@ -199,7 +199,7 @@ int ip4_add_del_route_t_handler (vl_api_ip_add_del_route_t * mp); int ip6_add_del_route_t_handler (vl_api_ip_add_del_route_t * mp); -void +static void handle_ip4_arp_event (u32 pool_index) { vpe_api_main_t *vam = &vpe_api_main; @@ -410,21 +410,19 @@ static void bd_main_t *bdm = &bd_main; vl_api_sw_interface_set_l2_bridge_reply_t *rmp; int rv = 0; - u32 rx_sw_if_index = ntohl (mp->rx_sw_if_index); - u32 bd_id = ntohl (mp->bd_id); - u32 bd_index; - u32 bvi = mp->bvi; - u8 shg = mp->shg; vlib_main_t *vm = vlib_get_main (); vnet_main_t *vnm = vnet_get_main (); VALIDATE_RX_SW_IF_INDEX (mp); + u32 rx_sw_if_index = ntohl (mp->rx_sw_if_index); - bd_index = bd_find_or_add_bd_index (bdm, bd_id); if (mp->enable) { - //VALIDATE_TX_SW_IF_INDEX(mp); + u32 bd_id = ntohl (mp->bd_id); + u32 bd_index = bd_find_or_add_bd_index (bdm, bd_id); + u32 bvi = mp->bvi; + u8 shg = mp->shg; rv = set_int_l2_mode (vm, vnm, MODE_L2_BRIDGE, rx_sw_if_index, bd_index, bvi, shg, 0); } @@ -448,6 +446,12 @@ vl_api_bd_ip_mac_add_del_t_handler (vl_api_bd_ip_mac_add_del_t * mp) u32 bd_index; uword *p; + if (bd_id == 0) + { + rv = VNET_API_ERROR_BD_NOT_MODIFIABLE; + goto out; + } + p = hash_get (bdm->bd_index_by_bd_id, bd_id); if (p == 0) { @@ -896,9 +900,10 @@ ip4_reset_fib_t_handler (vl_api_reset_fib_t * mp) /* *INDENT-OFF* */ pool_foreach (fib_table, im4->fibs, ({ - fib = &fib_table->v4; vnet_sw_interface_t * si; + fib = pool_elt_at_index (im4->v4_fibs, fib_table->ft_index); + if (fib->table_id != target_fib_id) continue; @@ -964,13 +969,17 @@ ip6_reset_fib_t_handler (vl_api_reset_fib_t * mp) pool_foreach (fib_table, im6->fibs, ({ vnet_sw_interface_t * si; - fib = &(fib_table->v6); + + fib = pool_elt_at_index (im6->v6_fibs, fib_table->ft_index); if (fib->table_id != target_fib_id) continue; vec_reset_length (sw_if_indices_to_shut); + /* Set the flow hash for this fib to the default */ + vnet_set_ip6_flow_hash (fib->table_id, IP_FLOW_HASH_DEFAULT); + /* Shut down interfaces in this FIB / clean out intfc routes */ pool_foreach (si, im->sw_interfaces, ({ @@ -1569,12 +1578,23 @@ vl_api_want_ip4_arp_events_t_handler (vl_api_want_ip4_arp_events_t * mp) vpe_api_main_t *am = &vpe_api_main; vnet_main_t *vnm = vnet_get_main (); vl_api_want_ip4_arp_events_reply_t *rmp; - vl_api_ip4_arp_event_t *event; int rv; if (mp->enable_disable) { + vl_api_ip4_arp_event_t *event; pool_get (am->arp_events, event); + rv = vnet_add_del_ip4_arp_change_event + (vnm, arp_change_data_callback, + mp->pid, &mp->address /* addr, in net byte order */ , + vpe_resolver_process_node.index, + IP4_ARP_EVENT, event - am->arp_events, 1 /* is_add */ ); + + if (rv) + { + pool_put (am->arp_events, event); + goto out; + } memset (event, 0, sizeof (*event)); event->_vl_msg_id = ntohs (VL_API_IP4_ARP_EVENT); @@ -1584,12 +1604,6 @@ vl_api_want_ip4_arp_events_t_handler (vl_api_want_ip4_arp_events_t * mp) event->pid = mp->pid; if (mp->address == 0) event->mac_ip = 1; - - rv = vnet_add_del_ip4_arp_change_event - (vnm, arp_change_data_callback, - mp->pid, &mp->address /* addr, in net byte order */ , - vpe_resolver_process_node.index, - IP4_ARP_EVENT, event - am->arp_events, 1 /* is_add */ ); } else { @@ -1599,6 +1613,7 @@ vl_api_want_ip4_arp_events_t_handler (vl_api_want_ip4_arp_events_t * mp) vpe_resolver_process_node.index, IP4_ARP_EVENT, ~0 /* pool index */ , 0 /* is_add */ ); } +out: REPLY_MACRO (VL_API_WANT_IP4_ARP_EVENTS_REPLY); } @@ -1608,12 +1623,24 @@ vl_api_want_ip6_nd_events_t_handler (vl_api_want_ip6_nd_events_t * mp) vpe_api_main_t *am = &vpe_api_main; vnet_main_t *vnm = vnet_get_main (); vl_api_want_ip6_nd_events_reply_t *rmp; - vl_api_ip6_nd_event_t *event; int rv; if (mp->enable_disable) { + vl_api_ip6_nd_event_t *event; pool_get (am->nd_events, event); + + rv = vnet_add_del_ip6_nd_change_event + (vnm, nd_change_data_callback, + mp->pid, mp->address /* addr, in net byte order */ , + vpe_resolver_process_node.index, + IP6_ND_EVENT, event - am->nd_events, 1 /* is_add */ ); + + if (rv) + { + pool_put (am->nd_events, event); + goto out; + } memset (event, 0, sizeof (*event)); event->_vl_msg_id = ntohs (VL_API_IP6_ND_EVENT); @@ -1624,11 +1651,6 @@ vl_api_want_ip6_nd_events_t_handler (vl_api_want_ip6_nd_events_t * mp) if (ip6_address_is_zero ((ip6_address_t *) mp->address)) event->mac_ip = 1; - rv = vnet_add_del_ip6_nd_change_event - (vnm, nd_change_data_callback, - mp->pid, mp->address /* addr, in net byte order */ , - vpe_resolver_process_node.index, - IP6_ND_EVENT, event - am->nd_events, 1 /* is_add */ ); } else { @@ -1638,6 +1660,7 @@ vl_api_want_ip6_nd_events_t_handler (vl_api_want_ip6_nd_events_t * mp) vpe_resolver_process_node.index, IP6_ND_EVENT, ~0 /* pool index */ , 0 /* is_add */ ); } +out: REPLY_MACRO (VL_API_WANT_IP6_ND_EVENTS_REPLY); } @@ -2268,7 +2291,7 @@ format_arp_event (u8 * s, va_list * args) { vl_api_ip4_arp_event_t *event = va_arg (*args, vl_api_ip4_arp_event_t *); - s = format (s, "pid %d: ", event->pid); + s = format (s, "pid %d: ", ntohl (event->pid)); if (event->mac_ip) s = format (s, "bd mac/ip4 binding events"); else @@ -2281,7 +2304,7 @@ format_nd_event (u8 * s, va_list * args) { vl_api_ip6_nd_event_t *event = va_arg (*args, vl_api_ip6_nd_event_t *); - s = format (s, "pid %d: ", event->pid); + s = format (s, "pid %d: ", ntohl (event->pid)); if (event->mac_ip) s = format (s, "bd mac/ip6 binding events"); else