table: fix crash during key overload

hash_key8_ext, hash_key16_ext and hash_key32_ext tables allocate cache
entries to support table overload cases. The crash can occur when cache
entry is free after use.
The problem is with computing the index of the free cache entry.

Signed-off-by: Mirek Walukiewicz <miroslaw.walukiewicz@intel.com>
Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
This commit is contained in:
Miroslaw Walukiewicz 2015-03-03 09:16:00 -05:00 committed by Thomas Monjalon
parent 38f4f01f8f
commit 2f95a470b8
3 changed files with 6 additions and 9 deletions

@ -535,9 +535,8 @@ rte_table_hash_entry_delete_key16_ext(
memset(bucket, 0,
sizeof(struct rte_bucket_4_16));
bucket_index = (bucket -
((struct rte_bucket_4_16 *)
f->memory)) - f->n_buckets;
bucket_index = (((uint8_t *)bucket -
(uint8_t *)f->memory)/f->bucket_size) - f->n_buckets;
f->stack[f->stack_pos++] = bucket_index;
}

@ -540,9 +540,8 @@ rte_table_hash_entry_delete_key32_ext(
memset(bucket, 0,
sizeof(struct rte_bucket_4_32));
bucket_index = (bucket -
((struct rte_bucket_4_32 *)
f->memory)) - f->n_buckets;
bucket_index = (((uint8_t *)bucket -
(uint8_t *)f->memory)/f->bucket_size) - f->n_buckets;
f->stack[f->stack_pos++] = bucket_index;
}

@ -528,9 +528,8 @@ rte_table_hash_entry_delete_key8_ext(
memset(bucket, 0,
sizeof(struct rte_bucket_4_8));
bucket_index = (bucket -
((struct rte_bucket_4_8 *)
f->memory)) - f->n_buckets;
bucket_index = (((uint8_t *)bucket -
(uint8_t *)f->memory)/f->bucket_size) - f->n_buckets;
f->stack[f->stack_pos++] = bucket_index;
}