components/open-fabrics/libibmad/patches/base.patch
changeset 1067 0dc41b42eadb
parent 995 52ebc73c889f
child 1216 bd892ba92960
--- a/components/open-fabrics/libibmad/patches/base.patch	Fri Nov 30 01:32:53 2012 -0800
+++ b/components/open-fabrics/libibmad/patches/base.patch	Fri Nov 30 09:00:34 2012 -0800
@@ -111,16 +111,46 @@
  
  #include <infiniband/umad.h>
  #include <infiniband/mad.h>
-@@ -104,12 +105,18 @@
+@@ -57,10 +58,18 @@
+ 
+ 	memset(sm_id, 0, sizeof(*sm_id));
+ 
+-	if (!smp_query_via(portinfo, &self, IB_ATTR_PORT_INFO, 0, 0, srcport))
++	if (!smp_query_via(portinfo, &self, IB_ATTR_PORT_INFO, 0, 0, srcport)) {
++		if (!errno)
++			errno = EIO;
+ 		return -1;
++	}
  
- 	if (!sm_id) {
+ 	mad_decode_field(portinfo, IB_PORT_SMLID_F, &lid);
++	if (lid == 0) {
++		if (!errno)
++			errno = EIO;
++		return -1;
++	}
+ 	mad_decode_field(portinfo, IB_PORT_SMSL_F, &sm_id->sl);
+ 
+ 	return ib_portid_set(sm_id, lid, 0, 0);
+@@ -95,7 +104,7 @@
+ 			ib_portid_t * sm_id, int timeout,
+ 			const struct ibmad_port *srcport)
+ {
+-	ib_portid_t sm_portid;
++	ib_portid_t sm_portid = { 0 };
+ 	uint8_t buf[IB_SA_DATA_SIZE] = { 0 };
+ 	ib_portid_t self = { 0 };
+ 	uint64_t selfguid, prefix;
+@@ -102,14 +111,19 @@
+ 	ibmad_gid_t selfgid;
+ 	uint8_t nodeinfo[64];
+ 
+-	if (!sm_id) {
++	if (!sm_id)
  		sm_id = &sm_portid;
--		if (ib_resolve_smlid_via(sm_id, timeout, srcport) < 0)
-+		if (ib_resolve_smlid_via(sm_id, timeout, srcport) < 0) {
-+			if (!errno)
-+				errno = EIO;
++
++	if (!sm_id->lid) {
+ 		if (ib_resolve_smlid_via(sm_id, timeout, srcport) < 0)
  			return -1;
-+		}
  	}
  
 -	if (!smp_query_via(nodeinfo, &self, IB_ATTR_NODE_INFO, 0, 0, srcport))