Change in osmo-bsc[master]: fix/refactor neighbor 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/gerrit-log@lists.osmocom.org/.

neels gerrit-no-reply at lists.osmocom.org
Sat Mar 13 08:37:41 UTC 2021


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


Change subject: fix/refactor neighbor config
......................................................................

fix/refactor neighbor config

The neighbor configuration storage is fundamentally broken: it requires
all local cells to be configured before being able to list them as
neighbors of each other. Upon config write-back, the neighbor config
however is placed back inline with the other config, and hence a
written-out neighbor config no longer works on program restart.

The cause of this problem is that the config is stored as explicit
pointers between local cells (struct gsm_bts), which of course requires
the pointer to exist before being able to reference it.

Instead, store the actual configuration that the user entered as-is,
without pointers or references to objects that need to be ready. Resolve
the neighbors every time a neighbor is needed.

Hence the user may enter any config at any place in the config file,
even non-working config (like a BTS number that doesn't exist), and the
relation to actual local or remote neighbor cells is made at runtime.

Related: OS#5018
Change-Id: I9ed992f8bfff888b3933733c0576f92d50f2625b
---
M include/osmocom/bsc/bts.h
M include/osmocom/bsc/gsm_data.h
M include/osmocom/bsc/handover.h
M include/osmocom/bsc/neighbor_ident.h
M src/osmo-bsc/bsc_init.c
M src/osmo-bsc/bsc_vty.c
M src/osmo-bsc/bts.c
M src/osmo-bsc/handover_decision.c
M src/osmo-bsc/handover_decision_2.c
M src/osmo-bsc/handover_fsm.c
M src/osmo-bsc/handover_logic.c
M src/osmo-bsc/neighbor_ident.c
M src/osmo-bsc/neighbor_ident_vty.c
M src/osmo-bsc/system_information.c
M tests/bsc/bsc_test.c
M tests/gsm0408/gsm0408_test.c
M tests/neighbor_ident.vty
17 files changed, 852 insertions(+), 1,024 deletions(-)



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

diff --git a/include/osmocom/bsc/bts.h b/include/osmocom/bsc/bts.h
index 3e3c73e..5dda44a 100644
--- a/include/osmocom/bsc/bts.h
+++ b/include/osmocom/bsc/bts.h
@@ -494,10 +494,13 @@
 
 	struct handover_cfg *ho;
 
-	/* A list of struct gsm_bts_ref, indicating neighbors of this BTS.
-	 * When the si_common neigh_list is in automatic mode, it is populated from this list as well as
-	 * gsm_network->neighbor_bss_cells. */
-	struct llist_head local_neighbors;
+	/* Local and remote neighbor configuration: a list of neighbors as written in the VTY config, not resolved to
+	 * actual cells. Entries may point at non-existing BTS numbers, or yet unconfigured ARFCN+BSIC. The point of
+	 * this list is to keep the config as the user entered it: a) to write it back exactly as entered, and b) to
+	 * allow adding neighbor cells that will only be configured further down in the config file.
+	 * An actual neighbor cell object (local or remote-BSS) is resolved "at runtime" whenever a neighbor is being
+	 * looked up. */
+	struct llist_head neighbors;
 
 	/* BTS-specific overrides for timer values from struct gsm_network. */
 	uint8_t T3122;	/* ASSIGNMENT REJECT wait indication */
diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index 1bf21ae..2a9da26 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -31,7 +31,6 @@
 #include <osmocom/abis/e1_input.h>
 #include <osmocom/bsc/meas_rep.h>
 #include <osmocom/bsc/acc.h>
-#include <osmocom/bsc/neighbor_ident.h>
 #include <osmocom/bsc/osmux.h>
 
 #define GSM_T3122_DEFAULT 10
@@ -174,10 +173,16 @@
 inline static const char *handover_scope_name(enum handover_scope val)
 { return get_value_string(handover_scope_names, val); }
 
+/* Cell ARFCN + BSIC. */
+struct cell_ab {
+	uint16_t arfcn;
+	uint8_t bsic;
+};
+
 struct handover_out_req {
 	enum hodec_id from_hodec_id;
 	struct gsm_lchan *old_lchan;
-	struct neighbor_ident_key target_nik;
+	struct cell_ab target_cell_ab;
 	enum gsm_chan_t new_lchan_type; /*< leave GSM_LCHAN_NONE to use same as old_lchan */
 };
 
@@ -205,7 +210,7 @@
 	enum hodec_id from_hodec_id;
 	enum handover_scope scope;
 	enum gsm_chan_t new_lchan_type;
-	struct neighbor_ident_key target_cell;
+	struct cell_ab target_cell_ab;
 
 	/* For inter-BSC handover, this may reflect more than one Cell ID. Must also be set for intra-BSC handover,
 	 * because it is used as key for penalty timers (e.g. in handover decision 2). */
@@ -850,12 +855,6 @@
 	unsigned int used;
 };
 
-/* Useful to track N-N relations between BTS, for example neighbors. */
-struct gsm_bts_ref {
-	struct llist_head entry;
-	struct gsm_bts *bts;
-};
-
 /* A single Page of a SMSCB message */
 struct bts_smscb_page {
 	/* SMSCB message we're part of */
@@ -1219,8 +1218,6 @@
 		struct osmo_tdef *tdefs;
 	} mgw;
 
-	/* Remote BSS Cell Identifier Lists */
-	struct neighbor_ident_list *neighbor_bss_cells;
 	/* Remote BSS resolution sevice (CTRL iface) */
 	struct {
 		char *addr;
diff --git a/include/osmocom/bsc/handover.h b/include/osmocom/bsc/handover.h
index a71bb98..f671491 100644
--- a/include/osmocom/bsc/handover.h
+++ b/include/osmocom/bsc/handover.h
@@ -82,8 +82,9 @@
 void bsc_tx_bssmap_ho_failure(struct gsm_subscriber_connection *conn);
 
 int find_handover_target_cell(struct gsm_bts **local_target_cell_p,
-			      const struct gsm0808_cell_id_list2 **remote_target_cell_p,
-			      struct gsm_subscriber_connection *conn, const struct neighbor_ident_key *search_for,
+			      struct gsm0808_cell_id_list2 *remote_target_cells,
+			      struct gsm_subscriber_connection *conn,
+			      const struct cell_ab *search_for,
 			      bool log_errors);
 
 void handover_parse_inter_bsc_mt(struct gsm_subscriber_connection *conn,
diff --git a/include/osmocom/bsc/neighbor_ident.h b/include/osmocom/bsc/neighbor_ident.h
index cab7f9e..48c44d3 100644
--- a/include/osmocom/bsc/neighbor_ident.h
+++ b/include/osmocom/bsc/neighbor_ident.h
@@ -7,62 +7,81 @@
 #include <osmocom/core/linuxlist.h>
 #include <osmocom/ctrl/control_cmd.h>
 
+#include <osmocom/bsc/gsm_data.h>
+
 struct vty;
 struct gsm_network;
 struct gsm_bts;
-struct neighbor_ident_list;
 struct gsm0808_cell_id_list2;
 
 #define NEIGHBOR_IDENT_KEY_ANY_BTS -1
 
 #define BSIC_ANY 0xff
 
-struct neighbor_ident_key {
-	int from_bts; /*< BTS nr 0..255 or NEIGHBOR_IDENT_KEY_ANY_BTS */
-	uint16_t arfcn;
-	uint8_t bsic;
+enum neighbor_type {
+	NEIGHBOR_TYPE_UNSET = 0,
+	NEIGHBOR_TYPE_BTS_NR = 1,
+	NEIGHBOR_TYPE_CELL_ID = 2,
 };
 
-const char *neighbor_ident_key_name(const struct neighbor_ident_key *ni_key);
+/* One line of VTY neighbor configuration as entered by the user.
+ * One of three variants:
+ *
+ * - just the local-BSS neighbor BTS nr:
+ *     neighbor bts 123
+ *
+ * - a neighbor cell identifier *without* ARFCN+BSIC:
+ *     neighbor (lac|lac-ci|cgi|cgi-ps) 1 2 3...
+ *   This is an elaborate / BTS-nr-agnostic way of indicating a local-BSS neighbor cell.
+ *
+ * - a neighbor cell identifier *with* ARFCN+BSIC:
+ *     neighbor (lac|lac-ci|cgi|cgi-ps) 1 2 3... arfcn 456 bsic (23|any)
+ *   This can either be
+ *   - a remote-BSS neighbor cell, or
+ *   - a super elaborate way of indicating a local-BSS neighbor, if this cell id exists in the local BSS.
+ */
+struct neighbor {
+	struct llist_head entry;
 
-struct neighbor_ident_list *neighbor_ident_init(void *talloc_ctx);
-void neighbor_ident_free(struct neighbor_ident_list *nil);
+	enum neighbor_type type;
+	union {
+		uint8_t bts_nr;
+		struct {
+			struct gsm0808_cell_id id;
+			bool ab_present;
+			struct cell_ab ab;
+		} cell_id;
+	};
+};
 
-bool neighbor_ident_key_match(const struct neighbor_ident_key *entry,
-			      const struct neighbor_ident_key *search_for,
-			      bool exact_match);
+struct gsm_bts *resolve_local_neighbor(struct gsm_bts *from_bts, const struct neighbor *neighbor);
+int resolve_remote_neighbors(struct gsm_bts *from_bts, const struct cell_ab *target_ab);
 
-int neighbor_ident_add(struct neighbor_ident_list *nil, const struct neighbor_ident_key *key,
-		       const struct gsm0808_cell_id_list2 *val);
-const struct gsm0808_cell_id_list2 *neighbor_ident_get(const struct neighbor_ident_list *nil,
-						       const struct neighbor_ident_key *key);
-bool neighbor_ident_del(struct neighbor_ident_list *nil, const struct neighbor_ident_key *key);
-void neighbor_ident_clear(struct neighbor_ident_list *nil);
+int cell_ab_to_str_buf(char *buf, size_t buflen, const struct cell_ab *cell);
+char *cell_ab_to_str_c(void *ctx, const struct cell_ab *cell);
 
-void neighbor_ident_iter(const struct neighbor_ident_list *nil,
-			 bool (* iter_cb )(const struct neighbor_ident_key *key,
-					   const struct gsm0808_cell_id_list2 *val,
-					   void *cb_data),
-			 void *cb_data);
+bool cell_ab_match(const struct cell_ab *entry, const struct cell_ab *search_for, bool exact_match);
+bool cell_ab_valid(const struct cell_ab *cell);
 
-struct neighbor_ident_key *bts_ident_key(const struct gsm_bts *bts);
+int neighbor_to_str_buf(char *buf, size_t buflen, const struct neighbor *n);
+char *neighbor_to_str_c(void *ctx, const struct neighbor *n);
+bool neighbor_same(const struct neighbor *a, const struct neighbor *b, bool check_cell_ab);
 
-void neighbor_ident_vty_init(struct gsm_network *net, struct neighbor_ident_list *nil);
+void bts_cell_ab(struct cell_ab *arfcn_bsic, const struct gsm_bts *bts);
+
+int resolve_neighbors(struct gsm_bts **local_neighbor_p, struct gsm0808_cell_id_list2 *remote_neighbors,
+		      struct gsm_bts *from_bts, const struct cell_ab *target_ab, bool log_errors);
+
+void neighbor_ident_vty_init();
 void neighbor_ident_vty_write_bts(struct vty *vty, const char *indent, struct gsm_bts *bts);
 void neighbor_ident_vty_write_network(struct vty *vty, const char *indent);
 
-bool neighbor_ident_bts_entry_exists(uint8_t from_bts);
-
-#define NEIGHBOR_IDENT_VTY_KEY_PARAMS "arfcn <0-1023> bsic (<0-63>|any)"
-#define NEIGHBOR_IDENT_VTY_KEY_DOC \
+#define CELL_AB_VTY_PARAMS "arfcn <0-1023> bsic (<0-63>|any)"
+#define CELL_AB_VTY_DOC \
 	"ARFCN of neighbor cell\n" "ARFCN value\n" \
 	"BSIC of neighbor cell\n" "BSIC value\n" \
 	"for all BSICs / use any BSIC in this ARFCN\n"
-bool neighbor_ident_vty_parse_key_params(struct vty *vty, const char **argv,
-					 struct neighbor_ident_key *key);
-bool neighbor_ident_bts_parse_key_params(struct vty *vty, struct gsm_bts *bts, const char **argv,
-					 struct neighbor_ident_key *key);
-
+void neighbor_ident_vty_parse_arfcn_bsic(struct cell_ab *ab, const char **argv);
 
 struct ctrl_handle *neighbor_controlif_setup(struct gsm_network *net);
 int neighbor_ctrl_cmds_install(struct gsm_network *net);
diff --git a/src/osmo-bsc/bsc_init.c b/src/osmo-bsc/bsc_init.c
index b959c9f..b572f27 100644
--- a/src/osmo-bsc/bsc_init.c
+++ b/src/osmo-bsc/bsc_init.c
@@ -100,7 +100,6 @@
 
 	net->ho = ho_cfg_init(net, NULL);
 	net->hodec2.congestion_check_interval_s = HO_CFG_CONGESTION_CHECK_DEFAULT;
-	net->neighbor_bss_cells = neighbor_ident_init(net);
 
 	/* init statistics */
 	net->bsc_ctrs = rate_ctr_group_alloc(net, &bsc_ctrg_desc, 0);
diff --git a/src/osmo-bsc/bsc_vty.c b/src/osmo-bsc/bsc_vty.c
index c8dfa8d..280fe9f 100644
--- a/src/osmo-bsc/bsc_vty.c
+++ b/src/osmo-bsc/bsc_vty.c
@@ -1881,8 +1881,8 @@
 		struct handover_out_req req = {
 			.from_hodec_id = HODEC_USER,
 			.old_lchan = from_lchan,
-			.target_nik = *bts_ident_key(to_bts),
 		};
+		bts_cell_ab(&req.target_cell_ab, to_bts);
 		handover_request(&req);
 	}
 	return CMD_SUCCESS;
@@ -2075,14 +2075,15 @@
 }
 
 DEFUN(handover_any_to_arfcn_bsic, handover_any_to_arfcn_bsic_cmd,
-      "handover any to " NEIGHBOR_IDENT_VTY_KEY_PARAMS,
+      "handover any to " CELL_AB_VTY_PARAMS,
       MANUAL_HANDOVER_STR
       "Pick any actively used TCH/F or TCH/H lchan to handover to another cell."
       " This is likely to fail outside of a lab setup where you are certain that"
       " all MS are able to see the target cell.\n"
       "'to'\n"
-      NEIGHBOR_IDENT_VTY_KEY_DOC)
+      CELL_AB_VTY_DOC)
 {
+	struct cell_ab ab = {};
 	struct handover_out_req req;
 	struct gsm_lchan *from_lchan;
 
@@ -2095,12 +2096,8 @@
 		.old_lchan = from_lchan,
 	};
 
-	if (!neighbor_ident_bts_parse_key_params(vty, from_lchan->ts->trx->bts,
-						 argv, &req.target_nik)) {
-		vty_out(vty, "%% BTS %u does not know about this neighbor%s",
-			from_lchan->ts->trx->bts->nr, VTY_NEWLINE);
-		return CMD_WARNING;
-	}
+	neighbor_ident_vty_parse_arfcn_bsic(&ab, argv);
+	req.target_cell_ab = ab;
 
 	handover_request(&req);
 	return CMD_SUCCESS;
@@ -7775,7 +7772,7 @@
 	install_element(BTS_NODE, &cfg_bts_rep_no_ul_dl_sacch_cmd);
 	install_element(BTS_NODE, &cfg_bts_rep_rxqual_cmd);
 
-	neighbor_ident_vty_init(network, network->neighbor_bss_cells);
+	neighbor_ident_vty_init();
 	/* See also handover commands added on bts level from handover_vty.c */
 
 	install_element(BTS_NODE, &cfg_bts_power_ctrl_cmd);
diff --git a/src/osmo-bsc/bts.c b/src/osmo-bsc/bts.c
index 3bb4f8a..5381a4e 100644
--- a/src/osmo-bsc/bts.c
+++ b/src/osmo-bsc/bts.c
@@ -273,7 +273,7 @@
 
 	INIT_LLIST_HEAD(&bts->abis_queue);
 	INIT_LLIST_HEAD(&bts->loc_list);
-	INIT_LLIST_HEAD(&bts->local_neighbors);
+	INIT_LLIST_HEAD(&bts->neighbors);
 	INIT_LLIST_HEAD(&bts->oml_fail_rep);
 	INIT_LLIST_HEAD(&bts->chan_rqd_queue);
 
@@ -442,59 +442,6 @@
 	OSMO_ASSERT(rc > 0);
 }
 
-static struct gsm_bts_ref *gsm_bts_ref_find(const struct llist_head *list, const struct gsm_bts *bts)
-{
-	struct gsm_bts_ref *ref;
-	if (!bts)
-		return NULL;
-	llist_for_each_entry(ref, list, entry) {
-		if (ref->bts == bts)
-			return ref;
-	}
-	return NULL;
-}
-
-/* Add a BTS reference to the local_neighbors list.
- * Return 1 if added, 0 if such an entry already existed, and negative on errors. */
-int gsm_bts_local_neighbor_add(struct gsm_bts *bts, struct gsm_bts *neighbor)
-{
-	struct gsm_bts_ref *ref;
-	if (!bts || !neighbor)
-		return -ENOMEM;
-
-	if (bts == neighbor)
-		return -EINVAL;
-
-	/* Already got this entry? */
-	ref = gsm_bts_ref_find(&bts->local_neighbors, neighbor);
-	if (ref)
-		return 0;
-
-	ref = talloc_zero(bts, struct gsm_bts_ref);
-	if (!ref)
-		return -ENOMEM;
-	ref->bts = neighbor;
-	llist_add_tail(&ref->entry, &bts->local_neighbors);
-	return 1;
-}
-
-/* Remove a BTS reference from the local_neighbors list.
- * Return 1 if removed, 0 if no such entry existed, and negative on errors. */
-int gsm_bts_local_neighbor_del(struct gsm_bts *bts, const struct gsm_bts *neighbor)
-{
-	struct gsm_bts_ref *ref;
-	if (!bts || !neighbor)
-		return -ENOMEM;
-
-	ref = gsm_bts_ref_find(&bts->local_neighbors, neighbor);
-	if (!ref)
-		return 0;
-
-	llist_del(&ref->entry);
-	talloc_free(ref);
-	return 1;
-}
-
 /* return the gsm_lchan for the CBCH (if it exists at all) */
 struct gsm_lchan *gsm_bts_get_cbch(struct gsm_bts *bts)
 {
diff --git a/src/osmo-bsc/handover_decision.c b/src/osmo-bsc/handover_decision.c
index 7eb8f31..1eeb277 100644
--- a/src/osmo-bsc/handover_decision.c
+++ b/src/osmo-bsc/handover_decision.c
@@ -201,8 +201,7 @@
 	req = (struct handover_out_req){
 		.from_hodec_id = HODEC1,
 		.old_lchan = mr->lchan,
-		.target_nik = {
-			.from_bts = bts->nr,
+		.target_cell_ab = {
 			.arfcn = best_cell->arfcn,
 			.bsic = best_cell->bsic,
 		},
diff --git a/src/osmo-bsc/handover_decision_2.c b/src/osmo-bsc/handover_decision_2.c
index 0d0391c..b397a9a 100644
--- a/src/osmo-bsc/handover_decision_2.c
+++ b/src/osmo-bsc/handover_decision_2.c
@@ -83,8 +83,8 @@
 #define LOGPHOCAND(candidate, level, fmt, args...) do {\
 	if ((candidate)->target.bts) \
 		LOGPHOLCHANTOBTS((candidate)->current.lchan, (candidate)->target.bts, level, fmt, ## args); \
-	else if ((candidate)->target.cil) \
-		LOGPHOLCHANTOREMOTE((candidate)->current.lchan, (candidate)->target.cil, level, fmt, ## args); \
+	else if ((candidate)->target.cell_ids.id_list_len) \
+		LOGPHOLCHANTOREMOTE((candidate)->current.lchan, &(candidate)->target.cell_ids, level, fmt, ## args); \
 	} while(0)
 
 
@@ -120,8 +120,8 @@
 		int lchan_frees_tchh;
 	} current;
 	struct {
-		struct neighbor_ident_key nik;	/* neighbor ARFCN+BSIC */
-		const struct gsm0808_cell_id_list2 *cil; /* target cells in remote BSS */
+		struct cell_ab ab;	/* neighbor ARFCN+BSIC */
+		struct gsm0808_cell_id_list2 cell_ids; /* target cells in remote BSS */
 		struct gsm_bts *bts;
 		int rxlev;
 		int rxlev_afs_bias;
@@ -747,9 +747,9 @@
 	/* Requirement A */
 
 	/* the handover penalty timer must not run for this bts */
-	penalty_time = penalty_timers_remaining_list(&c->current.lchan->conn->hodec2.penalty_timers, c->target.cil);
+	penalty_time = penalty_timers_remaining_list(&c->current.lchan->conn->hodec2.penalty_timers, &c->target.cell_ids);
 	if (penalty_time) {
-		LOGPHOLCHANTOREMOTE(c->current.lchan, c->target.cil, LOGL_DEBUG,
+		LOGPHOLCHANTOREMOTE(c->current.lchan, &c->target.cell_ids, LOGL_DEBUG,
 				    "not a candidate, target BSS still in penalty time"
 				    " (%u seconds left)\n", penalty_time);
 		return;
@@ -879,9 +879,9 @@
 	req = (struct handover_out_req){
 		.from_hodec_id = HODEC2,
 		.old_lchan = c->current.lchan,
-		.target_nik = *bts_ident_key(c->target.bts),
 		.new_lchan_type = full_rate? GSM_LCHAN_TCH_F : GSM_LCHAN_TCH_H,
 	};
+	bts_cell_ab(&req.target_cell_ab, c->target.bts);
 	handover_request(&req);
 	return 0;
 }
@@ -890,14 +890,14 @@
 {
 	struct handover_out_req req;
 
-	LOGPHOLCHANTOREMOTE(c->current.lchan, c->target.cil, LOGL_INFO,
+	LOGPHOLCHANTOREMOTE(c->current.lchan, &c->target.cell_ids, LOGL_INFO,
 			    "Triggering inter-BSC handover, due to %s\n",
 			    ho_reason_name(global_ho_reason));
 
 	req = (struct handover_out_req){
 		.from_hodec_id = HODEC2,
 		.old_lchan = c->current.lchan,
-		.target_nik = c->target.nik,
+		.target_cell_ab = c->target.ab,
 	};
 	handover_request(&req);
 	return 0;
@@ -933,13 +933,13 @@
 	     candidate->target.free_tch##tchx, candidate->target.min_free_tch##tchx, \
 	     REQUIREMENTS_ARGS(candidate->requirements, TCHX)
 
-	if (!candidate->target.bts && !candidate->target.cil)
+	if (!candidate->target.bts && !candidate->target.cell_ids.id_list_len)
 		LOGPHOLCHAN(candidate->current.lchan, LOGL_DEBUG, "Empty candidate\n");
-	if (candidate->target.bts && candidate->target.cil)
+	if (candidate->target.bts && candidate->target.cell_ids.id_list_len)
 		LOGPHOLCHAN(candidate->current.lchan, LOGL_ERROR, "Invalid candidate: both local- and remote-BSS target\n");
 
-	if (candidate->target.cil)
-		LOGPHOLCHANTOREMOTE(candidate->current.lchan, candidate->target.cil, LOGL_DEBUG,
+	if (candidate->target.cell_ids.id_list_len)
+		LOGPHOLCHANTOREMOTE(candidate->current.lchan, &candidate->target.cell_ids, LOGL_DEBUG,
 				    "RX level %d dBm -> %d dBm\n",
 				    rxlev2dbm(candidate->current.rxlev), rxlev2dbm(candidate->target.rxlev));
 
@@ -1052,9 +1052,8 @@
 {
 	struct gsm_bts *bts = lchan->ts->trx->bts;
 	struct gsm_bts *neighbor_bts;
-	const struct gsm0808_cell_id_list2 *neighbor_cil;
-	struct neighbor_ident_key ni = {
-		.from_bts = bts->nr,
+	struct gsm0808_cell_id_list2 neighbor_cil;
+	struct cell_ab target_ab = {
 		.arfcn = nmp->arfcn,
 		.bsic = nmp->bsic,
 	};
@@ -1078,9 +1077,9 @@
 	}
 
 	find_handover_target_cell(&neighbor_bts, &neighbor_cil,
-				  lchan->conn, &ni, false);
+				  lchan->conn, &target_ab, false);
 
-	if (!neighbor_bts && !neighbor_cil) {
+	if (!neighbor_bts && !neighbor_cil.id_list_len) {
 		LOGPHOBTS(bts, LOGL_DEBUG, "no neighbor ARFCN %u BSIC %u configured for this cell\n",
 			  nmp->arfcn, nmp->bsic);
 		return;
@@ -1103,9 +1102,9 @@
 			.rxlev = rxlev_current,
 		},
 		.target = {
-			.nik = ni,
+			.ab = target_ab,
 			.bts = neighbor_bts,
-			.cil = neighbor_cil,
+			.cell_ids = neighbor_cil,
 			.rxlev = neigh_meas_avg(nmp, ho_get_hodec2_rxlev_neigh_avg_win(bts->ho)),
 		},
 	};
diff --git a/src/osmo-bsc/handover_fsm.c b/src/osmo-bsc/handover_fsm.c
index 5270152..70e479f 100644
--- a/src/osmo-bsc/handover_fsm.c
+++ b/src/osmo-bsc/handover_fsm.c
@@ -146,7 +146,7 @@
 		snprintf(buf, sizeof(buf),
 			 "("LOG_FMT_FROM_LCHAN") --HO-> (%s) " LOG_FMT_HO_SCOPE,
 			 LOG_ARGS_FROM_LCHAN(conn->lchan),
-			 neighbor_ident_key_name(&ho->target_cell),
+			 cell_ab_to_str_c(OTC_SELECT, &ho->target_cell_ab),
 			 LOG_ARGS_HO_SCOPE(conn));
 
 	else if (ho->scope & HO_INTER_BSC_IN) {
@@ -227,9 +227,6 @@
 	conn = req->old_lchan->conn;
 	OSMO_ASSERT(conn && conn->fi);
 
-	/* Make sure the handover target neighbor_ident_key contains the correct source bts nr */
-	req->target_nik.from_bts = req->old_lchan->ts->trx->bts->nr;
-
 	/* To make sure we're allowed to start a handover, go through a gscon event dispatch. If that is accepted, the
 	 * same req is passed to handover_start(). */
 	osmo_fsm_inst_dispatch(conn->fi, GSCON_EV_HANDOVER_START, req);
@@ -315,10 +312,10 @@
 
 	OSMO_ASSERT(req && req->old_lchan && req->old_lchan->conn);
 	struct gsm_subscriber_connection *conn = req->old_lchan->conn;
-	const struct neighbor_ident_key *search_for = &req->target_nik;
+	const struct cell_ab *search_for = &req->target_cell_ab;
 	struct handover *ho = &conn->ho;
 	struct gsm_bts *local_target_cell = NULL;
-	const struct gsm0808_cell_id_list2 *remote_target_cell = NULL;
+	struct gsm0808_cell_id_list2 remote_target_cells = {};
 
 	if (conn->ho.fi) {
 		LOG_HO(conn, LOGL_ERROR, "Handover requested while another handover is ongoing; Ignore\n");
@@ -335,9 +332,9 @@
 	ho->from_hodec_id = req->from_hodec_id;
 	ho->new_lchan_type = req->new_lchan_type == GSM_LCHAN_NONE ?
 		req->old_lchan->type : req->new_lchan_type;
-	ho->target_cell = req->target_nik;
+	ho->target_cell_ab = req->target_cell_ab;
 
-	if (find_handover_target_cell(&local_target_cell, &remote_target_cell,
+	if (find_handover_target_cell(&local_target_cell, &remote_target_cells,
 				      conn, search_for, true)) {
 		handover_end(conn, HO_RESULT_ERROR);
 		return;
@@ -349,8 +346,8 @@
 		return;
 	}
 
-	if (remote_target_cell) {
-		handover_start_inter_bsc_out(conn, remote_target_cell);
+	if (remote_target_cells.id_list_len) {
+		handover_start_inter_bsc_out(conn, &remote_target_cells);
 		return;
 	}
 
diff --git a/src/osmo-bsc/handover_logic.c b/src/osmo-bsc/handover_logic.c
index b0d175a..c0ed10d 100644
--- a/src/osmo-bsc/handover_logic.c
+++ b/src/osmo-bsc/handover_logic.c
@@ -126,7 +126,7 @@
 	return count;
 }
 
-/* Find out a handover target cell for the given neighbor_ident_key,
+/* Find out a handover target cell for the given arfcn_bsic,
  * and make sure there are no ambiguous matches.
  * Given a source BTS and a target ARFCN+BSIC, find which cell is the right handover target.
  * ARFCN+BSIC may be re-used within and/or across BSS, so make sure that only those cells that are explicitly
@@ -138,22 +138,20 @@
  * to be found.
  */
 int find_handover_target_cell(struct gsm_bts **local_target_cell_p,
-			      const struct gsm0808_cell_id_list2 **remote_target_cell_p,
-			      struct gsm_subscriber_connection *conn, const struct neighbor_ident_key *search_for,
+			      struct gsm0808_cell_id_list2 *remote_target_cells,
+			      struct gsm_subscriber_connection *conn,
+			      const struct cell_ab *search_for,
 			      bool log_errors)
 {
 	struct gsm_network *net = conn->network;
-	struct gsm_bts *from_bts;
 	struct gsm_bts *local_target_cell = NULL;
-	const struct gsm0808_cell_id_list2 *remote_target_cell = NULL;
-	struct gsm_bts_ref *neigh;
 	bool ho_active;
 	bool as_active;
+	struct gsm_bts *from_bts = conn->lchan->ts->trx->bts;
+	*remote_target_cells = (struct gsm0808_cell_id_list2){};
 
 	if (local_target_cell_p)
 		*local_target_cell_p = NULL;
-	if (remote_target_cell_p)
-		*remote_target_cell_p = NULL;
 
 	if (!search_for) {
 		if (log_errors)
@@ -161,7 +159,6 @@
 		return -EINVAL;
 	}
 
-	from_bts = gsm_bts_num(net, search_for->from_bts);
 	if (!from_bts) {
 		if (log_errors)
 			LOG_HO(conn, LOGL_ERROR, "Handover without source cell\n");
@@ -174,12 +171,11 @@
 	if (!ho_active && !as_active) {
 		if (log_errors)
 			LOG_HO(conn, LOGL_ERROR, "Cannot start Handover: Handover and Assignment disabled for this source cell (%s)\n",
-			       neighbor_ident_key_name(search_for));
+			       cell_ab_to_str_c(OTC_SELECT, search_for));
 		return -EINVAL;
 	}
 
-	if (llist_empty(&from_bts->local_neighbors)
-	    && !neighbor_ident_bts_entry_exists(from_bts->nr)) {
+	if (llist_empty(&from_bts->neighbors)) {
 		/* No explicit neighbor entries exist for this BTS. Hence apply the legacy default behavior that all
 		 * local cells are neighbors. */
 		struct gsm_bts *bts;
@@ -192,15 +188,16 @@
 		for (i = 0; i < 2; i++) {
 			bool exact_match = !i;
 			llist_for_each_entry(bts, &net->bts_list, list) {
-				struct neighbor_ident_key bts_key = *bts_ident_key(bts);
-				if (neighbor_ident_key_match(&bts_key, search_for, exact_match)) {
+				struct cell_ab bts_ab;
+				bts_cell_ab(&bts_ab, bts);
+				if (cell_ab_match(&bts_ab, search_for, exact_match)) {
 					if (local_target_cell) {
 						if (log_errors)
 							LOG_HO(conn, LOGL_ERROR,
 							       "NEIGHBOR CONFIGURATION ERROR: Multiple local cells match %s"
 							       " (BTS %d and BTS %d)."
 							       " Aborting Handover because of ambiguous network topology.\n",
-							       neighbor_ident_key_name(search_for),
+							       cell_ab_to_str_c(OTC_SELECT, search_for),
 							       local_target_cell->nr, bts->nr);
 						return -EINVAL;
 					}
@@ -214,7 +211,7 @@
 		if (!local_target_cell) {
 			if (log_errors)
 				LOG_HO(conn, LOGL_ERROR, "Cannot Handover, no cell matches %s\n",
-				       neighbor_ident_key_name(search_for));
+				       cell_ab_to_str_c(OTC_SELECT, search_for));
 			return -EINVAL;
 		}
 
@@ -222,14 +219,14 @@
 			if (log_errors)
 				LOG_HO(conn, LOGL_ERROR,
 				       "Cannot start re-assignment, Assignment disabled for this cell (%s)\n",
-				       neighbor_ident_key_name(search_for));
+				       cell_ab_to_str_c(OTC_SELECT, search_for));
 			return -EINVAL;
 		}
 		if (local_target_cell != from_bts && !ho_active) {
 			if (log_errors)
 				LOG_HO(conn, LOGL_ERROR,
 				       "Cannot start Handover, Handover disabled for this cell (%s)\n",
-				       neighbor_ident_key_name(search_for));
+				       cell_ab_to_str_c(OTC_SELECT, search_for));
 			return -EINVAL;
 		}
 
@@ -243,81 +240,60 @@
 
 	LOG_HO(conn, LOGL_DEBUG, "There are explicit neighbors configured for this cell\n");
 
-	/* Iterate explicit local neighbor cells */
-	llist_for_each_entry(neigh, &from_bts->local_neighbors, entry) {
-		struct gsm_bts *neigh_bts = neigh->bts;
-		struct neighbor_ident_key neigh_bts_key = *bts_ident_key(neigh_bts);
-		neigh_bts_key.from_bts = from_bts->nr;
-
-		LOG_HO(conn, LOGL_DEBUG, "Local neighbor %s\n", neighbor_ident_key_name(&neigh_bts_key));
-
-		if (!neighbor_ident_key_match(&neigh_bts_key, search_for, true)) {
-			LOG_HO(conn, LOGL_DEBUG, "Doesn't match %s\n", neighbor_ident_key_name(search_for));
-			continue;
-		}
-
-		if (local_target_cell) {
-			if (log_errors)
-				LOG_HO(conn, LOGL_ERROR,
-				       "NEIGHBOR CONFIGURATION ERROR: Multiple BTS match %s (BTS %d and BTS %d)."
-				       " Aborting Handover because of ambiguous network topology.\n",
-				       neighbor_ident_key_name(search_for), local_target_cell->nr, neigh_bts->nr);
-			return -EINVAL;
-		}
-
-		local_target_cell = neigh_bts;
+	if (resolve_neighbors(&local_target_cell, remote_target_cells, from_bts, search_for, log_errors)) {
+		LOG_HO(conn, LOGL_ERROR, "Cannot handover BTS %u -> %s: neighbor unknown\n",
+		       from_bts->nr, cell_ab_to_str_c(OTC_SELECT, search_for));
+		return -ENOENT;
 	}
 
-	/* Any matching remote-BSS neighbor cell? */
-	remote_target_cell = neighbor_ident_get(net->neighbor_bss_cells, search_for);
+	/* We have found possibly a local_target_cell (when != NULL), and / or remote_target_cells (when .id_list_len >
+	 * 0). Figure out what to do with them. */
 
-	if (remote_target_cell)
-		LOG_HO(conn, LOGL_DEBUG, "Found remote target cell %s\n",
-		       gsm0808_cell_id_list_name(remote_target_cell));
+	if (remote_target_cells->id_list_len)
+		LOG_HO(conn, LOGL_DEBUG, "Found remote target cell(s) %s\n",
+		       gsm0808_cell_id_list_name_c(OTC_SELECT, remote_target_cells));
 
-	if (local_target_cell && remote_target_cell) {
+	if (local_target_cell && remote_target_cells->id_list_len) {
 		if (log_errors)
-			LOG_HO(conn, LOGL_ERROR, "NEIGHBOR CONFIGURATION ERROR: Both a local and a remote-BSS cell match %s"
-			       " (BTS %d and remote %s)."
+			LOG_HO(conn, LOGL_ERROR, "NEIGHBOR CONFIGURATION ERROR: Both a local and a remote-BSS cell"
+			       " match BTS %u -> %s (BTS %d and remote %s)."
 			       " Aborting Handover because of ambiguous network topology.\n",
-			       neighbor_ident_key_name(search_for), local_target_cell->nr,
-			       gsm0808_cell_id_list_name(remote_target_cell));
+			       from_bts->nr, cell_ab_to_str_c(OTC_SELECT, search_for), local_target_cell->bts_nr,
+			       gsm0808_cell_id_list_name_c(OTC_SELECT, remote_target_cells));
 		return -EINVAL;
 	}
 
 	if (local_target_cell == from_bts && !as_active) {
 		if (log_errors)
 			LOG_HO(conn, LOGL_ERROR,
-			       "Cannot start re-assignment, Assignment disabled for this cell (%s)\n",
-			       neighbor_ident_key_name(search_for));
+			       "Cannot start re-assignment, Assignment disabled for this cell (BTS %u)\n",
+			       from_bts->nr);
 		return -EINVAL;
 	}
 
 	if (((local_target_cell && local_target_cell != from_bts)
-	     || remote_target_cell)
+	     || remote_target_cells->id_list_len)
 	    && !ho_active) {
 		if (log_errors)
 			LOG_HO(conn, LOGL_ERROR,
-			       "Cannot start Handover, Handover disabled for this cell (%s)\n",
-			       neighbor_ident_key_name(search_for));
+			       "Cannot start Handover, Handover disabled for this cell (BTS %u -> %s)\n",
+			       from_bts->bts_nr, cell_ab_to_str_c(OTC_SELECT, search_for));
 		return -EINVAL;
 	}
 
+	/* Return the result. After above checks, only one of local or remote cell has been found. */
 	if (local_target_cell) {
 		if (local_target_cell_p)
 			*local_target_cell_p = local_target_cell;
 		return 0;
 	}
 
-	if (remote_target_cell) {
-		if (remote_target_cell_p)
-			*remote_target_cell_p = remote_target_cell;
+	if (remote_target_cells->id_list_len)
 		return 0;
-	}
 
 	if (log_errors)
 		LOG_HO(conn, LOGL_ERROR, "Cannot handover %s: neighbor unknown\n",
-		       neighbor_ident_key_name(search_for));
+		       cell_ab_to_str_c(OTC_SELECT, search_for));
 
 	return -ENODEV;
 }
diff --git a/src/osmo-bsc/neighbor_ident.c b/src/osmo-bsc/neighbor_ident.c
index 3235508..b7ac7c9 100644
--- a/src/osmo-bsc/neighbor_ident.c
+++ b/src/osmo-bsc/neighbor_ident.c
@@ -40,88 +40,232 @@
 #include <osmocom/bsc/bts.h>
 #include <osmocom/bsc/debug.h>
 
-struct neighbor_ident_list {
-	struct llist_head list;
-};
-
-struct neighbor_ident {
-	struct llist_head entry;
-
-	struct neighbor_ident_key key;
-	struct gsm0808_cell_id_list2 val;
-};
-
-#define APPEND_THING(func, args...) do { \
-		int remain = buflen - (pos - buf); \
-		int l = func(pos, remain, ##args); \
-		if (l < 0 || l > remain) \
-			pos = buf + buflen; \
-		else \
-			pos += l; \
-	} while(0)
-#define APPEND_STR(fmt, args...) APPEND_THING(snprintf, fmt, ##args)
-
-const char *_neighbor_ident_key_name(char *buf, size_t buflen, const struct neighbor_ident_key *ni_key)
+void bts_cell_ab(struct cell_ab *arfcn_bsic, const struct gsm_bts *bts)
 {
-	char *pos = buf;
-
-	APPEND_STR("BTS ");
-	if (ni_key->from_bts == NEIGHBOR_IDENT_KEY_ANY_BTS)
-		APPEND_STR("*");
-	else if (ni_key->from_bts >= 0 && ni_key->from_bts <= 255)
-		APPEND_STR("%d", ni_key->from_bts);
-	else
-		APPEND_STR("invalid(%d)", ni_key->from_bts);
-
-	APPEND_STR(" to ");
-	if (ni_key->bsic == BSIC_ANY)
-		APPEND_STR("ARFCN %u (any BSIC)", ni_key->arfcn);
-	else
-		APPEND_STR("ARFCN %u BSIC %u", ni_key->arfcn, ni_key->bsic & 0x3f);
-	return buf;
+	*arfcn_bsic = (struct cell_ab){
+		.arfcn = bts->c0->arfcn,
+		.bsic = bts->bsic,
+	};
 }
 
-const char *neighbor_ident_key_name(const struct neighbor_ident_key *ni_key)
+/* Find the local gsm_bts pointer that a specific other BTS' neighbor config refers to. Return NULL if there is no such
+ * local cell in this BSS.
+ */
+struct gsm_bts *resolve_local_neighbor(struct gsm_bts *from_bts, const struct neighbor *neighbor)
 {
-	static char buf[64];
-	return _neighbor_ident_key_name(buf, sizeof(buf), ni_key);
+	struct gsm_bts *bts;
+	struct gsm_bts *bts_exact = NULL;
+	struct gsm_bts *bts_wildcard = NULL;
+
+	switch (neighbor->type) {
+	case NEIGHBOR_TYPE_BTS_NR:
+		bts = gsm_bts_num(bsc_gsmnet, neighbor->bts_nr);
+		goto check_bts;
+
+	case NEIGHBOR_TYPE_CELL_ID:
+		/* Find cell id below */
+		break;
+
+	default:
+		return NULL;
+	}
+
+	/* NEIGHBOR_TYPE_CELL_ID */
+	llist_for_each_entry(bts, &bsc_gsmnet->bts_list, list) {
+		struct gsm0808_cell_id cell_id;
+		gsm_bts_cell_id(&cell_id, bts);
+
+		if (gsm0808_cell_ids_match(&cell_id, &neighbor->cell_id.id, true)) {
+			if (bts_exact) {
+				LOGP(DHO, LOGL_ERROR,
+				     "NEIGHBOR CONFIG ERROR: Multiple BTS match %s (BTS %d and BTS %d)\n",
+				     gsm0808_cell_id_name_c(OTC_SELECT, &neighbor->cell_id.id),
+				     bts_exact->nr, bts->nr);
+			} else {
+				bts_exact = bts;
+			}
+		}
+
+		if (!bts_wildcard && gsm0808_cell_ids_match(&cell_id, &neighbor->cell_id.id, false))
+			bts_wildcard = bts;
+	}
+
+	bts = (bts_exact ? : bts_wildcard);
+
+check_bts:
+	/* A cell cannot be its own neighbor */
+	if (bts == from_bts) {
+		LOGP(DHO, LOGL_ERROR,
+		     "NEIGHBOR CONFIG ERROR: BTS %u -> %s: this cell is configured as its own neighbor\n",
+		     from_bts->nr, neighbor_to_str_c(OTC_SELECT, neighbor));
+		bts = NULL;
+	}
+
+	if (!bts)
+		return NULL;
+
+	/* Double check whether ARFCN + BSIC config matches, if present. */
+	if (neighbor->cell_id.ab_present) {
+		struct cell_ab cell_ab;
+		bts_cell_ab(&cell_ab, bts);
+		if (!cell_ab_match(&cell_ab, &neighbor->cell_id.ab, false)) {
+			LOGP(DHO, LOGL_ERROR, "NEIGHBOR CONFIG ERROR: Local BTS %d matches %s, but not ARFCN+BSIC %s\n",
+			     bts->nr, gsm0808_cell_id_name_c(OTC_SELECT, &neighbor->cell_id.id),
+			     cell_ab_to_str_c(OTC_SELECT, &cell_ab));
+			return NULL;
+		}
+	}
+
+	return bts;
 }
 
-struct neighbor_ident_list *neighbor_ident_init(void *talloc_ctx)
+int resolve_neighbors(struct gsm_bts **local_neighbor_p, struct gsm0808_cell_id_list2 *remote_neighbors,
+		      struct gsm_bts *from_bts, const struct cell_ab *target_ab, bool log_errors)
 {
-	struct neighbor_ident_list *nil = talloc_zero(talloc_ctx, struct neighbor_ident_list);
-	OSMO_ASSERT(nil);
-	INIT_LLIST_HEAD(&nil->list);
-	return nil;
+	struct neighbor *n;
+	struct gsm_bts *local_neighbor = NULL;
+	struct gsm0808_cell_id_list2 remotes = {};
+
+	llist_for_each_entry(n, &from_bts->neighbors, entry) {
+		struct gsm_bts *neigh_bts = resolve_local_neighbor(from_bts, n);
+
+		if (neigh_bts) {
+			/* This neighbor entry is a local cell neighbor. Do ARFCN and BSIC match? */
+			struct cell_ab ab;
+			bts_cell_ab(&ab, neigh_bts);
+			if (!cell_ab_match(&ab, target_ab, false))
+				continue;
+
+			/* Found a local cell neighbor that matches the target_ab */
+
+			/* If we already found one, these are ambiguous local neighbors */
+			if (local_neighbor) {
+				if (log_errors)
+					LOGP(DHO, LOGL_ERROR, "NEIGHBOR CONFIG ERROR:"
+					     " Local BTS %d -> %s resolves to local neighbor BTSes %u *and* %u\n",
+					     from_bts->nr, cell_ab_to_str_c(OTC_SELECT, target_ab), local_neighbor->nr,
+					     neigh_bts->nr);
+				return -ENOTSUP;
+			}
+			local_neighbor = neigh_bts;
+
+		} else if (n->type == NEIGHBOR_TYPE_CELL_ID && n->cell_id.ab_present) {
+			/* This neighbor entry is a remote-BSS neighbor. There may be multiple remote neighbors,
+			 * collect those in a gsm0808_cell_id_list2 (remote_target_cells). A limitation is that all of
+			 * them need to be of the same cell id type. */
+			struct gsm0808_cell_id_list2 add_item;
+			int rc;
+
+			if (!cell_ab_match(&n->cell_id.ab, target_ab, false))
+				continue;
+
+			/* Convert the gsm0808_cell_id to a list, so that we can use gsm0808_cell_id_list_add(). */
+			gsm0808_cell_id_to_list(&add_item, &n->cell_id.id);
+			rc = gsm0808_cell_id_list_add(&remotes, &add_item);
+			if (rc < 0) {
+				if (log_errors)
+					LOGP(DHO, LOGL_ERROR, "NEIGHBOR CONFIG ERROR:"
+					     " Local BTS %d -> %s resolves to remote-BSS neighbor %s;"
+					     " Could not store this in neighbors list %s\n",
+					     from_bts->nr, cell_ab_to_str_c(OTC_SELECT, target_ab),
+					     gsm0808_cell_id_name_c(OTC_SELECT, &n->cell_id.id),
+					     gsm0808_cell_id_list_name_c(OTC_SELECT, &remotes));
+				return rc;
+			}
+		}
+		/* else: neighbor entry that does not resolve to anything. */
+	}
+
+	if (local_neighbor_p)
+		*local_neighbor_p = local_neighbor;
+	if (remote_neighbors)
+		*remote_neighbors = remotes;
+
+	if (!local_neighbor && !remotes.id_list_len)
+		return -ENOENT;
+	return 0;
 }
 
-void neighbor_ident_free(struct neighbor_ident_list *nil)
+int cell_ab_to_str_buf(char *buf, size_t buflen, const struct cell_ab *cell)
 {
-	if (!nil)
-		return;
-	talloc_free(nil);
+	struct osmo_strbuf sb = { .buf = buf, .len = buflen };
+	OSMO_STRBUF_PRINTF(sb, "ARFCN-BSIC:%u", cell->arfcn);
+	if (cell->bsic == BSIC_ANY)
+		OSMO_STRBUF_PRINTF(sb, "-any");
+	else {
+		OSMO_STRBUF_PRINTF(sb, "-%u", cell->bsic);
+		if (cell->bsic > 0x3f)
+			OSMO_STRBUF_PRINTF(sb, "[ERANGE>63]");
+	}
+	return sb.chars_needed;
+}
+
+char *cell_ab_to_str_c(void *ctx, const struct cell_ab *cell)
+{
+	OSMO_NAME_C_IMPL(ctx, 64, "ERROR", cell_ab_to_str_buf, cell)
+}
+
+int neighbor_to_str_buf(char *buf, size_t buflen, const struct neighbor *n)
+{
+	struct osmo_strbuf sb = { .buf = buf, .len = buflen };
+	switch (n->type) {
+	case NEIGHBOR_TYPE_BTS_NR:
+		OSMO_STRBUF_PRINTF(sb, "BTS %u", n->bts_nr);
+		break;
+	case NEIGHBOR_TYPE_CELL_ID:
+		OSMO_STRBUF_APPEND_NOLEN(sb, gsm0808_cell_id_name_buf, &n->cell_id.id);
+		if (n->cell_id.ab_present) {
+			OSMO_STRBUF_PRINTF(sb, " ");
+			OSMO_STRBUF_APPEND(sb, cell_ab_to_str_buf, &n->cell_id.ab);
+		}
+		break;
+	case NEIGHBOR_TYPE_UNSET:
+		OSMO_STRBUF_PRINTF(sb, "UNSET");
+		break;
+	default:
+		OSMO_STRBUF_PRINTF(sb, "INVALID");
+		break;
+	}
+	return sb.chars_needed;
+}
+
+char *neighbor_to_str_c(void *ctx, const struct neighbor *n)
+{
+	OSMO_NAME_C_IMPL(ctx, 64, "ERROR", neighbor_to_str_buf, n);
+}
+
+bool neighbor_same(const struct neighbor *a, const struct neighbor *b, bool check_cell_ab)
+{
+	if (a == b)
+		return true;
+	if (a->type != b->type)
+		return false;
+
+	switch (a->type) {
+	case NEIGHBOR_TYPE_BTS_NR:
+		return a->bts_nr == b->bts_nr;
+
+	case NEIGHBOR_TYPE_CELL_ID:
+		if (check_cell_ab
+		    && (a->cell_id.ab_present != b->cell_id.ab_present
+			|| !cell_ab_match(&a->cell_id.ab, &b->cell_id.ab, true)))
+			return false;
+		return gsm0808_cell_ids_match(&a->cell_id.id, &b->cell_id.id, true);
+	default:
+		return a->type == b->type;
+	}
 }
 
 /* Return true when the entry matches the search_for requirements.
  * If exact_match is false, a BSIC_ANY entry acts as wildcard to match any search_for on that ARFCN,
- * and a BSIC_ANY in search_for likewise returns any one entry that matches the ARFCN;
- * also a from_bts == NEIGHBOR_IDENT_KEY_ANY_BTS in either entry or search_for will match.
- * If exact_match is true, only identical bsic values and identical from_bts values return a match.
+ * and a BSIC_ANY in search_for likewise returns any one entry that matches the ARFCN.
+ * If exact_match is true, only identical bsic values return a match.
  * Note, typically wildcard BSICs are only in entry, e.g. the user configured list, and search_for
  * contains a specific BSIC, e.g. as received from a Measurement Report. */
-bool neighbor_ident_key_match(const struct neighbor_ident_key *entry,
-			      const struct neighbor_ident_key *search_for,
-			      bool exact_match)
+bool cell_ab_match(const struct cell_ab *entry,
+		   const struct cell_ab *search_for,
+		   bool exact_match)
 {
-	if (exact_match
-	    && entry->from_bts != search_for->from_bts)
-		return false;
-
-	if (search_for->from_bts != NEIGHBOR_IDENT_KEY_ANY_BTS
-	    && entry->from_bts != NEIGHBOR_IDENT_KEY_ANY_BTS
-	    && entry->from_bts != search_for->from_bts)
-		return false;
-
 	if (entry->arfcn != search_for->arfcn)
 		return false;
 
@@ -134,144 +278,13 @@
 	return entry->bsic == search_for->bsic;
 }
 
-static struct neighbor_ident *_neighbor_ident_get(const struct neighbor_ident_list *nil,
-						  const struct neighbor_ident_key *key,
-						  bool exact_match)
+bool cell_ab_valid(const struct cell_ab *cell)
 {
-	struct neighbor_ident *ni;
-	struct neighbor_ident *wildcard_match = NULL;
-
-	/* Do both exact-bsic and wildcard matching in the same iteration:
-	 * Any exact match returns immediately, while for a wildcard match we still go through all
-	 * remaining items in case an exact match exists. */
-	llist_for_each_entry(ni, &nil->list, entry) {
-		if (neighbor_ident_key_match(&ni->key, key, true))
-			return ni;
-		if (!exact_match) {
-			if (neighbor_ident_key_match(&ni->key, key, false))
-				wildcard_match = ni;
-		}
-	}
-	return wildcard_match;
-}
-
-static void _neighbor_ident_free(struct neighbor_ident *ni)
-{
-	llist_del(&ni->entry);
-	talloc_free(ni);
-}
-
-bool neighbor_ident_key_valid(const struct neighbor_ident_key *key)
-{
-	if (key->from_bts != NEIGHBOR_IDENT_KEY_ANY_BTS
-	    && (key->from_bts < 0 || key->from_bts > 255))
-		return false;
-
-	if (key->bsic != BSIC_ANY && key->bsic > 0x3f)
+	if (cell->bsic != BSIC_ANY && cell->bsic > 0x3f)
 		return false;
 	return true;
 }
 
-/*! Add Cell Identifiers to an ARFCN+BSIC entry.
- * Exactly one kind of identifier is allowed per ARFCN+BSIC entry, and any number of entries of that kind
- * may be added up to the capacity of gsm0808_cell_id_list2, by one or more calls to this function. To
- * replace an existing entry, first call neighbor_ident_del(nil, key).
- * \returns number of entries in the resulting identifier list, or negative on error:
- *   see gsm0808_cell_id_list_add() for the meaning of returned error codes;
- *   return -ENOMEM when the list is not initialized, -ERANGE when the BSIC value is too large. */
-int neighbor_ident_add(struct neighbor_ident_list *nil, const struct neighbor_ident_key *key,
-		       const struct gsm0808_cell_id_list2 *val)
-{
-	struct neighbor_ident *ni;
-	int rc;
-
-	if (!nil)
-		return -ENOMEM;
-
-	if (!neighbor_ident_key_valid(key))
-		return -ERANGE;
-
-	ni = _neighbor_ident_get(nil, key, true);
-	if (!ni) {
-		ni = talloc_zero(nil, struct neighbor_ident);
-		OSMO_ASSERT(ni);
-		*ni = (struct neighbor_ident){
-			.key = *key,
-			.val = *val,
-		};
-		llist_add_tail(&ni->entry, &nil->list);
-		return ni->val.id_list_len;
-	}
-
-	rc = gsm0808_cell_id_list_add(&ni->val, val);
-
-	if (rc < 0)
-		return rc;
-
-	return ni->val.id_list_len;
-}
-
-/*! Find cell identity for given BTS, ARFCN and BSIC, as previously added by neighbor_ident_add().
- */
-const struct gsm0808_cell_id_list2 *neighbor_ident_get(const struct neighbor_ident_list *nil,
-						       const struct neighbor_ident_key *key)
-{
-	struct neighbor_ident *ni;
-	if (!nil)
-		return NULL;
-	ni = _neighbor_ident_get(nil, key, false);
-	if (!ni)
-		return NULL;
-	return &ni->val;
-}
-
-bool neighbor_ident_del(struct neighbor_ident_list *nil, const struct neighbor_ident_key *key)
-{
-	struct neighbor_ident *ni;
-	if (!nil)
-		return false;
-	ni = _neighbor_ident_get(nil, key, true);
-	if (!ni)
-		return false;
-	_neighbor_ident_free(ni);
-	return true;
-}
-
-void neighbor_ident_clear(struct neighbor_ident_list *nil)
-{
-	struct neighbor_ident *ni;
-	while ((ni = llist_first_entry_or_null(&nil->list, struct neighbor_ident, entry)))
-		_neighbor_ident_free(ni);
-}
-
-/*! Iterate all neighbor_ident_list entries and call iter_cb for each.
- * If iter_cb returns false, the iteration is stopped. */
-void neighbor_ident_iter(const struct neighbor_ident_list *nil,
-			 bool (* iter_cb )(const struct neighbor_ident_key *key,
-					   const struct gsm0808_cell_id_list2 *val,
-					   void *cb_data),
-			 void *cb_data)
-{
-	struct neighbor_ident *ni, *ni_next;
-	if (!nil)
-		return;
-	llist_for_each_entry_safe(ni, ni_next, &nil->list, entry) {
-		if (!iter_cb(&ni->key, &ni->val, cb_data))
-			return;
-	}
-}
-
-struct neighbor_ident_key *bts_ident_key(const struct gsm_bts *bts)
-{
-	static struct neighbor_ident_key key;
-	key = (struct neighbor_ident_key){
-		.from_bts = NEIGHBOR_IDENT_KEY_ANY_BTS,
-		.arfcn = bts->c0->arfcn,
-		.bsic = bts->bsic,
-	};
-	return &key;
-}
-
 /* Neighbor Resolution CTRL iface */
 
 CTRL_CMD_DEFINE_RO(neighbor_resolve_cgi_ps_from_lac_ci, "neighbor_resolve_cgi_ps_from_lac_ci");
@@ -293,13 +306,12 @@
 {
 	struct gsm_network *net = (struct gsm_network *)data;
 	struct gsm_bts *bts_tmp, *bts_found = NULL;
-	const struct gsm0808_cell_id_list2 *tgt_cell_li = NULL;
 	char *tmp = NULL, *tok, *saveptr;
-	struct neighbor_ident_key ni;
+	struct cell_ab ab;
 	unsigned lac, cell_id;
 	struct osmo_cell_global_id_ps local_cgi_ps;
 	const struct osmo_cell_global_id_ps *cgi_ps = NULL;
-	struct gsm_bts_ref *neigh;
+	struct neighbor *neigh;
 
 	if (!cmd->variable)
 		goto fmt_err;
@@ -324,13 +336,11 @@
 
 	if (!(tok = strtok_r(NULL, ".", &saveptr)))
 		goto fmt_err;
-	ni.arfcn = atoi(tok);
+	ab.arfcn = atoi(tok);
 
 	if (!(tok = strtok_r(NULL, "\0", &saveptr)))
 		goto fmt_err;
-	ni.bsic = atoi(tok);
-
-	ni.from_bts = NEIGHBOR_IDENT_KEY_ANY_BTS;
+	ab.bsic = atoi(tok);
 
 	llist_for_each_entry(bts_tmp, &net->bts_list, list) {
 		if (bts_tmp->location_area_code != lac)
@@ -338,38 +348,37 @@
 		if (bts_tmp->cell_identity != cell_id)
 			continue;
 		bts_found = bts_tmp;
-		ni.from_bts = bts_tmp->nr;
 		break;
 	}
 
 	if (!bts_found)
 		goto notfound_err;
 
-	LOG_BTS(bts_found, DLINP, LOGL_DEBUG, "Resolving neigbhor arfcn=%u bsic=%u\n", ni.arfcn, ni.bsic);
+	LOG_BTS(bts_found, DLINP, LOGL_DEBUG, "Resolving neigbhor %s\n", cell_ab_to_str_c(OTC_SELECT, &ab));
 
-	if (!neighbor_ident_key_valid(&ni))
+	if (!cell_ab_valid(&ab))
 		goto fmt_err;
 
 	/* Is there a local BTS that matches the key? */
-	llist_for_each_entry(neigh, &bts_found->local_neighbors, entry) {
-		struct gsm_bts *neigh_bts = neigh->bts;
-		struct neighbor_ident_key *neigh_bts_key = bts_ident_key(neigh_bts);
-		neigh_bts_key->from_bts = ni.from_bts;
-		if (!neighbor_ident_key_match(neigh_bts_key, &ni, true))
-			continue;
-		if (gsm_bts_get_cgi_ps(neigh->bts, &local_cgi_ps) < 0)
-			continue; /* Not supporting GPRS */
-		cgi_ps = &local_cgi_ps;
-		break;
+	llist_for_each_entry(neigh, &bts_found->neighbors, entry) {
+		struct gsm_bts *neigh_bts = resolve_local_neighbor(bts_found, neigh);
+		if (neigh_bts) {
+			/* A local neighbor */
+			if (gsm_bts_get_cgi_ps(neigh_bts, &local_cgi_ps) < 0)
+				continue; /* Not supporting GPRS */
+			cgi_ps = &local_cgi_ps;
+			break;
+		} else if (neigh->type == NEIGHBOR_TYPE_CELL_ID
+			   && neigh->cell_id.id.id_discr == CELL_IDENT_WHOLE_GLOBAL_PS) {
+			/* A remote PS neighbor */
+			cgi_ps = &neigh->cell_id.id.id.global_ps;
+			break;
+		}
 	}
 
-	/* No local neighbor found, looking for remote neighbors */
-	if (!cgi_ps) {
-		tgt_cell_li = neighbor_ident_get(net->neighbor_bss_cells, &ni);
-		if (!tgt_cell_li || tgt_cell_li->id_discr != CELL_IDENT_WHOLE_GLOBAL_PS || tgt_cell_li->id_list_len < 1)
-			goto notfound_err;
-		cgi_ps = &tgt_cell_li->id_list[0].global_ps;
-	}
+	/* No neighbor found */
+	if (!cgi_ps)
+		goto notfound_err;
 
 	ctrl_cmd_reply_printf(cmd, "%s", osmo_cgi_ps_name(cgi_ps));
 	talloc_free(tmp);
diff --git a/src/osmo-bsc/neighbor_ident_vty.c b/src/osmo-bsc/neighbor_ident_vty.c
index 72c11b0..90c8790 100644
--- a/src/osmo-bsc/neighbor_ident_vty.c
+++ b/src/osmo-bsc/neighbor_ident_vty.c
@@ -35,43 +35,6 @@
 #include <osmocom/bsc/gsm_data.h>
 #include <osmocom/bsc/bts.h>
 
-static struct gsm_network *g_net = NULL;
-static struct neighbor_ident_list *g_neighbor_cells = NULL;
-
-/* Parse VTY parameters matching NEIGHBOR_IDENT_VTY_KEY_PARAMS. Pass a pointer so that argv[0] is the
- * ARFCN value followed by the BSIC keyword and value. vty *must* reference a BTS_NODE. */
-bool neighbor_ident_vty_parse_key_params(struct vty *vty, const char **argv,
-					 struct neighbor_ident_key *key)
-{
-	struct gsm_bts *bts = vty->index;
-
-	OSMO_ASSERT(vty->node == BTS_NODE);
-	OSMO_ASSERT(bts);
-
-	return neighbor_ident_bts_parse_key_params(vty, bts, argv, key);
-}
-
-/* same as neighbor_ident_vty_parse_key_params() but pass an explicit bts, so it works on any node. */
-bool neighbor_ident_bts_parse_key_params(struct vty *vty, struct gsm_bts *bts, const char **argv,
-					 struct neighbor_ident_key *key)
-{
-	const char *arfcn_str = argv[0];
-	const char *bsic_str = argv[1];
-
-	OSMO_ASSERT(bts);
-
-	*key = (struct neighbor_ident_key){
-		.from_bts = bts->nr,
-		.arfcn = atoi(arfcn_str),
-	};
-
-	if (!strcmp(bsic_str, "any"))
-		key->bsic = BSIC_ANY;
-	else
-		key->bsic = atoi(bsic_str);
-	return true;
-}
-
 #define NEIGHBOR_ADD_CMD "neighbor "
 #define NEIGHBOR_DEL_CMD "no neighbor "
 #define NEIGHBOR_DOC "Manage local and remote-BSS neighbor cells\n"
@@ -79,67 +42,51 @@
 #define NEIGHBOR_DEL_DOC NO_STR "Remove local or remote-BSS neighbor cell\n"
 
 #define LAC_PARAMS "lac <0-65535>"
+#define LAC_ARGC 1
 #define LAC_DOC "Neighbor cell by LAC\n" "LAC\n"
 
 #define LAC_CI_PARAMS "lac-ci <0-65535> <0-65535>"
+#define LAC_CI_ARGC 2
 #define LAC_CI_DOC "Neighbor cell by LAC and CI\n" "LAC\n" "CI\n"
 
 #define CGI_PARAMS "cgi <0-999> <0-999> <0-65535> <0-65535>"
+#define CGI_ARGC 4
 #define CGI_DOC "Neighbor cell by cgi\n" "MCC\n" "MNC\n" "LAC\n" "CI\n"
 
 #define CGI_PS_PARAMS "cgi-ps <0-999> <0-999> <0-65535> <0-255> <0-65535>"
+#define CGI_PS_ARGC 5
 #define CGI_PS_DOC "Neighbor cell by cgi (Packet Switched, with RAC)\n" "MCC\n" "MNC\n" "LAC\n" "RAC\n" "CI\n"
 
 #define LOCAL_BTS_PARAMS "bts <0-255>"
 #define LOCAL_BTS_DOC "Neighbor cell by local BTS number\n" "BTS number\n"
 
-static struct gsm_bts *neighbor_ident_vty_parse_bts_nr(struct vty *vty, const char **argv)
+static int neighbor_ident_vty_parse_lac(struct vty *vty, struct gsm0808_cell_id *cell_id, const char **argv)
 {
-	const char *bts_nr_str = argv[0];
-	struct gsm_bts *bts = gsm_bts_num(g_net, atoi(bts_nr_str));
-	if (!bts)
-		vty_out(vty, "%% No such BTS: nr = %s%s\n", bts_nr_str, VTY_NEWLINE);
-	return bts;
-}
-
-static struct gsm_bts *bts_by_cell_id(struct vty *vty, struct gsm0808_cell_id *cell_id)
-{
-	struct gsm_bts *bts = gsm_bts_by_cell_id(g_net, cell_id, 0);
-	if (!bts)
-		vty_out(vty, "%% No such BTS: %s%s\n", gsm0808_cell_id_name(cell_id), VTY_NEWLINE);
-	return bts;
-}
-
-static struct gsm0808_cell_id *neighbor_ident_vty_parse_lac(struct vty *vty, const char **argv)
-{
-	static struct gsm0808_cell_id cell_id;
-	cell_id = (struct gsm0808_cell_id){
+	*cell_id = (struct gsm0808_cell_id){
 		.id_discr = CELL_IDENT_LAC,
 		.id.lac = atoi(argv[0]),
 	};
-	return &cell_id;
+	return 0;
 }
 
-static struct gsm0808_cell_id *neighbor_ident_vty_parse_lac_ci(struct vty *vty, const char **argv)
+static int neighbor_ident_vty_parse_lac_ci(struct vty *vty, struct gsm0808_cell_id *cell_id, const char **argv)
 {
-	static struct gsm0808_cell_id cell_id;
-	cell_id = (struct gsm0808_cell_id){
+	*cell_id = (struct gsm0808_cell_id){
 		.id_discr = CELL_IDENT_LAC_AND_CI,
 		.id.lac_and_ci = {
 			.lac = atoi(argv[0]),
 			.ci = atoi(argv[1]),
 		},
 	};
-	return &cell_id;
+	return 0;
 }
 
-static struct gsm0808_cell_id *neighbor_ident_vty_parse_cgi(struct vty *vty, const char **argv)
+static int neighbor_ident_vty_parse_cgi(struct vty *vty, struct gsm0808_cell_id *cell_id, const char **argv)
 {
-	static struct gsm0808_cell_id cell_id;
-	cell_id = (struct gsm0808_cell_id){
+	*cell_id = (struct gsm0808_cell_id){
 		.id_discr = CELL_IDENT_WHOLE_GLOBAL,
 	};
-	struct osmo_cell_global_id *cgi = &cell_id.id.global;
+	struct osmo_cell_global_id *cgi = &cell_id->id.global;
 	const char *mcc = argv[0];
 	const char *mnc = argv[1];
 	const char *lac = argv[2];
@@ -147,25 +94,25 @@
 
 	if (osmo_mcc_from_str(mcc, &cgi->lai.plmn.mcc)) {
 		vty_out(vty, "%% Error decoding MCC: %s%s", mcc, VTY_NEWLINE);
-		return NULL;
+		return -1;
 	}
 
 	if (osmo_mnc_from_str(mnc, &cgi->lai.plmn.mnc, &cgi->lai.plmn.mnc_3_digits)) {
 		vty_out(vty, "%% Error decoding MNC: %s%s", mnc, VTY_NEWLINE);
-		return NULL;
+		return -1;
 	}
 
 	cgi->lai.lac = atoi(lac);
 	cgi->cell_identity = atoi(ci);
-	return &cell_id;
+	return 0;
 }
 
-static struct gsm0808_cell_id *neighbor_ident_vty_parse_cgi_ps(struct vty *vty, const char **argv)
+static int neighbor_ident_vty_parse_cgi_ps(struct vty *vty, struct gsm0808_cell_id *cell_id, const char **argv)
 {
-	static struct gsm0808_cell_id cell_id = {
+	*cell_id = (struct gsm0808_cell_id){
 		.id_discr = CELL_IDENT_WHOLE_GLOBAL_PS,
 	};
-	struct osmo_cell_global_id_ps *cgi_ps = &cell_id.id.global_ps;
+	struct osmo_cell_global_id_ps *cgi_ps = &cell_id->id.global_ps;
 	const char *mcc = argv[0];
 	const char *mnc = argv[1];
 	const char *lac = argv[2];
@@ -174,400 +121,351 @@
 
 	if (osmo_mcc_from_str(mcc, &cgi_ps->rai.lac.plmn.mcc)) {
 		vty_out(vty, "%% Error decoding MCC: %s%s", mcc, VTY_NEWLINE);
-		return NULL;
+		return -1;
 	}
 
 	if (osmo_mnc_from_str(mnc, &cgi_ps->rai.lac.plmn.mnc, &cgi_ps->rai.lac.plmn.mnc_3_digits)) {
 		vty_out(vty, "%% Error decoding MNC: %s%s", mnc, VTY_NEWLINE);
-		return NULL;
+		return -1;
 	}
 
 	cgi_ps->rai.lac.lac = atoi(lac);
 	cgi_ps->rai.rac = atoi(rac);
 	cgi_ps->cell_identity = atoi(ci);
-	return &cell_id;
+	return 0;
 }
 
-static int add_local_bts(struct vty *vty, struct gsm_bts *neigh)
+void neighbor_ident_vty_parse_arfcn_bsic(struct cell_ab *ab, const char **argv)
 {
-	int rc;
+	const char *arfcn_str = argv[0];
+	const char *bsic_str = argv[1];
+
+	*ab = (struct cell_ab){
+		.arfcn = atoi(arfcn_str),
+		.bsic = (!strcmp(bsic_str, "any")) ? BSIC_ANY : atoi(bsic_str),
+	};
+}
+
+static int add_neighbor(struct vty *vty, struct neighbor *n)
+{
 	struct gsm_bts *bts = vty->index;
-	if (vty->node != BTS_NODE) {
-		vty_out(vty, "%% Error: cannot add local BTS neighbor, not on BTS node%s",
-			VTY_NEWLINE);
-		return CMD_WARNING;
+	struct neighbor *neighbor;
+
+	OSMO_ASSERT((vty->node == BTS_NODE) && bts);
+
+	llist_for_each_entry(neighbor, &bts->neighbors, entry) {
+		/* Check against duplicates */
+		if (neighbor_same(neighbor, n, false)) {
+			/* Found a match on Cell ID or BTS number, without ARFCN+BSIC. If they are fully identical, ignore the
+			 * duplicate. If the ARFCN+BSIC part differs, it's an error. */
+			vty_out(vty, "%% BTS %u already had neighbor %s%s", bts->nr, neighbor_to_str_c(OTC_SELECT, neighbor),
+				VTY_NEWLINE);
+			if (!neighbor_same(neighbor, n, true)) {
+				vty_out(vty, "%% ERROR: duplicate Cell ID in neighbor config, with differing ARFCN+BSIC: %s%s",
+					neighbor_to_str_c(OTC_SELECT, n), VTY_NEWLINE);
+				return CMD_WARNING;
+			}
+			/* Exact same neighbor again, just ignore. */
+			return CMD_SUCCESS;
+		}
+
+		/* Allow only one cell ID per remote-BSS neighbor, see OS#3656 */
+		if (n->type == NEIGHBOR_TYPE_CELL_ID
+		    && n->cell_id.ab_present && neighbor->cell_id.ab_present
+		    && cell_ab_match(&n->cell_id.ab, &neighbor->cell_id.ab, true)) {
+			vty_out(vty, "%% Error: only one Cell Identifier entry is allowed per remote neighbor."
+				" Already have: BTS %u -> %s%s", bts->nr,
+				neighbor_to_str_c(OTC_SELECT, neighbor), VTY_NEWLINE);
+			return CMD_WARNING;
+		}
 	}
-	if (!bts) {
-		vty_out(vty, "%% Error: cannot add local BTS neighbor, no BTS on this node%s",
-			VTY_NEWLINE);
-		return CMD_WARNING;
-	}
-	if (!neigh) {
-		vty_out(vty, "%% Error: cannot add local BTS neighbor to BTS %u, no such neighbor BTS%s"
-			"%% (To add remote-BSS neighbors, pass full ARFCN and BSIC as well)%s",
-			bts->nr, VTY_NEWLINE, VTY_NEWLINE);
-		return CMD_WARNING;
-	}
-	rc = gsm_bts_local_neighbor_add(bts, neigh);
-	if (rc < 0) {
-		vty_out(vty, "%% Error: cannot add local BTS %u as neighbor to BTS %u: %s%s",
-			neigh->nr, bts->nr, strerror(-rc), VTY_NEWLINE);
-		return CMD_WARNING;
-	} else
-		vty_out(vty, "%% BTS %u %s local neighbor BTS %u with LAC %u CI %u and ARFCN %u BSIC %u%s",
-			bts->nr, rc? "now has" : "already had",
-			neigh->nr, neigh->location_area_code, neigh->cell_identity,
-			neigh->c0->arfcn, neigh->bsic, VTY_NEWLINE);
+
+	neighbor = talloc_zero(bts, struct neighbor);
+	*neighbor = *n;
+	llist_add_tail(&neighbor->entry, &bts->neighbors);
 	return CMD_SUCCESS;
 }
 
-static int del_local_bts(struct vty *vty, struct gsm_bts *neigh)
+static int del_neighbor(struct vty *vty, struct neighbor *n)
 {
-	int rc;
 	struct gsm_bts *bts = vty->index;
-	if (vty->node != BTS_NODE) {
-		vty_out(vty, "%% Error: cannot remove local BTS neighbor, not on BTS node%s",
-			VTY_NEWLINE);
-		return CMD_WARNING;
+	struct neighbor *neighbor;
+
+	OSMO_ASSERT((vty->node == BTS_NODE) && bts);
+
+	llist_for_each_entry(neighbor, &bts->neighbors, entry) {
+		if (neighbor->type != n->type)
+			continue;
+
+		switch (n->type) {
+		case NEIGHBOR_TYPE_BTS_NR:
+			if (neighbor->bts_nr == n->bts_nr)
+				break;
+			continue;
+
+		case NEIGHBOR_TYPE_CELL_ID:
+			if (gsm0808_cell_ids_match(&neighbor->cell_id.id, &n->cell_id.id, true))
+				break;
+			continue;
+		default:
+			continue;
+		}
+
+		llist_del(&neighbor->entry);
+		talloc_free(neighbor);
+		return CMD_SUCCESS;
 	}
-	if (!bts) {
-		vty_out(vty, "%% Error: cannot remove local BTS neighbor, no BTS on this node%s",
-			VTY_NEWLINE);
-		return CMD_WARNING;
+
+	vty_out(vty, "%% Error: no such neighbor on BTS %d: %s%s",
+		bts->nr, neighbor_to_str_c(OTC_SELECT, n), VTY_NEWLINE);
+	return CMD_WARNING;
+}
+
+static int del_neighbor_by_cell_ab(struct vty *vty, const struct cell_ab *cell_ab)
+{
+	struct gsm_bts *bts = vty->index;
+	struct neighbor *neighbor, *safe;
+	struct gsm_bts *neighbor_bts;
+	struct cell_ab neighbor_ab;
+	int count = 0;
+
+	OSMO_ASSERT((vty->node == BTS_NODE) && bts);
+
+	llist_for_each_entry_safe(neighbor, safe, &bts->neighbors, entry) {
+		switch (neighbor->type) {
+		case NEIGHBOR_TYPE_BTS_NR:
+			neighbor_bts = resolve_local_neighbor(bts, neighbor);
+			if (!neighbor_bts)
+				continue;
+			bts_cell_ab(&neighbor_ab, neighbor_bts);
+			if (!cell_ab_match(&neighbor_ab, cell_ab, false))
+				continue;
+			break;
+
+		case NEIGHBOR_TYPE_CELL_ID:
+			if (!neighbor->cell_id.ab_present)
+				continue;
+			if (!cell_ab_match(&neighbor->cell_id.ab, cell_ab, false))
+				continue;
+			break;
+		default:
+			continue;
+		}
+
+		llist_del(&neighbor->entry);
+		talloc_free(neighbor);
+		count++;
 	}
-	if (!neigh) {
-		vty_out(vty, "%% Error: cannot remove local BTS neighbor from BTS %u, no such neighbor BTS%s",
-			bts->nr, VTY_NEWLINE);
-		return CMD_WARNING;
-	}
-	rc = gsm_bts_local_neighbor_del(bts, neigh);
-	if (rc < 0) {
-		vty_out(vty, "%% Error: cannot remove local BTS %u neighbor from BTS %u: %s%s",
-			neigh->nr, bts->nr, strerror(-rc), VTY_NEWLINE);
-		return CMD_WARNING;
-	}
-	if (rc == 0)
-		vty_out(vty, "%% BTS %u is no neighbor of BTS %u%s",
-			neigh->nr, bts->nr, VTY_NEWLINE);
-	return CMD_SUCCESS;
+	if (count)
+		return CMD_SUCCESS;
+
+	vty_out(vty, "%% Cannot remove: no such neighbor on BTS %u: %s%s",
+		bts->nr, cell_ab_to_str_c(OTC_SELECT, cell_ab), VTY_NEWLINE);
+	return CMD_WARNING;
 }
 
 DEFUN(cfg_neighbor_add_bts_nr, cfg_neighbor_add_bts_nr_cmd,
 	NEIGHBOR_ADD_CMD LOCAL_BTS_PARAMS,
 	NEIGHBOR_ADD_DOC LOCAL_BTS_DOC)
 {
-	return add_local_bts(vty, neighbor_ident_vty_parse_bts_nr(vty, argv));
+	struct neighbor n = {
+		.type = NEIGHBOR_TYPE_BTS_NR,
+		.bts_nr = atoi(argv[0]),
+	};
+	return add_neighbor(vty, &n);
 }
 
 DEFUN(cfg_neighbor_add_lac, cfg_neighbor_add_lac_cmd,
 	NEIGHBOR_ADD_CMD LAC_PARAMS,
 	NEIGHBOR_ADD_DOC LAC_DOC)
 {
-	return add_local_bts(vty, bts_by_cell_id(vty, neighbor_ident_vty_parse_lac(vty, argv)));
+	struct neighbor n = {
+		.type = NEIGHBOR_TYPE_CELL_ID,
+	};
+	if (neighbor_ident_vty_parse_lac(vty, &n.cell_id.id, argv))
+		return CMD_WARNING;
+	return add_neighbor(vty, &n);
 }
 
 DEFUN(cfg_neighbor_add_lac_ci, cfg_neighbor_add_lac_ci_cmd,
 	NEIGHBOR_ADD_CMD LAC_CI_PARAMS,
 	NEIGHBOR_ADD_DOC LAC_CI_DOC)
 {
-	return add_local_bts(vty, bts_by_cell_id(vty, neighbor_ident_vty_parse_lac_ci(vty, argv)));
+	struct neighbor n = {
+		.type = NEIGHBOR_TYPE_CELL_ID,
+	};
+	if (neighbor_ident_vty_parse_lac_ci(vty, &n.cell_id.id, argv))
+		return CMD_WARNING;
+	return add_neighbor(vty, &n);
 }
 
 DEFUN(cfg_neighbor_add_cgi, cfg_neighbor_add_cgi_cmd,
 	NEIGHBOR_ADD_CMD CGI_PARAMS,
 	NEIGHBOR_ADD_DOC CGI_DOC)
 {
-	return add_local_bts(vty, bts_by_cell_id(vty, neighbor_ident_vty_parse_cgi(vty, argv)));
+	struct neighbor n = {
+		.type = NEIGHBOR_TYPE_CELL_ID,
+	};
+	if (neighbor_ident_vty_parse_cgi(vty, &n.cell_id.id, argv))
+		return CMD_WARNING;
+	return add_neighbor(vty, &n);
 }
 
 DEFUN(cfg_neighbor_add_cgi_ps, cfg_neighbor_add_cgi_ps_cmd,
 	NEIGHBOR_ADD_CMD CGI_PS_PARAMS,
 	NEIGHBOR_ADD_DOC CGI_PS_DOC)
 {
-	return add_local_bts(vty, bts_by_cell_id(vty, neighbor_ident_vty_parse_cgi_ps(vty, argv)));
-}
-
-bool neighbor_ident_key_matches_bts(const struct neighbor_ident_key *key, struct gsm_bts *bts)
-{
-	if (!bts || !key)
-		return false;
-	return key->arfcn == bts->c0->arfcn
-		&& (key->bsic == BSIC_ANY || key->bsic == bts->bsic);
-}
-
-static int add_remote_or_local_bts(struct vty *vty, const struct gsm0808_cell_id *cell_id,
-				   const struct neighbor_ident_key *key)
-{
-	int rc;
-	struct gsm_bts *local_neigh;
-	const struct gsm0808_cell_id_list2 *exists;
-	struct gsm0808_cell_id_list2 cil;
-	struct gsm_bts *bts = vty->index;
-
-	if (vty->node != BTS_NODE) {
-		vty_out(vty, "%% Error: cannot add BTS neighbor, not on BTS node%s",
-			VTY_NEWLINE);
-		return CMD_WARNING;
-	}
-	if (!bts) {
-		vty_out(vty, "%% Error: cannot add BTS neighbor, no BTS on this node%s",
-			VTY_NEWLINE);
-		return CMD_WARNING;
-	}
-
-	/* Is there a local BTS that matches the cell_id? */
-	local_neigh = gsm_bts_by_cell_id(g_net, cell_id, 0);
-	if (local_neigh) {
-		/* But do the advertised ARFCN and BSIC match as intended?
-		 * The user may omit ARFCN and BSIC for local cells, but if they are provided,
-		 * they need to match. */
-		if (!neighbor_ident_key_matches_bts(key, local_neigh)) {
-			vty_out(vty, "%% Error: bts %u: neighbor cell id %s indicates local BTS %u,"
-				" but it does not match ARFCN+BSIC %s%s",
-				bts->nr, gsm0808_cell_id_name(cell_id), local_neigh->nr,
-				neighbor_ident_key_name(key), VTY_NEWLINE);
-			/* TODO: error out fatally for non-interactive VTY? */
-			return CMD_WARNING;
-		}
-		return add_local_bts(vty, local_neigh);
-	}
-
-	/* Allow only one cell ID per remote-BSS neighbor, see OS#3656 */
-	exists = neighbor_ident_get(g_neighbor_cells, key);
-	if (exists) {
-		vty_out(vty, "%% Error: only one Cell Identifier entry is allowed per remote neighbor."
-			" Already have: %s -> %s%s", neighbor_ident_key_name(key),
-			gsm0808_cell_id_list_name(exists), VTY_NEWLINE);
-		return CMD_WARNING;
-	}
-
-	/* The cell_id is not known in this BSS, so it must be a remote cell. */
-	gsm0808_cell_id_to_list(&cil, cell_id);
-	rc = neighbor_ident_add(g_neighbor_cells, key, &cil);
-
-	if (rc < 0) {
-		const char *reason;
-		switch (rc) {
-		case -EINVAL:
-			reason = ": mismatching type between current and newly added cell identifier";
-			break;
-		case -ENOSPC:
-			reason = ": list is full";
-			break;
-		default:
-			reason = "";
-			break;
-		}
-
-		vty_out(vty, "%% Error adding neighbor-BSS Cell Identifier %s%s%s",
-			gsm0808_cell_id_name(cell_id), reason, VTY_NEWLINE);
-		return CMD_WARNING;
-	}
-
-	vty_out(vty, "%% %s now has %d remote BSS Cell Identifier List %s%s",
-		neighbor_ident_key_name(key), rc, rc == 1? "entry" : "entries", VTY_NEWLINE);
-	return CMD_SUCCESS;
-}
-
-static int del_by_key(struct vty *vty, const struct neighbor_ident_key *key)
-{
-	int removed = 0;
-	int rc;
-	struct gsm_bts *bts = vty->index;
-	struct gsm_bts_ref *neigh, *safe;
-
-	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;
-	}
-
-	/* Is there a local BTS that matches the key? */
-	llist_for_each_entry_safe(neigh, safe, &bts->local_neighbors, entry) {
-		struct gsm_bts *neigh_bts = neigh->bts;
-		if (!neighbor_ident_key_matches_bts(key, neigh->bts))
-			continue;
-		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;
-		}
-	}
-
-	if (neighbor_ident_del(g_neighbor_cells, key)) {
-		vty_out(vty, "%% Removed remote BSS neighbor %s%s",
-			neighbor_ident_key_name(key), VTY_NEWLINE);
-		removed ++;
-	}
-
-	if (!removed) {
-		vty_out(vty, "%% Cannot remove, no such neighbor: %s%s",
-			neighbor_ident_key_name(key), VTY_NEWLINE);
-		return CMD_WARNING;
-	}
-	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;
-}
-
-bool neighbor_ident_bts_entry_exists(uint8_t from_bts)
-{
-	struct nil_match_bts_data d = {
-		.bts_nr = from_bts,
+	struct neighbor n = {
+		.type = NEIGHBOR_TYPE_CELL_ID,
 	};
-	neighbor_ident_iter(g_neighbor_cells, nil_match_bts, &d);
-	return (bool)d.found;
+	if (neighbor_ident_vty_parse_cgi_ps(vty, &n.cell_id.id, argv))
+		return CMD_WARNING;
+	return add_neighbor(vty, &n);
 }
 
 static int neighbor_del_all(struct vty *vty)
 {
-	int rc;
-	int removed = 0;
 	struct gsm_bts *bts = vty->index;
-
+	struct neighbor *n;
 	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 neighbor 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)
+	if (llist_empty(&bts->neighbors)) {
 		vty_out(vty, "%% No neighbors configured%s", VTY_NEWLINE);
+		return CMD_SUCCESS;
+	}
+
+	/* Remove all local neighbors and print to VTY for the user to know what changed */
+	while ((n = llist_first_entry_or_null(&bts->neighbors, struct neighbor, entry))) {
+		vty_out(vty, "%% Removed neighbor: BTS %u to %s%s",
+			bts->nr, neighbor_to_str_c(OTC_SELECT, n), VTY_NEWLINE);
+		llist_del(&n->entry);
+		talloc_free(n);
+	}
 	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)
+	NEIGHBOR_ADD_CMD LAC_PARAMS " " CELL_AB_VTY_PARAMS,
+	NEIGHBOR_ADD_DOC LAC_DOC CELL_AB_VTY_DOC)
 {
-	struct neighbor_ident_key nik;
-	struct gsm0808_cell_id *cell_id = neighbor_ident_vty_parse_lac(vty, argv);
-	if (!cell_id)
+	struct neighbor n = {
+		.type = NEIGHBOR_TYPE_CELL_ID,
+		.cell_id.ab_present = true,
+	};
+	if (neighbor_ident_vty_parse_lac(vty, &n.cell_id.id, argv))
 		return CMD_WARNING;
-	if (!neighbor_ident_vty_parse_key_params(vty, argv + 1, &nik))
-		return CMD_WARNING;
-	return add_remote_or_local_bts(vty, cell_id, &nik);
+	neighbor_ident_vty_parse_arfcn_bsic(&n.cell_id.ab, argv + LAC_ARGC);
+	return add_neighbor(vty, &n);
 }
 
 DEFUN(cfg_neighbor_add_lac_ci_arfcn_bsic, cfg_neighbor_add_lac_ci_arfcn_bsic_cmd,
-	NEIGHBOR_ADD_CMD LAC_CI_PARAMS " " NEIGHBOR_IDENT_VTY_KEY_PARAMS,
-	NEIGHBOR_ADD_DOC LAC_CI_DOC NEIGHBOR_IDENT_VTY_KEY_DOC)
+	NEIGHBOR_ADD_CMD LAC_CI_PARAMS " " CELL_AB_VTY_PARAMS,
+	NEIGHBOR_ADD_DOC LAC_CI_DOC CELL_AB_VTY_DOC)
 {
-	struct neighbor_ident_key nik;
-	struct gsm0808_cell_id *cell_id = neighbor_ident_vty_parse_lac_ci(vty, argv);
-	if (!cell_id)
+	struct neighbor n = {
+		.type = NEIGHBOR_TYPE_CELL_ID,
+		.cell_id.ab_present = true,
+	};
+	if (neighbor_ident_vty_parse_lac_ci(vty, &n.cell_id.id, argv))
 		return CMD_WARNING;
-	if (!neighbor_ident_vty_parse_key_params(vty, argv + 2, &nik))
-		return CMD_WARNING;
-	return add_remote_or_local_bts(vty, cell_id, &nik);
+	neighbor_ident_vty_parse_arfcn_bsic(&n.cell_id.ab, argv + LAC_CI_ARGC);
+	return add_neighbor(vty, &n);
 }
 
 DEFUN(cfg_neighbor_add_cgi_arfcn_bsic, cfg_neighbor_add_cgi_arfcn_bsic_cmd,
-	NEIGHBOR_ADD_CMD CGI_PARAMS " " NEIGHBOR_IDENT_VTY_KEY_PARAMS,
-	NEIGHBOR_ADD_DOC CGI_DOC NEIGHBOR_IDENT_VTY_KEY_DOC)
+	NEIGHBOR_ADD_CMD CGI_PARAMS " " CELL_AB_VTY_PARAMS,
+	NEIGHBOR_ADD_DOC CGI_DOC CELL_AB_VTY_DOC)
 {
-	struct neighbor_ident_key nik;
-	struct gsm0808_cell_id *cell_id = neighbor_ident_vty_parse_cgi(vty, argv);
-	if (!cell_id)
+	struct neighbor n = {
+		.type = NEIGHBOR_TYPE_CELL_ID,
+		.cell_id.ab_present = true,
+	};
+	if (neighbor_ident_vty_parse_cgi(vty, &n.cell_id.id, argv))
 		return CMD_WARNING;
-	if (!neighbor_ident_vty_parse_key_params(vty, argv + 4, &nik))
-		return CMD_WARNING;
-	return add_remote_or_local_bts(vty, cell_id, &nik);
+	neighbor_ident_vty_parse_arfcn_bsic(&n.cell_id.ab, argv + CGI_ARGC);
+	return add_neighbor(vty, &n);
 }
 
 DEFUN(cfg_neighbor_add_cgi_ps_arfcn_bsic, cfg_neighbor_add_cgi_ps_arfcn_bsic_cmd,
-	NEIGHBOR_ADD_CMD CGI_PS_PARAMS " " NEIGHBOR_IDENT_VTY_KEY_PARAMS,
-	NEIGHBOR_ADD_DOC CGI_PS_DOC NEIGHBOR_IDENT_VTY_KEY_DOC)
+	NEIGHBOR_ADD_CMD CGI_PS_PARAMS " " CELL_AB_VTY_PARAMS,
+	NEIGHBOR_ADD_DOC CGI_PS_DOC CELL_AB_VTY_DOC)
 {
-	struct neighbor_ident_key nik;
-	struct gsm0808_cell_id *cell_id = neighbor_ident_vty_parse_cgi_ps(vty, argv);
-	if (!cell_id)
+	struct neighbor n = {
+		.type = NEIGHBOR_TYPE_CELL_ID,
+		.cell_id.ab_present = true,
+	};
+	if (neighbor_ident_vty_parse_cgi_ps(vty, &n.cell_id.id, argv))
 		return CMD_WARNING;
-	if (!neighbor_ident_vty_parse_key_params(vty, argv + 5, &nik))
-		return CMD_WARNING;
-	return add_remote_or_local_bts(vty, cell_id, &nik);
+	neighbor_ident_vty_parse_arfcn_bsic(&n.cell_id.ab, argv + CGI_PS_ARGC);
+	return add_neighbor(vty, &n);
 }
 
 DEFUN(cfg_neighbor_del_bts_nr, cfg_neighbor_del_bts_nr_cmd,
 	NEIGHBOR_DEL_CMD LOCAL_BTS_PARAMS,
 	NEIGHBOR_DEL_DOC LOCAL_BTS_DOC)
 {
-	return del_local_bts(vty, neighbor_ident_vty_parse_bts_nr(vty, argv));
+	struct neighbor n = {
+		.type = NEIGHBOR_TYPE_BTS_NR,
+		.bts_nr = atoi(argv[0]),
+	};
+	return del_neighbor(vty, &n);
+}
+
+DEFUN(cfg_neighbor_del_lac, cfg_neighbor_del_lac_cmd,
+	NEIGHBOR_DEL_CMD LAC_PARAMS,
+	NEIGHBOR_DEL_DOC LAC_DOC)
+{
+	struct neighbor n = {
+		.type = NEIGHBOR_TYPE_CELL_ID,
+	};
+	if (neighbor_ident_vty_parse_lac(vty, &n.cell_id.id, argv))
+		return CMD_WARNING;
+	return del_neighbor(vty, &n);
+}
+
+DEFUN(cfg_neighbor_del_lac_ci, cfg_neighbor_del_lac_ci_cmd,
+	NEIGHBOR_DEL_CMD LAC_CI_PARAMS,
+	NEIGHBOR_DEL_DOC LAC_CI_DOC)
+{
+	struct neighbor n = {
+		.type = NEIGHBOR_TYPE_CELL_ID,
+	};
+	if (neighbor_ident_vty_parse_lac_ci(vty, &n.cell_id.id, argv))
+		return CMD_WARNING;
+	return del_neighbor(vty, &n);
+}
+
+DEFUN(cfg_neighbor_del_cgi, cfg_neighbor_del_cgi_cmd,
+	NEIGHBOR_DEL_CMD CGI_PARAMS,
+	NEIGHBOR_DEL_DOC CGI_DOC)
+{
+	struct neighbor n = {
+		.type = NEIGHBOR_TYPE_CELL_ID,
+	};
+	if (neighbor_ident_vty_parse_cgi(vty, &n.cell_id.id, argv))
+		return CMD_WARNING;
+	return del_neighbor(vty, &n);
+}
+
+DEFUN(cfg_neighbor_del_cgi_ps, cfg_neighbor_del_cgi_ps_cmd,
+	NEIGHBOR_DEL_CMD CGI_PS_PARAMS,
+	NEIGHBOR_DEL_DOC CGI_PS_DOC)
+{
+	struct neighbor n = {
+		.type = NEIGHBOR_TYPE_CELL_ID,
+	};
+	if (neighbor_ident_vty_parse_cgi_ps(vty, &n.cell_id.id, argv))
+		return CMD_WARNING;
+	return del_neighbor(vty, &n);
 }
 
 DEFUN(cfg_neighbor_del_arfcn_bsic, cfg_neighbor_del_arfcn_bsic_cmd,
-	NEIGHBOR_DEL_CMD NEIGHBOR_IDENT_VTY_KEY_PARAMS,
-	NEIGHBOR_DEL_DOC NEIGHBOR_IDENT_VTY_KEY_DOC)
+	NEIGHBOR_DEL_CMD CELL_AB_VTY_PARAMS,
+	NEIGHBOR_DEL_DOC CELL_AB_VTY_DOC)
 {
-	struct neighbor_ident_key key;
-
-	if (!neighbor_ident_vty_parse_key_params(vty, argv, &key))
-		return CMD_WARNING;
-
-	return del_by_key(vty, &key);
+	struct cell_ab ab;
+	neighbor_ident_vty_parse_arfcn_bsic(&ab, argv);
+	return del_neighbor_by_cell_ab(vty, &ab);
 }
 
 DEFUN(cfg_neighbor_del_all, cfg_neighbor_del_all_cmd,
@@ -584,133 +482,98 @@
 	NEIGHBOR_DOC "Bind Neighbor Resolution Service (CTRL interface) to given ip and port\n"
 	IP_STR IPV6_STR "Port to bind the service to [defaults to 4248 if not provided]\n")
 {
-	osmo_talloc_replace_string(g_net, &g_net->neigh_ctrl.addr, argv[0]);
+	osmo_talloc_replace_string(bsc_gsmnet, &bsc_gsmnet->neigh_ctrl.addr, argv[0]);
 	if (argc > 1)
-		g_net->neigh_ctrl.port = atoi(argv[1]);
+		bsc_gsmnet->neigh_ctrl.port = atoi(argv[1]);
 	else
-		g_net->neigh_ctrl.port = OSMO_CTRL_PORT_BSC_NEIGH;
+		bsc_gsmnet->neigh_ctrl.port = OSMO_CTRL_PORT_BSC_NEIGH;
 	return CMD_SUCCESS;
 }
 
 void neighbor_ident_vty_write_network(struct vty *vty, const char *indent)
 {
-	if (g_net->neigh_ctrl.addr)
-		vty_out(vty, "%sneighbor-resolution bind %s %" PRIu16 "%s", indent, g_net->neigh_ctrl.addr,
-			g_net->neigh_ctrl.port, VTY_NEWLINE);
+	if (bsc_gsmnet->neigh_ctrl.addr)
+		vty_out(vty, "%sneighbor-resolution bind %s %" PRIu16 "%s", indent, bsc_gsmnet->neigh_ctrl.addr,
+			bsc_gsmnet->neigh_ctrl.port, VTY_NEWLINE);
 }
 
-
-struct write_neighbor_ident_entry_data {
-	struct vty *vty;
-	const char *indent;
-	struct gsm_bts *bts;
-};
-
-static bool write_neighbor_ident_list(const struct neighbor_ident_key *key,
-				      const struct gsm0808_cell_id_list2 *val,
-				      void *cb_data)
+static int vty_write_cell_id_u(struct vty *vty, enum CELL_IDENT id_discr, const union gsm0808_cell_id_u *cell_id_u)
 {
-	struct write_neighbor_ident_entry_data *d = cb_data;
-	struct vty *vty = d->vty;
-	int i;
+	const struct osmo_cell_global_id *cgi;
+	const struct osmo_cell_global_id_ps *cgi_ps;
 
-	if (d->bts) {
-		if (d->bts->nr != key->from_bts)
-			return true;
-	} else if (key->from_bts != NEIGHBOR_IDENT_KEY_ANY_BTS)
-			return true;
-
-#define NEIGH_BSS_WRITE(fmt, args...) do { \
-		vty_out(vty, "%sneighbor " fmt " arfcn %u ", d->indent, ## args, key->arfcn); \
-		if (key->bsic == BSIC_ANY) \
-			vty_out(vty, "bsic any"); \
-		else \
-			vty_out(vty, "bsic %u", key->bsic & 0x3f); \
-		vty_out(vty, "%s", VTY_NEWLINE); \
-	} while(0)
-
-	switch (val->id_discr) {
+	switch (id_discr) {
 	case CELL_IDENT_LAC:
-		for (i = 0; i < val->id_list_len; i++) {
-			NEIGH_BSS_WRITE("lac %u", val->id_list[i].lac);
-		}
+		vty_out(vty, "lac %u", cell_id_u->lac);
 		break;
 	case CELL_IDENT_LAC_AND_CI:
-		for (i = 0; i < val->id_list_len; i++) {
-			NEIGH_BSS_WRITE("lac-ci %u %u",
-					val->id_list[i].lac_and_ci.lac,
-					val->id_list[i].lac_and_ci.ci);
-		}
+		vty_out(vty, "lac-ci %u %u", cell_id_u->lac_and_ci.lac, cell_id_u->lac_and_ci.ci);
 		break;
 	case CELL_IDENT_WHOLE_GLOBAL:
-		for (i = 0; i < val->id_list_len; i++) {
-			const struct osmo_cell_global_id *cgi = &val->id_list[i].global;
-			NEIGH_BSS_WRITE("cgi %s %s %u %u",
-					osmo_mcc_name(cgi->lai.plmn.mcc),
-					osmo_mnc_name(cgi->lai.plmn.mnc, cgi->lai.plmn.mnc_3_digits),
-					cgi->lai.lac, cgi->cell_identity);
-		}
+		cgi = &cell_id_u->global;
+		vty_out(vty, "cgi %s %s %u %u",
+			osmo_mcc_name(cgi->lai.plmn.mcc),
+			osmo_mnc_name(cgi->lai.plmn.mnc, cgi->lai.plmn.mnc_3_digits),
+			cgi->lai.lac, cgi->cell_identity);
 		break;
 	case CELL_IDENT_WHOLE_GLOBAL_PS:
-		for (i = 0; i < val->id_list_len; i++) {
-			const struct osmo_cell_global_id_ps *cgi_ps = &val->id_list[i].global_ps;
-			NEIGH_BSS_WRITE("cgi-ps %s %s %u %u %u",
-					osmo_mcc_name(cgi_ps->rai.lac.plmn.mcc),
-					osmo_mnc_name(cgi_ps->rai.lac.plmn.mnc, cgi_ps->rai.lac.plmn.mnc_3_digits),
-					cgi_ps->rai.lac.lac, cgi_ps->rai.rac,
-					cgi_ps->cell_identity);
-		}
+		cgi_ps = &cell_id_u->global_ps;
+		vty_out(vty, "cgi-ps %s %s %u %u %u",
+			osmo_mcc_name(cgi_ps->rai.lac.plmn.mcc),
+			osmo_mnc_name(cgi_ps->rai.lac.plmn.mnc, cgi_ps->rai.lac.plmn.mnc_3_digits),
+			cgi_ps->rai.lac.lac, cgi_ps->rai.rac,
+			cgi_ps->cell_identity);
 		break;
 	default:
-		vty_out(vty, "%% Unsupported Cell Identity%s", VTY_NEWLINE);
+		return -1;
 	}
-#undef NEIGH_BSS_WRITE
-
-	return true;
-}
-
-void neighbor_ident_vty_write_remote_bss(struct vty *vty, const char *indent, struct gsm_bts *bts)
-{
-	struct write_neighbor_ident_entry_data d = {
-		.vty = vty,
-		.indent = indent,
-		.bts = bts,
-	};
-
-	neighbor_ident_iter(g_neighbor_cells, write_neighbor_ident_list, &d);
-}
-
-void neighbor_ident_vty_write_local_neighbors(struct vty *vty, const char *indent, struct gsm_bts *bts)
-{
-	struct gsm_bts_ref *neigh;
-
-	llist_for_each_entry(neigh, &bts->local_neighbors, entry) {
-		vty_out(vty, "%sneighbor bts %u%s", indent, neigh->bts->nr, VTY_NEWLINE);
-	}
+	return 0;
 }
 
 void neighbor_ident_vty_write_bts(struct vty *vty, const char *indent, struct gsm_bts *bts)
 {
-	neighbor_ident_vty_write_local_neighbors(vty, indent, bts);
-	neighbor_ident_vty_write_remote_bss(vty, indent, bts);
+	struct neighbor *n;
+
+	llist_for_each_entry(n, &bts->neighbors, entry) {
+		switch (n->type) {
+		case NEIGHBOR_TYPE_BTS_NR:
+			vty_out(vty, "%sneighbor bts %u%s", indent, n->bts_nr, VTY_NEWLINE);
+			break;
+
+		case NEIGHBOR_TYPE_CELL_ID:
+			vty_out(vty, "%sneighbor ", indent);
+			if (vty_write_cell_id_u(vty, n->cell_id.id.id_discr, &n->cell_id.id.id)) {
+				vty_out(vty, "[Unsupported Cell Identity]%s", VTY_NEWLINE);
+				continue;
+			}
+
+			if (n->cell_id.ab_present) {
+				vty_out(vty, " arfcn %u ", n->cell_id.ab.arfcn);
+				if (n->cell_id.ab.bsic == BSIC_ANY)
+					vty_out(vty, "bsic any");
+				else
+					vty_out(vty, "bsic %u", n->cell_id.ab.bsic & 0x3f);
+			}
+			vty_out(vty, "%s", VTY_NEWLINE);
+			break;
+
+		default:
+			/* Ignore anything invalid */
+			break;
+		}
+	}
 }
 
 DEFUN(show_bts_neighbor, show_bts_neighbor_cmd,
-      "show bts <0-255> neighbor " NEIGHBOR_IDENT_VTY_KEY_PARAMS,
+      "show bts <0-255> neighbor " CELL_AB_VTY_PARAMS,
       SHOW_STR "Display information about a BTS\n" "BTS number\n"
       "Query which cell would be the target for this neighbor ARFCN+BSIC\n"
-      NEIGHBOR_IDENT_VTY_KEY_DOC)
+      CELL_AB_VTY_DOC)
 {
-	int found = 0;
-	struct neighbor_ident_key key;
-	struct gsm_bts_ref *neigh;
-	const struct gsm0808_cell_id_list2 *res;
-	struct gsm_bts *bts = gsm_bts_num(g_net, atoi(argv[0]));
-	struct write_neighbor_ident_entry_data d = {
-		.vty = vty,
-		.indent = "% ",
-		.bts = bts,
-	};
+	struct cell_ab ab;
+	struct gsm_bts *local_neighbor;
+	struct gsm0808_cell_id_list2 remote_neighbors;
+	struct gsm_bts *bts = gsm_bts_num(bsc_gsmnet, atoi(argv[0]));
 
 	if (!bts) {
 		vty_out(vty, "%% Error: cannot find BTS '%s'%s", argv[0],
@@ -718,35 +581,41 @@
 		return CMD_WARNING;
 	}
 
-	if (!neighbor_ident_bts_parse_key_params(vty, bts, &argv[1], &key))
+	neighbor_ident_vty_parse_arfcn_bsic(&ab, &argv[1]);
+
+	switch (resolve_neighbors(&local_neighbor, &remote_neighbors, bts, &ab, true)) {
+	case 0:
+		break;
+	case -ENOENT:
+		vty_out(vty, "%% No entry for BTS %u -> %s%s", bts->nr, cell_ab_to_str_c(OTC_SELECT, &ab), VTY_NEWLINE);
 		return CMD_WARNING;
-
-	/* Is there a local BTS that matches the key? */
-	llist_for_each_entry(neigh, &bts->local_neighbors, entry) {
-		if (!neighbor_ident_key_matches_bts(&key, neigh->bts))
-			continue;
-		vty_out(vty, "%% %s resolves to local BTS %u lac-ci %u %u%s",
-			neighbor_ident_key_name(&key), neigh->bts->nr, neigh->bts->location_area_code,
-			neigh->bts->cell_identity, VTY_NEWLINE);
-		found++;
+	default:
+		vty_out(vty, "%% Error while resolving neighbors BTS %u -> %s%s", bts->nr,
+			cell_ab_to_str_c(OTC_SELECT, &ab), VTY_NEWLINE);
+		return CMD_WARNING;
 	}
 
-	res = neighbor_ident_get(g_neighbor_cells, &key);
-	if (res) {
-		write_neighbor_ident_list(&key, res, &d);
-		found++;
+	/* From successful rc == 0, there is exactly either a local_neighbor or a nonempty remote_neighbors list. */
+
+	vty_out(vty, "%% BTS %u -> %s resolves to", bts->nr, cell_ab_to_str_c(OTC_SELECT, &ab));
+	if (local_neighbor) {
+		vty_out(vty, " local BTS %u lac-ci %u %u%s",
+			local_neighbor->nr,
+			local_neighbor->location_area_code,
+			local_neighbor->cell_identity, VTY_NEWLINE);
 	}
 
-	if (!found)
-		vty_out(vty, "%% No entry for %s%s", neighbor_ident_key_name(&key), VTY_NEWLINE);
+	if (remote_neighbors.id_list_len) {
+		vty_out(vty, " remote-BSS neighbors: %s%s",
+			gsm0808_cell_id_list_name_c(OTC_SELECT, &remote_neighbors),
+			VTY_NEWLINE);
+	}
 
 	return CMD_SUCCESS;
 }
 
-void neighbor_ident_vty_init(struct gsm_network *net, struct neighbor_ident_list *nil)
+void neighbor_ident_vty_init()
 {
-	g_net = net;
-	g_neighbor_cells = nil;
 	install_element(GSMNET_NODE, &cfg_neighbor_bind_cmd);
 
 	install_element(BTS_NODE, &cfg_neighbor_add_bts_nr_cmd);
@@ -759,6 +628,10 @@
 	install_element(BTS_NODE, &cfg_neighbor_add_cgi_arfcn_bsic_cmd);
 	install_element(BTS_NODE, &cfg_neighbor_add_cgi_ps_arfcn_bsic_cmd);
 	install_element(BTS_NODE, &cfg_neighbor_del_bts_nr_cmd);
+	install_element(BTS_NODE, &cfg_neighbor_del_lac_cmd);
+	install_element(BTS_NODE, &cfg_neighbor_del_lac_ci_cmd);
+	install_element(BTS_NODE, &cfg_neighbor_del_cgi_cmd);
+	install_element(BTS_NODE, &cfg_neighbor_del_cgi_ps_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/src/osmo-bsc/system_information.c b/src/osmo-bsc/system_information.c
index fae1355..20d033d 100644
--- a/src/osmo-bsc/system_information.c
+++ b/src/osmo-bsc/system_information.c
@@ -602,25 +602,6 @@
 	return bitvec2freq_list(chan_list, bv, bts, false, false);
 }
 
-struct generate_bcch_chan_list__ni_iter_data {
-	struct gsm_bts *bts;
-	struct bitvec *bv;
-};
-
-static bool generate_bcch_chan_list__ni_iter_cb(const struct neighbor_ident_key *key,
-						const struct gsm0808_cell_id_list2 *val,
-						void *cb_data)
-{
-	struct generate_bcch_chan_list__ni_iter_data *data = cb_data;
-
-	if (key->from_bts != NEIGHBOR_IDENT_KEY_ANY_BTS
-	    && key->from_bts != data->bts->nr)
-		return true;
-
-	bitvec_set_bit_pos(data->bv, key->arfcn, 1);
-	return true;
-}
-
 /*! generate a cell channel list as per Section 10.5.2.22 of 04.08
  *  \param[out] chan_list caller-provided output buffer
  *  \param[in] bts BTS descriptor used for input data
@@ -646,7 +627,7 @@
 		/* Zero-initialize the bit-vector */
 		memset(bv->data, 0, bv->data_len);
 
-		if (llist_empty(&bts->local_neighbors)) {
+		if (llist_empty(&bts->neighbors)) {
 			/* There are no explicit neighbors, assume all BTS are. */
 			llist_for_each_entry(cur_bts, &bts->network->bts_list, list) {
 				if (cur_bts == bts)
@@ -655,21 +636,21 @@
 			}
 		} else {
 			/* Only add explicit neighbor cells */
-			struct gsm_bts_ref *neigh;
-			llist_for_each_entry(neigh, &bts->local_neighbors, entry) {
-				bitvec_set_bit_pos(bv, neigh->bts->c0->arfcn, 1);
+			struct neighbor *n;
+			llist_for_each_entry(n, &bts->neighbors, entry) {
+				if (n->type == NEIGHBOR_TYPE_CELL_ID && n->cell_id.ab_present) {
+					bitvec_set_bit_pos(bv, n->cell_id.ab.arfcn, 1);
+				} else {
+					struct gsm_bts *neigh_bts = resolve_local_neighbor(bts, n);
+					if (neigh_bts)
+						bitvec_set_bit_pos(bv, n->cell_id.ab.arfcn, 1);
+					else
+						LOGP(DHO, LOGL_ERROR,
+						     "Neither local nor remote neighbor: BTS %u -> %s\n",
+						     bts->nr, neighbor_to_str_c(OTC_SELECT, n));
+				}
 			}
 		}
-
-		/* Also add neighboring BSS cells' ARFCNs */
-		{
-			struct generate_bcch_chan_list__ni_iter_data data = {
-				.bv = bv,
-				.bts = bts,
-			};
-			neighbor_ident_iter(bts->network->neighbor_bss_cells,
-					    generate_bcch_chan_list__ni_iter_cb, &data);
-		}
 	}
 
 	/* then we generate a GSM 04.08 frequency list from the bitvec */
diff --git a/tests/bsc/bsc_test.c b/tests/bsc/bsc_test.c
index 0ed504b..dbb547e 100644
--- a/tests/bsc/bsc_test.c
+++ b/tests/bsc/bsc_test.c
@@ -39,6 +39,7 @@
 #include <search.h>
 
 void *ctx = NULL;
+struct gsm_network *bsc_gsmnet = NULL;
 
 enum test {
 	TEST_SCAN_TO_BTS,
@@ -125,6 +126,7 @@
 	struct gsm_network *net = gsm_network_init(ctx);
 	struct gsm_subscriber_connection *conn = talloc_zero(net, struct gsm_subscriber_connection);
 
+	bsc_gsmnet = net;
 	conn->network = net;
 
 	/* start testing with proper messages */
@@ -176,6 +178,7 @@
 	}
 
 	talloc_free(net);
+	bsc_gsmnet = NULL;
 }
 
 static const struct log_info_cat log_categories[] = {
diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c
index c23b262..7545381 100644
--- a/tests/gsm0408/gsm0408_test.c
+++ b/tests/gsm0408/gsm0408_test.c
@@ -59,6 +59,7 @@
 	}
 
 
+struct gsm_network *bsc_gsmnet = NULL;
 
 static inline void gen(struct gsm_bts *bts, const char *s)
 {
@@ -899,6 +900,7 @@
 		printf("Network init failure.\n");
 		return EXIT_FAILURE;
 	}
+	bsc_gsmnet = net;
 
 	test_si_range_helpers();
 	test_arfcn_filter();
diff --git a/tests/neighbor_ident.vty b/tests/neighbor_ident.vty
index 93571b7..b1429d8 100644
--- a/tests/neighbor_ident.vty
+++ b/tests/neighbor_ident.vty
@@ -94,6 +94,10 @@
   neighbor cgi <0-999> <0-999> <0-65535> <0-65535> arfcn <0-1023> bsic (<0-63>|any)
   neighbor cgi-ps <0-999> <0-999> <0-65535> <0-255> <0-65535> arfcn <0-1023> bsic (<0-63>|any)
   no neighbor bts <0-255>
+  no neighbor lac <0-65535>
+  no neighbor lac-ci <0-65535> <0-65535>
+  no neighbor cgi <0-999> <0-999> <0-65535> <0-65535>
+  no neighbor cgi-ps <0-999> <0-999> <0-65535> <0-255> <0-65535>
   no neighbor arfcn <0-1023> bsic (<0-63>|any)
   no neighbors
 ...
@@ -173,8 +177,12 @@
   neighbor  Remove local or remote-BSS neighbor cell
 
 OsmoBSC(config-net-bts)# no neighbor ?
-  bts    Neighbor cell by local BTS number
-  arfcn  ARFCN of neighbor cell
+  bts     Neighbor cell by local BTS number
+  lac     Neighbor cell by LAC
+  lac-ci  Neighbor cell by LAC and CI
+  cgi     Neighbor cell by cgi
+  cgi-ps  Neighbor cell by cgi (Packet Switched, with RAC)
+  arfcn   ARFCN of neighbor cell
 
 OsmoBSC(config-net-bts)# no neighbor bts ?
   <0-255>  BTS number
@@ -199,52 +207,64 @@
 % Unknown command.
 
 OsmoBSC(config-net-bts)# neighbor bts 0
-% Error: cannot add local BTS 0 as neighbor to BTS 0: Invalid argument
+OsmoBSC(config-net-bts)# no neighbor bts 0
 
 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)# no neighbor bts 1
+% Error: no such neighbor on BTS 0: BTS 1
 
+OsmoBSC(config-net-bts)# ### Add non-existing BTS nr -- is allowed, checking plausibility at runtime
+OsmoBSC(config-net-bts)# neighbor bts 123
+
+OsmoBSC(config-net-bts)# ### A neighbor by LAC and by BTS number are two distinct neighbor entries, resolved at runtime
 OsmoBSC(config-net-bts)# neighbor lac 22
-% BTS 0 now has local neighbor BTS 2 with LAC 22 CI 65535 and ARFCN 42 BSIC 12
 OsmoBSC(config-net-bts)# no neighbor bts 2
+% Error: no such neighbor on BTS 0: BTS 2
+OsmoBSC(config-net-bts)# no neighbor lac 22
+
 OsmoBSC(config-net-bts)# neighbor cgi 901 70 22 65535
-% BTS 0 now has local neighbor BTS 2 with LAC 22 CI 65535 and ARFCN 42 BSIC 12
 
 OsmoBSC(config-net-bts)# neighbor cgi 23 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)# ### adding the same entry again results in no change
-OsmoBSC(config-net-bts)# neighbor bts 1
-% BTS 0 already had local neighbor BTS 1 with LAC 21 CI 31 and ARFCN 41 BSIC 11
-OsmoBSC(config-net-bts)# neighbor lac-ci 21 31
-% BTS 0 already had local neighbor BTS 1 with LAC 21 CI 31 and ARFCN 41 BSIC 11
-OsmoBSC(config-net-bts)# neighbor cgi 23 42 423 5 arfcn 23 bsic 42
-% Error: only one Cell Identifier entry is allowed per remote neighbor. Already have: BTS 0 to ARFCN 23 BSIC 42 -> CGI[1]:{023-42-423-5}
-OsmoBSC(config-net-bts)# neighbor cgi 23 42 423 5 arfcn 23 bsic 42
-% Error: only one Cell Identifier entry is allowed per remote neighbor. Already have: BTS 0 to ARFCN 23 BSIC 42 -> CGI[1]:{023-42-423-5}
-OsmoBSC(config-net-bts)# neighbor cgi 23 42 423 5 arfcn 23 bsic 42
-% Error: only one Cell Identifier entry is allowed per remote neighbor. Already have: BTS 0 to ARFCN 23 BSIC 42 -> CGI[1]:{023-42-423-5}
+OsmoBSC(config-net-bts)# neighbor bts 123
+% BTS 0 already had neighbor BTS 123
 
-OsmoBSC(config-net-bts)# neighbor cgi 23 042 423 6 arfcn 23 bsic 42
-% Error: only one Cell Identifier entry is allowed per remote neighbor. Already have: BTS 0 to ARFCN 23 BSIC 42 -> CGI[1]:{023-42-423-5}
+OsmoBSC(config-net-bts)# neighbor lac-ci 21 31 arfcn 41 bsic 11
+OsmoBSC(config-net-bts)# neighbor lac-ci 21 31 arfcn 41 bsic 11
+% BTS 0 already had neighbor LAC-CI:21-31 ARFCN-BSIC:41-11
+OsmoBSC(config-net-bts)# neighbor lac-ci 21 31 arfcn 22 bsic 32
+% BTS 0 already had neighbor LAC-CI:21-31 ARFCN-BSIC:41-11
+% ERROR: duplicate Cell ID in neighbor config, with differing ARFCN+BSIC: LAC-CI:21-31 ARFCN-BSIC:22-32
+OsmoBSC(config-net-bts)# show running-config
+...
+  neighbor lac-ci 21 31 arfcn 41 bsic 11
+...
+
+OsmoBSC(config-net-bts)# neighbor cgi 23 42 423 5 arfcn 23 bsic 42
+% BTS 0 already had neighbor CGI:023-42-423-5 ARFCN-BSIC:23-42
+
+OsmoBSC(config-net-bts)# neighbor cgi 23 042 423 5 arfcn 23 bsic 42
+% Error: only one Cell Identifier entry is allowed per remote neighbor. Already have: BTS 0 -> CGI:023-42-423-5 ARFCN-BSIC:23-42
+
+OsmoBSC(config-net-bts)# neighbor cgi 23 42 423 6 arfcn 23 bsic 42
+% Error: only one Cell Identifier entry is allowed per remote neighbor. Already have: BTS 0 -> CGI:023-42-423-5 ARFCN-BSIC:23-42
+
+OsmoBSC(config-net-bts)# neighbor cgi 23 42 423 6 arfcn 42 bsic 1
 
 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 cgi 23 042 234 56 arfcn 23 bsic 42
-% Error: only one Cell Identifier entry is allowed per remote neighbor. Already have: BTS 0 to ARFCN 23 BSIC 42 -> CGI[1]:{023-42-423-5}
 
 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)# neighbor lac-ci 789 10 arfcn 423 bsic 63
-% Error: only one Cell Identifier entry is allowed per remote neighbor. Already have: BTS 0 to ARFCN 423 BSIC 63 -> LAC-CI[1]:{789-10}
+% BTS 0 already had neighbor LAC-CI:789-10 ARFCN-BSIC:423-any
+% ERROR: duplicate Cell ID in neighbor config, with differing ARFCN+BSIC: LAC-CI:789-10 ARFCN-BSIC:423-63
 
 OsmoBSC(config-net-bts)# neighbor lac-ci 789 10 arfcn 423 bsic 1
-% Error: only one Cell Identifier entry is allowed per remote neighbor. Already have: BTS 0 to ARFCN 423 BSIC 1 -> LAC-CI[1]:{789-10}
+% BTS 0 already had neighbor LAC-CI:789-10 ARFCN-BSIC:423-any
+% ERROR: duplicate Cell ID in neighbor config, with differing ARFCN+BSIC: LAC-CI:789-10 ARFCN-BSIC:423-1
 
 OsmoBSC(config-net-bts)# show running-config
 ...
@@ -252,119 +272,125 @@
 ... !neighbor 
  bts 0
 ... !neighbor 
-  neighbor bts 1
-  neighbor bts 2
+  neighbor bts 123
+  neighbor cgi 901 70 22 65535
   neighbor cgi 023 42 423 5 arfcn 23 bsic 42
+  neighbor lac-ci 21 31 arfcn 41 bsic 11
+  neighbor cgi 023 42 423 6 arfcn 42 bsic 1
   neighbor lac 456 arfcn 123 bsic 45
   neighbor lac-ci 789 10 arfcn 423 bsic any
 ... !neighbor 
 
 OsmoBSC(config-net-bts)# do show bts 0 neighbor arfcn 99 bsic any
-% No entry for BTS 0 to ARFCN 99 (any BSIC)
+% No entry for BTS 0 -> ARFCN-BSIC:99-any
 
 OsmoBSC(config-net-bts)# do show bts 0 neighbor arfcn 41 bsic any
-% BTS 0 to ARFCN 41 (any BSIC) resolves to local BTS 1 lac-ci 21 31
+% BTS 0 -> ARFCN-BSIC:41-any resolves to local BTS 1 lac-ci 21 31
 
 OsmoBSC(config-net-bts)# do show bts 0 neighbor arfcn 423 bsic 1
-% neighbor lac-ci 789 10 arfcn 423 bsic 1
+% BTS 0 -> ARFCN-BSIC:423-1 resolves to remote-BSS neighbors: LAC-CI[1]:{789-10}
 
 OsmoBSC(config-net-bts)# do show bts 0 neighbor arfcn 423 bsic 23
-% neighbor lac-ci 789 10 arfcn 423 bsic 23
+% BTS 0 -> ARFCN-BSIC:423-23 resolves to remote-BSS neighbors: LAC-CI[1]:{789-10}
 
 OsmoBSC(config-net-bts)# no neighbor arfcn 99 bsic 7
-% Cannot remove, no such neighbor: BTS 0 to ARFCN 99 BSIC 7
+% Cannot remove: no such neighbor on BTS 0: ARFCN-BSIC:99-7
 
 OsmoBSC(config-net-bts)# no neighbor arfcn 23 bsic 42
-% Removed remote BSS neighbor BTS 0 to ARFCN 23 BSIC 42
 
 OsmoBSC(config-net-bts)# show running-config
 ... !neighbor 
-  neighbor bts 1
-  neighbor bts 2
+  neighbor bts 123
+  neighbor cgi 901 70 22 65535
+  neighbor lac-ci 21 31 arfcn 41 bsic 11
+  neighbor cgi 023 42 423 6 arfcn 42 bsic 1
   neighbor lac 456 arfcn 123 bsic 45
   neighbor lac-ci 789 10 arfcn 423 bsic any
 ... !neighbor 
 
 OsmoBSC(config-net-bts)# no neighbor arfcn 123 bsic 45
-% Removed remote BSS neighbor BTS 0 to ARFCN 123 BSIC 45
 
 OsmoBSC(config-net-bts)# show running-config
 ... !neighbor 
-  neighbor bts 1
-  neighbor bts 2
+  neighbor bts 123
+  neighbor cgi 901 70 22 65535
+  neighbor lac-ci 21 31 arfcn 41 bsic 11
+  neighbor cgi 023 42 423 6 arfcn 42 bsic 1
   neighbor lac-ci 789 10 arfcn 423 bsic any
 ... !neighbor 
 
 OsmoBSC(config-net-bts)# no neighbor arfcn 423 bsic any
-% Removed remote BSS neighbor BTS 0 to ARFCN 423 (any BSIC)
 
 OsmoBSC(config-net-bts)# show running-config
 ... !neighbor 
-  neighbor bts 1
-  neighbor bts 2
+  neighbor bts 123
+  neighbor cgi 901 70 22 65535
+  neighbor lac-ci 21 31 arfcn 41 bsic 11
+  neighbor cgi 023 42 423 6 arfcn 42 bsic 1
 ... !neighbor 
 
 OsmoBSC(config-net-bts)# no neighbor arfcn 423 bsic 63
-% Cannot remove, no such neighbor: BTS 0 to ARFCN 423 BSIC 63
+% Cannot remove: no such neighbor on BTS 0: ARFCN-BSIC:423-63
 
 OsmoBSC(config-net-bts)# show running-config
 ... !neighbor 
-  neighbor bts 1
-  neighbor bts 2
+  neighbor bts 123
+  neighbor cgi 901 70 22 65535
+  neighbor lac-ci 21 31 arfcn 41 bsic 11
+  neighbor cgi 023 42 423 6 arfcn 42 bsic 1
 ... !neighbor 
 
 OsmoBSC(config-net-bts)# no neighbor arfcn 423 bsic 1
-% Cannot remove, no such neighbor: BTS 0 to ARFCN 423 BSIC 1
+% Cannot remove: no such neighbor on BTS 0: ARFCN-BSIC:423-1
 
 OsmoBSC(config-net-bts)# show running-config
 ... !neighbor 
-  neighbor bts 1
-  neighbor bts 2
+  neighbor bts 123
+  neighbor cgi 901 70 22 65535
+  neighbor lac-ci 21 31 arfcn 41 bsic 11
+  neighbor cgi 023 42 423 6 arfcn 42 bsic 1
 ... !neighbor 
 
 OsmoBSC(config-net-bts)# no neighbor arfcn 41 bsic any
-% Removed local neighbor bts 0 to bts 1
 
 OsmoBSC(config-net-bts)# show running-config
 ... !neighbor 
-  neighbor bts 2
+  neighbor bts 123
+  neighbor cgi 901 70 22 65535
+  neighbor cgi 023 42 423 6 arfcn 42 bsic 1
 ... !neighbor 
 
 OsmoBSC(config-net-bts)# no neighbor arfcn 41 bsic any
-% Cannot remove, no such neighbor: BTS 0 to ARFCN 41 (any BSIC)
+% Cannot remove: no such neighbor on BTS 0: ARFCN-BSIC:41-any
 
 OsmoBSC(config-net-bts)# show running-config
 ... !neighbor 
-  neighbor bts 2
+  neighbor bts 123
+  neighbor cgi 901 70 22 65535
+  neighbor cgi 023 42 423 6 arfcn 42 bsic 1
 ... !neighbor 
 
-OsmoBSC(config-net-bts)# no neighbor arfcn 42 bsic 12
-% Removed local neighbor bts 0 to bts 2
+OsmoBSC(config-net-bts)# no neighbor bts 123
+OsmoBSC(config-net-bts)# no neighbor cgi 901 70 22 65535
+OsmoBSC(config-net-bts)# no neighbor arfcn 42 bsic 1
 
 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)# neighbor cgi-ps 23 42 423 2 5 arfcn 23 bsic 32
-% BTS 0 to ARFCN 23 BSIC 32 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)
-% Removed remote BSS neighbor BTS 0 to ARFCN 23 BSIC 32
+% Removed neighbor: BTS 0 to BTS 1
+% Removed neighbor: BTS 0 to BTS 2
+% Removed neighbor: BTS 0 to CGI:023-42-423-5 ARFCN-BSIC:23-42
+% Removed neighbor: BTS 0 to LAC:456 ARFCN-BSIC:123-45
+% Removed neighbor: BTS 0 to LAC-CI:789-10 ARFCN-BSIC:423-any
+% Removed neighbor: BTS 0 to CGI-PS:023-42-423-2-5 ARFCN-BSIC:23-32
 
 OsmoBSC(config-net-bts)# show running-config
 ... !neighbor 

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

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I9ed992f8bfff888b3933733c0576f92d50f2625b
Gerrit-Change-Number: 23360
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/20210313/33130fa2/attachment.htm>


More information about the gerrit-log mailing list