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
Tue Aug 13 21:45:34 UTC 2019


neels has submitted this change and it was merged. ( 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.

Related: OS#4056
	 Ia4ba0e75abd3d45a3422b2525e5f938cdc5a04cc (osmo-ttcn3-hacks)
Change-Id: I8623ab581639e9f8af6a9ff1eca990518d1b1211
---
M src/osmo-bsc/neighbor_ident_vty.c
M tests/neighbor_ident.vty
2 files changed, 111 insertions(+), 0 deletions(-)

Approvals:
  neels: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/src/osmo-bsc/neighbor_ident_vty.c b/src/osmo-bsc/neighbor_ident_vty.c
index 203b150..2b8cd7e 100644
--- a/src/osmo-bsc/neighbor_ident_vty.c
+++ b/src/osmo-bsc/neighbor_ident_vty.c
@@ -372,6 +372,82 @@
 	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 neighbor_del_all(struct vty *vty)
+{
+	int rc;
+	int removed = 0;
+	struct gsm_bts *bts = vty->index;
+
+	OSMO_ASSERT((vty->node == BTS_NODE) && bts);
+
+	/* Remove all local neighbors and print to VTY for the user to know what changed */
+	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;
+		if (!neigh)
+			break;
+
+		neigh_bts = neigh->bts;
+		OSMO_ASSERT(neigh_bts);
+
+		/* It would be more efficient to just llist_del() the gsm_bts_ref directly, but for the sake of
+		 * safe/sane API use and against code dup, rather invoke the central gsm_bts_local_neighbor_del()
+		 * function intended for this task. */
+		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 = {
+			.bts_nr = bts->nr,
+		};
+		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, "%% No neighbors configured%s", VTY_NEWLINE);
+	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 +506,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 neighbor_del_all(vty);
+}
+
 struct write_neighbor_ident_entry_data {
 	struct vty *vty;
 	const char *indent;
@@ -576,5 +661,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..ce414e1 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
 
@@ -332,3 +336,24 @@
 
 OsmoBSC(config-net-bts)# show running-config
 ... !neighbor 
+
+OsmoBSC(config-net-bts)# neighbor bts 1
+% BTS 0 now has local neighbor BTS 1 with LAC 21 CI 31 and ARFCN 41 BSIC 11
+OsmoBSC(config-net-bts)# neighbor bts 2
+% BTS 0 now has local neighbor BTS 2 with LAC 22 CI 65535 and ARFCN 42 BSIC 12
+OsmoBSC(config-net-bts)# neighbor cgi 023 42 423 5 arfcn 23 bsic 42
+% BTS 0 to ARFCN 23 BSIC 42 now has 1 remote BSS Cell Identifier List entry
+OsmoBSC(config-net-bts)# neighbor lac 456 arfcn 123 bsic 45
+% BTS 0 to ARFCN 123 BSIC 45 now has 1 remote BSS Cell Identifier List entry
+OsmoBSC(config-net-bts)# neighbor lac-ci 789 10 arfcn 423 bsic any
+% BTS 0 to ARFCN 423 (any BSIC) now has 1 remote BSS Cell Identifier List entry
+
+OsmoBSC(config-net-bts)# no neighbors
+% Removed local neighbor bts 0 to bts 1
+% Removed local neighbor bts 0 to bts 2
+% Removed remote BSS neighbor BTS 0 to ARFCN 23 BSIC 42
+% Removed remote BSS neighbor BTS 0 to ARFCN 123 BSIC 45
+% Removed remote BSS neighbor BTS 0 to ARFCN 423 (any BSIC)
+
+OsmoBSC(config-net-bts)# show running-config
+... !neighbor 

-- 
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: 4
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-CC: laforge <laforge at gnumonks.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190813/4a89f989/attachment.htm>


More information about the gerrit-log mailing list