X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fip%2Fip_api.c;h=37656f3232fea4bb4eda31394ff22b6ca48863f4;hb=f2984bbb0;hp=3f593c6d3ce8ad96cdb0dc0e14f0ccb2a6c65a4c;hpb=5a59b2bac48611a316adf128bdb0e1e2fe889656;p=vpp.git diff --git a/src/vnet/ip/ip_api.c b/src/vnet/ip/ip_api.c index 3f593c6d3ce..37656f3232f 100644 --- a/src/vnet/ip/ip_api.c +++ b/src/vnet/ip/ip_api.c @@ -45,6 +45,7 @@ #include #include #include +#include #include @@ -66,40 +67,43 @@ #include -#define foreach_ip_api_msg \ -_(SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable) \ -_(IP_TABLE_DUMP, ip_table_dump) \ -_(IP_ROUTE_DUMP, ip_route_dump) \ -_(IP_MTABLE_DUMP, ip_mtable_dump) \ -_(IP_MROUTE_DUMP, ip_mroute_dump) \ -_(IP_MROUTE_ADD_DEL, ip_mroute_add_del) \ -_(MFIB_SIGNAL_DUMP, mfib_signal_dump) \ -_(IP_ADDRESS_DUMP, ip_address_dump) \ -_(IP_UNNUMBERED_DUMP, ip_unnumbered_dump) \ -_(IP_DUMP, ip_dump) \ -_(IP_TABLE_REPLACE_BEGIN, ip_table_replace_begin) \ -_(IP_TABLE_REPLACE_END, ip_table_replace_end) \ -_(IP_TABLE_FLUSH, ip_table_flush) \ -_(IP_ROUTE_ADD_DEL, ip_route_add_del) \ -_(IP_ROUTE_LOOKUP, ip_route_lookup) \ -_(IP_TABLE_ADD_DEL, ip_table_add_del) \ -_(IP_PUNT_POLICE, ip_punt_police) \ -_(IP_PUNT_REDIRECT, ip_punt_redirect) \ -_(SET_IP_FLOW_HASH,set_ip_flow_hash) \ -_(IP_CONTAINER_PROXY_ADD_DEL, ip_container_proxy_add_del) \ -_(IP_CONTAINER_PROXY_DUMP, ip_container_proxy_dump) \ -_(IOAM_ENABLE, ioam_enable) \ -_(IOAM_DISABLE, ioam_disable) \ -_(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) \ - _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, \ - sw_interface_ip6_set_link_local_address) \ -_(IP_REASSEMBLY_SET, ip_reassembly_set) \ -_(IP_REASSEMBLY_GET, ip_reassembly_get) \ -_(IP_REASSEMBLY_ENABLE_DISABLE, ip_reassembly_enable_disable) \ -_(IP_PUNT_REDIRECT_DUMP, ip_punt_redirect_dump) +#define foreach_ip_api_msg \ + _ (SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable) \ + _ (IP_TABLE_DUMP, ip_table_dump) \ + _ (IP_ROUTE_DUMP, ip_route_dump) \ + _ (IP_MTABLE_DUMP, ip_mtable_dump) \ + _ (IP_MROUTE_DUMP, ip_mroute_dump) \ + _ (IP_MROUTE_ADD_DEL, ip_mroute_add_del) \ + _ (MFIB_SIGNAL_DUMP, mfib_signal_dump) \ + _ (IP_ADDRESS_DUMP, ip_address_dump) \ + _ (IP_UNNUMBERED_DUMP, ip_unnumbered_dump) \ + _ (IP_DUMP, ip_dump) \ + _ (IP_TABLE_REPLACE_BEGIN, ip_table_replace_begin) \ + _ (IP_TABLE_REPLACE_END, ip_table_replace_end) \ + _ (IP_TABLE_FLUSH, ip_table_flush) \ + _ (IP_ROUTE_ADD_DEL, ip_route_add_del) \ + _ (IP_ROUTE_LOOKUP, ip_route_lookup) \ + _ (IP_TABLE_ADD_DEL, ip_table_add_del) \ + _ (IP_PUNT_POLICE, ip_punt_police) \ + _ (IP_PUNT_REDIRECT, ip_punt_redirect) \ + _ (SET_IP_FLOW_HASH, set_ip_flow_hash) \ + _ (SET_IP_FLOW_HASH_V2, set_ip_flow_hash_v2) \ + _ (IP_CONTAINER_PROXY_ADD_DEL, ip_container_proxy_add_del) \ + _ (IP_CONTAINER_PROXY_DUMP, ip_container_proxy_dump) \ + _ (IOAM_ENABLE, ioam_enable) \ + _ (IOAM_DISABLE, ioam_disable) \ + _ (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) \ + _ (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, \ + sw_interface_ip6_set_link_local_address) \ + _ (SW_INTERFACE_IP6_GET_LINK_LOCAL_ADDRESS, \ + sw_interface_ip6_get_link_local_address) \ + _ (IP_REASSEMBLY_SET, ip_reassembly_set) \ + _ (IP_REASSEMBLY_GET, ip_reassembly_get) \ + _ (IP_REASSEMBLY_ENABLE_DISABLE, ip_reassembly_enable_disable) \ + _ (IP_PUNT_REDIRECT_DUMP, ip_punt_redirect_dump) static void vl_api_sw_interface_ip6_enable_disable_t_handler @@ -153,17 +157,17 @@ vl_api_ip_table_dump_t_handler (vl_api_ip_table_dump_t * mp) return; /* *INDENT-OFF* */ - pool_foreach (fib_table, ip4_main.fibs, - ({ + pool_foreach (fib_table, ip4_main.fibs) + { send_ip_table_details(am, reg, mp->context, fib_table); - })); - pool_foreach (fib_table, ip6_main.fibs, - ({ + } + pool_foreach (fib_table, ip6_main.fibs) + { /* don't send link locals */ if (fib_table->ft_flags & FIB_TABLE_FLAG_IP6_LL) continue; send_ip_table_details(am, reg, mp->context, fib_table); - })); + } /* *INDENT-ON* */ } @@ -293,14 +297,14 @@ vl_api_ip_mtable_dump_t_handler (vl_api_ip_mtable_dump_t * mp) return; /* *INDENT-OFF* */ - pool_foreach (mfib_table, ip4_main.mfibs, - ({ + pool_foreach (mfib_table, ip4_main.mfibs) + { send_ip_mtable_details (reg, mp->context, mfib_table); - })); - pool_foreach (mfib_table, ip6_main.mfibs, - ({ + } + pool_foreach (mfib_table, ip6_main.mfibs) + { send_ip_mtable_details (reg, mp->context, mfib_table); - })); + } /* *INDENT-ON* */ } @@ -745,6 +749,7 @@ api_mroute_add_del_t_handler (vl_api_ip_mroute_add_del_t * mp, { fib_route_path_t *rpath, *rpaths = NULL; fib_node_index_t mfib_entry_index; + mfib_entry_flags_t eflags; mfib_prefix_t pfx; u32 fib_index; int rv; @@ -769,10 +774,11 @@ api_mroute_add_del_t_handler (vl_api_ip_mroute_add_del_t * mp, goto out; } + eflags = mfib_api_path_entry_flags_decode (mp->route.entry_flags); mfib_entry_index = mroute_add_del_handler (mp->is_add, mp->is_add, fib_index, &pfx, - ntohl (mp->route.entry_flags), + eflags, ntohl (mp->route.rpf_id), rpaths); @@ -947,8 +953,8 @@ vl_api_ip_unnumbered_dump_t_handler (vl_api_ip_unnumbered_dump_t * mp) else { /* *INDENT-OFF* */ - pool_foreach (si, im->sw_interfaces, - ({ + pool_foreach (si, im->sw_interfaces) + { if ((si->flags & VNET_SW_INTERFACE_FLAG_UNNUMBERED)) { send_ip_unnumbered_details(am, reg, @@ -956,7 +962,7 @@ vl_api_ip_unnumbered_dump_t_handler (vl_api_ip_unnumbered_dump_t * mp) si->unnumbered_sw_if_index, mp->context); } - })); + } /* *INDENT-ON* */ } @@ -982,10 +988,10 @@ vl_api_ip_dump_t_handler (vl_api_ip_dump_t * mp) sorted_sis = vec_new (vnet_sw_interface_t, pool_elts (im->sw_interfaces)); _vec_len (sorted_sis) = 0; /* *INDENT-OFF* */ - pool_foreach (si, im->sw_interfaces, - ({ + pool_foreach (si, im->sw_interfaces) + { vec_add1 (sorted_sis, si[0]); - })); + } /* *INDENT-ON* */ vec_foreach (si, sorted_sis) @@ -1005,7 +1011,7 @@ vl_api_ip_dump_t_handler (vl_api_ip_dump_t * mp) } static void -set_ip6_flow_hash (vl_api_set_ip_flow_hash_t * mp) +vl_api_set_ip_flow_hash_t_handler (vl_api_set_ip_flow_hash_t *mp) { vl_api_set_ip_flow_hash_reply_t *rmp; int rv; @@ -1015,41 +1021,29 @@ set_ip6_flow_hash (vl_api_set_ip_flow_hash_t * mp) table_id = ntohl (mp->vrf_id); #define _(a,b) if (mp->a) flow_hash_config |= b; - foreach_flow_hash_bit; + foreach_flow_hash_bit_v1; #undef _ - rv = vnet_set_ip6_flow_hash (table_id, flow_hash_config); + rv = ip_flow_hash_set ((mp->is_ipv6 ? AF_IP6 : AF_IP4), table_id, + flow_hash_config); REPLY_MACRO (VL_API_SET_IP_FLOW_HASH_REPLY); } static void -set_ip4_flow_hash (vl_api_set_ip_flow_hash_t * mp) +vl_api_set_ip_flow_hash_v2_t_handler (vl_api_set_ip_flow_hash_v2_t *mp) { - vl_api_set_ip_flow_hash_reply_t *rmp; + vl_api_set_ip_flow_hash_v2_reply_t *rmp; + ip_address_family_t af; int rv; - u32 table_id; - flow_hash_config_t flow_hash_config = 0; - - table_id = ntohl (mp->vrf_id); - -#define _(a,b) if (mp->a) flow_hash_config |= b; - foreach_flow_hash_bit; -#undef _ - - rv = vnet_set_ip4_flow_hash (table_id, flow_hash_config); - REPLY_MACRO (VL_API_SET_IP_FLOW_HASH_REPLY); -} + rv = ip_address_family_decode (mp->af, &af); + if (!rv) + rv = ip_flow_hash_set (af, htonl (mp->table_id), + htonl (mp->flow_hash_config)); -static void -vl_api_set_ip_flow_hash_t_handler (vl_api_set_ip_flow_hash_t * mp) -{ - if (mp->is_ipv6 == 0) - set_ip4_flow_hash (mp); - else - set_ip6_flow_hash (mp); + REPLY_MACRO (VL_API_SET_IP_FLOW_HASH_V2_REPLY); } void @@ -1360,6 +1354,30 @@ static void REPLY_MACRO (VL_API_SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY); } +static void +vl_api_sw_interface_ip6_get_link_local_address_t_handler ( + vl_api_sw_interface_ip6_get_link_local_address_t *mp) +{ + vl_api_sw_interface_ip6_get_link_local_address_reply_t *rmp; + const ip6_address_t *ip = NULL; + int rv = 0; + + VALIDATE_SW_IF_INDEX (mp); + + ip = ip6_get_link_local_address (ntohl (mp->sw_if_index)); + if (NULL == ip) + rv = VNET_API_ERROR_IP6_NOT_ENABLED; + + BAD_SW_IF_INDEX_LABEL; + /* clang-format off */ + REPLY_MACRO2 (VL_API_SW_INTERFACE_IP6_GET_LINK_LOCAL_ADDRESS_REPLY, + ({ + if (!rv) + ip6_address_encode (ip, rmp->ip); + })) + /* clang-format on */ +} + static void vl_api_ip_table_replace_begin_t_handler (vl_api_ip_table_replace_begin_t * mp) { @@ -1426,8 +1444,8 @@ vl_api_ip_table_flush_t_handler (vl_api_ip_table_flush_t * mp) /* Shut down interfaces in this FIB / clean out intfc routes */ /* *INDENT-OFF* */ - pool_foreach (si, im->sw_interfaces, - ({ + pool_foreach (si, im->sw_interfaces) + { if (fib_index == fib_table_get_index_for_sw_if_index (fproto, si->sw_if_index)) { @@ -1435,7 +1453,7 @@ vl_api_ip_table_flush_t_handler (vl_api_ip_table_flush_t * mp) flags &= ~VNET_SW_INTERFACE_FLAG_ADMIN_UP; vnet_sw_interface_set_flags (vnm, si->sw_if_index, flags); } - })); + } /* *INDENT-ON* */ fib_table_flush (fib_index, fproto, FIB_SOURCE_API);