89 sizeof(uint64_t)); |
89 sizeof(uint64_t)); |
90 return ntohll(val); |
90 return ntohll(val); |
91 } |
91 } |
92 diff -r -u /tmp/libibmad-1.3.7/src/resolve.c libibmad-1.3.7/src/resolve.c |
92 diff -r -u /tmp/libibmad-1.3.7/src/resolve.c libibmad-1.3.7/src/resolve.c |
93 --- /tmp/libibmad-1.3.7/src/resolve.c Wed Feb 16 02:12:53 2011 |
93 --- /tmp/libibmad-1.3.7/src/resolve.c Wed Feb 16 02:12:53 2011 |
94 +++ libibmad-1.3.7/src/resolve.c Thu Oct 4 23:29:01 2012 |
94 +++ libibmad-1.3.7/src/resolve.c Wed Jan 9 09:41:48 2013 |
95 @@ -40,6 +40,7 @@ |
95 @@ -40,6 +40,7 @@ |
96 #include <stdlib.h> |
96 #include <stdlib.h> |
97 #include <string.h> |
97 #include <string.h> |
98 #include <arpa/inet.h> |
98 #include <arpa/inet.h> |
99 +#include <errno.h> |
99 +#include <errno.h> |
100 |
100 |
101 #include <infiniband/umad.h> |
101 #include <infiniband/umad.h> |
102 #include <infiniband/mad.h> |
102 #include <infiniband/mad.h> |
103 @@ -104,12 +105,18 @@ |
103 @@ -57,10 +58,18 @@ |
104 |
104 |
105 if (!sm_id) { |
105 memset(sm_id, 0, sizeof(*sm_id)); |
|
106 |
|
107 - if (!smp_query_via(portinfo, &self, IB_ATTR_PORT_INFO, 0, 0, srcport)) |
|
108 + if (!smp_query_via(portinfo, &self, IB_ATTR_PORT_INFO, 0, 0, srcport)) { |
|
109 + if (!errno) |
|
110 + errno = EIO; |
|
111 return -1; |
|
112 + } |
|
113 |
|
114 mad_decode_field(portinfo, IB_PORT_SMLID_F, &lid); |
|
115 + if (lid == 0) { |
|
116 + if (!errno) |
|
117 + errno = EIO; |
|
118 + return -1; |
|
119 + } |
|
120 mad_decode_field(portinfo, IB_PORT_SMSL_F, &sm_id->sl); |
|
121 |
|
122 return ib_portid_set(sm_id, lid, 0, 0); |
|
123 @@ -95,7 +104,7 @@ |
|
124 ib_portid_t * sm_id, int timeout, |
|
125 const struct ibmad_port *srcport) |
|
126 { |
|
127 - ib_portid_t sm_portid; |
|
128 + ib_portid_t sm_portid = { 0 }; |
|
129 uint8_t buf[IB_SA_DATA_SIZE] = { 0 }; |
|
130 ib_portid_t self = { 0 }; |
|
131 uint64_t selfguid, prefix; |
|
132 @@ -102,14 +111,19 @@ |
|
133 ibmad_gid_t selfgid; |
|
134 uint8_t nodeinfo[64]; |
|
135 |
|
136 - if (!sm_id) { |
|
137 + if (!sm_id) |
106 sm_id = &sm_portid; |
138 sm_id = &sm_portid; |
107 - if (ib_resolve_smlid_via(sm_id, timeout, srcport) < 0) |
139 + |
108 + if (ib_resolve_smlid_via(sm_id, timeout, srcport) < 0) { |
140 + if (!sm_id->lid) { |
109 + if (!errno) |
141 if (ib_resolve_smlid_via(sm_id, timeout, srcport) < 0) |
110 + errno = EIO; |
|
111 return -1; |
142 return -1; |
112 + } |
|
113 } |
143 } |
114 |
144 |
115 - if (!smp_query_via(nodeinfo, &self, IB_ATTR_NODE_INFO, 0, 0, srcport)) |
145 - if (!smp_query_via(nodeinfo, &self, IB_ATTR_NODE_INFO, 0, 0, srcport)) |
116 + if (!smp_query_via(nodeinfo, &self, IB_ATTR_NODE_INFO, 0, 0, srcport)) { |
146 + if (!smp_query_via(nodeinfo, &self, IB_ATTR_NODE_INFO, 0, 0, srcport)) { |
117 + if (!errno) |
147 + if (!errno) |