Support Neighbor Address Resolution over PCUIF IPA multiplex

While NACC was initially 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 breaking existing deployments until they are upgraded to new
versions of osmo-pcu and osmo-bsc.

Change-Id: I9073a121564503f483c84263ac72476041e47c03
Related: SYS#4971
This commit is contained in:
Pau Espin 2021-09-07 17:56:47 +02:00
parent df93b188ec
commit 506aa70d77
6 changed files with 190 additions and 50 deletions

View File

@ -747,19 +747,41 @@ network
This PS information is solely used by the Neighbor Resolution Service, aimed at
nodes other than BSC itself, and described below.
=== Neighbor Resolution Service CTRL interface
=== Neighbor Address Resolution Service
This service is provided in order to provide the PCU a way to translate
This service is provided in order to provide the PCU with a way to translate
ARCFCN+BSIC into CGI-PS in order to use RIM services and accomplish PS
Handovers.
This interface is Osmocom specific, since the standard doesn't provide any
specifications on how to provide this kind of information to the PCU.
Since the PCU can be either BSC-colocated or BTS-colocated (hence on a different
host than BSC), this must be a network-based interface. Since the service is
Osmocom-specific, it was decided to re-use the CTRL interface available in most
Osmocom processes (see <<control>>).
Since the PCU can be either BSC co-located or BTS co-located (hence on a
different host than BSC), messages may need to be sent over the network at some
point.
In consequence, it was decided implement a new _Container_ type message in
PCUIF which the PCU can use to directly communicate with the BSC. If the PCU is
BSC co-located, then the BSC can directly communicate over the unix socket. If
the PCU is BTS co-located, then PCU sends PCUIF messages over the unix socket to
the BTS, and the BTS forwards the PCUIF messages transparently over the the IPA
multiplex of the OML connection towards the BSC and back.
Support for this interface is available by default nowadays in OsmoPCU, OsmoBTS
and OsmoBSC, and requires no specific configuration, it will just work out of
the box.
==== Neighbor Address Resolution Service CTRL interface (deprecated)
Before the existence of the PCUIF forwarded over IPA multiplex interface (see
above), the Neighbor Address Resolution Service was implemented by means of a
CTRL interface, similar to the one used in most Osmocom processes (see
<<control>>).
CAUTION: This interface is nowadays considered deprecated and should not be used
anymore. Any related VTY options should be dropped from configuration files, to
let OsmoPCU use the new interface instead. This section is kept here for a while
as a reference for old deployments using old versions of the programs.
Due to security concerns, the set of CTRL commands available in this
service is configured in a different IP address and port, since the service

View File

@ -86,6 +86,10 @@ int neighbors_check_cfg();
"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);

View File

@ -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 @@ struct gsm_pcu_if_container {
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 */

View File

@ -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 @@ static int abis_osmo_pcu_sendmsg(struct gsm_bts *bts, struct msgb *msg)
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 @@ static int rcvmsg_pcu_container(struct gsm_bts *bts, struct gsm_pcu_if_container
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);

View File

@ -366,18 +366,70 @@ static int gsm_bts_get_cgi_ps(const struct gsm_bts *bts, struct osmo_cell_global
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 int lac, cell_id;
struct osmo_cell_global_id_ps cgi_ps;
if (!cmd->variable)
goto fmt_err;
@ -407,48 +459,13 @@ static int get_neighbor_resolve_cgi_ps_from_lac_ci(struct ctrl_cmd *cmd, void *d
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;

View File

@ -481,6 +481,10 @@ DEFUN(cfg_neighbor_bind, cfg_neighbor_bind_cmd,
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]);