bts: ipa/osmo-bts/sysmobts: MO: add support for the second NSVC

The second NSVC MO has been explicit skipped and never been interacted with.
osmo-bts is already supporting it for a long time as well the PCU is
supporting it at least since the NS2 code migration.
Fixes the ttcn3 test case BTS_Tests.TC_pcu_socket_two_nsvc.

Closes: OS#5835
Change-Id: I3486a7cc9a424602b73f8adc2fefce169213e46b
This commit is contained in:
Alexander Couzens 2022-12-19 21:21:32 +01:00 committed by lynxis lazus
parent 6cc5f08eb8
commit 315af2f9ea
6 changed files with 33 additions and 19 deletions

View File

@ -27,10 +27,11 @@
struct gsm_bts_sm; struct gsm_bts_sm;
struct gsm_bts; struct gsm_bts;
struct gsm_bts_trx; struct gsm_bts_trx;
struct gsm_gprs_nsvc;
struct msgb *nanobts_gen_set_bts_attr(struct gsm_bts *bts); struct msgb *nanobts_gen_set_bts_attr(struct gsm_bts *bts);
struct msgb *nanobts_gen_set_nse_attr(struct gsm_bts_sm *bts_sm); struct msgb *nanobts_gen_set_nse_attr(struct gsm_bts_sm *bts_sm);
struct msgb *nanobts_gen_set_cell_attr(struct gsm_bts *bts); struct msgb *nanobts_gen_set_cell_attr(struct gsm_bts *bts);
struct msgb *nanobts_gen_set_nsvc_attr(struct gsm_bts *bts); struct msgb *nanobts_gen_set_nsvc_attr(struct gsm_gprs_nsvc *nsvc);
struct msgb *nanobts_gen_set_radio_attr(struct gsm_bts *bts, struct msgb *nanobts_gen_set_radio_attr(struct gsm_bts *bts,
struct gsm_bts_trx *trx); struct gsm_bts_trx *trx);

View File

@ -184,9 +184,6 @@ static int nm_statechg_event(int evt, struct nm_statechg_signal_data *nsd)
break; break;
case NM_OC_GPRS_NSVC: case NM_OC_GPRS_NSVC:
nsvc = obj; nsvc = obj;
/* We skip NSVC1 since we only use NSVC0 */
if (nsvc->id == 1)
break;
osmo_fsm_inst_dispatch(nsvc->mo.fi, NM_EV_STATE_CHG_REP, nsd); osmo_fsm_inst_dispatch(nsvc->mo.fi, NM_EV_STATE_CHG_REP, nsd);
break; break;
default: default:

View File

@ -206,21 +206,20 @@ struct msgb *nanobts_gen_set_cell_attr(struct gsm_bts *bts)
return msgb; return msgb;
} }
struct msgb *nanobts_gen_set_nsvc_attr(struct gsm_bts *bts) struct msgb *nanobts_gen_set_nsvc_attr(struct gsm_gprs_nsvc *nsvc)
{ {
struct msgb *msgb; struct msgb *msgb;
uint8_t buf[256]; uint8_t buf[256];
struct gsm_bts_sm *bts_sm = bts->site_mgr;
msgb = msgb_alloc(1024, "nanobts_attr_bts"); msgb = msgb_alloc(1024, "nanobts_attr_bts");
if (!msgb) if (!msgb)
return NULL; return NULL;
/* 925 */ /* 925 */
buf[0] = bts_sm->gprs.nsvc[0].nsvci >> 8; buf[0] = nsvc->nsvci >> 8;
buf[1] = bts_sm->gprs.nsvc[0].nsvci & 0xff; buf[1] = nsvc->nsvci & 0xff;
msgb_tl16v_put(msgb, NM_ATT_IPACC_NSVCI, 2, buf); msgb_tl16v_put(msgb, NM_ATT_IPACC_NSVCI, 2, buf);
switch (bts_sm->gprs.nsvc->remote.u.sa.sa_family) { switch (nsvc->remote.u.sa.sa_family) {
case AF_INET6: case AF_INET6:
/* all fields are encoded in network byte order */ /* all fields are encoded in network byte order */
/* protocol family */ /* protocol family */
@ -228,20 +227,20 @@ struct msgb *nanobts_gen_set_nsvc_attr(struct gsm_bts *bts)
/* padding */ /* padding */
buf[1] = 0x00; buf[1] = 0x00;
/* local udp port */ /* local udp port */
osmo_store16be(bts_sm->gprs.nsvc[0].local_port, &buf[2]); osmo_store16be(nsvc->local_port, &buf[2]);
/* remote udp port */ /* remote udp port */
memcpy(&buf[4], &bts_sm->gprs.nsvc[0].remote.u.sin6.sin6_port, sizeof(uint16_t)); memcpy(&buf[4], &nsvc->remote.u.sin6.sin6_port, sizeof(uint16_t));
/* remote ip address */ /* remote ip address */
memcpy(&buf[6], &bts_sm->gprs.nsvc[0].remote.u.sin6.sin6_addr, sizeof(struct in6_addr)); memcpy(&buf[6], &nsvc->remote.u.sin6.sin6_addr, sizeof(struct in6_addr));
msgb_tl16v_put(msgb, NM_ATT_OSMO_NS_LINK_CFG, 6 + sizeof(struct in6_addr), buf); msgb_tl16v_put(msgb, NM_ATT_OSMO_NS_LINK_CFG, 6 + sizeof(struct in6_addr), buf);
break; break;
case AF_INET: case AF_INET:
/* remote udp port */ /* remote udp port */
memcpy(&buf[0], &bts_sm->gprs.nsvc[0].remote.u.sin.sin_port, sizeof(uint16_t)); memcpy(&buf[0], &nsvc->remote.u.sin.sin_port, sizeof(uint16_t));
/* remote ip address */ /* remote ip address */
memcpy(&buf[2], &bts_sm->gprs.nsvc[0].remote.u.sin.sin_addr, sizeof(struct in_addr)); memcpy(&buf[2], &nsvc->remote.u.sin.sin_addr, sizeof(struct in_addr));
/* local udp port */ /* local udp port */
osmo_store16be(bts_sm->gprs.nsvc[0].local_port, &buf[6]); osmo_store16be(nsvc->local_port, &buf[6]);
msgb_tl16v_put(msgb, NM_ATT_IPACC_NS_LINK_CFG, 8, buf); msgb_tl16v_put(msgb, NM_ATT_IPACC_NS_LINK_CFG, 8, buf);
break; break;
default: default:

View File

@ -143,8 +143,11 @@ static void rx_get_attr_rep(struct gsm_bts *bts, bool allow_opstart)
bts->mo.get_attr_sent = false; bts->mo.get_attr_sent = false;
/* Announce bts_features are available to related NSVC MOs */ /* Announce bts_features are available to related NSVC MOs */
nsvc = gsm_bts_sm_nsvc_num(bts->site_mgr, 0); /* we only support NSVC0 so far */ for (int i = 0; i < ARRAY_SIZE(bts->site_mgr->gprs.nsvc); i++) {
osmo_fsm_inst_dispatch(nsvc->mo.fi, NM_EV_FEATURE_NEGOTIATED, NULL); nsvc = gsm_bts_sm_nsvc_num(bts->site_mgr, i);
if (nsvc)
osmo_fsm_inst_dispatch(nsvc->mo.fi, NM_EV_FEATURE_NEGOTIATED, NULL);
}
/* Move FSM forward */ /* Move FSM forward */
configure_loop(bts, &bts->mo.nm_state, allow_opstart); configure_loop(bts, &bts->mo.nm_state, allow_opstart);

View File

@ -90,6 +90,17 @@ static void st_op_disabled_notinstalled(struct osmo_fsm_inst *fi, uint32_t event
} }
} }
static bool has_valid_nsvc(struct gsm_gprs_nsvc *nsvc)
{
switch (nsvc->remote.u.sa.sa_family) {
case AF_INET:
case AF_INET6:
return (nsvc->local_port > 0 && !osmo_sockaddr_is_any(&nsvc->remote));
default:
return false;
}
}
static void configure_loop(struct gsm_gprs_nsvc *nsvc, const struct gsm_nm_state *state, bool allow_opstart) static void configure_loop(struct gsm_gprs_nsvc *nsvc, const struct gsm_nm_state *state, bool allow_opstart)
{ {
struct msgb *msgb; struct msgb *msgb;
@ -110,8 +121,11 @@ static void configure_loop(struct gsm_gprs_nsvc *nsvc, const struct gsm_nm_state
nsvc->bts->nr); nsvc->bts->nr);
return; return;
} }
if (!has_valid_nsvc(nsvc))
return;
nsvc->mo.set_attr_sent = true; nsvc->mo.set_attr_sent = true;
msgb = nanobts_gen_set_nsvc_attr(nsvc->bts); msgb = nanobts_gen_set_nsvc_attr(nsvc);
OSMO_ASSERT(msgb); OSMO_ASSERT(msgb);
abis_nm_ipaccess_set_attr(nsvc->bts, NM_OC_GPRS_NSVC, nsvc->bts->bts_nr, abis_nm_ipaccess_set_attr(nsvc->bts, NM_OC_GPRS_NSVC, nsvc->bts->bts_nr,
nsvc->id, 0xff, msgb->data, msgb->len); nsvc->id, 0xff, msgb->data, msgb->len);

View File

@ -88,7 +88,7 @@ static void test_nanobts_gen_set_nsvc_attr(struct gsm_bts *bts, uint8_t *expecte
printf("Testing nanobts_gen_set_nsvc_attr()...\n"); printf("Testing nanobts_gen_set_nsvc_attr()...\n");
msgb = nanobts_gen_set_nsvc_attr(bts); msgb = nanobts_gen_set_nsvc_attr(&bts->site_mgr->gprs.nsvc[0]);
printf("result= %s\n", osmo_hexdump_nospc(msgb->data, msgb->len)); printf("result= %s\n", osmo_hexdump_nospc(msgb->data, msgb->len));
printf("expected=%s\n", osmo_hexdump_nospc(expected, msgb->len)); printf("expected=%s\n", osmo_hexdump_nospc(expected, msgb->len));
OSMO_ASSERT(msgb_eq_data_print(msgb, expected, msgb->len)); OSMO_ASSERT(msgb_eq_data_print(msgb, expected, msgb->len));