aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/ip
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2021-06-23 14:38:38 +0000
committerNeale Ranns <neale@graphiant.com>2021-07-01 10:10:35 +0000
commit5ff59a1f8b7f6de7738a0fd95e1dbf250dbf1a6a (patch)
tree8f1f444f4b4ca02f9b21c8d41a3aa986f7dfe36c /src/vnet/ip
parentb946b209b9c4d75af5b49b6187ecb70bd658728e (diff)
ip: api cleanup
Use autogenerated code. Does not change API definitions. Type: improvement Signed-off-by: Filip Tehlar <ftehlar@cisco.com> Change-Id: I4b6d881571c158b7a69a78b9680732d090c4f8b5
Diffstat (limited to 'src/vnet/ip')
-rw-r--r--src/vnet/ip/ip4.h2
-rw-r--r--src/vnet/ip/ip_api.c116
2 files changed, 21 insertions, 97 deletions
diff --git a/src/vnet/ip/ip4.h b/src/vnet/ip/ip4.h
index 32552eafbff..bc971a2b7ca 100644
--- a/src/vnet/ip/ip4.h
+++ b/src/vnet/ip/ip4.h
@@ -164,6 +164,8 @@ typedef struct ip4_main_t
u8 pad[2];
} host_config;
+
+ u16 msg_id_base;
} ip4_main_t;
#define ARP_THROTTLE_BITS (512)
diff --git a/src/vnet/ip/ip_api.c b/src/vnet/ip/ip_api.c
index 91b12e5896a..6f06e382024 100644
--- a/src/vnet/ip/ip_api.c
+++ b/src/vnet/ip/ip_api.c
@@ -48,71 +48,12 @@
#include <vnet/ip/ip_table.h>
#include <vnet/ip/ip_container_proxy.h>
-#include <vnet/vnet_msg_enum.h>
-
-#define vl_typedefs /* define message structures */
-#include <vnet/vnet_all_api_h.h>
-#undef vl_typedefs
-
-#define vl_endianfun /* define message structures */
-#include <vnet/vnet_all_api_h.h>
-#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 <vnet/vnet_all_api_h.h>
-#undef vl_printfun
-
-#include <vlibapi/api_helper_macros.h>
-
#include <vnet/format_fns.h>
+#include <vnet/ip/ip.api_enum.h>
+#include <vnet/ip/ip.api_types.h>
-#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_ROUTE_V2_DUMP, ip_route_v2_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_ADD_DEL_V2, ip_route_add_del_v2) \
- _ (IP_ROUTE_LOOKUP, ip_route_lookup) \
- _ (IP_ROUTE_LOOKUP_V2, ip_route_lookup_v2) \
- _ (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) \
- _ (SET_IP_FLOW_HASH_ROUTER_ID, set_ip_flow_hash_router_id) \
- _ (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) \
- _ (IP_PATH_MTU_UPDATE, ip_path_mtu_update) \
- _ (IP_PATH_MTU_REPLACE_BEGIN, ip_path_mtu_replace_begin) \
- _ (IP_PATH_MTU_REPLACE_END, ip_path_mtu_replace_end) \
- _ (IP_PATH_MTU_GET, ip_path_mtu_get)
+#define REPLY_MSG_ID_BASE ip4_main.msg_id_base
+#include <vlibapi/api_helper_macros.h>
static void
vl_api_sw_interface_ip6_enable_disable_t_handler
@@ -143,7 +84,7 @@ send_ip_table_details (vpe_api_main_t * am,
if (!mp)
return;
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_IP_TABLE_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_IP_TABLE_DETAILS);
mp->context = context;
mp->table.is_ip6 = (table->ft_proto == FIB_PROTOCOL_IP6);
@@ -215,7 +156,7 @@ send_ip_route_details (vpe_api_main_t * am,
if (!mp)
return;
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_IP_ROUTE_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_IP_ROUTE_DETAILS);
mp->context = context;
ip_prefix_encode (pfx, &mp->route.prefix);
@@ -257,7 +198,7 @@ send_ip_route_v2_details (vpe_api_main_t *am, vl_api_registration_t *reg,
if (!mp)
return;
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_IP_ROUTE_V2_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_IP_ROUTE_V2_DETAILS);
mp->context = context;
ip_prefix_encode (pfx, &mp->route.prefix);
@@ -366,7 +307,7 @@ send_ip_mtable_details (vl_api_registration_t * reg,
if (!mp)
return;
memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_IP_MTABLE_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_IP_MTABLE_DETAILS);
mp->context = context;
mp->table.table_id = htonl (mfib_table->mft_table_id);
@@ -432,7 +373,7 @@ send_ip_mroute_details (vpe_api_main_t * am,
if (!mp)
return;
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_IP_MROUTE_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_IP_MROUTE_DETAILS);
mp->context = context;
ip_mprefix_encode (pfx, &mp->route.prefix);
@@ -1031,7 +972,7 @@ send_ip_details (vpe_api_main_t * am,
mp = vl_msg_api_alloc (sizeof (*mp));
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_IP_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_IP_DETAILS);
mp->sw_if_index = ntohl (sw_if_index);
mp->is_ipv6 = is_ipv6;
@@ -1050,7 +991,7 @@ send_ip_address_details (vpe_api_main_t * am,
mp = vl_msg_api_alloc (sizeof (*mp));
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_IP_ADDRESS_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_IP_ADDRESS_DETAILS);
ip_prefix_encode (pfx, &mp->prefix);
mp->context = context;
@@ -1126,7 +1067,7 @@ send_ip_unnumbered_details (vpe_api_main_t * am,
mp = vl_msg_api_alloc (sizeof (*mp));
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_IP_UNNUMBERED_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_IP_UNNUMBERED_DETAILS);
mp->context = context;
mp->sw_if_index = htonl (sw_if_index);
@@ -1286,7 +1227,7 @@ vl_mfib_signal_send_one (vl_api_registration_t * reg,
mp = vl_msg_api_alloc (sizeof (*mp));
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_MFIB_SIGNAL_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_MFIB_SIGNAL_DETAILS);
mp->context = context;
mfi = mfib_itf_get (mfs->mfs_itf);
@@ -1367,7 +1308,8 @@ ip_container_proxy_send_details (const fib_prefix_t * pfx, u32 sw_if_index,
return 1;
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_IP_CONTAINER_PROXY_DETAILS);
+ mp->_vl_msg_id =
+ ntohs (REPLY_MSG_ID_BASE + VL_API_IP_CONTAINER_PROXY_DETAILS);
mp->context = ctx->context;
mp->sw_if_index = ntohl (sw_if_index);
@@ -1758,7 +1700,7 @@ vl_api_ip_reassembly_get_t_handler (vl_api_ip_reassembly_get_t * mp)
vl_api_ip_reassembly_get_reply_t *rmp = vl_msg_api_alloc (sizeof (*rmp));
clib_memset (rmp, 0, sizeof (*rmp));
- rmp->_vl_msg_id = ntohs (VL_API_IP_REASSEMBLY_GET_REPLY);
+ rmp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_IP_REASSEMBLY_GET_REPLY);
rmp->context = mp->context;
rmp->retval = 0;
u32 timeout_ms;
@@ -1854,7 +1796,7 @@ send_ip_punt_redirect_details (u32 rx_sw_if_index,
return (WALK_STOP);;
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_IP_PUNT_REDIRECT_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_IP_PUNT_REDIRECT_DETAILS);
mp->context = ctx->context;
fib_path_list_walk_w_ext (ipr->pl, NULL, fib_path_encode, &path_ctx);
@@ -1975,33 +1917,13 @@ vl_api_ip_path_mtu_get_t_handler (vl_api_ip_path_mtu_get_t *mp)
({ send_ip_path_mtu_details (cursor, rp, mp->context); }));
}
-#define vl_msg_name_crc_list
-#include <vnet/ip/ip.api.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_ip;
-#undef _
-}
+#include <vnet/ip/ip.api.c>
static clib_error_t *
ip_api_hookup (vlib_main_t * vm)
{
api_main_t *am = vlibapi_get_main ();
-#define _(N,n) \
- vl_msg_api_set_handlers(VL_API_##N, #n, \
- vl_api_##n##_t_handler, \
- vl_noop_handler, \
- vl_api_##n##_t_endian, \
- vl_api_##n##_t_print, \
- sizeof(vl_api_##n##_t), 1);
- foreach_ip_api_msg;
-#undef _
-
/*
* Mark the route add/del API as MP safe
*/
@@ -2013,7 +1935,7 @@ ip_api_hookup (vlib_main_t * vm)
/*
* Set up the (msg_name, crc, message-id) table
*/
- setup_message_id_table (am);
+ REPLY_MSG_ID_BASE = setup_message_id_table ();
return 0;
}