laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-abis/+/17430 )
Change subject: ortp: disable SO_REUSEADDR + SO_REUSEPORT ...................................................................... ortp: disable SO_REUSEADDR + SO_REUSEPORT ortp >= 0.24.0 doesn't differentiate between SO_REUSEADDR and SO_REUSEPORT, and has both enabled by default. The latter means that we can end up with non-unique port bindings as we will not fail to bind the same port twice. This should have caused visible problems not only when operating multiple osmo-bts on one machine (rare), but also with a single osmo-bts. Once the range (default 16384-17407 ) wraps, there is a risk of new sockets (for new cals) colliding with old ones. As two ports (RTP+RTCP) are used per call, this means every 512 voice calls we expect the BTS to wrap. And from that point onwards there's a risk of overlapping with previously allocated sockets. Change-Id: I4fc9eee561c7958c70c63b4ffdc6cb700b795e28 Closes: OS#4444 --- M src/trau/osmo_ortp.c M tests/rtp_test/rtp_test.c M tests/rtp_test/rtp_test.ok 3 files changed, 8 insertions(+), 2 deletions(-) Approvals: Jenkins Builder: Verified fixeria: Looks good to me, but someone else must approve pespin: Looks good to me, approved diff --git a/src/trau/osmo_ortp.c b/src/trau/osmo_ortp.c index 8b81e37..c070915 100644 --- a/src/trau/osmo_ortp.c +++ b/src/trau/osmo_ortp.c @@ -378,6 +378,12 @@ rtp_session_set_profile(rs->sess, osmo_pt_profile); rtp_session_set_jitter_compensation(rs->sess, 100); + /* ortp >= 0.24.0 doesn't differentiate between SO_REUSEADDR and + * SO_REUSEPORT, and has both enabled by default. The latter means that + * we can end up with non-unique port bindings as we will not fail to + * bind the same port twice */ + rtp_session_set_reuseaddr(rs->sess, false); + rtp_session_signal_connect(rs->sess, "ssrc_changed", (RtpCallback) ortp_sig_cb_ssrc, RTP_SIGNAL_PTR_CAST(rs)); diff --git a/tests/rtp_test/rtp_test.c b/tests/rtp_test/rtp_test.c index d696033..ae7d8ef 100644 --- a/tests/rtp_test/rtp_test.c +++ b/tests/rtp_test/rtp_test.c @@ -54,7 +54,7 @@ else { printf("FAILED - second bind to port %u worked\n", port[0]); fflush(stdout); - //OSMO_ASSERT(0); + OSMO_ASSERT(0); } osmo_rtp_socket_free(rs[0]); diff --git a/tests/rtp_test/rtp_test.ok b/tests/rtp_test/rtp_test.ok index ded2792..ddb68a4 100644 --- a/tests/rtp_test/rtp_test.ok +++ b/tests/rtp_test/rtp_test.ok @@ -1,2 +1,2 @@ First bind to any random local port... -Now try to bind another socket to the same port: FAILED - second bind to port 16384 worked +Now try to bind another socket to the same port: OK (EADDRINUSE) -- To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/17430 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Change-Id: I4fc9eee561c7958c70c63b4ffdc6cb700b795e28 Gerrit-Change-Number: 17430 Gerrit-PatchSet: 3 Gerrit-Owner: laforge <lafo...@osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <axilira...@gmail.com> Gerrit-Reviewer: laforge <lafo...@osmocom.org> Gerrit-Reviewer: pespin <pes...@sysmocom.de> Gerrit-MessageType: merged