[PATCH] vty: Check with the application before writing the config

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/OpenBSC@lists.osmocom.org/.

Holger Hans Peter Freyther holger at freyther.de
Fri Nov 21 09:43:30 UTC 2014


From: Holger Hans Peter Freyther <holger at moiji-mobile.com>

For the BSC/NITB application we see that people modify the band
without modifying the ARFCN. This creates an unbootable config.
Using the new hook the BSC/NITB can check if the config is
consistent and prevent the config file being written.

Related: SYS#739
---
 TODO-RELEASE              | 1 +
 include/osmocom/vty/vty.h | 2 ++
 src/vty/command.c         | 9 +++++++++
 3 files changed, 12 insertions(+)

diff --git a/TODO-RELEASE b/TODO-RELEASE
index 72a27a4..290fb0e 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -1,2 +1,3 @@
 #library	what		description / commit summary line
 libosmocore	abi-change	logging: Add ability to save/print current log filters
+libosmovty	abi-change	vty: Check with the application before writing the config
diff --git a/include/osmocom/vty/vty.h b/include/osmocom/vty/vty.h
index ea02e4a..1dcc230 100644
--- a/include/osmocom/vty/vty.h
+++ b/include/osmocom/vty/vty.h
@@ -159,6 +159,8 @@ struct vty_app_info {
 	enum node_type (*go_parent_cb)(struct vty *vty);
 	/*! \brief call-back to determine if node is config node */
 	int (*is_config_node)(struct vty *vty, int node);
+	/*! \brief Check if the config is consistent before write */
+	int (*config_is_consistent)(struct vty *vty);
 };
 
 /* Prototypes. */
diff --git a/src/vty/command.c b/src/vty/command.c
index 44a1b6c..3ff5f77 100644
--- a/src/vty/command.c
+++ b/src/vty/command.c
@@ -2497,6 +2497,15 @@ DEFUN(config_write_file,
 	char *failed_file;
 	int rc;
 
+	if (host.app_info->config_is_consistent) {
+		rc = host.app_info->config_is_consistent(vty);
+		if (!rc) {
+			vty_out(vty, "Configuration is not consistent%s",
+				VTY_NEWLINE);
+			return CMD_WARNING;
+		}
+	}
+
 	if (host.config == NULL) {
 		vty_out(vty, "Can't save to configuration file, using vtysh.%s",
 			VTY_NEWLINE);
-- 
2.1.3




More information about the OpenBSC mailing list