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/mad.c libibmad-1.3.7/src/mad.c |
92 diff -r -u /tmp/libibmad-1.3.7/src/mad.c libibmad-1.3.7/src/mad.c |
93 --- /tmp/libibmad-1.3.7/src/mad.c Wed Feb 16 02:12:53 2011 |
93 --- /tmp/libibmad-1.3.7/src/mad.c Wed Feb 16 02:12:53 2011 |
94 +++ libibmad-1.3.7/src/mad.c Wed Oct 10 10:28:45 2012 |
94 +++ libibmad-1.3.7/src/mad.c Mon Nov 12 09:27:48 2012 |
95 @@ -61,6 +61,7 @@ |
95 @@ -61,6 +61,7 @@ |
96 trid = random(); |
96 trid = random(); |
97 } |
97 } |
98 next = ++trid | (base << 32); |
98 next = ++trid | (base << 32); |
99 + next &= 0x00ffffffffffffff; |
99 + next &= 0x00ffffffffffffff; |
109 #include <arpa/inet.h> |
109 #include <arpa/inet.h> |
110 +#include <errno.h> |
110 +#include <errno.h> |
111 |
111 |
112 #include <infiniband/umad.h> |
112 #include <infiniband/umad.h> |
113 #include <infiniband/mad.h> |
113 #include <infiniband/mad.h> |
114 @@ -104,12 +105,18 @@ |
114 @@ -57,10 +58,18 @@ |
115 |
115 |
116 if (!sm_id) { |
116 memset(sm_id, 0, sizeof(*sm_id)); |
|
117 |
|
118 - if (!smp_query_via(portinfo, &self, IB_ATTR_PORT_INFO, 0, 0, srcport)) |
|
119 + if (!smp_query_via(portinfo, &self, IB_ATTR_PORT_INFO, 0, 0, srcport)) { |
|
120 + if (!errno) |
|
121 + errno = EIO; |
|
122 return -1; |
|
123 + } |
|
124 |
|
125 mad_decode_field(portinfo, IB_PORT_SMLID_F, &lid); |
|
126 + if (lid == 0) { |
|
127 + if (!errno) |
|
128 + errno = EIO; |
|
129 + return -1; |
|
130 + } |
|
131 mad_decode_field(portinfo, IB_PORT_SMSL_F, &sm_id->sl); |
|
132 |
|
133 return ib_portid_set(sm_id, lid, 0, 0); |
|
134 @@ -95,7 +104,7 @@ |
|
135 ib_portid_t * sm_id, int timeout, |
|
136 const struct ibmad_port *srcport) |
|
137 { |
|
138 - ib_portid_t sm_portid; |
|
139 + ib_portid_t sm_portid = { 0 }; |
|
140 uint8_t buf[IB_SA_DATA_SIZE] = { 0 }; |
|
141 ib_portid_t self = { 0 }; |
|
142 uint64_t selfguid, prefix; |
|
143 @@ -102,14 +111,19 @@ |
|
144 ibmad_gid_t selfgid; |
|
145 uint8_t nodeinfo[64]; |
|
146 |
|
147 - if (!sm_id) { |
|
148 + if (!sm_id) |
117 sm_id = &sm_portid; |
149 sm_id = &sm_portid; |
118 - if (ib_resolve_smlid_via(sm_id, timeout, srcport) < 0) |
150 + |
119 + if (ib_resolve_smlid_via(sm_id, timeout, srcport) < 0) { |
151 + if (!sm_id->lid) { |
120 + if (!errno) |
152 if (ib_resolve_smlid_via(sm_id, timeout, srcport) < 0) |
121 + errno = EIO; |
|
122 return -1; |
153 return -1; |
123 + } |
|
124 } |
154 } |
125 |
155 |
126 - if (!smp_query_via(nodeinfo, &self, IB_ATTR_NODE_INFO, 0, 0, srcport)) |
156 - if (!smp_query_via(nodeinfo, &self, IB_ATTR_NODE_INFO, 0, 0, srcport)) |
127 + if (!smp_query_via(nodeinfo, &self, IB_ATTR_NODE_INFO, 0, 0, srcport)) { |
157 + if (!smp_query_via(nodeinfo, &self, IB_ATTR_NODE_INFO, 0, 0, srcport)) { |
128 + if (!errno) |
158 + if (!errno) |