aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKlement Sekera <ksekera@cisco.com>2021-12-03 10:48:13 +0000
committerKlement Sekera <ksekera@cisco.com>2021-12-03 10:51:11 +0000
commit5d5f85f5e4003476fb6d9a0ccd6ad58ad90e5138 (patch)
treeb1f30e5bc4de1610badc00093d33ee88ca058336
parent03092c1982468ff6ffe260b0215f910d4c486b04 (diff)
api: refactor to use REPLY_MSG_ID_BASE #define
REPLY_MSG_ID_BASE is the standard way to define reply message id base, so this refactor makes all the files use that. This is a preparation patch for future safety add-ons which rely on REPLY_MACRO* parameters to be preprocessor tokens identifying the message instead, Type: refactor Signed-off-by: Klement Sekera <ksekera@cisco.com> Change-Id: Ibe3e056a3d9326d08af45bbcb25588b11e870141
-rw-r--r--src/plugins/abf/abf_api.c7
-rw-r--r--src/plugins/af_xdp/api.c13
-rw-r--r--src/plugins/arping/arping_api.c3
-rw-r--r--src/plugins/avf/avf_api.c9
-rw-r--r--src/plugins/igmp/igmp.h1
-rw-r--r--src/plugins/igmp/igmp_api.c15
-rw-r--r--src/plugins/l3xc/l3xc_api.c10
-rw-r--r--src/plugins/rdma/api.c17
-rw-r--r--src/plugins/svs/svs_api.c7
-rw-r--r--src/plugins/vmxnet3/vmxnet3_api.c9
10 files changed, 41 insertions, 50 deletions
diff --git a/src/plugins/abf/abf_api.c b/src/plugins/abf/abf_api.c
index cc55b214e35..66121acbdf0 100644
--- a/src/plugins/abf/abf_api.c
+++ b/src/plugins/abf/abf_api.c
@@ -34,10 +34,11 @@
#include <abf/abf.api_types.h>
/**
- * Base message ID fot the plugin
+ * Base message ID for the plugin
*/
static u32 abf_base_msg_id;
+#define REPLY_MSG_ID_BASE (abf_base_msg_id)
#include <vlibapi/api_helper_macros.h>
static void
@@ -93,7 +94,7 @@ vl_api_abf_policy_add_del_t_handler (vl_api_abf_policy_add_del_t * mp)
done:
vec_free (paths);
- REPLY_MACRO (VL_API_ABF_POLICY_ADD_DEL_REPLY + abf_base_msg_id);
+ REPLY_MACRO (VL_API_ABF_POLICY_ADD_DEL_REPLY);
}
static void
@@ -118,7 +119,7 @@ vl_api_abf_itf_attach_add_del_t_handler (vl_api_abf_itf_attach_add_del_t * mp)
ntohl (mp->attach.sw_if_index));
}
- REPLY_MACRO (VL_API_ABF_ITF_ATTACH_ADD_DEL_REPLY + abf_base_msg_id);
+ REPLY_MACRO (VL_API_ABF_ITF_ATTACH_ADD_DEL_REPLY);
}
typedef struct abf_dump_walk_ctx_t_
diff --git a/src/plugins/af_xdp/api.c b/src/plugins/af_xdp/api.c
index 45dab284e4c..659825a73b6 100644
--- a/src/plugins/af_xdp/api.c
+++ b/src/plugins/af_xdp/api.c
@@ -27,6 +27,7 @@
#include <af_xdp/af_xdp.api_enum.h>
#include <af_xdp/af_xdp.api_types.h>
+#define REPLY_MSG_ID_BASE (rm->msg_id_base)
#include <vlibapi/api_helper_macros.h>
static af_xdp_mode_t
@@ -78,12 +79,8 @@ vl_api_af_xdp_create_t_handler (vl_api_af_xdp_create_t * mp)
af_xdp_create_if (vm, &args);
rv = args.rv;
- /* *INDENT-OFF* */
- REPLY_MACRO2 (VL_API_AF_XDP_CREATE_REPLY + rm->msg_id_base,
- ({
- rmp->sw_if_index = ntohl (args.sw_if_index);
- }));
- /* *INDENT-ON* */
+ REPLY_MACRO2 (VL_API_AF_XDP_CREATE_REPLY,
+ ({ rmp->sw_if_index = ntohl (args.sw_if_index); }));
}
static void
@@ -111,7 +108,7 @@ vl_api_af_xdp_create_v2_t_handler (vl_api_af_xdp_create_v2_t *mp)
rv = args.rv;
/* clang-format off */
- REPLY_MACRO2 (VL_API_AF_XDP_CREATE_V2_REPLY + rm->msg_id_base,
+ REPLY_MACRO2 (VL_API_AF_XDP_CREATE_V2_REPLY,
({
rmp->sw_if_index = ntohl (args.sw_if_index);
}));
@@ -143,7 +140,7 @@ vl_api_af_xdp_delete_t_handler (vl_api_af_xdp_delete_t * mp)
af_xdp_delete_if (vm, rd);
reply:
- REPLY_MACRO (VL_API_AF_XDP_DELETE_REPLY + rm->msg_id_base);
+ REPLY_MACRO (VL_API_AF_XDP_DELETE_REPLY);
}
/* set tup the API message handling tables */
diff --git a/src/plugins/arping/arping_api.c b/src/plugins/arping/arping_api.c
index 015c6148f5e..e0c47c7cf33 100644
--- a/src/plugins/arping/arping_api.c
+++ b/src/plugins/arping/arping_api.c
@@ -31,6 +31,7 @@
#include <arping/arping.api_enum.h>
#include <arping/arping.api_types.h>
+#define REPLY_MSG_ID_BASE (am->msg_id_base)
#include <vlibapi/api_helper_macros.h>
static void
@@ -57,7 +58,7 @@ vl_api_arping_t_handler (vl_api_arping_t *mp)
BAD_SW_IF_INDEX_LABEL;
- REPLY_MACRO2 (VL_API_ARPING_REPLY + am->msg_id_base,
+ REPLY_MACRO2 (VL_API_ARPING_REPLY,
({ rmp->reply_count = ntohl (args.reply_count); }));
}
diff --git a/src/plugins/avf/avf_api.c b/src/plugins/avf/avf_api.c
index 883b374331f..366a983f373 100644
--- a/src/plugins/avf/avf_api.c
+++ b/src/plugins/avf/avf_api.c
@@ -29,6 +29,7 @@
#include <avf/avf.api_enum.h>
#include <avf/avf.api_types.h>
+#define REPLY_MSG_ID_BASE (am->msg_id_base)
#include <vlibapi/api_helper_macros.h>
static void
@@ -52,10 +53,8 @@ vl_api_avf_create_t_handler (vl_api_avf_create_t * mp)
rv = args.rv;
/* *INDENT-OFF* */
- REPLY_MACRO2 (VL_API_AVF_CREATE_REPLY + am->msg_id_base,
- ({
- rmp->sw_if_index = ntohl (args.sw_if_index);
- }));
+ REPLY_MACRO2 (VL_API_AVF_CREATE_REPLY,
+ ({ rmp->sw_if_index = ntohl (args.sw_if_index); }));
/* *INDENT-ON* */
}
@@ -82,7 +81,7 @@ vl_api_avf_delete_t_handler (vl_api_avf_delete_t * mp)
AVF_PROCESS_EVENT_DELETE_IF, hw->dev_instance);
reply:
- REPLY_MACRO (VL_API_AVF_DELETE_REPLY + am->msg_id_base);
+ REPLY_MACRO (VL_API_AVF_DELETE_REPLY);
}
/* set tup the API message handling tables */
diff --git a/src/plugins/igmp/igmp.h b/src/plugins/igmp/igmp.h
index 9f9b611a649..4131d6d3b09 100644
--- a/src/plugins/igmp/igmp.h
+++ b/src/plugins/igmp/igmp.h
@@ -20,6 +20,7 @@
#include <vlib/vlib.h>
#include <vnet/ip/ip.h>
+#define REPLY_MSG_ID_BASE (igmp_main.msg_id_base)
#include <vlibapi/api_helper_macros.h>
#include <vnet/ip/igmp_packet.h>
#include <vnet/adj/adj_mcast.h>
diff --git a/src/plugins/igmp/igmp_api.c b/src/plugins/igmp/igmp_api.c
index 72c1b0394a8..a4746ab5c5b 100644
--- a/src/plugins/igmp/igmp_api.c
+++ b/src/plugins/igmp/igmp_api.c
@@ -71,7 +71,7 @@ vl_api_igmp_listen_t_handler (vl_api_igmp_listen_t * mp)
BAD_SW_IF_INDEX_LABEL;
done:;
- REPLY_MACRO (IGMP_MSG_ID (VL_API_IGMP_LISTEN_REPLY));
+ REPLY_MACRO (VL_API_IGMP_LISTEN_REPLY);
}
static void
@@ -88,7 +88,7 @@ vl_api_igmp_enable_disable_t_handler (vl_api_igmp_enable_disable_t * mp)
BAD_SW_IF_INDEX_LABEL;
- REPLY_MACRO (IGMP_MSG_ID (VL_API_IGMP_ENABLE_DISABLE_REPLY));
+ REPLY_MACRO (VL_API_IGMP_ENABLE_DISABLE_REPLY);
}
static void
@@ -106,7 +106,7 @@ vl_api_igmp_proxy_device_add_del_t_handler (vl_api_igmp_proxy_device_add_del_t
BAD_SW_IF_INDEX_LABEL;
- REPLY_MACRO (IGMP_MSG_ID (VL_API_IGMP_PROXY_DEVICE_ADD_DEL_REPLY));
+ REPLY_MACRO (VL_API_IGMP_PROXY_DEVICE_ADD_DEL_REPLY);
}
static void
@@ -124,8 +124,7 @@ static void
BAD_SW_IF_INDEX_LABEL;
- REPLY_MACRO (IGMP_MSG_ID
- (VL_API_IGMP_PROXY_DEVICE_ADD_DEL_INTERFACE_REPLY));
+ REPLY_MACRO (VL_API_IGMP_PROXY_DEVICE_ADD_DEL_INTERFACE_REPLY);
}
static void
@@ -209,7 +208,7 @@ vl_api_igmp_clear_interface_t_handler (vl_api_igmp_clear_interface_t * mp)
if (config)
igmp_clear_config (config);
- REPLY_MACRO (IGMP_MSG_ID (VL_API_IGMP_CLEAR_INTERFACE_REPLY));
+ REPLY_MACRO (VL_API_IGMP_CLEAR_INTERFACE_REPLY);
}
static vl_api_group_prefix_type_t
@@ -250,7 +249,7 @@ vl_api_igmp_group_prefix_set_t_handler (vl_api_igmp_group_prefix_set_t * mp)
ip_prefix_decode (&mp->gp.prefix, &pfx);
igmp_group_prefix_set (&pfx, igmp_group_type_api_to_int (mp->gp.type));
- REPLY_MACRO (IGMP_MSG_ID (VL_API_IGMP_GROUP_PREFIX_SET_REPLY));
+ REPLY_MACRO (VL_API_IGMP_GROUP_PREFIX_SET_REPLY);
}
typedef struct igmp_ssm_range_walk_ctx_t_
@@ -343,7 +342,7 @@ vl_api_want_igmp_events_t_handler (vl_api_want_igmp_events_t * mp)
rv = VNET_API_ERROR_INVALID_REGISTRATION;
done:
- REPLY_MACRO (VL_API_WANT_IGMP_EVENTS_REPLY + im->msg_id_base);
+ REPLY_MACRO (VL_API_WANT_IGMP_EVENTS_REPLY);
}
static clib_error_t *
diff --git a/src/plugins/l3xc/l3xc_api.c b/src/plugins/l3xc/l3xc_api.c
index 847acaac331..d4a837d7d9c 100644
--- a/src/plugins/l3xc/l3xc_api.c
+++ b/src/plugins/l3xc/l3xc_api.c
@@ -37,6 +37,7 @@
*/
static u32 l3xc_base_msg_id;
+#define REPLY_MSG_ID_BASE (l3xc_base_msg_id)
#include <vlibapi/api_helper_macros.h>
static void
@@ -96,12 +97,7 @@ done:
BAD_SW_IF_INDEX_LABEL;
- /* *INDENT-OFF* */
- REPLY_MACRO2 (VL_API_L3XC_UPDATE_REPLY + l3xc_base_msg_id,
- ({
- rmp->stats_index = 0;
- }))
- /* *INDENT-ON* */
+ REPLY_MACRO2 (VL_API_L3XC_UPDATE_REPLY, ({ rmp->stats_index = 0; }))
}
static void
@@ -116,7 +112,7 @@ vl_api_l3xc_del_t_handler (vl_api_l3xc_del_t * mp)
BAD_SW_IF_INDEX_LABEL;
- REPLY_MACRO (VL_API_L3XC_DEL_REPLY + l3xc_base_msg_id);
+ REPLY_MACRO (VL_API_L3XC_DEL_REPLY);
}
typedef struct l3xc_dump_walk_ctx_t_
diff --git a/src/plugins/rdma/api.c b/src/plugins/rdma/api.c
index 7fe77105596..8455cc456aa 100644
--- a/src/plugins/rdma/api.c
+++ b/src/plugins/rdma/api.c
@@ -27,6 +27,7 @@
#include <rdma/rdma.api_enum.h>
#include <rdma/rdma.api_types.h>
+#define REPLY_MSG_ID_BASE (rm->msg_id_base)
#include <vlibapi/api_helper_macros.h>
static rdma_mode_t
@@ -103,7 +104,7 @@ vl_api_rdma_create_v3_t_handler (vl_api_rdma_create_v3_t *mp)
rdma_create_if (vm, &args);
rv = args.rv;
- REPLY_MACRO2 (VL_API_RDMA_CREATE_V3_REPLY + rm->msg_id_base,
+ REPLY_MACRO2 (VL_API_RDMA_CREATE_V3_REPLY,
({ rmp->sw_if_index = ntohl (args.sw_if_index); }));
}
@@ -131,10 +132,8 @@ vl_api_rdma_create_v2_t_handler (vl_api_rdma_create_v2_t * mp)
rv = args.rv;
/* *INDENT-OFF* */
- REPLY_MACRO2 (VL_API_RDMA_CREATE_V2_REPLY + rm->msg_id_base,
- ({
- rmp->sw_if_index = ntohl (args.sw_if_index);
- }));
+ REPLY_MACRO2 (VL_API_RDMA_CREATE_V2_REPLY,
+ ({ rmp->sw_if_index = ntohl (args.sw_if_index); }));
/* *INDENT-ON* */
}
@@ -163,10 +162,8 @@ vl_api_rdma_create_t_handler (vl_api_rdma_create_t * mp)
rv = args.rv;
/* *INDENT-OFF* */
- REPLY_MACRO2 (VL_API_RDMA_CREATE_REPLY + rm->msg_id_base,
- ({
- rmp->sw_if_index = ntohl (args.sw_if_index);
- }));
+ REPLY_MACRO2 (VL_API_RDMA_CREATE_REPLY,
+ ({ rmp->sw_if_index = ntohl (args.sw_if_index); }));
/* *INDENT-ON* */
}
@@ -195,7 +192,7 @@ vl_api_rdma_delete_t_handler (vl_api_rdma_delete_t * mp)
rdma_delete_if (vm, rd);
reply:
- REPLY_MACRO (VL_API_RDMA_DELETE_REPLY + rm->msg_id_base);
+ REPLY_MACRO (VL_API_RDMA_DELETE_REPLY);
}
/* set tup the API message handling tables */
diff --git a/src/plugins/svs/svs_api.c b/src/plugins/svs/svs_api.c
index 7c0850738f3..b1660bc97dc 100644
--- a/src/plugins/svs/svs_api.c
+++ b/src/plugins/svs/svs_api.c
@@ -35,6 +35,7 @@
* Base message ID fot the plugin
*/
static u32 svs_base_msg_id;
+#define REPLY_MSG_ID_BASE (svs_base_msg_id)
#include <vlibapi/api_helper_macros.h>
static void
@@ -80,7 +81,7 @@ vl_api_svs_table_add_del_t_handler (vl_api_svs_table_add_del_t * mp)
}
error:
- REPLY_MACRO (VL_API_SVS_TABLE_ADD_DEL_REPLY + svs_base_msg_id);
+ REPLY_MACRO (VL_API_SVS_TABLE_ADD_DEL_REPLY);
}
static void
@@ -102,7 +103,7 @@ vl_api_svs_route_add_del_t_handler (vl_api_svs_route_add_del_t * mp)
rv = svs_route_delete (ntohl (mp->table_id), &pfx);
}
- REPLY_MACRO (VL_API_SVS_ROUTE_ADD_DEL_REPLY + svs_base_msg_id);
+ REPLY_MACRO (VL_API_SVS_ROUTE_ADD_DEL_REPLY);
}
static void
@@ -130,7 +131,7 @@ vl_api_svs_enable_disable_t_handler (vl_api_svs_enable_disable_t * mp)
BAD_SW_IF_INDEX_LABEL;
error:
- REPLY_MACRO (VL_API_SVS_ENABLE_DISABLE_REPLY + svs_base_msg_id);
+ REPLY_MACRO (VL_API_SVS_ENABLE_DISABLE_REPLY);
}
typedef struct svs_dump_walk_ctx_t_
diff --git a/src/plugins/vmxnet3/vmxnet3_api.c b/src/plugins/vmxnet3/vmxnet3_api.c
index cef0770a63b..90608082a3e 100644
--- a/src/plugins/vmxnet3/vmxnet3_api.c
+++ b/src/plugins/vmxnet3/vmxnet3_api.c
@@ -29,6 +29,7 @@
#include <vmxnet3/vmxnet3.api_enum.h>
#include <vmxnet3/vmxnet3.api_types.h>
+#define REPLY_MSG_ID_BASE (vmxm->msg_id_base)
#include <vlibapi/api_helper_macros.h>
static void
@@ -55,10 +56,8 @@ vl_api_vmxnet3_create_t_handler (vl_api_vmxnet3_create_t * mp)
rv = args.rv;
/* *INDENT-OFF* */
- REPLY_MACRO2 (VL_API_VMXNET3_CREATE_REPLY + vmxm->msg_id_base,
- ({
- rmp->sw_if_index = ntohl (args.sw_if_index);
- }));
+ REPLY_MACRO2 (VL_API_VMXNET3_CREATE_REPLY,
+ ({ rmp->sw_if_index = ntohl (args.sw_if_index); }));
/* *INDENT-ON* */
}
@@ -87,7 +86,7 @@ vl_api_vmxnet3_delete_t_handler (vl_api_vmxnet3_delete_t * mp)
vmxnet3_delete_if (vm, vd);
reply:
- REPLY_MACRO (VL_API_VMXNET3_DELETE_REPLY + vmxm->msg_id_base);
+ REPLY_MACRO (VL_API_VMXNET3_DELETE_REPLY);
}
static void