Hello Jenkins Builder, I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/4779 to look at the new patch set (#6). vty: do not change number_endpoints at runtime The variable number_endpoints is used as a length indicator for the array that contains the trunk endpoints at all times. When osmo-mgw is startet up, the variable is set and osmo-mgw will allocate the memory for the endpoints. However, it is still possible to manipulate the variable via the telnet interface. When the value is increased osmo-mgw might start using unallocated memory at some point. Store subsequent changes of number_enspoints in a separate variable in order to write them to the config file. The changes will then take effect after a restart. Closes: OS#2632 Change-Id: I3994af016fb96427263edbba05f560743f85fdd4 --- M include/osmocom/mgcp/mgcp.h M src/libosmo-mgcp/mgcp_protocol.c M src/libosmo-mgcp/mgcp_vty.c M tests/mgcp/mgcp_test.c 4 files changed, 14 insertions(+), 13 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/79/4779/6 diff --git a/include/osmocom/mgcp/mgcp.h b/include/osmocom/mgcp/mgcp.h index 42a91d8..c7634fb 100644 --- a/include/osmocom/mgcp/mgcp.h +++ b/include/osmocom/mgcp/mgcp.h @@ -151,6 +151,7 @@ int rtp_accept_all; unsigned int number_endpoints; + int vty_number_endpoints; struct mgcp_endpoint *endpoints; }; diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c index 9e04e50..f542745 100644 --- a/src/libosmo-mgcp/mgcp_protocol.c +++ b/src/libosmo-mgcp/mgcp_protocol.c @@ -1170,7 +1170,7 @@ trunk->audio_payload = 126; trunk->audio_send_ptime = 1; trunk->audio_send_name = 1; - trunk->number_endpoints = 33; + trunk->vty_number_endpoints = 33; trunk->omit_rtcp = 0; mgcp_trunk_set_keepalive(trunk, MGCP_KEEPALIVE_ONCE); llist_add_tail(&trunk->entry, &cfg->trunks); @@ -1202,12 +1202,12 @@ tcfg->endpoints = _talloc_zero_array(tcfg->cfg, sizeof(struct mgcp_endpoint), - tcfg->number_endpoints, + tcfg->vty_number_endpoints, "endpoints"); if (!tcfg->endpoints) return -1; - for (i = 0; i < tcfg->number_endpoints; ++i) { + for (i = 0; i < tcfg->vty_number_endpoints; ++i) { INIT_LLIST_HEAD(&tcfg->endpoints[i].conns); tcfg->endpoints[i].cfg = tcfg->cfg; tcfg->endpoints[i].tcfg = tcfg; @@ -1217,6 +1217,7 @@ tcfg->endpoints[i].type = &ep_typeset.rtp; } + tcfg->number_endpoints = tcfg->vty_number_endpoints; return 0; } diff --git a/src/libosmo-mgcp/mgcp_vty.c b/src/libosmo-mgcp/mgcp_vty.c index 9420d96..80396e0 100644 --- a/src/libosmo-mgcp/mgcp_vty.c +++ b/src/libosmo-mgcp/mgcp_vty.c @@ -115,7 +115,7 @@ g_cfg->trunk.audio_send_name ? "" : "no ", VTY_NEWLINE); vty_out(vty, " loop %u%s", ! !g_cfg->trunk.audio_loop, VTY_NEWLINE); vty_out(vty, " number endpoints %u%s", - g_cfg->trunk.number_endpoints - 1, VTY_NEWLINE); + g_cfg->trunk.vty_number_endpoints - 1, VTY_NEWLINE); vty_out(vty, " %sallow-transcoding%s", g_cfg->trunk.no_audio_transcoding ? "no " : "", VTY_NEWLINE); if (g_cfg->call_agent_addr) @@ -524,7 +524,7 @@ "Number options\n" "Endpoints available\n" "Number endpoints\n") { /* + 1 as we start counting at one */ - g_cfg->trunk.number_endpoints = atoi(argv[0]) + 1; + g_cfg->trunk.vty_number_endpoints = atoi(argv[0]) + 1; return CMD_SUCCESS; } diff --git a/tests/mgcp/mgcp_test.c b/tests/mgcp/mgcp_test.c index 99491e6..f35dc93 100644 --- a/tests/mgcp/mgcp_test.c +++ b/tests/mgcp/mgcp_test.c @@ -563,9 +563,8 @@ cfg = mgcp_config_alloc(); - cfg->trunk.number_endpoints = 64; + cfg->trunk.vty_number_endpoints = 64; mgcp_endpoints_allocate(&cfg->trunk); - cfg->policy_cb = mgcp_test_policy_cb; mgcp_endpoints_allocate(mgcp_trunk_alloc(cfg, 1)); @@ -685,7 +684,7 @@ cfg = mgcp_config_alloc(); - cfg->trunk.number_endpoints = 64; + cfg->trunk.vty_number_endpoints = 64; mgcp_endpoints_allocate(&cfg->trunk); mgcp_endpoints_allocate(mgcp_trunk_alloc(cfg, 1)); @@ -737,7 +736,7 @@ cfg = mgcp_config_alloc(); cfg->rqnt_cb = rqnt_cb; - cfg->trunk.number_endpoints = 64; + cfg->trunk.vty_number_endpoints = 64; mgcp_endpoints_allocate(&cfg->trunk); mgcp_endpoints_allocate(mgcp_trunk_alloc(cfg, 1)); @@ -1025,7 +1024,7 @@ endp.type = &ep_typeset.rtp; - trunk.number_endpoints = 1; + trunk.vty_number_endpoints = 1; trunk.endpoints = &endp; trunk.force_constant_ssrc = patch_ssrc; trunk.force_aligned_timing = patch_ts; @@ -1097,7 +1096,7 @@ printf("Testing multiple payload types\n"); cfg = mgcp_config_alloc(); - cfg->trunk.number_endpoints = 64; + cfg->trunk.vty_number_endpoints = 64; mgcp_endpoints_allocate(&cfg->trunk); cfg->policy_cb = mgcp_test_policy_cb; mgcp_endpoints_allocate(mgcp_trunk_alloc(cfg, 1)); @@ -1228,7 +1227,7 @@ printf("Testing no sequence flow on initial packet\n"); cfg = mgcp_config_alloc(); - cfg->trunk.number_endpoints = 64; + cfg->trunk.vty_number_endpoints = 64; mgcp_endpoints_allocate(&cfg->trunk); endp = &cfg->trunk.endpoints[1]; @@ -1274,7 +1273,7 @@ printf("Testing no rtpmap name\n"); cfg = mgcp_config_alloc(); - cfg->trunk.number_endpoints = 64; + cfg->trunk.vty_number_endpoints = 64; cfg->trunk.audio_send_name = 0; mgcp_endpoints_allocate(&cfg->trunk); -- To view, visit https://gerrit.osmocom.org/4779 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I3994af016fb96427263edbba05f560743f85fdd4 Gerrit-PatchSet: 6 Gerrit-Project: osmo-mgw Gerrit-Branch: master Gerrit-Owner: dexter <pma...@sysmocom.de> Gerrit-Reviewer: Holger Freyther <hol...@freyther.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr <nhofm...@sysmocom.de>