Change in osmo-msc[master]: add VTY commands: mncc internal / external (== -M)

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

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Wed Dec 5 02:27:33 UTC 2018


Neels Hofmeyr has uploaded this change for review. ( https://gerrit.osmocom.org/12131


Change subject: add VTY commands: mncc internal / external (== -M)
......................................................................

add VTY commands: mncc internal / external (== -M)

So far the only way to use external MNCC is to pass the -M cmdline arg:

  osmo-msc -M /path/to/socket

However, the osmo-msc.service file for systemd is installed by 'make install',
and hence it is quite impractical to depend on such a config item to be
required in the service file:

- It defies any scheme an operator may have in place to compose the
  osmo-msc.cfg file -- this option doesn't go in the .cfg file but needs
  separate action to add to the installed service file.

- After a make install or package upgrades / re-installations, this option will
  be plain overwritten silently, or lead to the need for resolving file
  conflicts.

The initial spark for this came from configuring the 35c3 GSM from cfg
templates.

Change-Id: I2ec59d5eba407f83295528b51b93678d446b9cee
---
M include/osmocom/msc/gsm_data.h
M include/osmocom/msc/msc_common.h
M src/libmsc/msc_vty.c
M src/libmsc/osmo_msc.c
M src/osmo-msc/msc_main.c
M tests/test_nodes.vty
6 files changed, 68 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/31/12131/1

diff --git a/include/osmocom/msc/gsm_data.h b/include/osmocom/msc/gsm_data.h
index d3cb7d8..63af3e7 100644
--- a/include/osmocom/msc/gsm_data.h
+++ b/include/osmocom/msc/gsm_data.h
@@ -140,6 +140,7 @@
 	struct osmo_counter *active_nc_ss;
 
 	/* layer 4 */
+	char *mncc_sock_path;
 	struct mncc_sock_state *mncc_state;
 	mncc_recv_cb_t mncc_recv;
 	struct llist_head upqueue;
diff --git a/include/osmocom/msc/msc_common.h b/include/osmocom/msc/msc_common.h
index ffe8902..3ca3469 100644
--- a/include/osmocom/msc/msc_common.h
+++ b/include/osmocom/msc/msc_common.h
@@ -15,6 +15,7 @@
 typedef int (*mncc_recv_cb_t)(struct gsm_network *, struct msgb *);
 
 struct gsm_network *gsm_network_init(void *ctx, mncc_recv_cb_t mncc_recv);
+void gsm_network_set_mncc_sock_path(struct gsm_network *net, const char *mncc_sock_path);
 
 int msc_vlr_alloc(struct gsm_network *net);
 int msc_vlr_start(struct gsm_network *net);
diff --git a/src/libmsc/msc_vty.c b/src/libmsc/msc_vty.c
index d9e57a7..e1d1b40 100644
--- a/src/libmsc/msc_vty.c
+++ b/src/libmsc/msc_vty.c
@@ -339,6 +339,25 @@
 #define MNCC_GUARD_TIMEOUT_STR "Set global guard timer for mncc interface activity\n"
 #define MNCC_GUARD_TIMEOUT_VALUE_STR "guard timer value (sec.)\n"
 
+DEFUN(cfg_msc_mncc_internal,
+      cfg_msc_mncc_internal_cmd,
+      "mncc internal",
+      MNCC_STR "Use internal MNCC handler (default; changes need a program restart)\n")
+{
+	gsm_network_set_mncc_sock_path(gsmnet, NULL);
+	return CMD_SUCCESS;
+}
+
+DEFUN(cfg_msc_mncc_external,
+      cfg_msc_mncc_external_cmd,
+      "mncc external MNCC_SOCKET_PATH",
+      MNCC_STR "Use external MNCC handler (changes need a program restart)\n"
+      "File system path to create the MNCC unix domain socket at\n")
+{
+	gsm_network_set_mncc_sock_path(gsmnet, argv[0]);
+	return CMD_SUCCESS;
+}
+
 DEFUN(cfg_msc_mncc_guard_timeout,
       cfg_msc_mncc_guard_timeout_cmd,
       "mncc guard-timeout <0-255>",
@@ -442,6 +461,8 @@
 static int config_write_msc(struct vty *vty)
 {
 	vty_out(vty, "msc%s", VTY_NEWLINE);
+	if (gsmnet->mncc_sock_path)
+		vty_out(vty, " mncc external %s%s", gsmnet->mncc_sock_path, VTY_NEWLINE);
 	vty_out(vty, " mncc guard-timeout %i%s",
 		gsmnet->mncc_guard_timeout, VTY_NEWLINE);
 	vty_out(vty, " %sassign-tmsi%s",
@@ -1451,6 +1472,8 @@
 	install_element(CONFIG_NODE, &cfg_msc_cmd);
 	install_node(&msc_node, config_write_msc);
 	install_element(MSC_NODE, &cfg_msc_assign_tmsi_cmd);
+	install_element(MSC_NODE, &cfg_msc_mncc_internal_cmd);
+	install_element(MSC_NODE, &cfg_msc_mncc_external_cmd);
 	install_element(MSC_NODE, &cfg_msc_mncc_guard_timeout_cmd);
 	install_element(MSC_NODE, &cfg_msc_deprecated_mncc_guard_timeout_cmd);
 	install_element(MSC_NODE, &cfg_msc_no_assign_tmsi_cmd);
diff --git a/src/libmsc/osmo_msc.c b/src/libmsc/osmo_msc.c
index 52277b7..37c1d15 100644
--- a/src/libmsc/osmo_msc.c
+++ b/src/libmsc/osmo_msc.c
@@ -76,6 +76,13 @@
 	return net;
 }
 
+void gsm_network_set_mncc_sock_path(struct gsm_network *net, const char *mncc_sock_path)
+{
+	if (net->mncc_sock_path)
+		talloc_free(net->mncc_sock_path);
+	net->mncc_sock_path = mncc_sock_path ? talloc_strdup(net, mncc_sock_path) : NULL;
+}
+
 /* Receive a SAPI-N-REJECT from BSC */
 void ran_conn_sapi_n_reject(struct ran_conn *conn, int dlci)
 {
diff --git a/src/osmo-msc/msc_main.c b/src/osmo-msc/msc_main.c
index 4434056..a192b64 100644
--- a/src/osmo-msc/msc_main.c
+++ b/src/osmo-msc/msc_main.c
@@ -573,11 +573,20 @@
 		return 1;
 	}
 
-	/* Initialize MNCC socket if appropriate */
+	/* Initialize MNCC socket if appropriate. If the cmdline option -M is present, it overrides the .cfg file
+	 * setting 'msc' / 'mncc external MNCC_SOCKET_PATH'. Note that when -M is given, it "bleeds" back into the vty
+	 * 'write' command and is reflected in the written out 'mncc external' cfg. */
 	if (msc_cmdline_config.mncc_sock_path) {
+		LOGP(DMNCC, LOGL_NOTICE,
+		     "MNCC socket path is configured from commandline argument -M."
+		     " This affects a written-back config file. Instead consider using the config file directly"
+		     " ('msc' / 'mncc external MNCC_SOCKET_PATH').\n");
+		gsm_network_set_mncc_sock_path(msc_network, msc_cmdline_config.mncc_sock_path);
+	}
+	if (msc_network->mncc_sock_path) {
 		msc_network->mncc_recv = mncc_sock_from_cc;
 		rc = mncc_sock_init(msc_network,
-				    msc_cmdline_config.mncc_sock_path);
+				    msc_network->mncc_sock_path);
 		if (rc) {
 			fprintf(stderr, "MNCC socket initialization failed. exiting.\n");
 			exit(1);
diff --git a/tests/test_nodes.vty b/tests/test_nodes.vty
index 6a55e1b..c6902da 100644
--- a/tests/test_nodes.vty
+++ b/tests/test_nodes.vty
@@ -30,6 +30,8 @@
 OsmoMSC(config-msc)# list
 ...
   assign-tmsi
+  mncc internal
+  mncc external MNCC_SOCKET_PATH
   mncc guard-timeout <0-255>
   no assign-tmsi
   auth-tuple-max-reuse-count <-1-2147483647>
@@ -48,6 +50,29 @@
   asn1 debug (1|0)
   asn1 xer-print (1|0)
 
+OsmoMSC(config-msc)# mncc?
+  mncc  Configure Mobile Network Call Control
+
+OsmoMSC(config-msc)# mncc ?
+  internal       Use internal MNCC handler (default; changes need a program restart)
+  external       Use external MNCC handler (changes need a program restart)
+  guard-timeout  Set global guard timer for mncc interface activity
+
+OsmoMSC(config-msc)# mncc external ?
+  MNCC_SOCKET_PATH  File system path to create the MNCC unix domain socket at
+
+OsmoMSC(config-msc)# mncc external /path/not/used
+OsmoMSC(config-msc)# show running-config
+...
+msc
+...
+ mncc external /path/not/used
+...
+
+OsmoMSC(config-msc)# mncc internal
+OsmoMSC(config-msc)# show running-config
+... ! mncc external
+
 OsmoMSC(config-msc)# exit
 OsmoMSC(config)# mncc-int
 OsmoMSC(config-mncc-int)# list

-- 
To view, visit https://gerrit.osmocom.org/12131
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2ec59d5eba407f83295528b51b93678d446b9cee
Gerrit-Change-Number: 12131
Gerrit-PatchSet: 1
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181205/bed1ccee/attachment.htm>


More information about the gerrit-log mailing list