<p>laforge <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/libosmo-abis/+/17430">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Jenkins Builder: Verified
  fixeria: Looks good to me, but someone else must approve
  pespin: Looks good to me, approved

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">ortp: disable SO_REUSEADDR + SO_REUSEPORT<br><br>ortp >= 0.24.0 doesn't differentiate between SO_REUSEADDR and<br>SO_REUSEPORT, and has both enabled by default.  The latter means that<br>we can end up with non-unique port bindings as we will not fail to<br>bind the same port twice.<br><br>This should have caused visible problems not only when operating multiple<br>osmo-bts on one machine (rare), but also with a single osmo-bts. Once the range<br>(default 16384-17407 ) wraps, there is a risk of new sockets (for new cals)<br>colliding with old ones. As two ports (RTP+RTCP) are used per call, this means<br>every 512 voice calls we expect the BTS to wrap. And from that point onwards<br>there's a risk of overlapping with previously allocated sockets.<br><br>Change-Id: I4fc9eee561c7958c70c63b4ffdc6cb700b795e28<br>Closes: OS#4444<br>---<br>M src/trau/osmo_ortp.c<br>M tests/rtp_test/rtp_test.c<br>M tests/rtp_test/rtp_test.ok<br>3 files changed, 8 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/trau/osmo_ortp.c b/src/trau/osmo_ortp.c</span><br><span>index 8b81e37..c070915 100644</span><br><span>--- a/src/trau/osmo_ortp.c</span><br><span>+++ b/src/trau/osmo_ortp.c</span><br><span>@@ -378,6 +378,12 @@</span><br><span>       rtp_session_set_profile(rs->sess, osmo_pt_profile);</span><br><span>       rtp_session_set_jitter_compensation(rs->sess, 100);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+    /* ortp >= 0.24.0 doesn't differentiate between SO_REUSEADDR and</span><br><span style="color: hsl(120, 100%, 40%);">+        * SO_REUSEPORT, and has both enabled by default.  The latter means that</span><br><span style="color: hsl(120, 100%, 40%);">+       * we can end up with non-unique port bindings as we will not fail to</span><br><span style="color: hsl(120, 100%, 40%);">+  * bind the same port twice */</span><br><span style="color: hsl(120, 100%, 40%);">+        rtp_session_set_reuseaddr(rs->sess, false);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>     rtp_session_signal_connect(rs->sess, "ssrc_changed",</span><br><span>                               (RtpCallback) ortp_sig_cb_ssrc,</span><br><span>                              RTP_SIGNAL_PTR_CAST(rs));</span><br><span>diff --git a/tests/rtp_test/rtp_test.c b/tests/rtp_test/rtp_test.c</span><br><span>index d696033..ae7d8ef 100644</span><br><span>--- a/tests/rtp_test/rtp_test.c</span><br><span>+++ b/tests/rtp_test/rtp_test.c</span><br><span>@@ -54,7 +54,7 @@</span><br><span>    else {</span><br><span>               printf("FAILED - second bind to port %u worked\n", port[0]);</span><br><span>               fflush(stdout);</span><br><span style="color: hsl(0, 100%, 40%);">-         //OSMO_ASSERT(0);</span><br><span style="color: hsl(120, 100%, 40%);">+             OSMO_ASSERT(0);</span><br><span>      }</span><br><span> </span><br><span>        osmo_rtp_socket_free(rs[0]);</span><br><span>diff --git a/tests/rtp_test/rtp_test.ok b/tests/rtp_test/rtp_test.ok</span><br><span>index ded2792..ddb68a4 100644</span><br><span>--- a/tests/rtp_test/rtp_test.ok</span><br><span>+++ b/tests/rtp_test/rtp_test.ok</span><br><span>@@ -1,2 +1,2 @@</span><br><span> First bind to any random local port...</span><br><span style="color: hsl(0, 100%, 40%);">-Now try to bind another socket to the same port: FAILED - second bind to port 16384 worked</span><br><span style="color: hsl(120, 100%, 40%);">+Now try to bind another socket to the same port: OK (EADDRINUSE)</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmo-abis/+/17430">change 17430</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/libosmo-abis/+/17430"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmo-abis </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I4fc9eee561c7958c70c63b4ffdc6cb700b795e28 </div>
<div style="display:none"> Gerrit-Change-Number: 17430 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: fixeria <axilirator@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-Reviewer: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>