[PATCH] openbsc[master]: libbsc: Create pcu-socket only as specified in config file

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

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon May 29 11:46:07 UTC 2017


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

libbsc: Create pcu-socket only as specified in config file

Since commit b4999b60d48bcbb5aa575973d068e07ab672e095 we created PCU
sockets at hard-coded paths in the filesystem by default for all BTSs.
This is inflexible and prevents the use of multiple BSC instances on a
single filesystem, or the placement of the sockets in a more secure
location than /tmp.

The new approach with this patch is that
* no PCU sockets are created by default
* only for those BTSs where a 'pcu-socket' is configured via VTY,
  the socket will actually be created

Change-Id: Ie9079470584777dcc31f85f9bf0808f479156ccb
Closes: OS#2293
---
M openbsc/include/openbsc/gsm_data_shared.h
M openbsc/include/openbsc/pcu_if.h
M openbsc/src/libbsc/bsc_init.c
M openbsc/src/libbsc/bsc_vty.c
4 files changed, 27 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/77/2777/1

diff --git a/openbsc/include/openbsc/gsm_data_shared.h b/openbsc/include/openbsc/gsm_data_shared.h
index 3371fb9..1380a6c 100644
--- a/openbsc/include/openbsc/gsm_data_shared.h
+++ b/openbsc/include/openbsc/gsm_data_shared.h
@@ -870,6 +870,7 @@
 	struct amr_multirate_conf mr_half;
 
 	/* PCU socket state */
+	char *pcu_sock_path;
 	struct pcu_sock_state *pcu_state;
 
 #endif /* ROLE_BSC */
diff --git a/openbsc/include/openbsc/pcu_if.h b/openbsc/include/openbsc/pcu_if.h
index 0c355b7..1f398b4 100644
--- a/openbsc/include/openbsc/pcu_if.h
+++ b/openbsc/include/openbsc/pcu_if.h
@@ -1,8 +1,6 @@
 #ifndef _PCU_IF_H
 #define _PCU_IF_H
 
-#define PCU_SOCK_DEFAULT	"/tmp/pcu_bts"
-
 #include <osmocom/gsm/l1sap.h>
 
 extern int pcu_direct;
diff --git a/openbsc/src/libbsc/bsc_init.c b/openbsc/src/libbsc/bsc_init.c
index 520b2e2..caec800 100644
--- a/openbsc/src/libbsc/bsc_init.c
+++ b/openbsc/src/libbsc/bsc_init.c
@@ -507,8 +507,6 @@
 {
 	struct gsm_bts *bts;
 	int rc;
-	char pcu_sock_path[PATH_MAX];
-	char pcu_sock_path_ending[PATH_MAX];
 
 	rc = vty_read_config_file(config_file, NULL);
 	if (rc < 0) {
@@ -534,18 +532,6 @@
 		rc = e1_reconfig_bts(bts);
 		if (rc < 0) {
 			LOGP(DNM, LOGL_FATAL, "Error enabling E1 input driver\n");
-			return rc;
-		}
-
-		strcpy(pcu_sock_path, PCU_SOCK_DEFAULT);
-		sprintf(pcu_sock_path_ending,"_%i", bts->nr);
-		if (bts->nr > 0)
-			strcat(pcu_sock_path, pcu_sock_path_ending);
-		rc = pcu_sock_init(pcu_sock_path, bts);
-
-		if (rc < 0) {
-			LOGP(DNM, LOGL_FATAL,
-			     "PCU L1 socket failed for bts %i\n", bts->nr);
 			return rc;
 		}
 	}
diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c
index f14a205..f17bde6 100644
--- a/openbsc/src/libbsc/bsc_vty.c
+++ b/openbsc/src/libbsc/bsc_vty.c
@@ -53,6 +53,7 @@
 #include <openbsc/abis_rsl.h>
 #include <openbsc/bsc_msc_data.h>
 #include <openbsc/osmo_bsc_rf.h>
+#include <openbsc/pcu_if.h>
 
 #include <openbsc/common_cs.h>
 
@@ -280,6 +281,8 @@
 	vty_out(vty, "Early Classmark Sending: %s%s",
 		bts->early_classmark_allowed ? "allowed" : "forbidden",
 		VTY_NEWLINE);
+	if (bts->pcu_sock_path)
+		vty_out(vty, "PCU Socket Path: %s%s", bts->pcu_sock_path, VTY_NEWLINE);
 	if (is_ipaccess_bts(bts))
 		vty_out(vty, "  Unit ID: %u/%u/0, OML Stream ID 0x%02x%s",
 			bts->ip_access.site_id, bts->ip_access.bts_id,
@@ -764,6 +767,8 @@
 			vty_out(vty, "  depends-on-bts %d%s", bts_nr, VTY_NEWLINE);
 		}
 	}
+	if (bts->pcu_sock_path)
+		vty_out(vty, "  pcu-socket %s%s", bts->pcu_sock_path, VTY_NEWLINE);
 
 	config_write_bts_model(vty, bts);
 }
@@ -2933,6 +2938,26 @@
 	return CMD_SUCCESS;
 }
 
+DEFUN(cfg_bts_pcu_sock, cfg_bts_pcu_sock_cmd,
+	"pcu-socket PATH",
+	"PCU Socket Path for using OsmoPCU co-located with BSC (legacy BTS)\n"
+	"Path in the file system for the unix-domain PCU socket\n")
+{
+	struct gsm_bts *bts = vty->index;
+	int rc;
+
+	bsc_replace_string(bts, &bts->pcu_sock_path, argv[0]);
+	pcu_sock_exit(bts);
+	rc = pcu_sock_init(bts->pcu_sock_path, bts);
+	if (rc < 0) {
+		vty_out(vty, "%% Error creating PCU socket `%s' for BTS %u%s",
+			bts->pcu_sock_path, bts->nr, VTY_NEWLINE);
+		return CMD_WARNING;
+	}
+
+	return CMD_SUCCESS;
+}
+
 #define EXCL_RFLOCK_STR "Exclude this BTS from the global RF Lock\n"
 
 DEFUN(cfg_bts_excl_rf_lock,
@@ -4231,6 +4256,7 @@
 	install_element(BTS_NODE, &cfg_bts_amr_hr_hyst2_cmd);
 	install_element(BTS_NODE, &cfg_bts_amr_hr_hyst3_cmd);
 	install_element(BTS_NODE, &cfg_bts_amr_hr_start_mode_cmd);
+	install_element(BTS_NODE, &cfg_bts_pcu_sock_cmd);
 
 	install_element(BTS_NODE, &cfg_trx_cmd);
 	install_node(&trx_node, dummy_config_write);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie9079470584777dcc31f85f9bf0808f479156ccb
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>



More information about the gerrit-log mailing list