summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDharmik Thakkar <dharmik.thakkar@arm.com>2019-05-09 17:19:06 +0000
committerThomas Monjalon <thomas@monjalon.net>2019-05-09 22:31:29 +0200
commit52c7abbea95064edd73eee6ab1ceafaab066d55a (patch)
treef37b204fabf24b66092a0ad895ca322a2f5903d1
parent2bc731197b8afc0ea0a0796dd7cea43474a6e1f9 (diff)
downloaddpdk-draft-windows-52c7abbea95064edd73eee6ab1ceafaab066d55a.zip
dpdk-draft-windows-52c7abbea95064edd73eee6ab1ceafaab066d55a.tar.gz
dpdk-draft-windows-52c7abbea95064edd73eee6ab1ceafaab066d55a.tar.xz
hash: fix total entries count
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: 9d033dac7d7c ("hash: support no free on delete") Cc: stable@dpdk.org 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>
-rw-r--r--lib/librte_hash/rte_cuckoo_hash.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
index 1f5808e..2dc423f 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -1594,7 +1594,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)