optimize: decode PS msgs only when PFCP is enabled

For the benefit of skipping decoding of all PS RANAP and RUA messages,
introduce code dup: decode CS and PS separately.

Related: SYS#5895
Change-Id: Ifb57bad6a0d5ff263e4c6c3facc51620e110e7d2
This commit is contained in:
Neels Hofmeyr 2022-08-09 17:38:13 +02:00
parent 26f1410dde
commit a4a35532e3
2 changed files with 48 additions and 26 deletions

View File

@ -373,11 +373,12 @@ static int handle_cn_data_ind(struct hnbgw_cnlink *cnlink,
}
/* Intercept RAB Assignment Request, to map RTP and GTP between access and core */
message = talloc_zero(map, ranap_message);
rc = ranap_ran_rx_co_decode(map, message, msgb_l2(oph->msg), msgb_l2len(oph->msg));
if (rc == 0) {
if (!map->is_ps) {
/* Circuit-Switched. Set up mapping of RTP ports via MGW */
if (!map->is_ps) {
/* Circuit-Switched. Set up mapping of RTP ports via MGW */
message = talloc_zero(map, ranap_message);
rc = ranap_ran_rx_co_decode(map, message, msgb_l2(oph->msg), msgb_l2len(oph->msg));
if (rc == 0) {
switch (message->procedureCode) {
case RANAP_ProcedureCode_id_RAB_Assignment:
/* mgw_fsm_alloc_and_handle_rab_ass_req() takes ownership of (ranap) message */
@ -388,10 +389,18 @@ static int handle_cn_data_ind(struct hnbgw_cnlink *cnlink,
mgw_fsm_release(map);
break;
}
ranap_ran_rx_co_free(message);
}
talloc_free(message);
#if ENABLE_PFCP
} else {
struct hnb_gw *hnb_gw = cnlink->gw;
/* Packet-Switched. Set up mapping of GTP ports via UPF */
} else {
struct hnb_gw *hnb_gw = cnlink->gw;
/* Packet-Switched. Set up mapping of GTP ports via UPF */
message = talloc_zero(map, ranap_message);
rc = ranap_ran_rx_co_decode(map, message, msgb_l2(oph->msg), msgb_l2len(oph->msg));
if (rc == 0) {
switch (message->procedureCode) {
case RANAP_ProcedureCode_id_RAB_Assignment:
@ -408,16 +417,17 @@ static int handle_cn_data_ind(struct hnbgw_cnlink *cnlink,
break;
case RANAP_ProcedureCode_id_Iu_Release:
/* An IU Release will terminate the PFCP sessions for all RABs (ps_rab FSM instances).
* Terminate all RABs and forward the IU Release directly by rua_tx_dt() below. */
/* Any IU Release will terminate the MGW FSM, the message itsself is not passed to the
* FSM code. It is just forwarded normally by the rua_tx_dt() call below. */
hnbgw_gtpmap_release(map);
break;
}
#endif
ranap_ran_rx_co_free(message);
}
ranap_ran_rx_co_free(message);
talloc_free(message);
#endif
}
talloc_free(message);
return rua_tx_dt(map->hnb_ctx, map->is_ps, map->rua_ctx_id,
msgb_l2(oph->msg), msgb_l2len(oph->msg));

View File

@ -276,25 +276,37 @@ int rua_to_scu(struct hnb_context *hnb,
/* If there is data, see if it is a RAB Assignment message where we need to change the user plane information,
* for RTP mapping via MGW (soon also GTP mapping via UPF). */
if (data && len && map && !release_context_map) {
message = talloc_zero(map, ranap_message);
rc = ranap_cn_rx_co_decode(map, message, msgb_l2(prim->oph.msg), msgb_l2len(prim->oph.msg));
if (!map->is_ps) {
message = talloc_zero(map, ranap_message);
rc = ranap_cn_rx_co_decode(map, message, msgb_l2(prim->oph.msg), msgb_l2len(prim->oph.msg));
if (rc == 0) {
switch (message->procedureCode) {
case RANAP_ProcedureCode_id_RAB_Assignment:
if (!map->is_ps) {
if (rc == 0) {
switch (message->procedureCode) {
case RANAP_ProcedureCode_id_RAB_Assignment:
/* mgw_fsm_handle_rab_ass_resp() takes ownership of prim->oph and (ranap) message */
return mgw_fsm_handle_rab_ass_resp(map, &prim->oph, message);
}
#if ENABLE_PFCP
/* ps_rab_ass_fsm takes ownership of prim->oph and RANAP message */
return hnbgw_gtpmap_rx_rab_ass_resp(map, &prim->oph, message);
#endif
ranap_cn_rx_co_free(message);
}
ranap_cn_rx_co_free(message);
}
talloc_free(message);
talloc_free(message);
#if ENABLE_PFCP
} else {
message = talloc_zero(map, ranap_message);
rc = ranap_cn_rx_co_decode(map, message, msgb_l2(prim->oph.msg), msgb_l2len(prim->oph.msg));
if (rc == 0) {
switch (message->procedureCode) {
case RANAP_ProcedureCode_id_RAB_Assignment:
/* ps_rab_ass_fsm takes ownership of prim->oph and RANAP message */
return hnbgw_gtpmap_rx_rab_ass_resp(map, &prim->oph, message);
}
ranap_cn_rx_co_free(message);
}
talloc_free(message);
#endif
}
}
rc = osmo_sccp_user_sap_down(cn->sccp_user, &prim->oph);