aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2018-06-04 18:41:24 -0700
committerNeale Ranns <nranns@cisco.com>2018-06-10 19:27:56 -0400
commit98ee17424bb9483cbf21d8f218f970001ba68adf (patch)
tree0f38b3ab408254823562c3a4212b02bac32007a5 /src/plugins
parentd9aa9ff03c85cda61e5df72190807ba11a417c8b (diff)
Add reaper functions to want events APIs (VPP-1304)
Change-Id: Iaeb52d94cb6da63ee93af7c1cf2dade6046cba1d Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/igmp/igmp.h22
-rw-r--r--src/plugins/igmp/igmp_api.c45
2 files changed, 43 insertions, 24 deletions
diff --git a/src/plugins/igmp/igmp.h b/src/plugins/igmp/igmp.h
index 0dcf11f64f7..70f90437c54 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>
+#include <vlibapi/api_helper_macros.h>
#include <vnet/ip/igmp_packet.h>
#include <vnet/adj/adj_mcast.h>
#include <igmp/igmp_format.h>
@@ -110,12 +111,6 @@ struct igmp_timer_t_;
typedef struct igmp_timer_t_ igmp_timer_t;
-typedef struct igmp_api_client_t_
-{
- u32 client_index;
- u32 pid;
-} igmp_api_client_t;
-
typedef struct
{
u8 *name;
@@ -137,7 +132,7 @@ typedef struct igmp_main_t_
uword *igmp_api_client_by_client_index;
/** pool of api clients registered for join/leave notifications */
- igmp_api_client_t *api_clients;
+ vpe_client_registration_t *api_clients;
/* get config index by config key */
uword *igmp_config_by_sw_if_index;
@@ -262,19 +257,6 @@ igmp_sg_lookup (igmp_config_t * config, igmp_sg_key_t * key)
return sg;
}
-always_inline igmp_api_client_t *
-igmp_api_client_lookup (igmp_main_t * im, u32 client_index)
-{
- uword *p;
- igmp_api_client_t *api_client = NULL;
-
- p = hash_get_mem (im->igmp_api_client_by_client_index, &client_index);
- if (p)
- api_client = vec_elt_at_index (im->api_clients, p[0]);
-
- return api_client;
-}
-
#endif /* _IGMP_H_ */
/*
diff --git a/src/plugins/igmp/igmp_api.c b/src/plugins/igmp/igmp_api.c
index 256f9245e35..5da733b1f6a 100644
--- a/src/plugins/igmp/igmp_api.c
+++ b/src/plugins/igmp/igmp_api.c
@@ -186,11 +186,28 @@ vl_api_igmp_clear_interface_t_handler (vl_api_igmp_clear_interface_t * mp)
vl_msg_api_send_shmem (q, (u8 *) & rmp);
}
+/** \brief igmp group lookup
+ @param im - igmp main
+ @param client_index - client index
+*/
+static vpe_client_registration_t *
+igmp_api_client_lookup (igmp_main_t * im, u32 client_index)
+{
+ uword *p;
+ vpe_client_registration_t *api_client = NULL;
+
+ p = hash_get_mem (im->igmp_api_client_by_client_index, &client_index);
+ if (p)
+ api_client = vec_elt_at_index (im->api_clients, p[0]);
+
+ return api_client;
+}
+
static void
vl_api_want_igmp_events_t_handler (vl_api_want_igmp_events_t * mp)
{
igmp_main_t *im = &igmp_main;
- igmp_api_client_t *api_client;
+ vpe_client_registration_t *api_client;
vl_api_want_igmp_events_reply_t *rmp;
int rv = 0;
@@ -210,9 +227,9 @@ vl_api_want_igmp_events_t_handler (vl_api_want_igmp_events_t * mp)
if (mp->enable)
{
pool_get (im->api_clients, api_client);
- memset (api_client, 0, sizeof (igmp_api_client_t));
+ memset (api_client, 0, sizeof (vpe_client_registration_t));
api_client->client_index = mp->client_index;
- api_client->pid = mp->pid;
+ api_client->client_pid = mp->pid;
hash_set_mem (im->igmp_api_client_by_client_index,
&mp->client_index, api_client - im->api_clients);
goto done;
@@ -233,6 +250,26 @@ done:;
vl_msg_api_send_shmem (q, (u8 *) & rmp);
}
+static clib_error_t *
+want_igmp_events_reaper (u32 client_index)
+{
+ igmp_main_t *im = &igmp_main;
+ vpe_client_registration_t *api_client;
+ uword *p;
+
+ p = hash_get_mem (im->igmp_api_client_by_client_index, &client_index);
+
+ if (p)
+ {
+ api_client = pool_elt_at_index (im->api_clients, p[0]);
+ pool_put (im->api_clients, api_client);
+ hash_unset_mem (im->igmp_api_client_by_client_index, &client_index);
+ }
+ return (NULL);
+}
+
+VL_MSG_API_REAPER_FUNCTION (want_igmp_events_reaper);
+
void
send_igmp_event (unix_shared_memory_queue_t * q, u32 context,
igmp_main_t * im, igmp_config_t * config, igmp_sg_t * sg)
@@ -254,7 +291,7 @@ send_igmp_event (unix_shared_memory_queue_t * q, u32 context,
void
igmp_event (igmp_main_t * im, igmp_config_t * config, igmp_sg_t * sg)
{
- igmp_api_client_t *api_client;
+ vpe_client_registration_t *api_client;
unix_shared_memory_queue_t *q;
/* *INDENT-OFF* */
pool_foreach (api_client, im->api_clients,