<p></p>

<h3 dir="auto">Description</h3>
<p dir="auto">I found some failures in the stress test of MSRP messages and prompted the following error log:<br>
DEBUG: msrp [msrp_netio.c:98]: msrp_relay(): To-Path has only one URI -- nowehere to forward;</p>

<p dir="auto">After adding the log embedding point, it is found that there is a problem in the logic of adding the linked list of "_msrp_cmap_head - > cslots". The node with a smaller hash value will be added behind the node with a larger "citemid" value, so that the linked list is not arranged strictly in the ascending order of "citemid", resulting in the failure of subsequent queries such as "msrp_cmap_lookup", and thus the normal relay cannot be performed.<br>
37(81) ERROR: msrp [msrp_cmap.c:291]: msrp_cmap_save(): _msrp_cmap_head->cslots[<strong>492932</strong>] item citemid is [<strong>2183628164</strong>], sessionid is [xxxxxxxx]<br>
37(81) ERROR: msrp [msrp_cmap.c:291]: msrp_cmap_save(): _msrp_cmap_head->cslots[<strong>492932</strong>] item citemid is [<strong>2174190980</strong>], sessionid is [xxxxxxxx]<br>
<strong>2183628164>2174190980, out of order.</strong></p>
<h3 dir="auto">Troubleshooting</h3>
<p dir="auto">source code:<br>
for(itb=_msrp_cmap_head->cslots[idx].first; itb; itb=itb->next)<br>
{<br>
if(itb->citemid>it->citemid || itb->next==NULL) {<br>
<strong>if(itb->next==NULL)</strong> {<br>
itb->next=it;<br>
it->prev = itb;<br>
} else {<br>
it->next = itb;<br>
if(itb->prev==NULL) {<br>
_msrp_cmap_head->cslots[idx].first = it;<br>
} else {<br>
itb->prev->next = it;<br>
}<br>
it->prev = itb->prev;<br>
itb->prev = it;<br>
}<br>
break;<br>
}<br>
}</p>
<h4 dir="auto">Reproduction</h4>

<h4 dir="auto">Debugging Data</h4>

<pre class="notranslate"><code class="notranslate">(paste your debugging data here)
</code></pre>
<h4 dir="auto">Log Messages</h4>

<pre class="notranslate"><code class="notranslate">(paste your log messages here)
</code></pre>
<h4 dir="auto">SIP Traffic</h4>

<pre class="notranslate"><code class="notranslate">(paste your sip traffic here)
</code></pre>
<h3 dir="auto">Possible Solutions</h3>

<h3 dir="auto">Additional Information</h3>
<p dir="auto">Tested against kamailio 5.4.x and actually all versions are affected`</p>
<pre class="notranslate"><code class="notranslate">fixed code:
for(itb=_msrp_cmap_head->cslots[idx].first; itb; itb=itb->next)
                        {
                                if(itb->citemid>it->citemid || itb->next==NULL) {
                                       //modifed code
                                        if(itb->next==NULL && (itb->citemid < it->citemid)) {
                                                itb->next=it;
                                                it->prev = itb;
                                        } else {
                                                it->next = itb;
                                                if(itb->prev==NULL) {
                                                        _msrp_cmap_head->cslots[idx].first = it;
                                                } else {
                                                        itb->prev->next = it;
                                                }
                                                it->prev = itb->prev;
                                                itb->prev = it;
                                        }
                                        break;
                                }
                        }
</code></pre>
<ul dir="auto">
<li><strong>Operating System</strong>:</li>
</ul>

<pre class="notranslate"><code class="notranslate">Ubuntu 16.04
</code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/issues/3215">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABO7UZMDAVI3NHTJNSPU6E3VZIKZLANCNFSM56RYZ36Q">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/ABO7UZLQPF3WSOVGPJEYOBLVZIKZLA5CNFSM56RYZ362YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4T6MQY2Q.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><kamailio/kamailio/issues/3215</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/issues/3215",
"url": "https://github.com/kamailio/kamailio/issues/3215",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>