[PATCH] osmo-mgw[master]: vty: do not change number_endpoints at runtime

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/.

dexter gerrit-no-reply at lists.osmocom.org
Fri Nov 10 16:39:59 UTC 2017


Review at  https://gerrit.osmocom.org/4779

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.

Change-Id: I3994af016fb96427263edbba05f560743f85fdd4
---
M include/osmocom/mgcp/mgcp.h
M src/libosmo-mgcp/mgcp_vty.c
2 files changed, 17 insertions(+), 3 deletions(-)


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

diff --git a/include/osmocom/mgcp/mgcp.h b/include/osmocom/mgcp/mgcp.h
index 42a91d8..1d46b8e 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 new_number_endpoints;
 	struct mgcp_endpoint *endpoints;
 };
 
diff --git a/src/libosmo-mgcp/mgcp_vty.c b/src/libosmo-mgcp/mgcp_vty.c
index fcf756b..ac4e82b 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.new_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)
@@ -509,8 +509,19 @@
       "number endpoints <0-65534>",
       "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;
+	if (g_cfg->trunk.new_number_endpoints < 0) {
+		/* + 1 as we start counting at one */
+		g_cfg->trunk.number_endpoints = atoi(argv[0]) + 1;
+		g_cfg->trunk.new_number_endpoints =
+		    g_cfg->trunk.number_endpoints;
+	} else {
+		g_cfg->trunk.new_number_endpoints = atoi(argv[0]) + 1;
+		vty_out(vty, "%%endpoint number changed, write config file and%s",
+			VTY_NEWLINE);
+		vty_out(vty, "%%restart osmo-mgw for the changes take effect%s",
+			VTY_NEWLINE);
+	}
+
 	return CMD_SUCCESS;
 }
 
@@ -1262,6 +1273,8 @@
 	cfg->osmux_batch_size = OSMUX_BATCH_DEFAULT_MAX;
 
 	g_cfg = cfg;
+	g_cfg->trunk.new_number_endpoints = -1;
+
 	rc = vty_read_config_file(config_file, NULL);
 	if (rc < 0) {
 		fprintf(stderr, "Failed to parse the config file: '%s'\n",

-- 
To view, visit https://gerrit.osmocom.org/4779
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3994af016fb96427263edbba05f560743f85fdd4
Gerrit-PatchSet: 1
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>



More information about the gerrit-log mailing list