IGMP: use simple u32 bit hash key
some IGMP hashse use only a u32 key, which is not stored in the object, so don't use memory based hash Change-Id: Iaa4eddf568ea0164bc2a812da4cc502f1811b93c Signed-off-by: Neale Ranns <nranns@cisco.com>
This commit is contained in:
@ -50,7 +50,7 @@ igmp_clear_config (igmp_config_t * config)
|
|||||||
pool_free (config->sg);
|
pool_free (config->sg);
|
||||||
hash_free (config->igmp_sg_by_key);
|
hash_free (config->igmp_sg_by_key);
|
||||||
|
|
||||||
hash_unset_mem (im->igmp_config_by_sw_if_index, &config->sw_if_index);
|
hash_unset (im->igmp_config_by_sw_if_index, config->sw_if_index);
|
||||||
pool_put (im->configs, config);
|
pool_put (im->configs, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -503,12 +503,10 @@ igmp_send_state_changed (vlib_main_t * vm, vlib_node_runtime_t * rt,
|
|||||||
pool_put (config->sg, sg);
|
pool_put (config->sg, sg);
|
||||||
if (pool_elts (config->sg) == 0)
|
if (pool_elts (config->sg) == 0)
|
||||||
{
|
{
|
||||||
hash_unset_mem (im->igmp_config_by_sw_if_index,
|
hash_unset (im->igmp_config_by_sw_if_index, config->sw_if_index);
|
||||||
&config->sw_if_index);
|
|
||||||
pool_put (im->configs, config);
|
pool_put (im->configs, config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -631,8 +629,8 @@ igmp_listen (vlib_main_t * vm, u8 enable, u32 sw_if_index,
|
|||||||
config->adj_index =
|
config->adj_index =
|
||||||
adj_mcast_add_or_lock (FIB_PROTOCOL_IP4, VNET_LINK_IP4,
|
adj_mcast_add_or_lock (FIB_PROTOCOL_IP4, VNET_LINK_IP4,
|
||||||
config->sw_if_index);
|
config->sw_if_index);
|
||||||
hash_set_mem (im->igmp_config_by_sw_if_index, &config->sw_if_index,
|
hash_set (im->igmp_config_by_sw_if_index,
|
||||||
config - im->configs);
|
config->sw_if_index, config - im->configs);
|
||||||
}
|
}
|
||||||
else if (config->cli_api_configured != cli_api_configured)
|
else if (config->cli_api_configured != cli_api_configured)
|
||||||
{
|
{
|
||||||
@ -742,11 +740,8 @@ igmp_init (vlib_main_t * vm)
|
|||||||
if ((error = vlib_call_init_function (vm, ip4_lookup_init)))
|
if ((error = vlib_call_init_function (vm, ip4_lookup_init)))
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
im->igmp_config_by_sw_if_index =
|
im->igmp_config_by_sw_if_index = hash_create (0, sizeof (u32));
|
||||||
hash_create_mem (0, sizeof (u32), sizeof (uword));
|
im->igmp_api_client_by_client_index = hash_create (0, sizeof (u32));
|
||||||
im->igmp_api_client_by_client_index =
|
|
||||||
hash_create_mem (0, sizeof (u32), sizeof (uword));
|
|
||||||
|
|
||||||
vec_validate_aligned (im->buffers, tm->n_vlib_mains - 1,
|
vec_validate_aligned (im->buffers, tm->n_vlib_mains - 1,
|
||||||
CLIB_CACHE_LINE_BYTES);
|
CLIB_CACHE_LINE_BYTES);
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ igmp_config_lookup (igmp_main_t * im, u32 sw_if_index)
|
|||||||
uword *p;
|
uword *p;
|
||||||
igmp_config_t *config = NULL;
|
igmp_config_t *config = NULL;
|
||||||
|
|
||||||
p = hash_get_mem (im->igmp_config_by_sw_if_index, &sw_if_index);
|
p = hash_get (im->igmp_config_by_sw_if_index, sw_if_index);
|
||||||
if (p)
|
if (p)
|
||||||
config = vec_elt_at_index (im->configs, p[0]);
|
config = vec_elt_at_index (im->configs, p[0]);
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ igmp_api_client_lookup (igmp_main_t * im, u32 client_index)
|
|||||||
uword *p;
|
uword *p;
|
||||||
vpe_client_registration_t *api_client = NULL;
|
vpe_client_registration_t *api_client = NULL;
|
||||||
|
|
||||||
p = hash_get_mem (im->igmp_api_client_by_client_index, &client_index);
|
p = hash_get (im->igmp_api_client_by_client_index, client_index);
|
||||||
if (p)
|
if (p)
|
||||||
api_client = vec_elt_at_index (im->api_clients, p[0]);
|
api_client = vec_elt_at_index (im->api_clients, p[0]);
|
||||||
|
|
||||||
@ -219,8 +219,8 @@ vl_api_want_igmp_events_t_handler (vl_api_want_igmp_events_t * mp)
|
|||||||
rv = VNET_API_ERROR_INVALID_REGISTRATION;
|
rv = VNET_API_ERROR_INVALID_REGISTRATION;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
hash_unset_mem (im->igmp_api_client_by_client_index,
|
hash_unset (im->igmp_api_client_by_client_index,
|
||||||
&api_client->client_index);
|
api_client->client_index);
|
||||||
pool_put (im->api_clients, api_client);
|
pool_put (im->api_clients, api_client);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@ -230,8 +230,8 @@ vl_api_want_igmp_events_t_handler (vl_api_want_igmp_events_t * mp)
|
|||||||
memset (api_client, 0, sizeof (vpe_client_registration_t));
|
memset (api_client, 0, sizeof (vpe_client_registration_t));
|
||||||
api_client->client_index = mp->client_index;
|
api_client->client_index = mp->client_index;
|
||||||
api_client->client_pid = mp->pid;
|
api_client->client_pid = mp->pid;
|
||||||
hash_set_mem (im->igmp_api_client_by_client_index,
|
hash_set (im->igmp_api_client_by_client_index,
|
||||||
&mp->client_index, api_client - im->api_clients);
|
mp->client_index, api_client - im->api_clients);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
rv = VNET_API_ERROR_INVALID_REGISTRATION;
|
rv = VNET_API_ERROR_INVALID_REGISTRATION;
|
||||||
@ -257,13 +257,13 @@ want_igmp_events_reaper (u32 client_index)
|
|||||||
vpe_client_registration_t *api_client;
|
vpe_client_registration_t *api_client;
|
||||||
uword *p;
|
uword *p;
|
||||||
|
|
||||||
p = hash_get_mem (im->igmp_api_client_by_client_index, &client_index);
|
p = hash_get (im->igmp_api_client_by_client_index, client_index);
|
||||||
|
|
||||||
if (p)
|
if (p)
|
||||||
{
|
{
|
||||||
api_client = pool_elt_at_index (im->api_clients, p[0]);
|
api_client = pool_elt_at_index (im->api_clients, p[0]);
|
||||||
pool_put (im->api_clients, api_client);
|
pool_put (im->api_clients, api_client);
|
||||||
hash_unset_mem (im->igmp_api_client_by_client_index, &client_index);
|
hash_unset (im->igmp_api_client_by_client_index, client_index);
|
||||||
}
|
}
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@ -308,8 +308,7 @@ igmp_event (igmp_main_t * im, igmp_config_t * config, igmp_sg_t * sg)
|
|||||||
pool_put (config->sg, sg);
|
pool_put (config->sg, sg);
|
||||||
if (pool_elts (config->sg) == 0)
|
if (pool_elts (config->sg) == 0)
|
||||||
{
|
{
|
||||||
hash_unset_mem (im->igmp_config_by_sw_if_index,
|
hash_unset (im->igmp_config_by_sw_if_index, config->sw_if_index);
|
||||||
&config->sw_if_index);
|
|
||||||
pool_put (im->configs, config);
|
pool_put (im->configs, config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user