From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id BA412C43A for ; Thu, 30 Jul 2015 05:39:37 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP; 29 Jul 2015 20:39:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,574,1432623600"; d="scan'208";a="772902201" Received: from pgsmsx107.gar.corp.intel.com ([10.221.44.105]) by fmsmga002.fm.intel.com with ESMTP; 29 Jul 2015 20:39:28 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by PGSMSX107.gar.corp.intel.com (10.221.44.105) with Microsoft SMTP Server (TLS) id 14.3.224.2; Thu, 30 Jul 2015 11:36:45 +0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.126]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.188]) with mapi id 14.03.0224.002; Thu, 30 Jul 2015 11:36:37 +0800 From: "Liang, Cunming" To: "Tao, Zhe" , "dev@dpdk.org" Thread-Topic: [dpdk-dev][PATCH v2] lpm: fix extended flag check when adding a "depth small" entry Thread-Index: AQHQynaUIdL4Af93Wk6MTK0ECEqb7J3zXDxA Date: Thu, 30 Jul 2015 03:36:36 +0000 Message-ID: References: <1438074846-13874-1-git-send-email-zhe.tao@intel.com> <1438226342-13113-1-git-send-email-zhe.tao@intel.com> In-Reply-To: <1438226342-13113-1-git-send-email-zhe.tao@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2] 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: Thu, 30 Jul 2015 03:39:38 -0000 > -----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 >=20 > 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. >=20 > Signed-off-by: Zhe Tao > --- > PATCH v2: Edit to keep line size below 80 characters >=20 > PATCH v1: Fix extended flag check when adding a "depth small" entry >=20 > lib/librte_lpm/rte_lpm.c | 54 +++++++++++++++++++++++++++---------------= ---- > -- > 1 file changed, 30 insertions(+), 24 deletions(-) >=20 > 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, > }; >=20 > /* Setting tbl24 entry in one go to avoid race > - * conditions */ > + * conditions > + */ > lpm->tbl24[i] =3D new_tbl24_entry; >=20 > continue; > } >=20 > - /* If tbl24 entry is valid and extended calculate the index > - * into tbl8. */ > - tbl8_index =3D lpm->tbl24[i].tbl8_gindex * > - RTE_LPM_TBL8_GROUP_NUM_ENTRIES; > - tbl8_group_end =3D tbl8_index + > RTE_LPM_TBL8_GROUP_NUM_ENTRIES; > - > - for (j =3D tbl8_index; j < tbl8_group_end; j++) { > - if (!lpm->tbl8[j].valid || > - lpm->tbl8[j].depth <=3D depth) { > - struct rte_lpm_tbl8_entry new_tbl8_entry =3D { > - .valid =3D VALID, > - .valid_group =3D VALID, > - .depth =3D depth, > - .next_hop =3D next_hop, > - }; > - > - /* > - * Setting tbl8 entry in one go to avoid race > - * conditions > - */ > - lpm->tbl8[j] =3D new_tbl8_entry; > - > - continue; > + if (lpm->tbl24[i].ext_entry =3D=3D 1) { > + /* If tbl24 entry is valid and extended calculate the > + * index into tbl8. > + */ > + tbl8_index =3D lpm->tbl24[i].tbl8_gindex * > + RTE_LPM_TBL8_GROUP_NUM_ENTRIES; > + tbl8_group_end =3D tbl8_index + > + RTE_LPM_TBL8_GROUP_NUM_ENTRIES; > + > + for (j =3D tbl8_index; j < tbl8_group_end; j++) { > + if (!lpm->tbl8[j].valid || > + lpm->tbl8[j].depth <=3D depth) { > + struct rte_lpm_tbl8_entry > + new_tbl8_entry =3D { > + .valid =3D VALID, > + .valid_group =3D VALID, > + .depth =3D depth, > + .next_hop =3D next_hop, > + }; > + > + /* > + * Setting tbl8 entry in one go to avoid > + * race conditions > + */ > + lpm->tbl8[j] =3D new_tbl8_entry; > + > + continue; > + } > } > } > } > -- > 1.9.3 Acked-by: Cunming Liang