diff mbox

[opensm] osm_pkey.c: Fix find common pkey bug fix

Message ID 5263CCD0.2010605@dev.mellanox.co.il (mailing list archive)
State Accepted
Delegated to: Hal Rosenstock
Headers show

Commit Message

Hal Rosenstock Oct. 20, 2013, 12:30 p.m. UTC
From: Daniel Klein <danielk@mellanox.com>

When OpenSM supports keeping both full and limited membership pkeys
for same port, search common pkey algorithm might miss a pkey shared
by two ports.

OpenSM iterates over pkey table of both ports, trying to find a
matching pkey, where the pkeys are sorted by network order value of
the pkeys (including membership bit).

When OpenSM searches for the shared pkey, it advances the iterator with
the lower key value. when comparing the keys without ignoring the
membership bit, OpenSM might miss a shared pkey.

For example:
Port 1 pkeys : 0x0081 0x0082
Port 2 pkeys : 0x0002 0x0003

Signed-off-by: Daniel Klein <danielk@mellanox.com>
Signed-off-by: Alex Netes <alexne@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
---
 opensm/osm_pkey.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/opensm/osm_pkey.c b/opensm/osm_pkey.c
index 4f5aa73..7a24156 100644
--- a/opensm/osm_pkey.c
+++ b/opensm/osm_pkey.c
@@ -430,8 +430,8 @@  ib_net16_t osm_physp_find_common_pkey(IN const osm_physp_t * p_physp1,
 			return *pkey1;
 
 		/* advance the lower value if they are not equal */
-		pkey1_base = cl_map_key(map_iter1);
-		pkey2_base = cl_map_key(map_iter2);
+		pkey1_base = ib_pkey_get_base(cl_map_key(map_iter1));
+		pkey2_base = ib_pkey_get_base(cl_map_key(map_iter2));
 		if (pkey2_base == pkey1_base) {
 			map_iter1 = cl_map_next(map_iter1);
 			map_iter2 = cl_map_next(map_iter2);
@@ -463,8 +463,8 @@  ib_net16_t osm_physp_find_common_pkey(IN const osm_physp_t * p_physp1,
 			return *pkey1;
 
 		/* advance the lower value if they are not equal */
-		pkey1_base = cl_map_key(map_iter1);
-		pkey2_base = cl_map_key(map_iter2);
+		pkey1_base = ib_pkey_get_base(cl_map_key(map_iter1));
+		pkey2_base = ib_pkey_get_base(cl_map_key(map_iter2));
 		if (pkey2_base == pkey1_base) {
 			map_iter1 = cl_map_next(map_iter1);
 			map_iter2 = cl_map_next(map_iter2);