Change in osmo-bsc[master]: Support Neighbor Address Resolution over PCUIF IPA multiplex

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/.

pespin gerrit-no-reply at lists.osmocom.org
Wed Sep 8 14:44:28 UTC 2021


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


Change subject: Support Neighbor Address Resolution over PCUIF IPA multiplex
......................................................................

Support Neighbor Address Resolution over PCUIF IPA multiplex

While NACC was initiall developed, it became clear there was need for a
way to interact PCU<->BSC in order resolve ARFCN+BSIC into CGI-PS for
later RIM usage.
Hence, this resolution was first (until today) implemented using an out
of bands RPC system using the CTRL interface, which required specific
config to be written and matches in osmo-pcu and osmo-bsc VTY (ip+port
of the CTRL interface to use).
However, this has several shortcomings:
* As explained above, specific configuration is required
* Since recently, we do support BSC redundancy in osmo-bts. Hence the BTS
  may switch to a BSC other than first one. If that happened, that'd mean
  the CTRL interface would still point to the initially configured one,
  which may not be the same currently serving the PCU.

During recent development of ANR related features, a similar need for
PCU<->BSC was required, but this time it was decided to extend the IPA
multiplex of the Abis OML connection to pass PCUIF messages,
transparently forwarded to each side by the BTS.
This has the advantage that connection PCU<->BTS is handled by BTS and
both sides send messages transparently.

Let's switch by default to using this new interface, while still
maintaing the old way for a while (announcing them as deprecated) to
avoid rbeaking existing deployments until they are upgraded to new
versions of osmo-pcu and osmo-bsc.

Change-Id: I9073a121564503f483c84263ac72476041e47c03
Related: SYS#4971
---
M include/osmocom/bsc/neighbor_ident.h
M include/osmocom/bsc/pcuif_proto.h
M src/osmo-bsc/abis_osmo.c
M src/osmo-bsc/neighbor_ident.c
M src/osmo-bsc/neighbor_ident_vty.c
5 files changed, 162 insertions(+), 44 deletions(-)



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

diff --git a/include/osmocom/bsc/neighbor_ident.h b/include/osmocom/bsc/neighbor_ident.h
index 0565d52..58300ba 100644
--- a/include/osmocom/bsc/neighbor_ident.h
+++ b/include/osmocom/bsc/neighbor_ident.h
@@ -86,6 +86,10 @@
 	"for all BSICs / use any BSIC in this ARFCN\n"
 void neighbor_ident_vty_parse_arfcn_bsic(struct cell_ab *ab, const char **argv);
 
+int neighbor_address_resolution(const struct gsm_network *net, const struct cell_ab *ab,
+				uint16_t lac, uint16_t cell_id,
+				struct osmo_cell_global_id_ps *res_cgi_ps);
+
 struct ctrl_handle *neighbor_controlif_setup(struct gsm_network *net);
 int neighbor_ctrl_cmds_install(struct gsm_network *net);
 
diff --git a/include/osmocom/bsc/pcuif_proto.h b/include/osmocom/bsc/pcuif_proto.h
index 3e6f651..4921fc3 100644
--- a/include/osmocom/bsc/pcuif_proto.h
+++ b/include/osmocom/bsc/pcuif_proto.h
@@ -26,6 +26,10 @@
 #define PCU_IF_MSG_TXT_IND	0x70	/* Text indication for BTS */
 #define PCU_IF_MSG_CONTAINER	0x80	/* Transparent container message */
 
+/* msg_type coming from BSC (inside PCU_IF_MSG_CONTAINER) */
+#define PCU_IF_MSG_NEIGH_ADDR_REQ	0x81	/* Neighbor Address Resolution Request */
+#define PCU_IF_MSG_NEIGH_ADDR_CNF	0x82	/* Neighbor Address Resolution Confirmation */
+
 /* sapi */
 #define PCU_IF_SAPI_RACH	0x01	/* channel request on CCCH */
 #define PCU_IF_SAPI_AGCH	0x02	/* assignment on AGCH */
@@ -226,6 +230,30 @@
 	uint8_t		data[0];
 } __attribute__ ((packed));
 
+/*** Used inside container: NOTE: values must be network byte order here! ***/
+/* Neighbor Address Resolution Request */
+struct gsm_pcu_if_neigh_addr_req {
+	uint16_t	local_lac;
+	uint16_t	local_ci;
+	uint16_t	tgt_arfcn;
+	uint8_t		tgt_bsic;
+} __attribute__ ((packed));
+
+/* Neighbor Address Resolution Confirmation */
+struct gsm_pcu_if_neigh_addr_cnf {
+	struct gsm_pcu_if_neigh_addr_req orig_req;
+	uint8_t		err_code; /* 0 success, !0 failed & below unset */
+	/* RAI + CI (CGI-PS): */
+	struct __attribute__ ((packed)) {
+		uint16_t	mcc;
+		uint16_t	mnc;
+		uint8_t		mnc_3_digits;
+		uint16_t	lac;
+		uint8_t		rac;
+		uint16_t	cell_identity;
+	} cgi_ps;
+} __attribute__ ((packed));
+
 struct gsm_pcu_if {
 	/* context based information */
 	uint8_t		msg_type;	/* message type */
diff --git a/src/osmo-bsc/abis_osmo.c b/src/osmo-bsc/abis_osmo.c
index 39caac6..4345a6f 100644
--- a/src/osmo-bsc/abis_osmo.c
+++ b/src/osmo-bsc/abis_osmo.c
@@ -32,6 +32,7 @@
 #include <osmocom/bsc/debug.h>
 #include <osmocom/bsc/bts.h>
 #include <osmocom/bsc/pcuif_proto.h>
+#include <osmocom/bsc/neighbor_ident.h>
 
 #define OM_HEADROOM_SIZE	128
 
@@ -40,7 +41,6 @@
 ///////////////////////////////////////
 #define PCUIF_HDR_SIZE ( sizeof(struct gsm_pcu_if) - sizeof(((struct gsm_pcu_if *)0)->u) )
 
-#if 0
 static struct msgb *abis_osmo_pcu_msgb_alloc(uint8_t msg_type, uint8_t bts_nr, size_t extra_size)
 {
 	struct msgb *msg;
@@ -62,7 +62,65 @@
 	ipa_prepend_header_ext(msg, IPAC_PROTO_EXT_PCU);
 	return abis_osmo_sendmsg(bts, msg);
 }
-#endif
+
+static int abis_osmo_pcu_tx_neigh_addr_cnf(struct gsm_bts *bts, const struct gsm_pcu_if_neigh_addr_req *naddr_req,
+				    uint8_t err_code, const struct osmo_cell_global_id_ps *cgi_ps)
+{
+	struct msgb *msg = abis_osmo_pcu_msgb_alloc(PCU_IF_MSG_CONTAINER, bts->bts_nr, sizeof(struct gsm_pcu_if_neigh_addr_cnf));
+	struct gsm_pcu_if *pcu_prim = (struct gsm_pcu_if *) msgb_data(msg);
+	struct gsm_pcu_if_neigh_addr_cnf *naddr_cnf = (struct gsm_pcu_if_neigh_addr_cnf *)&pcu_prim->u.container.data[0];
+
+	msgb_put(msg, sizeof(pcu_prim->u.container) + sizeof(struct gsm_pcu_if_neigh_addr_cnf));
+	pcu_prim->u.container.msg_type = PCU_IF_MSG_NEIGH_ADDR_CNF;
+	osmo_store16be(sizeof(struct gsm_pcu_if_neigh_addr_cnf), &pcu_prim->u.container.length);
+
+	naddr_cnf->orig_req = *naddr_req;
+	naddr_cnf->err_code = err_code;
+	if (err_code == 0) {
+		osmo_store16be(cgi_ps->rai.lac.plmn.mcc, &naddr_cnf->cgi_ps.mcc);
+		osmo_store16be(cgi_ps->rai.lac.plmn.mnc, &naddr_cnf->cgi_ps.mnc);
+		naddr_cnf->cgi_ps.mnc_3_digits = cgi_ps->rai.lac.plmn.mnc_3_digits;
+		osmo_store16be(cgi_ps->rai.lac.lac, &naddr_cnf->cgi_ps.lac);
+		naddr_cnf->cgi_ps.rac = cgi_ps->rai.rac;
+		osmo_store16be(cgi_ps->cell_identity, &naddr_cnf->cgi_ps.cell_identity);
+	}
+
+	return abis_osmo_pcu_sendmsg(bts, msg);
+}
+
+static int rcvmsg_pcu_neigh_addr_req(struct gsm_bts *bts, const struct gsm_pcu_if_neigh_addr_req *naddr_req)
+{
+
+	struct cell_ab ab;
+	uint16_t local_lac, local_ci;
+	struct osmo_cell_global_id_ps cgi_ps;
+	int rc;
+
+	local_lac = osmo_load16be(&naddr_req->local_lac);
+	local_ci = osmo_load16be(&naddr_req->local_ci);
+	ab = (struct cell_ab){
+		.arfcn = osmo_load16be(&naddr_req->tgt_arfcn),
+		.bsic = naddr_req->tgt_bsic,
+	};
+
+	LOGP(DNM, LOGL_INFO, "(bts=%d) Rx Neighbor Address Resolution Req (ARFCN=%u,BSIC=%u) from (LAC=%u,CI=%u)\n",
+	     bts->nr, ab.arfcn, ab.bsic, local_lac, local_ci);
+
+	if (!cell_ab_valid(&ab)) {
+		rc = 2;
+		goto do_fail;
+	}
+
+	if (neighbor_address_resolution(bts->network, &ab, local_lac, local_ci, &cgi_ps) < 0) {
+		rc = 1;
+		goto do_fail;
+	}
+	return abis_osmo_pcu_tx_neigh_addr_cnf(bts, naddr_req, 0, &cgi_ps);
+
+do_fail:
+	return abis_osmo_pcu_tx_neigh_addr_cnf(bts, naddr_req, rc, NULL);
+}
+
 
 static int rcvmsg_pcu_container(struct gsm_bts *bts, struct gsm_pcu_if_container *container, size_t container_len)
 {
@@ -79,6 +137,13 @@
 	     bts->nr, container->msg_type);
 
 	switch (container->msg_type) {
+	case PCU_IF_MSG_NEIGH_ADDR_REQ:
+		if (data_length < sizeof(struct gsm_pcu_if_neigh_addr_req)) {
+			LOGP(DNM, LOGL_ERROR, "ABIS_OSMO_PCU CONTAINER ANR_CNF message too short\n");
+			return -EINVAL;
+		}
+		rc = rcvmsg_pcu_neigh_addr_req(bts, (struct gsm_pcu_if_neigh_addr_req*)&container->data);
+		break;
 	default:
 		LOGP(DNM, LOGL_NOTICE, "(bts=%d) Rx ABIS_OSMO_PCU unexpected msg type (%u) inside container!\n",
 		     bts->nr, container->msg_type);
diff --git a/src/osmo-bsc/neighbor_ident.c b/src/osmo-bsc/neighbor_ident.c
index 6e70625..23697bf 100644
--- a/src/osmo-bsc/neighbor_ident.c
+++ b/src/osmo-bsc/neighbor_ident.c
@@ -366,18 +366,70 @@
 	return 0;
 }
 
-static int get_neighbor_resolve_cgi_ps_from_lac_ci(struct ctrl_cmd *cmd, void *data)
+/* Attempt resolution of cgi_ps from ARFCN+BSIC of neighbor from BTS identified by LAC+CI */
+int neighbor_address_resolution(const struct gsm_network *net, const struct cell_ab *ab,
+				uint16_t lac, uint16_t cell_id,
+				struct osmo_cell_global_id_ps *res_cgi_ps)
 {
-	struct gsm_network *net = (struct gsm_network *)data;
 	struct gsm_bts *bts_tmp, *bts_found = NULL;
-	char *tmp = NULL, *tok, *saveptr;
-	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 *local_neighbor = NULL;
 	struct gsm0808_cell_id_list2 remote_neighbors = { 0 };
 
+	llist_for_each_entry(bts_tmp, &net->bts_list, list) {
+		if (bts_tmp->location_area_code != lac)
+			continue;
+		if (bts_tmp->cell_identity != cell_id)
+			continue;
+		bts_found = bts_tmp;
+		break;
+	}
+
+	if (!bts_found)
+		goto notfound_err;
+
+	LOG_BTS(bts_found, DLINP, LOGL_DEBUG, "Resolving neighbor BTS %u -> %s\n", bts_found->nr,
+		cell_ab_to_str_c(OTC_SELECT, ab));
+
+	if (resolve_neighbors(&local_neighbor, &remote_neighbors, bts_found, ab, true))
+		goto notfound_err;
+
+	/* resolve_neighbors() returns either a local_neighbor or remote_neighbors.
+	 * Local-BSS neighbor? */
+	if (local_neighbor) {
+		/* Supporting GPRS? */
+		if (gsm_bts_get_cgi_ps(local_neighbor, &local_cgi_ps) >= 0)
+			cgi_ps = &local_cgi_ps;
+	}
+
+	/* Remote-BSS neighbor?
+	 * By spec, there can be multiple remote neighbors for a given ARFCN+BSIC, but so far osmo-bsc enforces only a
+	 * single remote neighbor. */
+	if (remote_neighbors.id_list_len
+	    && remote_neighbors.id_discr == CELL_IDENT_WHOLE_GLOBAL_PS) {
+		cgi_ps = &remote_neighbors.id_list[0].global_ps;
+	}
+
+	/* No neighbor found */
+	if (!cgi_ps)
+		goto notfound_err;
+
+	*res_cgi_ps = *cgi_ps;
+	return 0;
+
+notfound_err:
+	return -1;
+}
+
+static int get_neighbor_resolve_cgi_ps_from_lac_ci(struct ctrl_cmd *cmd, void *data)
+{
+	struct gsm_network *net = (struct gsm_network *)data;
+	char *tmp = NULL, *tok, *saveptr;
+	struct cell_ab ab;
+	unsigned lac, cell_id;
+	struct osmo_cell_global_id_ps cgi_ps;
+
 	if (!cmd->variable)
 		goto fmt_err;
 
@@ -407,48 +459,13 @@
 		goto fmt_err;
 	ab.bsic = atoi(tok);
 
-	llist_for_each_entry(bts_tmp, &net->bts_list, list) {
-		if (bts_tmp->location_area_code != lac)
-			continue;
-		if (bts_tmp->cell_identity != cell_id)
-			continue;
-		bts_found = bts_tmp;
-		break;
-	}
-
-	if (!bts_found)
-		goto notfound_err;
-
-	LOG_BTS(bts_found, DLINP, LOGL_DEBUG, "Resolving neighbor BTS %u -> %s\n", bts_found->nr,
-		cell_ab_to_str_c(OTC_SELECT, &ab));
-
 	if (!cell_ab_valid(&ab))
 		goto fmt_err;
 
-	if (resolve_neighbors(&local_neighbor, &remote_neighbors, bts_found, &ab, true))
+	if (neighbor_address_resolution(net, &ab, lac, cell_id, &cgi_ps) < 0)
 		goto notfound_err;
 
-	/* resolve_neighbors() returns either a local_neighbor or remote_neighbors.
-	 * Local-BSS neighbor? */
-	if (local_neighbor) {
-		/* Supporting GPRS? */
-		if (gsm_bts_get_cgi_ps(local_neighbor, &local_cgi_ps) >= 0)
-			cgi_ps = &local_cgi_ps;
-	}
-
-	/* Remote-BSS neighbor?
-	 * By spec, there can be multiple remote neighbors for a given ARFCN+BSIC, but so far osmo-bsc enforces only a
-	 * single remote neighbor. */
-	if (remote_neighbors.id_list_len
-	    && remote_neighbors.id_discr == CELL_IDENT_WHOLE_GLOBAL_PS) {
-		cgi_ps = &remote_neighbors.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));
+	ctrl_cmd_reply_printf(cmd, "%s", osmo_cgi_ps_name(&cgi_ps));
 	talloc_free(tmp);
 	return CTRL_CMD_REPLY;
 
diff --git a/src/osmo-bsc/neighbor_ident_vty.c b/src/osmo-bsc/neighbor_ident_vty.c
index b9160ec..b500b34 100644
--- a/src/osmo-bsc/neighbor_ident_vty.c
+++ b/src/osmo-bsc/neighbor_ident_vty.c
@@ -481,6 +481,10 @@
 	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")
 {
+	vty_out(vty, "%% Warning: The CTRL interface for Neighbor Address Resolution is now deprecated."
+		"Upgrade osmo-pcu and drop the 'neighbor-resolution bind " VTY_IPV46_CMD " [<0-65535>]' VTY "
+		"option in order to let osmo-pcu use the new resoluton method using the PCUIF over IPA "
+		"multiplex, which will work out of the box without required configuration.%s", VTY_NEWLINE);
 	osmo_talloc_replace_string(bsc_gsmnet, &bsc_gsmnet->neigh_ctrl.addr, argv[0]);
 	if (argc > 1)
 		bsc_gsmnet->neigh_ctrl.port = atoi(argv[1]);

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

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I9073a121564503f483c84263ac72476041e47c03
Gerrit-Change-Number: 25408
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210908/a7633ca4/attachment.htm>


More information about the gerrit-log mailing list