aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2019-04-10 09:44:23 +0200
committerDave Wallace <dwallacelf@gmail.com>2019-04-10 13:06:45 +0000
commit2e1c8967faf4e9f7b45471df02e4e5b07fbb520a (patch)
tree172579d8d04927851d1781262bd2483fa9bf8643 /src
parent13464f323a8bbd530bd85256de1c033781e098a7 (diff)
API: Fix shared memory only action handlers.
Some API action handlers called vl_msg_ai_send_shmem() directly. That breaks Unix domain socket API transport. A couple (bond / vhost) also tried to send a sw_interface_event directly, but did not send the message to all that had registred interest. That scheme never worked correctly. Refactored and improved the interface event code. Change-Id: Idb90edfd8703c6ae593b36b4eeb4d3ed7da5c808 Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/abf/abf_api.c46
-rw-r--r--src/plugins/acl/acl.c12
-rw-r--r--src/plugins/igmp/igmp_api.c42
-rw-r--r--src/plugins/ioam/lib-trace/trace_api.c70
-rw-r--r--src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c59
-rw-r--r--src/plugins/nat/nat_api.c22
-rw-r--r--src/plugins/nsh/nsh_api.c36
-rw-r--r--src/plugins/svs/svs_api.c29
-rw-r--r--src/vlibmemory/memory_client.c1
-rw-r--r--src/vlibmemory/memory_shared.h1
-rw-r--r--src/vnet/bonding/bond_api.c80
-rw-r--r--src/vnet/devices/tap/tapv2_api.c24
-rw-r--r--src/vnet/devices/virtio/vhost_user_api.c22
-rw-r--r--src/vnet/devices/virtio/virtio_api.c25
-rw-r--r--src/vnet/interface_api.c121
-rw-r--r--src/vnet/ip/ip_api.c9
16 files changed, 191 insertions, 408 deletions
diff --git a/src/plugins/abf/abf_api.c b/src/plugins/abf/abf_api.c
index bf2566901c4..9da08394fe6 100644
--- a/src/plugins/abf/abf_api.c
+++ b/src/plugins/abf/abf_api.c
@@ -72,24 +72,20 @@ static void
vl_api_abf_plugin_get_version_t_handler (vl_api_abf_plugin_get_version_t * mp)
{
vl_api_abf_plugin_get_version_reply_t *rmp;
- int msg_size = sizeof (*rmp);
- unix_shared_memory_queue_t *q;
+ vl_api_registration_t *rp;
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (q == 0)
- {
- return;
- }
+ rp = vl_api_client_index_to_registration (mp->client_index);
+ if (rp == 0)
+ return;
- rmp = vl_msg_api_alloc (msg_size);
- clib_memset (rmp, 0, msg_size);
+ rmp = vl_msg_api_alloc (sizeof (*rmp));
rmp->_vl_msg_id =
ntohs (VL_API_ABF_PLUGIN_GET_VERSION_REPLY + abf_base_msg_id);
rmp->context = mp->context;
rmp->major = htonl (ABF_PLUGIN_VERSION_MAJOR);
rmp->minor = htonl (ABF_PLUGIN_VERSION_MINOR);
- vl_msg_api_send_shmem (q, (u8 *) & rmp);
+ vl_api_send_msg (rp, (u8 *) rmp);
}
static void
@@ -155,7 +151,7 @@ vl_api_abf_itf_attach_add_del_t_handler (vl_api_abf_itf_attach_add_del_t * mp)
typedef struct abf_dump_walk_ctx_t_
{
- unix_shared_memory_queue_t *q;
+ vl_api_registration_t *rp;
u32 context;
} abf_dump_walk_ctx_t;
@@ -194,7 +190,7 @@ abf_policy_send_details (u32 api, void *args)
fp++;
}
- vl_msg_api_send_shmem (ctx->q, (u8 *) & mp);
+ vl_api_send_msg (ctx->rp, (u8 *) mp);
return (1);
}
@@ -202,16 +198,14 @@ abf_policy_send_details (u32 api, void *args)
static void
vl_api_abf_policy_dump_t_handler (vl_api_abf_policy_dump_t * mp)
{
- unix_shared_memory_queue_t *q;
+ vl_api_registration_t *rp;
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (q == 0)
- {
- return;
- }
+ rp = vl_api_client_index_to_registration (mp->client_index);
+ if (rp == 0)
+ return;
abf_dump_walk_ctx_t ctx = {
- .q = q,
+ .rp = rp,
.context = mp->context,
};
@@ -239,7 +233,7 @@ abf_itf_attach_send_details (u32 aiai, void *args)
mp->attach.priority = htonl (aia->aia_prio);
mp->attach.is_ipv6 = (aia->aia_proto == FIB_PROTOCOL_IP6);
- vl_msg_api_send_shmem (ctx->q, (u8 *) & mp);
+ vl_api_send_msg (ctx->rp, (u8 *) mp);
return (1);
}
@@ -247,16 +241,14 @@ abf_itf_attach_send_details (u32 aiai, void *args)
static void
vl_api_abf_itf_attach_dump_t_handler (vl_api_abf_itf_attach_dump_t * mp)
{
- unix_shared_memory_queue_t *q;
+ vl_api_registration_t *rp;
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (q == 0)
- {
- return;
- }
+ rp = vl_api_client_index_to_registration (mp->client_index);
+ if (rp == 0)
+ return;
abf_dump_walk_ctx_t ctx = {
- .q = q,
+ .rp = rp,
.context = mp->context,
};
diff --git a/src/plugins/acl/acl.c b/src/plugins/acl/acl.c
index 396fe1fd114..63aafec6daf 100644
--- a/src/plugins/acl/acl.c
+++ b/src/plugins/acl/acl.c
@@ -305,13 +305,11 @@ static void
acl_main_t *am = &acl_main;
vl_api_acl_plugin_get_conn_table_max_entries_reply_t *rmp;
int msg_size = sizeof (*rmp);
- unix_shared_memory_queue_t *q;
+ vl_api_registration_t *rp;
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (q == 0)
- {
- return;
- }
+ rp = vl_api_client_index_to_registration (mp->client_index);
+ if (rp == 0)
+ return;
rmp = vl_msg_api_alloc (msg_size);
memset (rmp, 0, msg_size);
@@ -321,7 +319,7 @@ static void
rmp->context = mp->context;
rmp->conn_table_max_entries = __bswap_64 (am->fa_conn_table_max_entries);
- vl_msg_api_send_shmem (q, (u8 *) & rmp);
+ vl_api_send_msg (rp, (u8 *) rmp);
}
static void
diff --git a/src/plugins/igmp/igmp_api.c b/src/plugins/igmp/igmp_api.c
index 0149b2af127..d619abdd893 100644
--- a/src/plugins/igmp/igmp_api.c
+++ b/src/plugins/igmp/igmp_api.c
@@ -160,7 +160,7 @@ static void
}
static void
-send_igmp_details (unix_shared_memory_queue_t * q, igmp_main_t * im,
+send_igmp_details (vl_api_registration_t * rp, igmp_main_t * im,
igmp_config_t * config, igmp_group_t * group,
igmp_src_t * src, u32 context)
{
@@ -175,12 +175,12 @@ send_igmp_details (unix_shared_memory_queue_t * q, igmp_main_t * im,
clib_memcpy (&mp->saddr, &src->key->ip4, sizeof (src->key->ip4));
clib_memcpy (&mp->gaddr, &group->key->ip4, sizeof (group->key->ip4));
- vl_msg_api_send_shmem (q, (u8 *) & mp);
+ vl_api_send_msg (rp, (u8 *) mp);
}
static void
igmp_config_dump (igmp_main_t * im,
- unix_shared_memory_queue_t * q,
+ vl_api_registration_t * rp,
u32 context, igmp_config_t * config)
{
igmp_group_t *group;
@@ -191,7 +191,7 @@ igmp_config_dump (igmp_main_t * im,
({
FOR_EACH_SRC (src, group, IGMP_FILTER_MODE_INCLUDE,
({
- send_igmp_details (q, im, config, group, src, context);
+ send_igmp_details (rp, im, config, group, src, context);
}));
}));
/* *INDENT-ON* */
@@ -200,13 +200,13 @@ igmp_config_dump (igmp_main_t * im,
static void
vl_api_igmp_dump_t_handler (vl_api_igmp_dump_t * mp)
{
- unix_shared_memory_queue_t *q;
igmp_main_t *im = &igmp_main;
igmp_config_t *config;
u32 sw_if_index;
+ vl_api_registration_t *rp;
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (!q)
+ rp = vl_api_client_index_to_registration (mp->client_index);
+ if (rp == 0)
return;
sw_if_index = ntohl (mp->sw_if_index);
@@ -215,7 +215,7 @@ vl_api_igmp_dump_t_handler (vl_api_igmp_dump_t * mp)
/* *INDENT-OFF* */
pool_foreach (config, im->configs,
({
- igmp_config_dump(im, q, mp->context, config);
+ igmp_config_dump(im, rp, mp->context, config);
}));
/* *INDENT-ON* */
}
@@ -224,7 +224,7 @@ vl_api_igmp_dump_t_handler (vl_api_igmp_dump_t * mp)
config = igmp_config_lookup (sw_if_index);
if (config)
{
- igmp_config_dump (im, q, mp->context, config);
+ igmp_config_dump (im, rp, mp->context, config);
}
}
}
@@ -286,7 +286,7 @@ vl_api_igmp_group_prefix_set_t_handler (vl_api_igmp_group_prefix_set_t * mp)
typedef struct igmp_ssm_range_walk_ctx_t_
{
- unix_shared_memory_queue_t *q;
+ vl_api_registration_t *rp;
u32 context;
} igmp_ssm_range_walk_ctx_t;
@@ -305,7 +305,7 @@ igmp_ssm_range_walk_dump (const fib_prefix_t * pfx,
mp->gp.type = igmp_group_type_int_to_api (type);
ip_prefix_encode (pfx, &mp->gp.prefix);
- vl_msg_api_send_shmem (ctx->q, (u8 *) & mp);
+ vl_api_send_msg (ctx->rp, (u8 *) mp);
return (WALK_CONTINUE);
}
@@ -313,14 +313,14 @@ igmp_ssm_range_walk_dump (const fib_prefix_t * pfx,
static void
vl_api_igmp_group_prefix_dump_t_handler (vl_api_igmp_dump_t * mp)
{
- unix_shared_memory_queue_t *q;
+ vl_api_registration_t *rp;
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (!q)
+ rp = vl_api_client_index_to_registration (mp->client_index);
+ if (rp == 0)
return;
igmp_ssm_range_walk_ctx_t ctx = {
- .q = q,
+ .rp = rp,
.context = mp->context,
};
@@ -398,7 +398,7 @@ want_igmp_events_reaper (u32 client_index)
VL_MSG_API_REAPER_FUNCTION (want_igmp_events_reaper);
void
-send_igmp_event (unix_shared_memory_queue_t * q,
+send_igmp_event (vl_api_registration_t * rp,
u32 context,
igmp_filter_mode_t filter,
u32 sw_if_index,
@@ -414,7 +414,7 @@ send_igmp_event (unix_shared_memory_queue_t * q,
clib_memcpy (&mp->saddr, &saddr->ip4, sizeof (ip4_address_t));
clib_memcpy (&mp->gaddr, &gaddr->ip4, sizeof (ip4_address_t));
- vl_msg_api_send_shmem (q, (u8 *) & mp);
+ vl_api_send_msg (rp, (u8 *) mp);
}
void
@@ -423,7 +423,7 @@ igmp_event (igmp_filter_mode_t filter,
const ip46_address_t * saddr, const ip46_address_t * gaddr)
{
vpe_client_registration_t *api_client;
- unix_shared_memory_queue_t *q;
+ vl_api_registration_t *rp;
igmp_main_t *im;
im = &igmp_main;
@@ -438,9 +438,9 @@ igmp_event (igmp_filter_mode_t filter,
/* *INDENT-OFF* */
pool_foreach (api_client, im->api_clients,
({
- q = vl_api_client_index_to_input_queue (api_client->client_index);
- if (q)
- send_igmp_event (q, 0, filter, sw_if_index, saddr, gaddr);
+ rp = vl_api_client_index_to_registration (api_client->client_index);
+ if (rp)
+ send_igmp_event (rp, 0, filter, sw_if_index, saddr, gaddr);
}));
/* *INDENT-ON* */
}
diff --git a/src/plugins/ioam/lib-trace/trace_api.c b/src/plugins/ioam/lib-trace/trace_api.c
index bb043f7c831..f74d4e7f43b 100644
--- a/src/plugins/ioam/lib-trace/trace_api.c
+++ b/src/plugins/ioam/lib-trace/trace_api.c
@@ -23,7 +23,7 @@
#include <vnet/plugin/plugin.h>
#include <ioam/lib-trace/trace_util.h>
#include <ioam/lib-trace/trace_config.h>
-
+#include <vlibapi/api_helper_macros.h>
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
@@ -52,47 +52,6 @@
#include <ioam/lib-trace/trace_all_api_h.h>
#undef vl_api_version
-/*
- * A handy macro to set up a message reply.
- * Assumes that the following variables are available:
- * mp - pointer to request message
- * rmp - pointer to reply message type
- * rv - return value
- */
-
-#define TRACE_REPLY_MACRO(t) \
-do { \
- svm_queue_t * q = \
- vl_api_client_index_to_input_queue (mp->client_index); \
- if (!q) \
- return; \
- \
- rmp = vl_msg_api_alloc (sizeof (*rmp)); \
- rmp->_vl_msg_id = ntohs((t)+sm->msg_id_base); \
- rmp->context = mp->context; \
- rmp->retval = ntohl(rv); \
- \
- vl_msg_api_send_shmem (q, (u8 *)&rmp); \
-} while(0);
-
-/* *INDENT-OFF* */
-#define TRACE_REPLY_MACRO2(t, body) \
-do { \
- svm_queue_t * q; \
- rv = vl_msg_api_pd_handler (mp, rv); \
- q = vl_api_client_index_to_input_queue (mp->client_index); \
- if (!q) \
- return; \
- \
- rmp = vl_msg_api_alloc (sizeof (*rmp)); \
- rmp->_vl_msg_id = ntohs((t)+sm->msg_id_base); \
- rmp->context = mp->context; \
- rmp->retval = ntohl(rv); \
- do {body;} while (0); \
- vl_msg_api_send_shmem (q, (u8 *)&rmp); \
-} while(0);
-/* *INDENT-ON* */
-
/* List of message types that this plugin understands */
#define foreach_trace_plugin_api_msg \
@@ -103,7 +62,6 @@ _(TRACE_PROFILE_SHOW_CONFIG, trace_profile_show_config)
static void vl_api_trace_profile_add_t_handler
(vl_api_trace_profile_add_t * mp)
{
- trace_main_t *sm = &trace_main;
int rv = 0;
vl_api_trace_profile_add_reply_t *rmp;
trace_profile *profile = NULL;
@@ -123,45 +81,43 @@ static void vl_api_trace_profile_add_t_handler
rv = -3;
}
ERROROUT:
- TRACE_REPLY_MACRO (VL_API_TRACE_PROFILE_ADD_REPLY);
+ REPLY_MACRO (VL_API_TRACE_PROFILE_ADD_REPLY);
}
static void vl_api_trace_profile_del_t_handler
(vl_api_trace_profile_del_t * mp)
{
- trace_main_t *sm = &trace_main;
int rv = 0;
vl_api_trace_profile_del_reply_t *rmp;
clear_trace_profiles ();
- TRACE_REPLY_MACRO (VL_API_TRACE_PROFILE_DEL_REPLY);
+ REPLY_MACRO (VL_API_TRACE_PROFILE_DEL_REPLY);
}
static void vl_api_trace_profile_show_config_t_handler
(vl_api_trace_profile_show_config_t * mp)
{
- trace_main_t *sm = &trace_main;
vl_api_trace_profile_show_config_reply_t *rmp;
int rv = 0;
trace_profile *profile = trace_profile_find ();
if (profile->valid)
{
- TRACE_REPLY_MACRO2 (VL_API_TRACE_PROFILE_SHOW_CONFIG_REPLY,
- rmp->trace_type = profile->trace_type;
- rmp->num_elts = profile->num_elts;
- rmp->trace_tsp = profile->trace_tsp;
- rmp->node_id = htonl (profile->node_id);
- rmp->app_data = htonl (profile->app_data);
+ REPLY_MACRO2 (VL_API_TRACE_PROFILE_SHOW_CONFIG_REPLY,
+ rmp->trace_type = profile->trace_type;
+ rmp->num_elts = profile->num_elts;
+ rmp->trace_tsp = profile->trace_tsp;
+ rmp->node_id = htonl (profile->node_id);
+ rmp->app_data = htonl (profile->app_data);
);
}
else
{
- TRACE_REPLY_MACRO2 (VL_API_TRACE_PROFILE_SHOW_CONFIG_REPLY,
- rmp->trace_type = 0;
- rmp->num_elts = 0; rmp->trace_tsp = 0;
- rmp->node_id = 0; rmp->app_data = 0;
+ REPLY_MACRO2 (VL_API_TRACE_PROFILE_SHOW_CONFIG_REPLY,
+ rmp->trace_type = 0;
+ rmp->num_elts = 0; rmp->trace_tsp = 0;
+ rmp->node_id = 0; rmp->app_data = 0;
);
}
}
diff --git a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c
index 2d9c6bfab3d..e46d0fbf866 100644
--- a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c
+++ b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c
@@ -22,7 +22,7 @@
#include <vnet/vnet.h>
#include <vnet/plugin/plugin.h>
#include <ioam/lib-vxlan-gpe/vxlan_gpe_ioam.h>
-
+#include <vlibapi/api_helper_macros.h>
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
@@ -51,47 +51,6 @@
#include <ioam/lib-vxlan-gpe/vxlan_gpe_all_api_h.h>
#undef vl_api_version
-/*
- * A handy macro to set up a message reply.
- * Assumes that the following variables are available:
- * mp - pointer to request message
- * rmp - pointer to reply message type
- * rv - return value
- */
-
-#define VXLAN_GPE_REPLY_MACRO(t) \
-do { \
- svm_queue_t * q = \
- vl_api_client_index_to_input_queue (mp->client_index); \
- if (!q) \
- return; \
- \
- rmp = vl_msg_api_alloc (sizeof (*rmp)); \
- rmp->_vl_msg_id = ntohs((t)+sm->msg_id_base); \
- rmp->context = mp->context; \
- rmp->retval = ntohl(rv); \
- \
- vl_msg_api_send_shmem (q, (u8 *)&rmp); \
-} while(0);
-
-/* *INDENT-OFF* */
-#define VXLAN_GPE_REPLY_MACRO2(t, body) \
-do { \
- svm_queue_t * q; \
- rv = vl_msg_api_pd_handler (mp, rv); \
- q = vl_api_client_index_to_input_queue (mp->client_index); \
- if (!q) \
- return; \
- \
- rmp = vl_msg_api_alloc (sizeof (*rmp)); \
- rmp->_vl_msg_id = ntohs((t)); \
- rmp->context = mp->context; \
- rmp->retval = ntohl(rv); \
- do {body;} while (0); \
- vl_msg_api_send_shmem (q, (u8 *)&rmp); \
-} while(0);
-/* *INDENT-ON* */
-
/* List of message types that this plugin understands */
#define foreach_vxlan_gpe_plugin_api_msg \
@@ -109,7 +68,6 @@ static void vl_api_vxlan_gpe_ioam_enable_t_handler
int rv = 0;
vl_api_vxlan_gpe_ioam_enable_reply_t *rmp;
clib_error_t *error;
- vxlan_gpe_ioam_main_t *sm = &vxlan_gpe_ioam_main;
/* Ignoring the profile id as currently a single profile
* is supported */
@@ -121,7 +79,7 @@ static void vl_api_vxlan_gpe_ioam_enable_t_handler
rv = clib_error_get_code (error);
}
- VXLAN_GPE_REPLY_MACRO (VL_API_VXLAN_GPE_IOAM_ENABLE_REPLY);
+ REPLY_MACRO (VL_API_VXLAN_GPE_IOAM_ENABLE_REPLY);
}
static void vl_api_vxlan_gpe_ioam_disable_t_handler
@@ -130,7 +88,6 @@ static void vl_api_vxlan_gpe_ioam_disable_t_handler
int rv = 0;
vl_api_vxlan_gpe_ioam_disable_reply_t *rmp;
clib_error_t *error;
- vxlan_gpe_ioam_main_t *sm = &vxlan_gpe_ioam_main;
/* Ignoring the profile id as currently a single profile
* is supported */
@@ -141,7 +98,7 @@ static void vl_api_vxlan_gpe_ioam_disable_t_handler
rv = clib_error_get_code (error);
}
- VXLAN_GPE_REPLY_MACRO (VL_API_VXLAN_GPE_IOAM_DISABLE_REPLY);
+ REPLY_MACRO (VL_API_VXLAN_GPE_IOAM_DISABLE_REPLY);
}
static void vl_api_vxlan_gpe_ioam_vni_enable_t_handler
@@ -150,7 +107,6 @@ static void vl_api_vxlan_gpe_ioam_vni_enable_t_handler
int rv = 0;
vl_api_vxlan_gpe_ioam_vni_enable_reply_t *rmp;
clib_error_t *error;
- vxlan_gpe_ioam_main_t *sm = &vxlan_gpe_ioam_main;
vxlan4_gpe_tunnel_key_t key4;
uword *p = NULL;
vxlan_gpe_main_t *gm = &vxlan_gpe_main;
@@ -190,7 +146,7 @@ static void vl_api_vxlan_gpe_ioam_vni_enable_t_handler
rv = clib_error_get_code (error);
}
- VXLAN_GPE_REPLY_MACRO (VL_API_VXLAN_GPE_IOAM_VNI_ENABLE_REPLY);
+ REPLY_MACRO (VL_API_VXLAN_GPE_IOAM_VNI_ENABLE_REPLY);
}
@@ -200,7 +156,6 @@ static void vl_api_vxlan_gpe_ioam_vni_disable_t_handler
int rv = 0;
vl_api_vxlan_gpe_ioam_vni_enable_reply_t *rmp;
clib_error_t *error;
- vxlan_gpe_ioam_main_t *sm = &vxlan_gpe_ioam_main;
vxlan4_gpe_tunnel_key_t key4;
uword *p = NULL;
vxlan_gpe_main_t *gm = &vxlan_gpe_main;
@@ -238,7 +193,7 @@ static void vl_api_vxlan_gpe_ioam_vni_disable_t_handler
}
- VXLAN_GPE_REPLY_MACRO (VL_API_VXLAN_GPE_IOAM_VNI_DISABLE_REPLY);
+ REPLY_MACRO (VL_API_VXLAN_GPE_IOAM_VNI_DISABLE_REPLY);
}
static void vl_api_vxlan_gpe_ioam_transit_enable_t_handler
@@ -260,7 +215,7 @@ static void vl_api_vxlan_gpe_ioam_transit_enable_t_handler
mp->is_ipv6 ? 0 : 1,
1 /* is_add */ );
- VXLAN_GPE_REPLY_MACRO (VL_API_VXLAN_GPE_IOAM_TRANSIT_ENABLE_REPLY);
+ REPLY_MACRO (VL_API_VXLAN_GPE_IOAM_TRANSIT_ENABLE_REPLY);
}
static void vl_api_vxlan_gpe_ioam_transit_disable_t_handler
@@ -281,7 +236,7 @@ static void vl_api_vxlan_gpe_ioam_transit_disable_t_handler
dst_addr,
ntohl (mp->outer_fib_index),
mp->is_ipv6 ? 0 : 1);
- VXLAN_GPE_REPLY_MACRO (VL_API_VXLAN_GPE_IOAM_TRANSIT_DISABLE_REPLY);
+ REPLY_MACRO (VL_API_VXLAN_GPE_IOAM_TRANSIT_DISABLE_REPLY);
}
/* Set up the API message handling tables */
diff --git a/src/plugins/nat/nat_api.c b/src/plugins/nat/nat_api.c
index 516b27fb6f5..21b2cd44880 100644
--- a/src/plugins/nat/nat_api.c
+++ b/src/plugins/nat/nat_api.c
@@ -3267,7 +3267,7 @@ static void *vl_api_nat66_add_del_static_mapping_t_print
typedef struct nat66_api_walk_ctx_t_
{
- svm_queue_t *q;
+ vl_api_registration_t *rp;
u32 context;
} nat66_api_walk_ctx_t;
@@ -3285,7 +3285,7 @@ nat66_api_interface_walk (snat_interface_t * i, void *arg)
rmp->is_inside = nat_interface_is_inside (i);
rmp->context = ctx->context;
- vl_msg_api_send_shmem (ctx->q, (u8 *) & rmp);
+ vl_api_send_msg (ctx->rp, (u8 *) rmp);
return 0;
}
@@ -3293,14 +3293,14 @@ nat66_api_interface_walk (snat_interface_t * i, void *arg)
static void
vl_api_nat66_interface_dump_t_handler (vl_api_nat66_interface_dump_t * mp)
{
- svm_queue_t *q;
+ vl_api_registration_t *rp;
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (q == 0)
+ rp = vl_api_client_index_to_registration (mp->client_index);
+ if (rp == 0)
return;
nat66_api_walk_ctx_t ctx = {
- .q = q,
+ .rp = rp,
.context = mp->context,
};
@@ -3345,7 +3345,7 @@ nat66_api_static_mapping_walk (nat66_static_mapping_t * m, void *arg)
rmp->total_pkts = clib_host_to_net_u64 (vc.packets);
rmp->context = ctx->context;
- vl_msg_api_send_shmem (ctx->q, (u8 *) & rmp);
+ vl_api_send_msg (ctx->rp, (u8 *) rmp);
return 0;
}
@@ -3354,14 +3354,14 @@ static void
vl_api_nat66_static_mapping_dump_t_handler (vl_api_nat66_static_mapping_dump_t
* mp)
{
- svm_queue_t *q;
+ vl_api_registration_t *rp;
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (q == 0)
+ rp = vl_api_client_index_to_registration (mp->client_index);
+ if (rp == 0)
return;
nat66_api_walk_ctx_t ctx = {
- .q = q,
+ .rp = rp,
.context = mp->context,
};
diff --git a/src/plugins/nsh/nsh_api.c b/src/plugins/nsh/nsh_api.c
index cf9fd574b34..e541301614b 100644
--- a/src/plugins/nsh/nsh_api.c
+++ b/src/plugins/nsh/nsh_api.c
@@ -124,7 +124,7 @@ VNET_DEVICE_CLASS (nsh_device_class, static) = {
/* *INDENT-ON* */
static void send_nsh_entry_details
- (nsh_entry_t * t, unix_shared_memory_queue_t * q, u32 context)
+ (nsh_entry_t * t, vl_api_registration_t * rp, u32 context)
{
vl_api_nsh_entry_details_t *rmp;
nsh_main_t *nm = &nsh_main;
@@ -157,11 +157,11 @@ static void send_nsh_entry_details
rmp->context = context;
- vl_msg_api_send_shmem (q, (u8 *) & rmp);
+ vl_api_send_msg (rp, (u8 *) rmp);
}
static void send_nsh_map_details
- (nsh_map_t * t, unix_shared_memory_queue_t * q, u32 context)
+ (nsh_map_t * t, vl_api_registration_t * rp, u32 context)
{
vl_api_nsh_map_details_t *rmp;
nsh_main_t *nm = &nsh_main;
@@ -179,22 +179,20 @@ static void send_nsh_map_details
rmp->context = context;
- vl_msg_api_send_shmem (q, (u8 *) & rmp);
+ vl_api_send_msg (rp, (u8 *) rmp);
}
static void
vl_api_nsh_map_dump_t_handler (vl_api_nsh_map_dump_t * mp)
{
- unix_shared_memory_queue_t *q;
nsh_main_t *nm = &nsh_main;
nsh_map_t *t;
u32 map_index;
+ vl_api_registration_t *rp;
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (q == 0)
- {
- return;
- }
+ rp = vl_api_client_index_to_registration (mp->client_index);
+ if (rp == 0)
+ return;
map_index = ntohl (mp->map_index);
@@ -202,7 +200,7 @@ vl_api_nsh_map_dump_t_handler (vl_api_nsh_map_dump_t * mp)
{
pool_foreach (t, nm->nsh_mappings, (
{
- send_nsh_map_details (t, q,
+ send_nsh_map_details (t, rp,
mp->context);
}
));
@@ -214,7 +212,7 @@ vl_api_nsh_map_dump_t_handler (vl_api_nsh_map_dump_t * mp)
return;
}
t = &nm->nsh_mappings[map_index];
- send_nsh_map_details (t, q, mp->context);
+ send_nsh_map_details (t, rp, mp->context);
}
}
@@ -650,16 +648,14 @@ static void vl_api_nsh_add_del_entry_t_handler
static void
vl_api_nsh_entry_dump_t_handler (vl_api_nsh_entry_dump_t * mp)
{
- unix_shared_memory_queue_t *q;
nsh_main_t *nm = &nsh_main;
nsh_entry_t *t;
u32 entry_index;
+ vl_api_registration_t *rp;
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (q == 0)
- {
- return;
- }
+ rp = vl_api_client_index_to_registration (mp->client_index);
+ if (rp == 0)
+ return;
entry_index = ntohl (mp->entry_index);
@@ -667,7 +663,7 @@ vl_api_nsh_entry_dump_t_handler (vl_api_nsh_entry_dump_t * mp)
{
pool_foreach (t, nm->nsh_entries, (
{
- send_nsh_entry_details (t, q,
+ send_nsh_entry_details (t, rp,
mp->context);
}
));
@@ -679,7 +675,7 @@ vl_api_nsh_entry_dump_t_handler (vl_api_nsh_entry_dump_t * mp)
return;
}
t = &nm->nsh_entries[entry_index];
- send_nsh_entry_details (t, q, mp->context);
+ send_nsh_entry_details (t, rp, mp->context);
}
}
diff --git a/src/plugins/svs/svs_api.c b/src/plugins/svs/svs_api.c
index 03941fea08e..068d2fa4e76 100644
--- a/src/plugins/svs/svs_api.c
+++ b/src/plugins/svs/svs_api.c
@@ -54,7 +54,6 @@
* Base message ID fot the plugin
*/
static u32 svs_base_msg_id;
-
#include <vlibapi/api_helper_macros.h>
/* List of message types that this plugin understands */
@@ -71,13 +70,11 @@ vl_api_svs_plugin_get_version_t_handler (vl_api_svs_plugin_get_version_t * mp)
{
vl_api_svs_plugin_get_version_reply_t *rmp;
int msg_size = sizeof (*rmp);
- unix_shared_memory_queue_t *q;
+ vl_api_registration_t *rp;
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (q == 0)
- {
- return;
- }
+ rp = vl_api_client_index_to_registration (mp->client_index);
+ if (rp == 0)
+ return;
rmp = vl_msg_api_alloc (msg_size);
clib_memset (rmp, 0, msg_size);
@@ -87,7 +84,7 @@ vl_api_svs_plugin_get_version_t_handler (vl_api_svs_plugin_get_version_t * mp)
rmp->major = htonl (SVS_PLUGIN_VERSION_MAJOR);
rmp->minor = htonl (SVS_PLUGIN_VERSION_MINOR);
- vl_msg_api_send_shmem (q, (u8 *) & rmp);
+ vl_api_send_msg (rp, (u8 *) rmp);
}
static void
@@ -160,7 +157,7 @@ vl_api_svs_enable_disable_t_handler (vl_api_svs_enable_disable_t * mp)
typedef struct svs_dump_walk_ctx_t_
{
- unix_shared_memory_queue_t *q;
+ vl_api_registration_t *rp;
u32 context;
} svs_dump_walk_ctx_t;
@@ -182,7 +179,7 @@ svs_send_details (fib_protocol_t fproto,
mp->table_id = htonl (table_id);
mp->af = fib_proto_to_api_address_family (fproto);
- vl_msg_api_send_shmem (ctx->q, (u8 *) & mp);
+ vl_api_send_msg (ctx->rp, (u8 *) mp);
return (WALK_CONTINUE);
}
@@ -190,16 +187,14 @@ svs_send_details (fib_protocol_t fproto,
static void
vl_api_svs_dump_t_handler (vl_api_svs_dump_t * mp)
{
- unix_shared_memory_queue_t *q;
+ vl_api_registration_t *rp;
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (q == 0)
- {
- return;
- }
+ rp = vl_api_client_index_to_registration (mp->client_index);
+ if (rp == 0)
+ return;
svs_dump_walk_ctx_t ctx = {
- .q = q,
+ .rp = rp,
.context = mp->context,
};
diff --git a/src/vlibmemory/memory_client.c b/src/vlibmemory/memory_client.c
index fb117340662..383d7428b72 100644
--- a/src/vlibmemory/memory_client.c
+++ b/src/vlibmemory/memory_client.c
@@ -164,6 +164,7 @@ noop_handler (void *notused)
{
}
+void vl_msg_api_send_shmem (svm_queue_t * q, u8 * elem);
int
vl_client_connect (const char *name, int ctx_quota, int input_queue_size)
{
diff --git a/src/vlibmemory/memory_shared.h b/src/vlibmemory/memory_shared.h
index 67ead7d2877..662eaf96589 100644
--- a/src/vlibmemory/memory_shared.h
+++ b/src/vlibmemory/memory_shared.h
@@ -120,7 +120,6 @@ void vl_unmap_shmem (void);
void vl_unmap_shmem_client (void);
void vl_register_mapped_shmem_region (svm_region_t * rp);
void vl_msg_api_send_shmem (svm_queue_t * q, u8 * elem);
-void vl_msg_api_send_shmem_nolock (svm_queue_t * q, u8 * elem);
int vl_mem_api_can_send (svm_queue_t * q);
void vl_set_memory_region_name (const char *name);
void vl_set_memory_root_path (const char *root_path);
diff --git a/src/vnet/bonding/bond_api.c b/src/vnet/bonding/bond_api.c
index 50bae5d528d..07c2cbc5ae6 100644
--- a/src/vnet/bonding/bond_api.c
+++ b/src/vnet/bonding/bond_api.c
@@ -52,48 +52,16 @@ _(SW_INTERFACE_BOND_DUMP, sw_interface_bond_dump)\
_(SW_INTERFACE_SLAVE_DUMP, sw_interface_slave_dump)
static void
-bond_send_sw_interface_event_deleted (vpe_api_main_t * am,
- unix_shared_memory_queue_t * q,
- u32 sw_if_index)
-{
- vl_api_sw_interface_event_t *mp;
-
- mp = vl_msg_api_alloc (sizeof (*mp));
- clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_EVENT);
- mp->sw_if_index = ntohl (sw_if_index);
-
- mp->admin_up_down = 0;
- mp->link_up_down = 0;
- mp->deleted = 1;
- vl_msg_api_send_shmem (q, (u8 *) & mp);
-}
-
-static void
vl_api_bond_delete_t_handler (vl_api_bond_delete_t * mp)
{
vlib_main_t *vm = vlib_get_main ();
int rv;
- vpe_api_main_t *vam = &vpe_api_main;
vl_api_bond_delete_reply_t *rmp;
- unix_shared_memory_queue_t *q;
u32 sw_if_index = ntohl (mp->sw_if_index);
rv = bond_delete_if (vm, sw_if_index);
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (!q)
- return;
-
- rmp = vl_msg_api_alloc (sizeof (*rmp));
- rmp->_vl_msg_id = ntohs (VL_API_BOND_DELETE_REPLY);
- rmp->context = mp->context;
- rmp->retval = ntohl (rv);
-
- vl_msg_api_send_shmem (q, (u8 *) & rmp);
-
- if (!rv)
- bond_send_sw_interface_event_deleted (vam, q, sw_if_index);
+ REPLY_MACRO (VL_API_BOND_DELETE_REPLY);
}
static void
@@ -101,7 +69,6 @@ vl_api_bond_create_t_handler (vl_api_bond_create_t * mp)
{
vlib_main_t *vm = vlib_get_main ();
vl_api_bond_create_reply_t *rmp;
- unix_shared_memory_queue_t *q;
bond_create_if_args_t _a, *ap = &_a;
clib_memset (ap, 0, sizeof (*ap));
@@ -118,19 +85,14 @@ vl_api_bond_create_t_handler (vl_api_bond_create_t * mp)
ap->lb = mp->lb;
bond_create_if (vm, ap);
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (!q)
- return;
+ int rv = ap->rv;
- if (ap->rv != 0)
- return;
- rmp = vl_msg_api_alloc (sizeof (*rmp));
- rmp->_vl_msg_id = ntohs (VL_API_BOND_CREATE_REPLY);
- rmp->context = mp->context;
- rmp->retval = ntohl (ap->rv);
- rmp->sw_if_index = ntohl (ap->sw_if_index);
-
- vl_msg_api_send_shmem (q, (u8 *) & rmp);
+ /* *INDENT-OFF* */
+ REPLY_MACRO2(VL_API_BOND_CREATE_REPLY,
+ ({
+ rmp->sw_if_index = ntohl (ap->sw_if_index);
+ }));
+ /* *INDENT-ON* */
}
static void
@@ -138,8 +100,8 @@ vl_api_bond_enslave_t_handler (vl_api_bond_enslave_t * mp)
{
vlib_main_t *vm = vlib_get_main ();
vl_api_bond_enslave_reply_t *rmp;
- unix_shared_memory_queue_t *q;
bond_enslave_args_t _a, *ap = &_a;
+ int rv = 0;
clib_memset (ap, 0, sizeof (*ap));
@@ -150,16 +112,7 @@ vl_api_bond_enslave_t_handler (vl_api_bond_enslave_t * mp)
bond_enslave (vm, ap);
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (!q)
- return;
-
- rmp = vl_msg_api_alloc (sizeof (*rmp));
- rmp->_vl_msg_id = ntohs (VL_API_BOND_ENSLAVE_REPLY);
- rmp->context = mp->context;
- rmp->retval = ntohl (ap->rv);
-
- vl_msg_api_send_shmem (q, (u8 *) & rmp);
+ REPLY_MACRO (VL_API_BOND_ENSLAVE_REPLY);
}
static void
@@ -167,24 +120,15 @@ vl_api_bond_detach_slave_t_handler (vl_api_bond_detach_slave_t * mp)
{
vlib_main_t *vm = vlib_get_main ();
vl_api_bond_detach_slave_reply_t *rmp;
- unix_shared_memory_queue_t *q;
bond_detach_slave_args_t _a, *ap = &_a;
+ int rv = 0;
clib_memset (ap, 0, sizeof (*ap));
ap->slave = ntohl (mp->sw_if_index);
bond_detach_slave (vm, ap);
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (!q)
- return;
-
- rmp = vl_msg_api_alloc (sizeof (*rmp));
- rmp->_vl_msg_id = ntohs (VL_API_BOND_DETACH_SLAVE_REPLY);
- rmp->context = mp->context;
- rmp->retval = htonl (ap->rv);
-
- vl_msg_api_send_shmem (q, (u8 *) & rmp);
+ REPLY_MACRO (VL_API_BOND_DETACH_SLAVE_REPLY);
}
static void
diff --git a/src/vnet/devices/tap/tapv2_api.c b/src/vnet/devices/tap/tapv2_api.c
index 1260afdd24f..40ff22eaeaa 100644
--- a/src/vnet/devices/tap/tapv2_api.c
+++ b/src/vnet/devices/tap/tapv2_api.c
@@ -137,30 +137,11 @@ vl_api_tap_create_v2_t_handler (vl_api_tap_create_v2_t * mp)
}
static void
-tap_send_sw_interface_event_deleted (vpe_api_main_t * am,
- vl_api_registration_t * reg,
- u32 sw_if_index)
-{
- vl_api_sw_interface_event_t *mp;
-
- mp = vl_msg_api_alloc (sizeof (*mp));
- clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_EVENT);
- mp->sw_if_index = ntohl (sw_if_index);
-
- mp->admin_up_down = 0;
- mp->link_up_down = 0;
- mp->deleted = 1;
- vl_api_send_msg (reg, (u8 *) mp);
-}
-
-static void
vl_api_tap_delete_v2_t_handler (vl_api_tap_delete_v2_t * mp)
{
vnet_main_t *vnm = vnet_get_main ();
vlib_main_t *vm = vlib_get_main ();
int rv;
- vpe_api_main_t *vam = &vpe_api_main;
vl_api_tap_delete_v2_reply_t *rmp;
vl_api_registration_t *reg;
u32 sw_if_index = ntohl (mp->sw_if_index);
@@ -179,10 +160,7 @@ vl_api_tap_delete_v2_t_handler (vl_api_tap_delete_v2_t * mp)
vl_api_send_msg (reg, (u8 *) rmp);
if (!rv)
- {
- vnet_clear_sw_interface_tag (vnm, sw_if_index);
- tap_send_sw_interface_event_deleted (vam, reg, sw_if_index);
- }
+ vnet_clear_sw_interface_tag (vnm, sw_if_index);
}
static void
diff --git a/src/vnet/devices/virtio/vhost_user_api.c b/src/vnet/devices/virtio/vhost_user_api.c
index 8142cf352ed..4c765f30961 100644
--- a/src/vnet/devices/virtio/vhost_user_api.c
+++ b/src/vnet/devices/virtio/vhost_user_api.c
@@ -48,26 +48,6 @@ _(MODIFY_VHOST_USER_IF, modify_vhost_user_if) \
_(DELETE_VHOST_USER_IF, delete_vhost_user_if) \
_(SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump)
-/*
- * WARNING: replicated pending api refactor completion
- */
-static void
-send_sw_interface_event_deleted (vpe_api_main_t * am,
- vl_api_registration_t * reg, u32 sw_if_index)
-{
- vl_api_sw_interface_event_t *mp;
-
- mp = vl_msg_api_alloc (sizeof (*mp));
- clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_EVENT);
- mp->sw_if_index = ntohl (sw_if_index);
-
- mp->admin_up_down = 0;
- mp->link_up_down = 0;
- mp->deleted = 1;
- vl_api_send_msg (reg, (u8 *) mp);
-}
-
static void
vl_api_create_vhost_user_if_t_handler (vl_api_create_vhost_user_if_t * mp)
{
@@ -135,7 +115,6 @@ vl_api_delete_vhost_user_if_t_handler (vl_api_delete_vhost_user_if_t * mp)
{
int rv = 0;
vl_api_delete_vhost_user_if_reply_t *rmp;
- vpe_api_main_t *vam = &vpe_api_main;
u32 sw_if_index = ntohl (mp->sw_if_index);
vl_api_registration_t *reg;
@@ -152,7 +131,6 @@ vl_api_delete_vhost_user_if_t_handler (vl_api_delete_vhost_user_if_t * mp)
return;
vnet_clear_sw_interface_tag (vnm, sw_if_index);
- send_sw_interface_event_deleted (vam, reg, sw_if_index);
}
}
diff --git a/src/vnet/devices/virtio/virtio_api.c b/src/vnet/devices/virtio/virtio_api.c
index 238c6adfb43..ff123ae081c 100644
--- a/src/vnet/devices/virtio/virtio_api.c
+++ b/src/vnet/devices/virtio/virtio_api.c
@@ -86,24 +86,6 @@ vl_api_virtio_pci_create_t_handler (vl_api_virtio_pci_create_t * mp)
}
static void
-virtio_pci_send_sw_interface_event_deleted (vpe_api_main_t * am,
- vl_api_registration_t * reg,
- u32 sw_if_index)
-{
- vl_api_sw_interface_event_t *mp;
-
- mp = vl_msg_api_alloc (sizeof (*mp));
- clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = htons (VL_API_SW_INTERFACE_EVENT);
- mp->sw_if_index = htonl (sw_if_index);
-
- mp->admin_up_down = 0;
- mp->link_up_down = 0;
- mp->deleted = 1;
- vl_api_send_msg (reg, (u8 *) mp);
-}
-
-static void
vl_api_virtio_pci_delete_t_handler (vl_api_virtio_pci_delete_t * mp)
{
vnet_main_t *vnm = vnet_get_main ();
@@ -112,10 +94,8 @@ vl_api_virtio_pci_delete_t_handler (vl_api_virtio_pci_delete_t * mp)
int rv = 0;
vnet_hw_interface_t *hw;
virtio_if_t *vif;
- vpe_api_main_t *vam = &vpe_api_main;
vl_api_virtio_pci_delete_reply_t *rmp;
vl_api_registration_t *reg;
- u32 sw_if_index = ntohl (mp->sw_if_index);
hw = vnet_get_sup_hw_interface (vnm, htonl (mp->sw_if_index));
if (hw == NULL || virtio_device_class.index != hw->dev_class_index)
@@ -139,11 +119,6 @@ reply:
rmp->retval = htonl (rv);
vl_api_send_msg (reg, (u8 *) rmp);
-
- if (!rv)
- {
- virtio_pci_send_sw_interface_event_deleted (vam, reg, sw_if_index);
- }
}
static void
diff --git a/src/vnet/interface_api.c b/src/vnet/interface_api.c
index bd5588e2625..f49af9473e5 100644
--- a/src/vnet/interface_api.c
+++ b/src/vnet/interface_api.c
@@ -694,38 +694,36 @@ vl_api_sw_interface_clear_stats_t_handler (vl_api_sw_interface_clear_stats_t *
REPLY_MACRO (VL_API_SW_INTERFACE_CLEAR_STATS_REPLY);
}
-#define API_LINK_STATE_EVENT 1
-#define API_ADMIN_UP_DOWN_EVENT 2
-
-static int
-event_data_cmp (void *a1, void *a2)
+/*
+ * Events used for sw_interface_events
+ */
+enum api_events
{
- uword *e1 = a1;
- uword *e2 = a2;
-
- return (word) e1[0] - (word) e2[0];
-}
+ API_LINK_STATE_UP_EVENT = 1 << 1,
+ API_LINK_STATE_DOWN_EVENT = 1 << 2,
+ API_ADMIN_UP_EVENT = 1 << 3,
+ API_ADMIN_DOWN_EVENT = 1 << 4,
+ API_SW_INTERFACE_ADD_EVENT = 1 << 5,
+ API_SW_INTERFACE_DEL_EVENT = 1 << 6,
+};
static void
send_sw_interface_event (vpe_api_main_t * am,
vpe_client_registration_t * reg,
vl_api_registration_t * vl_reg,
- vnet_sw_interface_t * swif)
+ u32 sw_if_index, enum api_events events)
{
vl_api_sw_interface_event_t *mp;
- vnet_main_t *vnm = am->vnet_main;
- vnet_hw_interface_t *hi = vnet_get_sup_hw_interface (vnm,
- swif->sw_if_index);
mp = vl_msg_api_alloc (sizeof (*mp));
clib_memset (mp, 0, sizeof (*mp));
mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_EVENT);
- mp->sw_if_index = ntohl (swif->sw_if_index);
+ mp->sw_if_index = ntohl (sw_if_index);
mp->client_index = reg->client_index;
mp->pid = reg->client_pid;
-
- mp->admin_up_down = (swif->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ? 1 : 0;
- mp->link_up_down = (hi->flags & VNET_HW_INTERFACE_FLAG_LINK_UP) ? 1 : 0;
+ mp->admin_up_down = events & API_ADMIN_UP_EVENT ? 1 : 0;
+ mp->link_up_down = events & API_LINK_STATE_UP_EVENT ? 1 : 0;
+ mp->deleted = events & API_SW_INTERFACE_DEL_EVENT ? 1 : 0;
vl_api_send_msg (vl_reg, (u8 *) mp);
}
@@ -734,13 +732,13 @@ link_state_process (vlib_main_t * vm,
vlib_node_runtime_t * rt, vlib_frame_t * f)
{
vpe_api_main_t *vam = &vpe_api_main;
- vnet_main_t *vnm = vam->vnet_main;
- vnet_sw_interface_t *swif;
- uword *event_data = 0;
+ uword *event_by_sw_if_index = 0;
vpe_client_registration_t *reg;
int i;
- u32 prev_sw_if_index;
vl_api_registration_t *vl_reg;
+ uword event_type;
+ uword *event_data = 0;
+ u32 sw_if_index;
vam->link_state_process_up = 1;
@@ -748,42 +746,33 @@ link_state_process (vlib_main_t * vm,
{
vlib_process_wait_for_event (vm);
- /* Unified list of changed link or admin state sw_if_indices */
- vlib_process_get_events_with_type
- (vm, &event_data, API_LINK_STATE_EVENT);
- vlib_process_get_events_with_type
- (vm, &event_data, API_ADMIN_UP_DOWN_EVENT);
-
- /* Sort, so we can eliminate duplicates */
- vec_sort_with_function (event_data, event_data_cmp);
-
- prev_sw_if_index = ~0;
+ /* Batch up events */
+ while ((event_type = vlib_process_get_events (vm, &event_data)) != ~0)
+ {
+ for (i = 0; i < vec_len (event_data); i++)
+ {
+ sw_if_index = event_data[i];
+ vec_validate_init_empty (event_by_sw_if_index, sw_if_index, 0);
+ event_by_sw_if_index[sw_if_index] |= event_type;
+ }
+ vec_reset_length (event_data);
+ }
- for (i = 0; i < vec_len (event_data); i++)
+ for (i = 0; i < vec_len (event_by_sw_if_index); i++)
{
- /* Only one message per swif */
- if (prev_sw_if_index == event_data[i])
+ if (event_by_sw_if_index[i] == 0)
continue;
- prev_sw_if_index = event_data[i];
/* *INDENT-OFF* */
pool_foreach(reg, vam->interface_events_registrations,
({
vl_reg = vl_api_client_index_to_registration (reg->client_index);
if (vl_reg)
- {
- /* sw_interface may be deleted already */
- if (!pool_is_free_index (vnm->interface_main.sw_interfaces,
- event_data[i]))
- {
- swif = vnet_get_sw_interface (vnm, event_data[i]);
- send_sw_interface_event (vam, reg, vl_reg, swif);
- }
- }
+ send_sw_interface_event (vam, reg, vl_reg, i, event_by_sw_if_index[i]);
}));
/* *INDENT-ON* */
}
- vec_reset_length (event_data);
+ vec_reset_length (event_by_sw_if_index);
}
return 0;
@@ -793,6 +782,9 @@ static clib_error_t *link_up_down_function (vnet_main_t * vm, u32 hw_if_index,
u32 flags);
static clib_error_t *admin_up_down_function (vnet_main_t * vm,
u32 hw_if_index, u32 flags);
+static clib_error_t *sw_interface_add_del_function (vnet_main_t * vm,
+ u32 sw_if_index,
+ u32 flags);
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (link_state_process_node,static) = {
@@ -804,6 +796,7 @@ VLIB_REGISTER_NODE (link_state_process_node,static) = {
VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION (admin_up_down_function);
VNET_HW_INTERFACE_LINK_UP_DOWN_FUNCTION (link_up_down_function);
+VNET_SW_INTERFACE_ADD_DEL_FUNCTION (sw_interface_add_del_function);
static clib_error_t *
link_up_down_function (vnet_main_t * vm, u32 hw_if_index, u32 flags)
@@ -812,9 +805,13 @@ link_up_down_function (vnet_main_t * vm, u32 hw_if_index, u32 flags)
vnet_hw_interface_t *hi = vnet_get_hw_interface (vm, hw_if_index);
if (vam->link_state_process_up)
- vlib_process_signal_event (vam->vlib_main,
- link_state_process_node.index,
- API_LINK_STATE_EVENT, hi->sw_if_index);
+ {
+ enum api_events event =
+ flags ? API_LINK_STATE_UP_EVENT : API_LINK_STATE_DOWN_EVENT;
+ vlib_process_signal_event (vam->vlib_main,
+ link_state_process_node.index, event,
+ hi->sw_if_index);
+ }
return 0;
}
@@ -829,9 +826,29 @@ admin_up_down_function (vnet_main_t * vm, u32 sw_if_index, u32 flags)
* routine.
*/
if (vam->link_state_process_up)
- vlib_process_signal_event (vam->vlib_main,
- link_state_process_node.index,
- API_ADMIN_UP_DOWN_EVENT, sw_if_index);
+ {
+ enum api_events event =
+ flags ? API_ADMIN_UP_EVENT : API_ADMIN_DOWN_EVENT;
+ vlib_process_signal_event (vam->vlib_main,
+ link_state_process_node.index, event,
+ sw_if_index);
+ }
+ return 0;
+}
+
+static clib_error_t *
+sw_interface_add_del_function (vnet_main_t * vm, u32 sw_if_index, u32 flags)
+{
+ vpe_api_main_t *vam = &vpe_api_main;
+
+ if (vam->link_state_process_up)
+ {
+ enum api_events event =
+ flags ? API_SW_INTERFACE_ADD_EVENT : API_SW_INTERFACE_DEL_EVENT;
+ vlib_process_signal_event (vam->vlib_main,
+ link_state_process_node.index, event,
+ sw_if_index);
+ }
return 0;
}
diff --git a/src/vnet/ip/ip_api.c b/src/vnet/ip/ip_api.c
index 9ecdfc8e244..ce3456d77d9 100644
--- a/src/vnet/ip/ip_api.c
+++ b/src/vnet/ip/ip_api.c
@@ -3343,11 +3343,10 @@ vl_api_ip_reassembly_set_t_handler (vl_api_ip_reassembly_set_t * mp)
void
vl_api_ip_reassembly_get_t_handler (vl_api_ip_reassembly_get_t * mp)
{
- unix_shared_memory_queue_t *q;
+ vl_api_registration_t *rp;
- q = vl_api_client_index_to_input_queue (mp->client_index);
-
- if (q == 0)
+ rp = vl_api_client_index_to_registration (mp->client_index);
+ if (rp == 0)
return;
vl_api_ip_reassembly_get_reply_t *rmp = vl_msg_api_alloc (sizeof (*rmp));
@@ -3371,7 +3370,7 @@ vl_api_ip_reassembly_get_t_handler (vl_api_ip_reassembly_get_t * mp)
rmp->max_reassemblies = clib_host_to_net_u32 (rmp->max_reassemblies);
rmp->expire_walk_interval_ms =
clib_host_to_net_u32 (rmp->expire_walk_interval_ms);
- vl_msg_api_send_shmem (q, (u8 *) & rmp);
+ vl_api_send_msg (rp, (u8 *) rmp);
}
void