This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Hoernchen gerrit-no-reply at lists.osmocom.orgHoernchen has submitted this change. ( https://gerrit.osmocom.org/c/osmo-mgw/+/25428 ) Change subject: endp: do not cache cfg pointer ...................................................................... endp: do not cache cfg pointer There is no obvious reason why we would want to complicate the code by caching pointers, since pointer traversal is probably not a performance bottleneck, and if it is we should rather take a look at our dozens of linked lists first.. Change-Id: I2456ba63598f76200d53e00223abf60bb36a49c0 --- M include/osmocom/mgcp/mgcp_endp.h M src/libosmo-mgcp/mgcp_conn.c M src/libosmo-mgcp/mgcp_endp.c M src/libosmo-mgcp/mgcp_network.c M src/libosmo-mgcp/mgcp_osmux.c M src/libosmo-mgcp/mgcp_protocol.c M src/libosmo-mgcp/mgcp_sdp.c M src/libosmo-mgcp/mgcp_stat.c M src/libosmo-mgcp/mgcp_vty.c M tests/mgcp/mgcp_test.c 10 files changed, 26 insertions(+), 33 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved pespin: Looks good to me, approved diff --git a/include/osmocom/mgcp/mgcp_endp.h b/include/osmocom/mgcp/mgcp_endp.h index f687bae..b8796c1 100644 --- a/include/osmocom/mgcp/mgcp_endp.h +++ b/include/osmocom/mgcp/mgcp_endp.h @@ -97,9 +97,6 @@ /*! List of struct mgcp_conn, of the connections active on this endpoint */ struct llist_head conns; - /*! Backpointer to the MGW configuration */ - struct mgcp_config *cfg; - /*! Backpointer to the trunk this endpoint belongs to */ struct mgcp_trunk *trunk; diff --git a/src/libosmo-mgcp/mgcp_conn.c b/src/libosmo-mgcp/mgcp_conn.c index ca12347..4acf18c 100644 --- a/src/libosmo-mgcp/mgcp_conn.c +++ b/src/libosmo-mgcp/mgcp_conn.c @@ -143,7 +143,7 @@ void mgcp_conn_watchdog_kick(struct mgcp_conn *conn) { - int timeout = conn->endp->cfg->conn_timeout; + int timeout = conn->endp->trunk->cfg->conn_timeout; if (!timeout) return; diff --git a/src/libosmo-mgcp/mgcp_endp.c b/src/libosmo-mgcp/mgcp_endp.c index 4fcddb8..19446ce 100644 --- a/src/libosmo-mgcp/mgcp_endp.c +++ b/src/libosmo-mgcp/mgcp_endp.c @@ -89,7 +89,6 @@ return NULL; INIT_LLIST_HEAD(&endp->conns); - endp->cfg = trunk->cfg; endp->trunk = trunk; switch (trunk->trunk_type) { diff --git a/src/libosmo-mgcp/mgcp_network.c b/src/libosmo-mgcp/mgcp_network.c index 5249fef..2d275ec 100644 --- a/src/libosmo-mgcp/mgcp_network.c +++ b/src/libosmo-mgcp/mgcp_network.c @@ -112,7 +112,7 @@ char *bind_addr; /* Try probing the local IP-Address */ - if (endp->cfg->net_ports.bind_addr_probe && rem_addr_set) { + if (endp->trunk->cfg->net_ports.bind_addr_probe && rem_addr_set) { rc = osmo_sock_local_ip(addr, osmo_sockaddr_ntop(&conn->end.addr.u.sa, ipbuf)); if (rc < 0) LOGPCONN(conn->conn, DRTP, LOGL_ERROR, @@ -130,13 +130,13 @@ /* Check there is a bind IP for the RTP traffic configured, * if so, use that IP-Address */ bind_addr = conn->end.addr.u.sa.sa_family == AF_INET6 ? - endp->cfg->net_ports.bind_addr_v6 : - endp->cfg->net_ports.bind_addr_v4; + endp->trunk->cfg->net_ports.bind_addr_v6 : + endp->trunk->cfg->net_ports.bind_addr_v4; } else { /* Choose any of the bind addresses, preferring v6 over v4 */ - bind_addr = endp->cfg->net_ports.bind_addr_v6; + bind_addr = endp->trunk->cfg->net_ports.bind_addr_v6; if (!strlen(bind_addr)) - bind_addr = endp->cfg->net_ports.bind_addr_v4; + bind_addr = endp->trunk->cfg->net_ports.bind_addr_v4; } if (strlen(bind_addr)) { LOGPCONN(conn->conn, DRTP, LOGL_DEBUG, @@ -146,7 +146,7 @@ /* No specific bind IP is configured for the RTP traffic, so * assume the IP where we listen for incoming MGCP messages * as bind IP */ - bind_addr = endp->cfg->source_addr; + bind_addr = endp->trunk->cfg->source_addr; LOGPCONN(conn->conn, DRTP, LOGL_DEBUG, "using mgcp bind ip as local rtp bind ip: %s\n", bind_addr); } @@ -1177,9 +1177,7 @@ do { /* Run transcoder */ - cont = endp->cfg->rtp_processing_cb(endp, rtp_end, - (char *)msgb_data(msg), &buflen, - RTP_BUF_SIZE); + cont = endp->trunk->cfg->rtp_processing_cb(endp, rtp_end, (char *)msgb_data(msg), &buflen, RTP_BUF_SIZE); if (cont < 0) break; @@ -1657,7 +1655,7 @@ osmo_fd_setup(&end->rtp, -1, OSMO_FD_READ, rtp_data_net, conn, 0); osmo_fd_setup(&end->rtcp, -1, OSMO_FD_READ, rtp_data_net, conn, 0); - return bind_rtp(endp->cfg, conn->end.local_addr, end, endp); + return bind_rtp(endp->trunk->cfg, conn->end.local_addr, end, endp); } /*! free allocated RTP and RTCP ports. diff --git a/src/libosmo-mgcp/mgcp_osmux.c b/src/libosmo-mgcp/mgcp_osmux.c index 8f0a906..de19042 100644 --- a/src/libosmo-mgcp/mgcp_osmux.c +++ b/src/libosmo-mgcp/mgcp_osmux.c @@ -116,7 +116,7 @@ osmux_handle_alloc(struct mgcp_conn_rtp *conn, struct in_addr *addr, int rem_port) { struct osmux_handle *h; - struct mgcp_config *cfg = conn->conn->endp->cfg; + struct mgcp_config *cfg = conn->conn->endp->trunk->cfg; h = talloc_zero(osmux, struct osmux_handle); if (!h) @@ -460,7 +460,7 @@ */ struct in6_addr addr_unset = {}; static const uint32_t rtp_ssrc_winlen = UINT32_MAX / (OSMUX_CID_MAX + 1); - uint16_t osmux_dummy = endp->cfg->osmux_dummy; + uint16_t osmux_dummy = endp->trunk->cfg->osmux_dummy; /* Check if osmux is enabled for the specified connection */ if (conn->osmux.state != OSMUX_STATE_ACTIVATING) { diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c index 736b071..6341f07 100644 --- a/src/libosmo-mgcp/mgcp_protocol.c +++ b/src/libosmo-mgcp/mgcp_protocol.c @@ -144,7 +144,7 @@ static int setup_rtp_processing(struct mgcp_endpoint *endp, struct mgcp_conn_rtp *conn) { - struct mgcp_config *cfg = endp->cfg; + struct mgcp_config *cfg = endp->trunk->cfg; struct mgcp_conn_rtp *conn_src = NULL; struct mgcp_conn_rtp *conn_dst = conn; struct mgcp_conn *_conn; @@ -273,7 +273,7 @@ * us for OSMUX connections. Perhaps adding a new internal API to get it * based on conn type. */ - const char *addr = strlen(endp->cfg->local_ip) ? endp->cfg->local_ip : conn->end.local_addr; + const char *addr = strlen(endp->trunk->cfg->local_ip) ? endp->trunk->cfg->local_ip : conn->end.local_addr; struct msgb *sdp; int rc; struct msgb *result; @@ -477,7 +477,7 @@ OSMO_ASSERT(conn); - range = &endp->cfg->net_ports; + range = &endp->trunk->cfg->net_ports; pthread_mutex_lock(&range->lock); /* attempt to find a port */ @@ -741,8 +741,8 @@ */ static int mgcp_osmux_setup(struct mgcp_endpoint *endp, const char *line) { - if (!endp->cfg->osmux_init) { - if (osmux_init(OSMUX_ROLE_BSC, endp->cfg) < 0) { + if (!endp->trunk->cfg->osmux_init) { + if (osmux_init(OSMUX_ROLE_BSC, endp->trunk->cfg) < 0) { LOGPENDP(endp, DLMGCP, LOGL_ERROR, "Cannot init OSMUX\n"); return -3; } @@ -887,7 +887,7 @@ case 'X': if (strncasecmp("Osmux: ", line + 2, strlen("Osmux: ")) == 0) { /* If osmux is disabled, just skip setting it up */ - if (!rq->endp->cfg->osmux) + if (!rq->endp->trunk->cfg->osmux) break; osmux_cid = mgcp_osmux_setup(endp, line); break; @@ -1001,7 +1001,7 @@ rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_CRCX_FAIL_NO_OSMUX)); goto error2; } - } else if (endp->cfg->osmux == OSMUX_USAGE_ONLY) { + } else if (endp->trunk->cfg->osmux == OSMUX_USAGE_ONLY) { LOGPCONN(_conn, DLMGCP, LOGL_ERROR, "CRCX: osmux only and no osmux offered\n"); rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_CRCX_FAIL_NO_OSMUX)); @@ -1165,7 +1165,7 @@ case 'X': if (strncasecmp("Osmux: ", line + 2, strlen("Osmux: ")) == 0) { /* If osmux is disabled, just skip setting it up */ - if (!endp->cfg->osmux) + if (!endp->trunk->cfg->osmux) break; osmux_cid = mgcp_osmux_setup(endp, line); break; @@ -1680,7 +1680,7 @@ if (len < 0) return -1; - rc = send_agent(endp->cfg, buf, len); + rc = send_agent(endp->trunk->cfg, buf, len); if (rc <= 0) return -1; diff --git a/src/libosmo-mgcp/mgcp_sdp.c b/src/libosmo-mgcp/mgcp_sdp.c index 077ac96..a36c6d2 100644 --- a/src/libosmo-mgcp/mgcp_sdp.c +++ b/src/libosmo-mgcp/mgcp_sdp.c @@ -576,7 +576,7 @@ OSMO_ASSERT(addr); /* FIXME: constify endp and conn args in get_net_donwlink_format_cb() */ - endp->cfg->get_net_downlink_format_cb((struct mgcp_endpoint *)endp, + endp->trunk->cfg->get_net_downlink_format_cb((struct mgcp_endpoint *)endp, &codec, &fmtp_extra, (struct mgcp_conn_rtp *)conn); @@ -601,7 +601,7 @@ payload_types[0] = payload_type; if (mgcp_conn_rtp_is_osmux(conn)) - local_port = endp->cfg->osmux_port; + local_port = endp->trunk->cfg->osmux_port; else local_port = conn->end.local_port; rc = add_audio(sdp, payload_types, 1, local_port); diff --git a/src/libosmo-mgcp/mgcp_stat.c b/src/libosmo-mgcp/mgcp_stat.c index 357b593..59ef917 100644 --- a/src/libosmo-mgcp/mgcp_stat.c +++ b/src/libosmo-mgcp/mgcp_stat.c @@ -28,6 +28,7 @@ #include <osmocom/mgcp/mgcp_conn.h> #include <osmocom/mgcp/mgcp_stat.h> #include <osmocom/mgcp/mgcp_endp.h> +#include <osmocom/mgcp/mgcp_trunk.h> /* Helper function for mgcp_format_stats_rtp() to calculate packet loss */ #if defined(__has_attribute) @@ -98,7 +99,7 @@ str += nchars; str_len -= nchars; - if (conn->conn->endp->cfg->osmux != OSMUX_USAGE_OFF) { + if (conn->conn->endp->trunk->cfg->osmux != OSMUX_USAGE_OFF) { /* Error Counter */ nchars = snprintf(str, str_len, "\r\nX-Osmo-CP: EC TI=%" PRIu64 ", TO=%" PRIu64, diff --git a/src/libosmo-mgcp/mgcp_vty.c b/src/libosmo-mgcp/mgcp_vty.c index 738bfcc..a05733f 100644 --- a/src/libosmo-mgcp/mgcp_vty.c +++ b/src/libosmo-mgcp/mgcp_vty.c @@ -218,7 +218,7 @@ vty_out(vty, " CONN: %s%s", mgcp_conn_dump(conn), VTY_NEWLINE); if (show_stats) { - if (endp->cfg->conn_timeout) { + if (endp->trunk->cfg->conn_timeout) { struct timeval remaining; osmo_timer_remaining(&conn->watchdog, NULL, &remaining); vty_out(vty, " Currently remaining timeout (seconds): %d.%06d%s", diff --git a/tests/mgcp/mgcp_test.c b/tests/mgcp/mgcp_test.c index 1c0d3cc..a8aad14 100644 --- a/tests/mgcp/mgcp_test.c +++ b/tests/mgcp/mgcp_test.c @@ -960,7 +960,7 @@ static int rqnt_cb(struct mgcp_endpoint *endp, char _tone) { ptrdiff_t tone = _tone; - endp->cfg->data = (void *)tone; + endp->trunk->cfg->data = (void *)tone; return 0; } @@ -1050,7 +1050,6 @@ memset(&endp, 0, sizeof(endp)); cfg = mgcp_config_alloc(); trunk = mgcp_trunk_alloc(cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID); - endp.cfg = cfg; endp.type = &ep_typeset.rtp; trunk->v.vty_number_endpoints = 1; trunk->endpoints = endpoints; @@ -1307,7 +1306,6 @@ state.in_stream.err_ts_ctr = &test_ctr_in; state.out_stream.err_ts_ctr = &test_ctr_out; - endp.cfg = cfg; endp.type = &ep_typeset.rtp; trunk->v.vty_number_endpoints = 1; -- To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/25428 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-mgw Gerrit-Branch: master Gerrit-Change-Id: I2456ba63598f76200d53e00223abf60bb36a49c0 Gerrit-Change-Number: 25428 Gerrit-PatchSet: 15 Gerrit-Owner: Hoernchen <ewild at sysmocom.de> Gerrit-Reviewer: Hoernchen <ewild at sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier at sysmocom.de> Gerrit-Reviewer: laforge <laforge at osmocom.org> Gerrit-Reviewer: pespin <pespin at sysmocom.de> Gerrit-MessageType: merged -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210914/63f32ce4/attachment.htm>