Attention is currently required from: Hoernchen, fixeria.
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/35525?usp=email )
Change subject: Revert "Revert "logging: add log level cache""
......................................................................
Patch Set 2: Code-Review+1
(2 comments)
Commit Message:
https://gerrit.osmocom.org/c/libosmocore/+/35525/comment/272bd1db_836c71ce
PS1, Line 11: some fallout expected
> I hear you, and I agree that it is the old test code that's broken. […]
Done
File include/osmocom/core/logging.h:
https://gerrit.osmocom.org/c/libosmocore/+/35525/comment/4ec5b19a_7155a913
PS2, Line 412: log_cache_enable
fyi, I intentionally didn't add a 'bool enable' argument or the like, as disabling it would mean freein'g the pointer in thread-safe way, which means additional overhead for every code path reading/accessing it.
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35525?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I539872fc9e3c50b407e6bc388f1e091fa2c826c3
Gerrit-Change-Number: 35525
Gerrit-PatchSet: 2
Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: Hoernchen <ewild(a)sysmocom.de>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Comment-Date: Wed, 20 Mar 2024 13:57:23 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Hoernchen <ewild(a)sysmocom.de>
Comment-In-Reply-To: laforge <laforge(a)osmocom.org>
Comment-In-Reply-To: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: comment
Attention is currently required from: Hoernchen, fixeria.
laforge has uploaded a new patch set (#3) to the change originally created by Hoernchen. ( https://gerrit.osmocom.org/c/libosmocore/+/35525?usp=email )
The following approvals got outdated and were removed:
Verified+1 by Jenkins Builder
Change subject: Revert "Revert "logging: add log level cache""
......................................................................
Revert "Revert "logging: add log level cache""
This reverts commit 7f1fb3ea817578f3f2f63e8065aa50f8355caa3b - slightly
amended with the new log_cache_enalbe() function. The cache is hence
disabled by default, and applications can enable it, if they wish to
benefit from it.
Reason for the original revert was: some fallout expected due to log
manipulation in test code
Change-Id: I539872fc9e3c50b407e6bc388f1e091fa2c826c3
---
M include/osmocom/core/logging.h
M src/core/libosmocore.map
M src/core/logging.c
M src/vty/logging_vty.c
4 files changed, 163 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/25/35525/3
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35525?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I539872fc9e3c50b407e6bc388f1e091fa2c826c3
Gerrit-Change-Number: 35525
Gerrit-PatchSet: 3
Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: Hoernchen <ewild(a)sysmocom.de>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: newpatchset
Attention is currently required from: Hoernchen, fixeria.
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/35525?usp=email )
Change subject: Revert "Revert "logging: add log level cache""
......................................................................
Patch Set 2:
(1 comment)
Commit Message:
https://gerrit.osmocom.org/c/libosmocore/+/35525/comment/adf9f90e_7f284559
PS1, Line 11: some fallout expected
> But that promise is impossible to keep because that means 11 year old test code that checks the numb […]
I hear you, and I agree that it is the old test code that's broken. However, as we cannot go back in history, and in this case it's easy to maek the new feature optional by adding the proposed log_cache_enable() function, I think it's the best way to do just that.
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35525?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I539872fc9e3c50b407e6bc388f1e091fa2c826c3
Gerrit-Change-Number: 35525
Gerrit-PatchSet: 2
Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: Hoernchen <ewild(a)sysmocom.de>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Comment-Date: Wed, 20 Mar 2024 13:54:36 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Hoernchen <ewild(a)sysmocom.de>
Comment-In-Reply-To: laforge <laforge(a)osmocom.org>
Comment-In-Reply-To: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: comment
Attention is currently required from: fixeria, laforge.
laforge has uploaded a new patch set (#2) to the change originally created by Hoernchen. ( https://gerrit.osmocom.org/c/libosmocore/+/35525?usp=email )
The following approvals got outdated and were removed:
Verified+1 by Jenkins Builder
Change subject: Revert "Revert "logging: add log level cache""
......................................................................
Revert "Revert "logging: add log level cache""
This reverts commit 7f1fb3ea817578f3f2f63e8065aa50f8355caa3b - slightly
amended with the new log_cache_enalbe() function. The cache is hence
disabled by default, and applications can enable it, if they wish to
benefit from it.
Reason for the original revert was: some fallout expected due to log
manipulation in test code
Change-Id: I539872fc9e3c50b407e6bc388f1e091fa2c826c3
---
M include/osmocom/core/logging.h
M src/core/libosmocore.map
M src/core/logging.c
M src/vty/logging_vty.c
4 files changed, 160 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/25/35525/2
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35525?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I539872fc9e3c50b407e6bc388f1e091fa2c826c3
Gerrit-Change-Number: 35525
Gerrit-PatchSet: 2
Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: newpatchset
laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-mgw/+/36357?usp=email )
(
1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
)Change subject: simplify unused transcoding/processing call-back
......................................................................
simplify unused transcoding/processing call-back
the processing call-back is working with a raw buffer + length,
while we actually work with struct msgb. Let's simply pass the msgb
into the call-back, and the call-back can then do what they want with
the contents of that msgb.
Change-Id: I002624f9008726e3d754d48aa2282c38e3b42953
---
M include/osmocom/mgcp/mgcp.h
M include/osmocom/mgcp/mgcp_network.h
M src/libosmo-mgcp/mgcp_network.c
3 files changed, 20 insertions(+), 13 deletions(-)
Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, approved
fixeria: Looks good to me, but someone else must approve
pespin: Looks good to me, but someone else must approve
diff --git a/include/osmocom/mgcp/mgcp.h b/include/osmocom/mgcp/mgcp.h
index 42d67cf..bfb412b 100644
--- a/include/osmocom/mgcp/mgcp.h
+++ b/include/osmocom/mgcp/mgcp.h
@@ -70,12 +70,10 @@
/**
* Return:
* < 0 in case no audio was processed
- * >= 0 in case audio was processed. The remaining payload
- * length will be returned.
+ * >= 0 in case audio was processed.
*/
typedef int (*mgcp_processing)(struct mgcp_endpoint *endp,
- struct mgcp_rtp_end *dst_end,
- char *data, int *len, int buf_size);
+ struct mgcp_rtp_end *dst_end, struct msgb *msg);
struct mgcp_conn_rtp;
diff --git a/include/osmocom/mgcp/mgcp_network.h b/include/osmocom/mgcp/mgcp_network.h
index a7bd333..1ec8979 100644
--- a/include/osmocom/mgcp/mgcp_network.h
+++ b/include/osmocom/mgcp/mgcp_network.h
@@ -159,8 +159,7 @@
int mgcp_get_local_addr(char *addr, struct mgcp_conn_rtp *conn);
/* payload processing default functions */
-int mgcp_rtp_processing_default(struct mgcp_endpoint *endp, struct mgcp_rtp_end *dst_end,
- char *data, int *len, int buf_size);
+int mgcp_rtp_processing_default(struct mgcp_endpoint *endp, struct mgcp_rtp_end *dst_end, struct msgb *msg);
int mgcp_setup_rtp_processing_default(struct mgcp_endpoint *endp,
struct mgcp_conn_rtp *conn_dst,
diff --git a/src/libosmo-mgcp/mgcp_network.c b/src/libosmo-mgcp/mgcp_network.c
index 19fcd9f..ee25f74 100644
--- a/src/libosmo-mgcp/mgcp_network.c
+++ b/src/libosmo-mgcp/mgcp_network.c
@@ -404,13 +404,11 @@
/*! dummy callback to disable transcoding (see also cfg->rtp_processing_cb).
* \param[in] associated endpoint.
* \param[in] destination RTP end.
- * \param[in,out] pointer to buffer with voice data.
- * \param[in] voice data length.
- * \param[in] maximum size of caller provided voice data buffer.
+ * \param[in,out] msg message bufffer containing data. Function might change length.
* \returns ignores input parameters, return always 0. */
int mgcp_rtp_processing_default(struct mgcp_endpoint *endp,
struct mgcp_rtp_end *dst_end,
- char *data, int *len, int buf_size)
+ struct msgb *msg)
{
return 0;
}
@@ -1167,14 +1165,12 @@
osmo_sockaddr_port(&rtp_end->addr.u.sa), ntohs(rtp_end->rtcp_port)
);
} else if (is_rtp) {
- int buflen = msgb_length(msg);
-
/* Make sure we have a valid RTP header, in cases where no RTP
* header is present, we will generate one. */
gen_rtp_header(msg, rtp_end, rtp_state);
/* Run transcoder */
- rc = endp->trunk->cfg->rtp_processing_cb(endp, rtp_end, (char *)msgb_data(msg), &buflen, RTP_BUF_SIZE);
+ rc = endp->trunk->cfg->rtp_processing_cb(endp, rtp_end, msg);
if (rc < 0) {
LOGPENDP(endp, DRTP, LOGL_ERROR, "Error %d during transcoding\n", rc);
return rc;
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/36357?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I002624f9008726e3d754d48aa2282c38e3b42953
Gerrit-Change-Number: 36357
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged
laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-mgw/+/36361?usp=email )
(
3 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
)Change subject: Change msgb ownership in processing of received msgb
......................................................................
Change msgb ownership in processing of received msgb
The old approach was: rtp_data_net() reads a msgb from the incomging
socket, calls through whatever function chain and in the end free's it.
So none of the intermediate functions was permitted to take msgb
ownership.
This was a good choice as all processing would happen synchronously,
up to the point where that msgb was written on the output RTP socket.
Let's change this from passing msgb ownership throug the whole call
chain, through rx_rtp() to the various *_dispatch_rtp() functions.
This is required for upcoming migration to osmo_io, as in that case the
write (sendto) calls are asynchronous and hence msgb ownership needs
to be transferred.
Change-Id: I6a331f3c6b2eb51ea312ac6ef8c357185ddb79cf
---
M TODO-RELEASE
M src/libosmo-mgcp/mgcp_e1.c
M src/libosmo-mgcp/mgcp_iuup.c
M src/libosmo-mgcp/mgcp_network.c
M src/libosmo-mgcp/mgcp_osmux.c
5 files changed, 136 insertions(+), 40 deletions(-)
Approvals:
jolly: Looks good to me, but someone else must approve
pespin: Looks good to me, but someone else must approve
Jenkins Builder: Verified
laforge: Looks good to me, approved
fixeria: Looks good to me, but someone else must approve
diff --git a/TODO-RELEASE b/TODO-RELEASE
index ea29b6a..59da45b 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -39,3 +39,5 @@
is backwards compat code that moves codecs[] entries, if any, over to
ptmap[], so callers may migrate at own leisure.
osmo-mgw remove cfg Remove VTY config item 'sdp audio fmtp-extra' (see OS#6313)
+libosmocore bump_dep; workaround Bump libosmocore version dependency after I68328adb952ca8833ba047cb3b49ccc6f8a1f1b5
+ has been merged to libosmocore.git; then remove my_msgb_copy_c wrapper function.
diff --git a/src/libosmo-mgcp/mgcp_e1.c b/src/libosmo-mgcp/mgcp_e1.c
index 40f976b..20aff95 100644
--- a/src/libosmo-mgcp/mgcp_e1.c
+++ b/src/libosmo-mgcp/mgcp_e1.c
@@ -301,7 +301,6 @@
mgcp_send(endp, 1, NULL, msg, &conn_dst->u.rtp, &conn_dst->u.rtp);
- msgb_free(msg);
return;
skip:
rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, E1_I460_TRAU_RX_FAIL_CTR));
diff --git a/src/libosmo-mgcp/mgcp_iuup.c b/src/libosmo-mgcp/mgcp_iuup.c
index 6ad62c8..3818d3e 100644
--- a/src/libosmo-mgcp/mgcp_iuup.c
+++ b/src/libosmo-mgcp/mgcp_iuup.c
@@ -311,7 +311,6 @@
};
rc = mgcp_send(conn_rtp_dst->conn->endp, true, NULL, msg, conn_rtp_src, conn_rtp_dst);
- msgb_free(msg);
return rc;
}
@@ -640,7 +639,7 @@
}
/* Build IuUP RNL Data primitive from msg containing an incoming RTP pkt from
- * peer and send it down the IuUP layer towards the destination as IuUP/RTP: */
+ * peer and send it down the IuUP layer towards the destination as IuUP/RTP. Takes ownership of msg. */
int mgcp_conn_iuup_send_rtp(struct mgcp_conn_rtp *conn_src_rtp, struct mgcp_conn_rtp *conn_dest_rtp, struct msgb *msg)
{
struct osmo_iuup_rnl_prim *irp;
diff --git a/src/libosmo-mgcp/mgcp_network.c b/src/libosmo-mgcp/mgcp_network.c
index 275aace..2fd62ae 100644
--- a/src/libosmo-mgcp/mgcp_network.c
+++ b/src/libosmo-mgcp/mgcp_network.c
@@ -70,6 +70,18 @@
rtpconn_rate_ctr_add(conn_rtp, endp, id, 1);
}
+/* wrapper around libosmocore msgb_copy_c, which [at least before libosmocore.git Change-Id
+ * I68328adb952ca8833ba047cb3b49ccc6f8a1f1b5] doesn't copy the cb */
+static inline struct msgb *mgw_msgb_copy_c(void *ctx, struct msgb *msg, const char *name)
+{
+ struct msgb *msg2 = msgb_copy_c(ctx, msg, name);
+ if (OSMO_UNLIKELY(!msg2))
+ return NULL;
+
+ memcpy(msg2->cb, msg->cb, sizeof(msg2->cb));
+ return msg2;
+}
+
static int rx_rtp(struct msgb *msg);
bool mgcp_rtp_end_remote_addr_available(const struct mgcp_rtp_end *rtp_end)
@@ -963,7 +975,7 @@
return 0;
}
-/*! Dispatch msg bridged from the sister conn in the endpoint.
+/*! Dispatch msg bridged from the sister conn in the endpoint. Takes ownership of msgb.
* \param[in] conn_dst The destination conn that should handle and transmit the content to
* its peer outside MGW.
* \param[in] msg msgb containing an RTP pkt received by the sister conn in the endpoint,
@@ -985,8 +997,10 @@
/* Before we try to deliver the packet, we check if the destination
* port and IP-Address make sense at all. If not, we will be unable
* to deliver the packet. */
- if (check_rtp_destin(conn_dst) != 0)
+ if (check_rtp_destin(conn_dst) != 0) {
+ msgb_free(msg);
return -1;
+ }
/* Depending on the RTP connection type, deliver the RTP packet to the
* destination connection. */
@@ -1021,7 +1035,7 @@
* be discarded, this should not happen, normally the MGCP type
* should be properly set */
LOGPENDP(endp, DRTP, LOGL_ERROR, "bad MGCP type -- data discarded!\n");
-
+ msgb_free(msg);
return -1;
}
@@ -1101,7 +1115,7 @@
return -1;
}
-/*! Send RTP/RTCP data to a specified destination connection.
+/*! Send RTP/RTCP data to a specified destination connection. Takes ownership of msg.
* \param[in] endp associated endpoint (for configuration, logging).
* \param[in] is_rtp flag to specify if the packet is of type RTP or RTCP.
* \param[in] addr spoofed source address (set to NULL to disable).
@@ -1140,6 +1154,7 @@
if (is_rtp && !mgcp_conn_rtp_is_iuup(conn_src)) {
if (mgcp_patch_pt(conn_dst, msg) < 0) {
LOGPENDP(endp, DRTP, LOGL_NOTICE, "unable to patch payload type RTP packet, discarding...\n");
+ msgb_free(msg);
return -EINVAL;
}
}
@@ -1173,6 +1188,7 @@
rc = endp->trunk->cfg->rtp_processing_cb(endp, rtp_end, msg);
if (rc < 0) {
LOGPENDP(endp, DRTP, LOGL_ERROR, "Error %d during transcoding\n", rc);
+ msgb_free(msg);
return rc;
}
@@ -1187,6 +1203,7 @@
LOGPENDP(endp, DRTP, LOGL_ERROR,
"Error in AMR octet-aligned <-> bandwidth-efficient mode conversion (target=%s)\n",
conn_dst->end.codec->param.amr_octet_aligned ? "octet-aligned" : "bandwidth-efficient");
+ msgb_free(msg);
return rc;
}
} else if (rtp_end->rfc5993_hr_convert &&
@@ -1194,6 +1211,7 @@
rc = rfc5993_hr_convert(endp, msg);
if (rc < 0) {
LOGPENDP(endp, DRTP, LOGL_ERROR, "Error while converting to GSM-HR-08\n");
+ msgb_free(msg);
return rc;
}
}
@@ -1212,14 +1230,16 @@
len = mgcp_udp_send(rtp_end->rtp.fd, &rtp_end->addr,
(char *)msgb_data(msg), msgb_length(msg));
-
- if (len <= 0)
+ if (len <= 0) {
+ msgb_free(msg);
return len;
+ }
rtpconn_rate_ctr_inc(conn_dst, endp, RTP_PACKETS_TX_CTR);
rtpconn_rate_ctr_add(conn_dst, endp, RTP_OCTETS_TX_CTR, len);
rtp_state->alt_rtp_tx_sequence++;
+ msgb_free(msg);
return len;
} else if (!trunk->omit_rtcp) {
struct osmo_sockaddr rtcp_addr = rtp_end->addr;
@@ -1238,12 +1258,43 @@
rtpconn_rate_ctr_add(conn_dst, endp, RTP_OCTETS_TX_CTR, len);
rtp_state->alt_rtp_tx_sequence++;
+ msgb_free(msg);
return len;
}
+ msgb_free(msg);
return 0;
}
+/*! determine if there's only a single recipient in endp for data received via conn_src.
+ * The function returns NULL in case there is no recipient, or in case there are multiple recipients.
+ * \param endp The MGCP endpoint whose connections to analyze
+ * \param conn_src The source MGCP connection [which shall not count in results]
+ * \returns recipient donnection if there is only one; NULL in case there are multiple */
+static struct mgcp_conn *rtpbridge_get_only_recipient(struct mgcp_endpoint *endp, struct mgcp_conn *conn_src)
+{
+ struct mgcp_conn *conn_ret = NULL;
+ struct mgcp_conn *conn_dst;
+
+ llist_for_each_entry(conn_dst, &endp->conns, entry) {
+ if (conn_dst == conn_src)
+ continue;
+ switch (conn_dst->mode) {
+ case MGCP_CONN_SEND_ONLY:
+ case MGCP_CONN_RECV_SEND:
+ case MGCP_CONN_CONFECHO:
+ if (conn_ret)
+ return NULL;
+ conn_ret = conn_dst;
+ break;
+ default:
+ break;
+ }
+ }
+
+ return conn_ret;
+}
+
/*! Dispatch incoming RTP packet to opposite RTP connection.
* \param[in] msg Message buffer to bridge, coming from source connection.
* msg shall contain "struct osmo_rtp_msg_ctx *" attached in
@@ -1301,23 +1352,44 @@
return rc;
}
- /* If the mode is "confecho", send RTP back to the sender. */
- if (conn->mode == MGCP_CONN_CONFECHO)
- rc = mgcp_conn_rtp_dispatch_rtp(conn_src, msg);
+ /* All the use cases above are 1:1 where we have one source msgb and we're sending that to one
+ * destination. msgb ownership had been passed to the respective _*dospatch_rtp() function.
+ * In the cases below, we actually [can] have multiple recipients, so we copy the original msgb
+ * for each of the recipients. */
- /* Dispatch RTP packet to all other connection(s) that send audio. */
- llist_for_each_entry(conn_dst, &endp->conns, entry) {
- if (conn_dst == conn)
- continue;
- switch (conn_dst->mode) {
- case MGCP_CONN_SEND_ONLY:
- case MGCP_CONN_RECV_SEND:
- case MGCP_CONN_CONFECHO:
- rc = mgcp_conn_rtp_dispatch_rtp(&conn_dst->u.rtp, msg);
- break;
- default:
- break;
+ /* If the mode is "confecho", send RTP back to the sender. */
+ if (conn->mode == MGCP_CONN_CONFECHO) {
+ struct msgb *msg2 = mgw_msgb_copy_c(conn, msg, "RTP confecho");
+ if (OSMO_LIKELY(msg2))
+ rc = mgcp_conn_rtp_dispatch_rtp(conn_src, msg2);
+ }
+
+ conn_dst = rtpbridge_get_only_recipient(endp, conn);
+ if (OSMO_LIKELY(conn_dst)) {
+ /* we only have a single recipient and cann hence send the original msgb without copying */
+ rc = mgcp_conn_rtp_dispatch_rtp(&conn_dst->u.rtp, msg);
+ } else {
+ /* Dispatch RTP packet to all other connection(s) that send audio. */
+ llist_for_each_entry(conn_dst, &endp->conns, entry) {
+ struct msgb *msg2;
+ if (conn_dst == conn)
+ continue;
+ switch (conn_dst->mode) {
+ case MGCP_CONN_SEND_ONLY:
+ case MGCP_CONN_RECV_SEND:
+ case MGCP_CONN_CONFECHO:
+ /* we have multiple recipients and must make copies for each recipient */
+ msg2 = mgw_msgb_copy_c(conn_dst, msg, "RTP Tx copy");
+ if (OSMO_LIKELY(msg2))
+ rc = mgcp_conn_rtp_dispatch_rtp(&conn_dst->u.rtp, msg2);
+ break;
+ default:
+ break;
+ }
}
+ /* as we only sent copies in the previous llist_for_each_entry() loop, we must free the
+ * original one */
+ msgb_free(msg);
}
return rc;
}
@@ -1471,11 +1543,11 @@
rc = rx_rtp(msg);
out:
- msgb_free(msg);
return rc;
}
-/* Note: This function is able to handle RTP and RTCP */
+/* Note: This function is able to handle RTP and RTCP. msgb ownership is transferred, so this function or its
+ * downstream consumers must make sure to [eventually] free the msgb. */
static int rx_rtp(struct msgb *msg)
{
struct osmo_rtp_msg_ctx *mc = OSMO_RTP_MSG_CTX(msg);
@@ -1488,7 +1560,7 @@
/* Check if the origin of the RTP packet seems plausible */
if (!trunk->rtp_accept_all && check_rtp_origin(conn_src, from_addr))
- return -1;
+ goto out_free;
/* Handle AMR frame format conversion (octet-aligned vs. bandwith-efficient) */
if (mc->proto == MGCP_PROTO_RTP
@@ -1498,13 +1570,13 @@
* communicated via SDP when the connection was created/modfied. */
int oa = amr_oa_check((char*)msgb_data(msg), msgb_length(msg));
if (oa < 0)
- return -1;
+ goto out_free;
if (((bool)oa) != conn_src->end.codec->param.amr_octet_aligned) {
LOG_CONN_RTP(conn_src, LOGL_NOTICE,
"rx_rtp(%u bytes): Expected RTP AMR octet-aligned=%u but got octet-aligned=%u."
" check the config of your call-agent!\n",
msgb_length(msg), conn_src->end.codec->param.amr_octet_aligned, oa);
- return -1;
+ goto out_free;
}
}
@@ -1513,6 +1585,9 @@
/* Execute endpoint specific implementation that handles the
* dispatching of the RTP data */
return conn->endp->type->dispatch_rtp_cb(msg);
+out_free:
+ msgb_free(msg);
+ return -1;
}
/*! bind RTP port to osmo_fd.
diff --git a/src/libosmo-mgcp/mgcp_osmux.c b/src/libosmo-mgcp/mgcp_osmux.c
index 997b07b..3df9972 100644
--- a/src/libosmo-mgcp/mgcp_osmux.c
+++ b/src/libosmo-mgcp/mgcp_osmux.c
@@ -204,17 +204,17 @@
return h->in;
}
-/*! send RTP packet through OSMUX connection.
+/*! send RTP packet through OSMUX connection. Takes ownership of msg.
* \param[in] conn associated RTP connection
* \param[in] msg msgb containing an RTP AMR packet
* \returns 0 on success, -1 on ERROR */
int conn_osmux_send_rtp(struct mgcp_conn_rtp *conn, struct msgb *msg)
{
int ret;
- struct msgb *msg2;
if (!conn->end.output_enabled) {
rtpconn_osmux_rate_ctr_inc(conn, OSMUX_RTP_PACKETS_TX_DROPPED_CTR);
+ msgb_free(msg);
return -1;
}
@@ -222,22 +222,19 @@
LOGPCONN(conn->conn, DOSMUX, LOGL_INFO, "forwarding RTP to Osmux conn not yet enabled, dropping (cid=%d)\n",
conn->osmux.remote_cid);
rtpconn_osmux_rate_ctr_inc(conn, OSMUX_RTP_PACKETS_TX_DROPPED_CTR);
+ msgb_free(msg);
return -1;
}
- /* msg is not owned by us and will be freed by the caller stack upon return: */
- msg2 = msgb_copy_c(conn->conn, msg, "osmux-rtp-send");
- if (!msg2)
- return -1;
-
/* Osmux implementation works with AMR OA only, make sure we convert to it if needed: */
- if (amr_oa_bwe_convert(conn->conn->endp, msg2, true) < 0) {
+ if (amr_oa_bwe_convert(conn->conn->endp, msg, true) < 0) {
LOGPCONN(conn->conn, DOSMUX, LOGL_ERROR,
"Error converting to AMR octet-aligned mode\n");
+ msgb_free(msg);
return -1;
}
- while ((ret = osmux_xfrm_input(conn->osmux.in, msg2, conn->osmux.remote_cid)) > 0) {
+ while ((ret = osmux_xfrm_input(conn->osmux.in, msg, conn->osmux.remote_cid)) > 0) {
/* batch full, build and deliver it */
osmux_xfrm_input_deliver(conn->osmux.in);
}
@@ -245,7 +242,7 @@
rtpconn_osmux_rate_ctr_inc(conn, OSMUX_RTP_PACKETS_TX_DROPPED_CTR);
} else {
rtpconn_osmux_rate_ctr_inc(conn, OSMUX_RTP_PACKETS_TX_CTR);
- rtpconn_osmux_rate_ctr_add(conn, OSMUX_AMR_OCTETS_TX_CTR, msgb_length(msg2) - sizeof(struct rtp_hdr));
+ rtpconn_osmux_rate_ctr_add(conn, OSMUX_AMR_OCTETS_TX_CTR, msgb_length(msg) - sizeof(struct rtp_hdr));
}
return 0;
}
@@ -325,7 +322,7 @@
};
endp->type->dispatch_rtp_cb(msg);
- msgb_free(msg);
+ /* dispatch_rtp_cb() has taken ownership of the msgb */
}
static struct msgb *osmux_recv(struct osmo_fd *ofd, struct osmo_sockaddr *addr)
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/36361?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I6a331f3c6b2eb51ea312ac6ef8c357185ddb79cf
Gerrit-Change-Number: 36361
Gerrit-PatchSet: 4
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged
Attention is currently required from: dexter.
Hello Jenkins Builder, dexter, fixeria, pespin,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/osmo-mgw/+/36357?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Verified+1 by Jenkins Builder
The change is no longer submittable: Verified is unsatisfied now.
Change subject: simplify unused transcoding/processing call-back
......................................................................
simplify unused transcoding/processing call-back
the processing call-back is working with a raw buffer + length,
while we actually work with struct msgb. Let's simply pass the msgb
into the call-back, and the call-back can then do what they want with
the contents of that msgb.
Change-Id: I002624f9008726e3d754d48aa2282c38e3b42953
---
M include/osmocom/mgcp/mgcp.h
M include/osmocom/mgcp/mgcp_network.h
M src/libosmo-mgcp/mgcp_network.c
3 files changed, 20 insertions(+), 13 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/57/36357/2
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/36357?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I002624f9008726e3d754d48aa2282c38e3b42953
Gerrit-Change-Number: 36357
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-MessageType: newpatchset