[MERGED] libosmocore[master]: gprs_ns_vty: guard against duplicate VTY elements

Harald Welte gerrit-no-reply at lists.osmocom.org
Thu Jan 12 23:34:05 UTC 2017


Harald Welte has submitted this change and it was merged.

Change subject: gprs_ns_vty: guard against duplicate VTY elements
......................................................................


gprs_ns_vty: guard against duplicate VTY elements

The TbfTest in osmo-pcu calls gprs_ns_vty_init() repeatedly, which aborts
because of duplicate VTY elements. Fix this by skipping the VTY init if
it already happened.

Change-Id: I05c7f25a4e873ae76b206819180b8b043b60103e
---
M src/gb/gprs_ns_vty.c
1 file changed, 8 insertions(+), 0 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/gb/gprs_ns_vty.c b/src/gb/gprs_ns_vty.c
index 5a951dc..ee305ba 100644
--- a/src/gb/gprs_ns_vty.c
+++ b/src/gb/gprs_ns_vty.c
@@ -573,8 +573,16 @@
 
 int gprs_ns_vty_init(struct gprs_ns_inst *nsi)
 {
+	static bool vty_elements_installed = false;
+
 	vty_nsi = nsi;
 
+	/* Regression test code may call this function repeatedly, so make sure
+	 * that VTY elements are not duplicated, which would assert. */
+	if (vty_elements_installed)
+		return 0;
+	vty_elements_installed = true;
+
 	install_element_ve(&show_ns_cmd);
 	install_element_ve(&show_ns_stats_cmd);
 	install_element_ve(&show_nse_cmd);

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I05c7f25a4e873ae76b206819180b8b043b60103e
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>


More information about the gerrit-log mailing list