DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] lpm: fix extended flag check when adding a "depth small" entry
@ 2015-07-28  9:14 Zhe Tao
  2015-07-29  8:22 ` Liang, Cunming
  2015-07-30  3:19 ` [dpdk-dev] [PATCH v2] " Zhe Tao
  0 siblings, 2 replies; 5+ messages in thread
From: Zhe Tao @ 2015-07-28  9:14 UTC (permalink / raw)
  To: dev

When adding a "depth small" entry, if its extended flag is not set
and its depth is smaller than the one in the tbl24, nothing should
be done otherwise will operate on the wrong memory area. 

Signed-off-by: Zhe Tao <zhe.tao@intel.com>
---
 lib/librte_lpm/rte_lpm.c | 51 +++++++++++++++++++++++++-----------------------
 1 file changed, 27 insertions(+), 24 deletions(-)

diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c
index de05307..0ef2421 100644
--- a/lib/librte_lpm/rte_lpm.c
+++ b/lib/librte_lpm/rte_lpm.c
@@ -447,30 +447,33 @@ add_depth_small(struct rte_lpm *lpm, uint32_t ip, uint8_t depth,
 
 			continue;
 		}
-
-		/* If tbl24 entry is valid and extended calculate the index
-		 * into tbl8. */
-		tbl8_index = lpm->tbl24[i].tbl8_gindex *
-				RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
-		tbl8_group_end = tbl8_index + RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
-
-		for (j = tbl8_index; j < tbl8_group_end; j++) {
-			if (!lpm->tbl8[j].valid ||
-					lpm->tbl8[j].depth <= depth) {
-				struct rte_lpm_tbl8_entry new_tbl8_entry = {
-					.valid = VALID,
-					.valid_group = VALID,
-					.depth = depth,
-					.next_hop = next_hop,
-				};
-
-				/*
-				 * Setting tbl8 entry in one go to avoid race
-				 * conditions
-				 */
-				lpm->tbl8[j] = new_tbl8_entry;
-
-				continue;
+
+		if (lpm->tbl24[i].ext_entry == 1) {
+
+			/* If tbl24 entry is valid and extended calculate the index
+			 * into tbl8. */
+			tbl8_index = lpm->tbl24[i].tbl8_gindex *
+					RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
+			tbl8_group_end = tbl8_index + RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
+
+			for (j = tbl8_index; j < tbl8_group_end; j++) {
+				if (!lpm->tbl8[j].valid ||
+						lpm->tbl8[j].depth <= depth) {
+					struct rte_lpm_tbl8_entry new_tbl8_entry = {
+						.valid = VALID,
+						.valid_group = VALID,
+						.depth = depth,
+						.next_hop = next_hop,
+					};
+
+					/*
+					 * Setting tbl8 entry in one go to avoid race
+					 * conditions
+					 */
+					lpm->tbl8[j] = new_tbl8_entry;
+
+					continue;
+				}
 			}
 		}
 	}
-- 
1.9.3

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH] lpm: fix extended flag check when adding a "depth small" entry
  2015-07-28  9:14 [dpdk-dev] [PATCH] lpm: fix extended flag check when adding a "depth small" entry Zhe Tao
@ 2015-07-29  8:22 ` Liang, Cunming
  2015-07-30  3:19 ` [dpdk-dev] [PATCH v2] " Zhe Tao
  1 sibling, 0 replies; 5+ messages in thread
From: Liang, Cunming @ 2015-07-29  8:22 UTC (permalink / raw)
  To: Zhe Tao; +Cc: dev



On 7/28/2015 5:14 PM, Zhe Tao wrote:
> When adding a "depth small" entry, if its extended flag is not set
> and its depth is smaller than the one in the tbl24, nothing should
> be done otherwise will operate on the wrong memory area.
>
> Signed-off-by: Zhe Tao <zhe.tao@intel.com>
> ---
>   lib/librte_lpm/rte_lpm.c | 51 +++++++++++++++++++++++++-----------------------
>   1 file changed, 27 insertions(+), 24 deletions(-)
>
> diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c
> index de05307..0ef2421 100644
> --- a/lib/librte_lpm/rte_lpm.c
> +++ b/lib/librte_lpm/rte_lpm.c
> @@ -447,30 +447,33 @@ add_depth_small(struct rte_lpm *lpm, uint32_t ip, uint8_t depth,
>   
>   			continue;
>   		}
> -
> -		/* If tbl24 entry is valid and extended calculate the index
> -		 * into tbl8. */
> -		tbl8_index = lpm->tbl24[i].tbl8_gindex *
> -				RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
> -		tbl8_group_end = tbl8_index + RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
> -
> -		for (j = tbl8_index; j < tbl8_group_end; j++) {
> -			if (!lpm->tbl8[j].valid ||
> -					lpm->tbl8[j].depth <= depth) {
> -				struct rte_lpm_tbl8_entry new_tbl8_entry = {
> -					.valid = VALID,
> -					.valid_group = VALID,
> -					.depth = depth,
> -					.next_hop = next_hop,
> -				};
> -
> -				/*
> -				 * Setting tbl8 entry in one go to avoid race
> -				 * conditions
> -				 */
> -				lpm->tbl8[j] = new_tbl8_entry;
> -
> -				continue;
> +
> +		if (lpm->tbl24[i].ext_entry == 1) {
> +
> +			/* If tbl24 entry is valid and extended calculate the index
> +			 * into tbl8. */
One minor comment on the format. Some lines are over 80 characters and 
the blank line ahead of the comment is not required.
> +			tbl8_index = lpm->tbl24[i].tbl8_gindex *
> +					RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
> +			tbl8_group_end = tbl8_index + RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
> +
> +			for (j = tbl8_index; j < tbl8_group_end; j++) {
> +				if (!lpm->tbl8[j].valid ||
> +						lpm->tbl8[j].depth <= depth) {
> +					struct rte_lpm_tbl8_entry new_tbl8_entry = {
> +						.valid = VALID,
> +						.valid_group = VALID,
> +						.depth = depth,
> +						.next_hop = next_hop,
> +					};
> +
> +					/*
> +					 * Setting tbl8 entry in one go to avoid race
> +					 * conditions
> +					 */
> +					lpm->tbl8[j] = new_tbl8_entry;
> +
> +					continue;
> +				}
>   			}
>   		}
>   	}

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dpdk-dev] [PATCH v2] lpm: fix extended flag check when adding a "depth small" entry
  2015-07-28  9:14 [dpdk-dev] [PATCH] lpm: fix extended flag check when adding a "depth small" entry Zhe Tao
  2015-07-29  8:22 ` Liang, Cunming
@ 2015-07-30  3:19 ` Zhe Tao
  2015-07-30  3:36   ` Liang, Cunming
  1 sibling, 1 reply; 5+ messages in thread
From: Zhe Tao @ 2015-07-30  3:19 UTC (permalink / raw)
  To: dev

When adding a "depth small" entry, if its extended flag is not set and 
its depth is smaller than the one in the tbl24, nothing should be done 
otherwise will operate on the wrong memory area.

Signed-off-by: Zhe Tao <zhe.tao@intel.com>
---
PATCH v2: Edit to keep line size below 80 characters

PATCH v1: Fix extended flag check when adding a "depth small" entry

 lib/librte_lpm/rte_lpm.c | 54 +++++++++++++++++++++++++++---------------------
 1 file changed, 30 insertions(+), 24 deletions(-)

diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c
index de05307..163ba3c 100644
--- a/lib/librte_lpm/rte_lpm.c
+++ b/lib/librte_lpm/rte_lpm.c
@@ -442,35 +442,41 @@ add_depth_small(struct rte_lpm *lpm, uint32_t ip, uint8_t depth,
 			};
 
 			/* Setting tbl24 entry in one go to avoid race
-			 * conditions */
+			 * conditions
+			 */
 			lpm->tbl24[i] = new_tbl24_entry;
 
 			continue;
 		}
 
-		/* If tbl24 entry is valid and extended calculate the index
-		 * into tbl8. */
-		tbl8_index = lpm->tbl24[i].tbl8_gindex *
-				RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
-		tbl8_group_end = tbl8_index + RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
-
-		for (j = tbl8_index; j < tbl8_group_end; j++) {
-			if (!lpm->tbl8[j].valid ||
-					lpm->tbl8[j].depth <= depth) {
-				struct rte_lpm_tbl8_entry new_tbl8_entry = {
-					.valid = VALID,
-					.valid_group = VALID,
-					.depth = depth,
-					.next_hop = next_hop,
-				};
-
-				/*
-				 * Setting tbl8 entry in one go to avoid race
-				 * conditions
-				 */
-				lpm->tbl8[j] = new_tbl8_entry;
-
-				continue;
+		if (lpm->tbl24[i].ext_entry == 1) {
+			/* If tbl24 entry is valid and extended calculate the
+			 *  index into tbl8.
+			 */
+			tbl8_index = lpm->tbl24[i].tbl8_gindex *
+					RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
+			tbl8_group_end = tbl8_index +
+					RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
+
+			for (j = tbl8_index; j < tbl8_group_end; j++) {
+				if (!lpm->tbl8[j].valid ||
+						lpm->tbl8[j].depth <= depth) {
+					struct rte_lpm_tbl8_entry
+						new_tbl8_entry = {
+						.valid = VALID,
+						.valid_group = VALID,
+						.depth = depth,
+						.next_hop = next_hop,
+					};
+
+					/*
+					 * Setting tbl8 entry in one go to avoid
+					 * race conditions
+					 */
+					lpm->tbl8[j] = new_tbl8_entry;
+
+					continue;
+				}
 			}
 		}
 	}
-- 
1.9.3

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH v2] lpm: fix extended flag check when adding a "depth small" entry
  2015-07-30  3:19 ` [dpdk-dev] [PATCH v2] " Zhe Tao
@ 2015-07-30  3:36   ` Liang, Cunming
  2015-08-03 11:53     ` Thomas Monjalon
  0 siblings, 1 reply; 5+ messages in thread
From: Liang, Cunming @ 2015-07-30  3:36 UTC (permalink / raw)
  To: Tao, Zhe, dev



> -----Original Message-----
> From: Tao, Zhe
> Sent: Thursday, July 30, 2015 11:19 AM
> To: dev@dpdk.org
> Cc: Tao, Zhe; Liang, Cunming; Richardson, Bruce
> Subject: [dpdk-dev][PATCH v2] lpm: fix extended flag check when adding a
> "depth small" entry
> 
> When adding a "depth small" entry, if its extended flag is not set and
> its depth is smaller than the one in the tbl24, nothing should be done
> otherwise will operate on the wrong memory area.
> 
> Signed-off-by: Zhe Tao <zhe.tao@intel.com>
> ---
> PATCH v2: Edit to keep line size below 80 characters
> 
> PATCH v1: Fix extended flag check when adding a "depth small" entry
> 
>  lib/librte_lpm/rte_lpm.c | 54 +++++++++++++++++++++++++++-------------------
> --
>  1 file changed, 30 insertions(+), 24 deletions(-)
> 
> diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c
> index de05307..163ba3c 100644
> --- a/lib/librte_lpm/rte_lpm.c
> +++ b/lib/librte_lpm/rte_lpm.c
> @@ -442,35 +442,41 @@ add_depth_small(struct rte_lpm *lpm, uint32_t ip,
> uint8_t depth,
>  			};
> 
>  			/* Setting tbl24 entry in one go to avoid race
> -			 * conditions */
> +			 * conditions
> +			 */
>  			lpm->tbl24[i] = new_tbl24_entry;
> 
>  			continue;
>  		}
> 
> -		/* If tbl24 entry is valid and extended calculate the index
> -		 * into tbl8. */
> -		tbl8_index = lpm->tbl24[i].tbl8_gindex *
> -				RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
> -		tbl8_group_end = tbl8_index +
> RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
> -
> -		for (j = tbl8_index; j < tbl8_group_end; j++) {
> -			if (!lpm->tbl8[j].valid ||
> -					lpm->tbl8[j].depth <= depth) {
> -				struct rte_lpm_tbl8_entry new_tbl8_entry = {
> -					.valid = VALID,
> -					.valid_group = VALID,
> -					.depth = depth,
> -					.next_hop = next_hop,
> -				};
> -
> -				/*
> -				 * Setting tbl8 entry in one go to avoid race
> -				 * conditions
> -				 */
> -				lpm->tbl8[j] = new_tbl8_entry;
> -
> -				continue;
> +		if (lpm->tbl24[i].ext_entry == 1) {
> +			/* If tbl24 entry is valid and extended calculate the
> +			 *  index into tbl8.
> +			 */
> +			tbl8_index = lpm->tbl24[i].tbl8_gindex *
> +					RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
> +			tbl8_group_end = tbl8_index +
> +					RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
> +
> +			for (j = tbl8_index; j < tbl8_group_end; j++) {
> +				if (!lpm->tbl8[j].valid ||
> +						lpm->tbl8[j].depth <= depth) {
> +					struct rte_lpm_tbl8_entry
> +						new_tbl8_entry = {
> +						.valid = VALID,
> +						.valid_group = VALID,
> +						.depth = depth,
> +						.next_hop = next_hop,
> +					};
> +
> +					/*
> +					 * Setting tbl8 entry in one go to avoid
> +					 * race conditions
> +					 */
> +					lpm->tbl8[j] = new_tbl8_entry;
> +
> +					continue;
> +				}
>  			}
>  		}
>  	}
> --
> 1.9.3

Acked-by: Cunming Liang <cunming.liang@intel.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH v2] lpm: fix extended flag check when adding a "depth small" entry
  2015-07-30  3:36   ` Liang, Cunming
@ 2015-08-03 11:53     ` Thomas Monjalon
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Monjalon @ 2015-08-03 11:53 UTC (permalink / raw)
  To: Tao, Zhe; +Cc: dev

> > When adding a "depth small" entry, if its extended flag is not set and
> > its depth is smaller than the one in the tbl24, nothing should be done
> > otherwise will operate on the wrong memory area.
> > 
> > Signed-off-by: Zhe Tao <zhe.tao@intel.com>
> 
> Acked-by: Cunming Liang <cunming.liang@intel.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-08-03 11:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-28  9:14 [dpdk-dev] [PATCH] lpm: fix extended flag check when adding a "depth small" entry Zhe Tao
2015-07-29  8:22 ` Liang, Cunming
2015-07-30  3:19 ` [dpdk-dev] [PATCH v2] " Zhe Tao
2015-07-30  3:36   ` Liang, Cunming
2015-08-03 11:53     ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).