Skip to content

Commit

Permalink
hash: fix total entries count
Browse files Browse the repository at this point in the history
[ upstream commit 52c7abb ]

In rte_hash, with current implementation, it is possible that keys
are stored at indexes greater than the number of total entries.

Currently, in rte_hash_free_key_with_position(), due to incorrect
computation of total_entries, application cannot free keys with
indexes greater than the number of total entries.

This patch fixes this incorrect computation of total_entries.

Bugzilla ID: 261
Fixes: 9d033da ("hash: support no free on delete")

Reported-by: Linfan <zhongdahulinfan@163.com>
Suggested-by: Linfan <zhongdahulinfan@163.com>
Signed-off-by: Dharmik Thakkar <dharmik.thakkar@arm.com>
Acked-by: Yipeng Wang <yipeng1.wang@intel.com>
  • Loading branch information
dhatha01 authored and kevintraynor committed May 14, 2019
1 parent 9ad5789 commit 4b66ba8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/librte_hash/rte_cuckoo_hash.c
Expand Up @@ -1543,7 +1543,9 @@ rte_hash_free_key_with_position(const struct rte_hash *h,

unsigned int lcore_id, n_slots;
struct lcore_cache *cached_free_slots;
const uint32_t total_entries = h->num_buckets * RTE_HASH_BUCKET_ENTRIES;
const uint32_t total_entries = h->use_local_cache ?
h->entries + (RTE_MAX_LCORE - 1) * (LCORE_CACHE_SIZE - 1) + 1
: h->entries + 1;

/* Out of bounds */
if (key_idx >= total_entries)
Expand Down

0 comments on commit 4b66ba8

Please sign in to comment.