patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Ruifeng Wang <ruifeng.wang@arm.com>
To: Bruce Richardson <bruce.richardson@intel.com>,
	Konstantin Ananyev <konstantin.ananyev@intel.com>,
	Vladimir Medvedkin <vladimir.medvedkin@intel.com>,
	Michal Kobylinski <michalx.kobylinski@intel.com>,
	David Hunt <david.hunt@intel.com>
Cc: dev@dpdk.org, nd@arm.com, jerinj@marvell.com,
	drc@linux.vnet.ibm.com, honnappa.nagarahalli@arm.com,
	Ruifeng Wang <ruifeng.wang@arm.com>,
	stable@dpdk.org
Subject: [dpdk-stable] [PATCH 2/4] lpm: fix vector lookup for x86
Date: Fri,  8 Jan 2021 08:21:24 +0000
Message-ID: <20210108082127.1061538-3-ruifeng.wang@arm.com> (raw)
In-Reply-To: <20210108082127.1061538-1-ruifeng.wang@arm.com>

rte_lpm_lookupx4 could return wrong next hop when more than 256 tbl8
groups are created. This is caused by incorrect type casting of tbl8
group index that been stored in tbl24 entry. The casting caused group
index truncation and hence wrong tbl8 group been searched.

Issue fixed by applying proper mask to tbl24 entry to get tbl8 group index.

Fixes: dc81ebbacaeb ("lpm: extend IPv4 next hop field")
Cc: michalx.kobylinski@intel.com
Cc: stable@dpdk.org

Signed-off-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 lib/librte_lpm/rte_lpm_sse.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/librte_lpm/rte_lpm_sse.h b/lib/librte_lpm/rte_lpm_sse.h
index 44770b6ff..eaa863c52 100644
--- a/lib/librte_lpm/rte_lpm_sse.h
+++ b/lib/librte_lpm/rte_lpm_sse.h
@@ -82,28 +82,28 @@ rte_lpm_lookupx4(const struct rte_lpm *lpm, xmm_t ip, uint32_t hop[4],
 	if (unlikely((pt & RTE_LPM_VALID_EXT_ENTRY_BITMASK) ==
 			RTE_LPM_VALID_EXT_ENTRY_BITMASK)) {
 		i8.u32[0] = i8.u32[0] +
-			(uint8_t)tbl[0] * RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
+			(tbl[0] & 0x00FFFFFF) * RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
 		ptbl = (const uint32_t *)&lpm->tbl8[i8.u32[0]];
 		tbl[0] = *ptbl;
 	}
 	if (unlikely((pt >> 32 & RTE_LPM_VALID_EXT_ENTRY_BITMASK) ==
 			RTE_LPM_VALID_EXT_ENTRY_BITMASK)) {
 		i8.u32[1] = i8.u32[1] +
-			(uint8_t)tbl[1] * RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
+			(tbl[1] & 0x00FFFFFF) * RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
 		ptbl = (const uint32_t *)&lpm->tbl8[i8.u32[1]];
 		tbl[1] = *ptbl;
 	}
 	if (unlikely((pt2 & RTE_LPM_VALID_EXT_ENTRY_BITMASK) ==
 			RTE_LPM_VALID_EXT_ENTRY_BITMASK)) {
 		i8.u32[2] = i8.u32[2] +
-			(uint8_t)tbl[2] * RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
+			(tbl[2] & 0x00FFFFFF) * RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
 		ptbl = (const uint32_t *)&lpm->tbl8[i8.u32[2]];
 		tbl[2] = *ptbl;
 	}
 	if (unlikely((pt2 >> 32 & RTE_LPM_VALID_EXT_ENTRY_BITMASK) ==
 			RTE_LPM_VALID_EXT_ENTRY_BITMASK)) {
 		i8.u32[3] = i8.u32[3] +
-			(uint8_t)tbl[3] * RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
+			(tbl[3] & 0x00FFFFFF) * RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
 		ptbl = (const uint32_t *)&lpm->tbl8[i8.u32[3]];
 		tbl[3] = *ptbl;
 	}
-- 
2.25.1


  parent reply	other threads:[~2021-01-08  8:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210108082127.1061538-1-ruifeng.wang@arm.com>
2021-01-08  8:21 ` [dpdk-stable] [PATCH 1/4] lpm: fix vector lookup for Arm Ruifeng Wang
2021-01-08  8:21 ` Ruifeng Wang [this message]
2021-01-13 18:46   ` [dpdk-stable] [PATCH 2/4] lpm: fix vector lookup for x86 Medvedkin, Vladimir
2021-01-08  8:21 ` [dpdk-stable] [PATCH 3/4] lpm: fix vector lookup for ppc64 Ruifeng Wang
2021-01-11 21:29   ` David Christensen
     [not found] ` <20210114065926.1200855-1-ruifeng.wang@arm.com>
2021-01-14  6:59   ` [dpdk-stable] [PATCH v2 1/4] lpm: fix vector lookup for Arm Ruifeng Wang
2021-01-14  6:59   ` [dpdk-stable] [PATCH v2 2/4] lpm: fix vector lookup for x86 Ruifeng Wang
2021-01-14  6:59   ` [dpdk-stable] [PATCH v2 3/4] lpm: fix vector lookup for ppc64 Ruifeng Wang

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=20210108082127.1061538-3-ruifeng.wang@arm.com \
    --to=ruifeng.wang@arm.com \
    --cc=bruce.richardson@intel.com \
    --cc=david.hunt@intel.com \
    --cc=dev@dpdk.org \
    --cc=drc@linux.vnet.ibm.com \
    --cc=honnappa.nagarahalli@arm.com \
    --cc=jerinj@marvell.com \
    --cc=konstantin.ananyev@intel.com \
    --cc=michalx.kobylinski@intel.com \
    --cc=nd@arm.com \
    --cc=stable@dpdk.org \
    --cc=vladimir.medvedkin@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

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ https://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git