<span class="gmail_quote"></span><div><span style="font-family: courier new,monospace;">Hi Hal.<br><br style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;">This patch fixes an OSM crash when working with Cisco's stack.
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Cisco's doesn't follow </span><span style="font-family: courier new,monospace;">the same TID convention when generating 
transaction id which in some bad flow revealed this bug in the get_madw lookup.<br>The bug is in get_madw which does not cleanup old pointers to <br>retrieved madw and also does not detect lookup of its reserved "free" entry of key==0.
<br></span><br>(This better text replaces my previous patch:<br> "OSM crash when working with Cisco's TopSpin stack")<br><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">Yevgeny</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Signed-off-by:  Yevgeny Kliteynik <
<a href="mailto:kliteyn@mellanox.co.il" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">kliteyn@mellanox.co.il</a>></span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
</div><span style="font-family: courier new,monospace;">Index: osm/libvendor/osm_vendor_ibumad.c</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">===================================================================
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">--- osm/libvendor/osm_vendor_ibumad.c   (revision 8614)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
+++ osm/libvendor/osm_vendor_ibumad.c   (working copy)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">@@ -141,12 +141,20 @@ get_madw(osm_vendor_t *p_vend, ib_net64_
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        ib_net64_t mtid = (*tid & cl_ntoh64(0x00000000ffffffffllu));</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        osm_madw_t *res;</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
+    /*</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">+     * Since mtid == 0 is the empty key we should not</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">+     * waste time looking for it</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">+     */</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">+    if (mtid == 0)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">+       return 0;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">+</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        cl_spinlock_acquire( &p_vend->match_tbl_lock );</span>
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        for (m = p_vend->mtbl.tbl, e = m + p_vend->mtbl.max; m < e; m++) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">                if (m->tid == mtid) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                        m->tid = 0;
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                        *tid = mtid;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
                        res = m->v;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">+                       m->v = NULL; /* just make sure we do not point to free'd madw */
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                        cl_spinlock_release( &p_vend->match_tbl_lock );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">                        return res;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                }</span><br><br>