<p>Hello all,</p>
<p>It seems there has been a regression between kamailio 5.1.0 and 5.1.1 with the topos module.</p>
<h3>Description</h3>
<p>Kamailio acts as a proxy for asterisk instances residing in a private IP range and other entities (subscribers, peers) residing on other networks. This is a multihomed installation, with 4 interfaces total (but mhomed is set to no).</p>
<p>Just by upgrading to 5.1.1, topos will complain with:<br>
<code>tps_storage_record(): no local address - do record routing for all initial requests</code><br>
for re-INVITEs within an established dialog. This warning is also printed for other in-dialog requests (BYE, ACK).</p>
<p>Also common behaviour with all those in-dialog requests is that if the request received by kamailio had a Contact header, topos will strip it before relaying (true for re-INVITE and ACK).</p>
<p>For ACK there seem to be no obvious side-effects, because there's no response to it. For BYE, its 200 OK response is routed properly, in contrast with the 200 OK to the re-INVITE.</p>
<p>During the processing of 200 OK to re-INVITE, the following relevant lines are printed in the logs:</p>
<pre><code>DEBUG: topos [tps_msg.c:1031]: tps_response_sent(): handling outgoing response
DEBUG: topos [tps_msg.c:1038]: tps_response_sent(): no x-branch header - nothing to do
</code></pre>
<p>During the processing of 200 OK to BYE, the following relevant lines are printed in the logs:</p>
<pre><code>DEBUG: topos [tps_msg.c:1031]: tps_response_sent(): handling outgoing response
DEBUG: topos [tps_msg.c:376]: tps_pack_message(): compacted headers - x_via1: [SIP/2.0/UDP 192.168.1.1:5060;rport=5060;received=2.2.2.2;branch=z9hG4bK-c1a29abe](86) - x_via2: [](0) - x_vbranch1: [z9hG4bK-c1a29abe](16)
DEBUG: topos [tps_msg.c:485]: tps_pack_message(): compacted headers - a_rr: [](0) - b_rr: [](0) - s_rr: [](0)
DEBUG: topos [tps_msg.c:490]: tps_pack_message(): compacted headers - as_contact: [](0) - bs_contact: [](0)
DEBUG: topos [tps_storage.c:124]: tps_storage_lock_get(): tps lock get: 436
</code></pre>
<h3>Troubleshooting</h3>
<p>Downgrading to 5.1.0 fixes the issue, with no changes in configuration.</p>
<h4>Reproduction</h4>
<p>Most SIP logic adheres to the sample configuration file, one difference being that record_route() is performed regardless of request method, as required for topos (although to reproduce this issue this change is not needed, as record_route() is performed for INVITEs anyway with the sample configuration file).</p>
<p>To reproduce on my setup, I initiate a call which kamailio will forward to asterisk, making sure topos is loaded. I then put the call on hold to generate a re-INVITE and watch as a) outgoing INVITE lacks a Contact header and b) Final reply to re-INVITE won't be routed, instead causing several retransmissions from asterisk.</p>
<h4>SIP Traffic</h4>
<p>I'm not sure SIP Traffic is relevant here, as only the Contact header missing is what strikes me as most odd. I can share pcaps and logs privately if needed.</p>
<h3>Additional Information</h3>
<ul>
<li>
<p><strong>Kamailio Version</strong><br>
Kamailio 5.1.1 on debian stretch from sipwise's repo</p>
</li>
<li>
<p><strong>Operating System</strong>:</p>
</li>
</ul>
<pre><code>Debian 9.1
</code></pre>
<ul>
<li><strong>Other pertinent configuration information</strong>:</li>
<li>The following issues might be relevant: <a href="https://github.com/kamailio/kamailio/issues/1356" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="280512160" data-permission-text="Issue title is private" data-url="https://github.com/kamailio/kamailio/issues/1356">#1356</a>, <a href="https://github.com/kamailio/kamailio/issues/1350" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="278733406" data-permission-text="Issue title is private" data-url="https://github.com/kamailio/kamailio/issues/1350">#1350</a></li>
<li>This kamailio box has several network interfaces. mhomed is not used, instead force_send_socket is called where necessary.</li>
</ul>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/issues/1421">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AF36ZVT6GJwaFhGhM_QjCLE-rWsdjiK4ks5tP25AgaJpZM4Ry4qH">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AF36ZYEUQArbwmFsZCwDm5v2Q1oWUsWbks5tP25AgaJpZM4Ry4qH.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
<link itemprop="url" href="https://github.com/kamailio/kamailio/issues/1421"></link>
<meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/kamailio/kamailio","title":"kamailio/kamailio","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/kamailio/kamailio"}},"updates":{"snippets":[{"icon":"DESCRIPTION","message":"topos 5.1.1 regression: missing Contact header in in-dialog requests despite record_route() having been executed for initial request (#1421)"}],"action":{"name":"View Issue","url":"https://github.com/kamailio/kamailio/issues/1421"}}}</script>