All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Liang, Cunming" <cunming.liang@intel.com>
To: Zhe Tao <zhe.tao@intel.com>
Cc: dev@dpdk.org
Subject: Re: [PATCH] lpm: fix extended flag check when adding a "depth small" entry
Date: Wed, 29 Jul 2015 16:22:35 +0800	[thread overview]
Message-ID: <55B88D4B.7080007@intel.com> (raw)
In-Reply-To: <1438074846-13874-1-git-send-email-zhe.tao@intel.com>



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;
> +				}
>   			}
>   		}
>   	}

  reply	other threads:[~2015-07-29  8:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-28  9:14 [PATCH] lpm: fix extended flag check when adding a "depth small" entry Zhe Tao
2015-07-29  8:22 ` Liang, Cunming [this message]
2015-07-30  3:19 ` [PATCH v2] " Zhe Tao
2015-07-30  3:36   ` Liang, Cunming
2015-08-03 11:53     ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55B88D4B.7080007@intel.com \
    --to=cunming.liang@intel.com \
    --cc=dev@dpdk.org \
    --cc=zhe.tao@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.