Change in osmo-mgw[master]: Fix OSMO_ASSERT() in case rtp.end.addr is still uninitialized

laforge gerrit-no-reply at lists.osmocom.org
Tue Apr 20 16:03:10 UTC 2021


laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/23812 )


Change subject: Fix OSMO_ASSERT() in case rtp.end.addr is still uninitialized
......................................................................

Fix OSMO_ASSERT() in case rtp.end.addr is still uninitialized

In case the local RTP socket IP/port has not yet been configured,
conn->u.rtp.end.addr.u.sa.sa_family is still uninitialized.

When receiving an inbound RTP packet that we want to loop back,
we hence run into the OSMO_ASSERT() that the socket sa_family (0)
is not AF_INET nor AF_INET6.

We have received a packet from a given source address on this socket,
and we hence should be able to send a response back.

This patch was written without a lot of understanding of the larger
osmo-mgw codebase.  Maybe the problem is that
conn->u.rtp.end.addr.u.sa.sa_family should be set correctly during
the CRCX time already.  Then of course that would be amore proper fix
than this one.

Change-Id: I2ecf81447e6a92fb566baba53fcf819f4029d54d
Closes: OS#5123
---
M src/libosmo-mgcp/mgcp_network.c
1 file changed, 4 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/12/23812/1

diff --git a/src/libosmo-mgcp/mgcp_network.c b/src/libosmo-mgcp/mgcp_network.c
index 6b31f2b..bd6a94e 100644
--- a/src/libosmo-mgcp/mgcp_network.c
+++ b/src/libosmo-mgcp/mgcp_network.c
@@ -1269,7 +1269,8 @@
 		 * address data from the UDP packet header to patch the
 		 * outgoing address in connection on the fly */
 		if (conn->u.rtp.end.rtp_port == 0) {
-			OSMO_ASSERT(conn->u.rtp.end.addr.u.sa.sa_family == from_addr->u.sa.sa_family);
+			OSMO_ASSERT(conn->u.rtp.end.addr.u.sa.sa_family == 0 ||
+				    conn->u.rtp.end.addr.u.sa.sa_family == from_addr->u.sa.sa_family);
 			switch (from_addr->u.sa.sa_family) {
 			case AF_INET:
 				conn->u.rtp.end.addr.u.sin.sin_addr = from_addr->u.sin.sin_addr;
@@ -1340,7 +1341,8 @@
 		 * address data from the UDP packet header to patch the
 		 * outgoing address in connection on the fly */
 		if (conn->u.rtp.end.rtp_port == 0) {
-			OSMO_ASSERT(conn->u.rtp.end.addr.u.sa.sa_family == from_addr->u.sa.sa_family);
+			OSMO_ASSERT(conn->u.rtp.end.addr.u.sa.sa_family == 0 ||
+				    conn->u.rtp.end.addr.u.sa.sa_family == from_addr->u.sa.sa_family);
 			switch (from_addr->u.sa.sa_family) {
 			case AF_INET:
 				conn->u.rtp.end.addr.u.sin.sin_addr = from_addr->u.sin.sin_addr;

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/23812
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I2ecf81447e6a92fb566baba53fcf819f4029d54d
Gerrit-Change-Number: 23812
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210420/98952562/attachment.htm>


More information about the gerrit-log mailing list