From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 49E07C3C2 for ; Wed, 29 Jul 2015 10:22:52 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP; 29 Jul 2015 01:22:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,569,1432623600"; d="scan'208";a="532178310" Received: from shwdeisgchi017.ccr.corp.intel.com (HELO [10.239.66.47]) ([10.239.66.47]) by FMSMGA003.fm.intel.com with ESMTP; 29 Jul 2015 01:22:34 -0700 Message-ID: <55B88D4B.7080007@intel.com> Date: Wed, 29 Jul 2015 16:22:35 +0800 From: "Liang, Cunming" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Zhe Tao References: <1438074846-13874-1-git-send-email-zhe.tao@intel.com> In-Reply-To: <1438074846-13874-1-git-send-email-zhe.tao@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH] lpm: fix extended flag check when adding a "depth small" entry X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Jul 2015 08:22:52 -0000 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 > --- > 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; > + } > } > } > }