Change in ...osmo-bsc[master]: add vty 'no neighbors' to remove all HO targets

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 gerrit-no-reply at lists.osmocom.org
Sat Jul 13 03:49:51 UTC 2019


neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bsc/+/14768


Change subject: add vty 'no neighbors' to remove all HO targets
......................................................................

add vty 'no neighbors' to remove all HO targets

This is required for an upcoming TTCN3 test that plays through various neighbor
configurations.

Change-Id: I8623ab581639e9f8af6a9ff1eca990518d1b1211
---
M src/osmo-bsc/neighbor_ident_vty.c
M tests/neighbor_ident.vty
2 files changed, 93 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/68/14768/1

diff --git a/src/osmo-bsc/neighbor_ident_vty.c b/src/osmo-bsc/neighbor_ident_vty.c
index 203b150..715ee8b 100644
--- a/src/osmo-bsc/neighbor_ident_vty.c
+++ b/src/osmo-bsc/neighbor_ident_vty.c
@@ -372,6 +372,85 @@
 	return CMD_SUCCESS;
 }
 
+struct nil_match_bts_data {
+	int bts_nr;
+	const struct neighbor_ident_key *found;
+};
+
+static bool nil_match_bts(const struct neighbor_ident_key *key,
+			  const struct gsm0808_cell_id_list2 *val,
+			  void *cb_data)
+{
+	struct nil_match_bts_data *d = cb_data;
+	if (key->from_bts == d->bts_nr) {
+		d->found = key;
+		return false;
+	}
+	return true;
+}
+
+static int del_all(struct vty *vty)
+{
+	int rc;
+	int removed = 0;
+	struct gsm_bts *bts = vty->index;
+
+	if (vty->node != BTS_NODE) {
+		vty_out(vty, "%% Error: cannot remove BTS neighbor, not on BTS node%s",
+			VTY_NEWLINE);
+		return CMD_WARNING;
+	}
+	if (!bts) {
+		vty_out(vty, "%% Error: cannot remove BTS neighbor, no BTS on this node%s",
+			VTY_NEWLINE);
+		return CMD_WARNING;
+	}
+
+	/* Remove all local neighbors */
+	while (1) {
+		struct gsm_bts_ref *neigh = llist_first_entry_or_null(&bts->local_neighbors, struct gsm_bts_ref, entry);
+		struct gsm_bts *neigh_bts = neigh ? neigh->bts : NULL;
+		if (!neigh)
+			break;
+
+		rc = gsm_bts_local_neighbor_del(bts, neigh_bts);
+		if (rc > 0) {
+			vty_out(vty, "%% Removed local neighbor bts %u to bts %u%s",
+				bts->nr, neigh_bts->nr, VTY_NEWLINE);
+			removed += rc;
+		} else {
+			vty_out(vty, "%% Error while removing local neigbor bts %u to bts %u, aborted%s",
+				bts->nr, neigh_bts->nr, VTY_NEWLINE);
+			return CMD_WARNING;
+		}
+	}
+
+	/* Remove all remote-BSS neighbors */
+	while (1) {
+		struct neighbor_ident_key k;
+		struct nil_match_bts_data d = {};
+		neighbor_ident_iter(g_neighbor_cells, nil_match_bts, &d);
+		if (!d.found)
+			break;
+		k = *d.found;
+		if (neighbor_ident_del(g_neighbor_cells, &k)) {
+			vty_out(vty, "%% Removed remote BSS neighbor %s%s",
+				neighbor_ident_key_name(&k), VTY_NEWLINE);
+			removed++;
+		} else {
+			vty_out(vty, "%% Error while removing remote BSS neighbor %s, aborted%s",
+				neighbor_ident_key_name(&k), VTY_NEWLINE);
+			return CMD_WARNING;
+		}
+	}
+
+	if (!removed) {
+		vty_out(vty, "%% Cannot remove, no neighbors configured%s", VTY_NEWLINE);
+		return CMD_WARNING;
+	}
+	return CMD_SUCCESS;
+}
+
 DEFUN(cfg_neighbor_add_lac_arfcn_bsic, cfg_neighbor_add_lac_arfcn_bsic_cmd,
 	NEIGHBOR_ADD_CMD LAC_PARAMS " " NEIGHBOR_IDENT_VTY_KEY_PARAMS,
 	NEIGHBOR_ADD_DOC LAC_DOC NEIGHBOR_IDENT_VTY_KEY_DOC)
@@ -430,6 +509,15 @@
 	return del_by_key(vty, &key);
 }
 
+DEFUN(cfg_neighbor_del_all, cfg_neighbor_del_all_cmd,
+	"no neighbors",
+	NO_STR
+	"Remove all local and remote-BSS neighbor config for this cell."
+	" Note that this falls back to the legacy behavior of regarding all local cells as neighbors.\n")
+{
+	return del_all(vty);
+}
+
 struct write_neighbor_ident_entry_data {
 	struct vty *vty;
 	const char *indent;
@@ -576,5 +664,6 @@
 	install_element(BTS_NODE, &cfg_neighbor_add_cgi_arfcn_bsic_cmd);
 	install_element(BTS_NODE, &cfg_neighbor_del_bts_nr_cmd);
 	install_element(BTS_NODE, &cfg_neighbor_del_arfcn_bsic_cmd);
+	install_element(BTS_NODE, &cfg_neighbor_del_all_cmd);
 	install_element_ve(&show_bts_neighbor_cmd);
 }
diff --git a/tests/neighbor_ident.vty b/tests/neighbor_ident.vty
index 4aeb6cc..224e8b3 100644
--- a/tests/neighbor_ident.vty
+++ b/tests/neighbor_ident.vty
@@ -89,6 +89,7 @@
   neighbor cgi <0-999> <0-999> <0-65535> <0-65535> arfcn <0-1023> bsic (<0-63>|any)
   no neighbor bts <0-255>
   no neighbor arfcn <0-1023> bsic (<0-63>|any)
+  no neighbors
 ...
 
 OsmoBSC(config-net-bts)# neighbor?
@@ -158,6 +159,9 @@
 OsmoBSC(config-net-bts)# neighbor cgi 0 0 0 0 arfcn 0 bsic 0 ?
   <cr>  
 
+OsmoBSC(config-net-bts)# no neighbors?
+  neighbors  Remove all local and remote-BSS neighbor config for this cell. Note that this falls back to the legacy behavior of regarding all local cells as neighbors.
+
 OsmoBSC(config-net-bts)# no neighbor?
   neighbor  Remove local or remote-BSS neighbor cell
 

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/14768
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I8623ab581639e9f8af6a9ff1eca990518d1b1211
Gerrit-Change-Number: 14768
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190713/9610f94f/attachment.htm>


More information about the gerrit-log mailing list