[dpdk-dev,1/4] table: fix empty bucket removal during entry deletion in rte_table_hash_ext

Message ID 1411658678-658-2-git-send-email-balazs.nemeth@intel.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

Balazs Nemeth Sept. 25, 2014, 3:24 p.m. UTC
When an entry is deleted from an extensible rte_table_hash, the bucket
that stored the entry can become empty. If this is the case, the
bucket needs to be removed from the chain of buckets.

During removal of the bucket, the chain should be updated first. If
the bucket that will be removed is cleared first, the chain is broken
and the information to update the chain is lost.

Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Signed-off-by: Balazs Nemeth <balazs.nemeth@intel.com>
---
 lib/librte_table/rte_table_hash_ext.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--
2.1.0
Intel Corporation NV/SA
Kings Square, Veldkant 31
2550 Kontich
RPM (Bruxelles) 0415.497.718. 
Citibank, Brussels, account 570/1031255/09

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
  

Comments

Neil Horman Sept. 25, 2014, 3:44 p.m. UTC | #1
On Thu, Sep 25, 2014 at 03:24:35PM +0000, Balazs Nemeth wrote:
> When an entry is deleted from an extensible rte_table_hash, the bucket
> that stored the entry can become empty. If this is the case, the
> bucket needs to be removed from the chain of buckets.
> 
> During removal of the bucket, the chain should be updated first. If
> the bucket that will be removed is cleared first, the chain is broken
> and the information to update the chain is lost.
> 
> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> Signed-off-by: Balazs Nemeth <balazs.nemeth@intel.com>
> ---
>  lib/librte_table/rte_table_hash_ext.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/librte_table/rte_table_hash_ext.c b/lib/librte_table/rte_table_hash_ext.c
> index 6e26d98..17c16cd 100644
> --- a/lib/librte_table/rte_table_hash_ext.c
> +++ b/lib/librte_table/rte_table_hash_ext.c
> @@ -408,12 +408,12 @@ void *entry)
>  				if ((bkt_prev != NULL) &&
>  				    (bkt->sig[0] == 0) && (bkt->sig[1] == 0) &&
>  				    (bkt->sig[2] == 0) && (bkt->sig[3] == 0)) {
> -					/* Clear bucket */
> -					memset(bkt, 0, sizeof(struct bucket));
> -
>  					/* Unchain bucket */
>  					BUCKET_NEXT_COPY(bkt_prev, bkt);
> 
> +					/* Clear bucket */
> +					memset(bkt, 0, sizeof(struct bucket));
> +
>  					/* Free bucket back to buckets ext */
>  					bkt_index = bkt - t->buckets_ext;
>  					t->bkt_ext_stack[t->bkt_ext_stack_tos++]
Acked-by: Neil Horman <nhorman@tuxdriver.com>

> --
> 2.1.0
> Intel Corporation NV/SA
> Kings Square, Veldkant 31
> 2550 Kontich
> RPM (Bruxelles) 0415.497.718. 
> Citibank, Brussels, account 570/1031255/09
> 
> This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
> 
>
  

Patch

diff --git a/lib/librte_table/rte_table_hash_ext.c b/lib/librte_table/rte_table_hash_ext.c
index 6e26d98..17c16cd 100644
--- a/lib/librte_table/rte_table_hash_ext.c
+++ b/lib/librte_table/rte_table_hash_ext.c
@@ -408,12 +408,12 @@  void *entry)
 				if ((bkt_prev != NULL) &&
 				    (bkt->sig[0] == 0) && (bkt->sig[1] == 0) &&
 				    (bkt->sig[2] == 0) && (bkt->sig[3] == 0)) {
-					/* Clear bucket */
-					memset(bkt, 0, sizeof(struct bucket));
-
 					/* Unchain bucket */
 					BUCKET_NEXT_COPY(bkt_prev, bkt);

+					/* Clear bucket */
+					memset(bkt, 0, sizeof(struct bucket));
+
 					/* Free bucket back to buckets ext */
 					bkt_index = bkt - t->buckets_ext;
 					t->bkt_ext_stack[t->bkt_ext_stack_tos++]