neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/29003 )
Change subject: optimize: decode PS msgs only when PFCP is enabled ......................................................................
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 --- M src/osmo-hnbgw/hnbgw_cn.c M src/osmo-hnbgw/hnbgw_rua.c 2 files changed, 48 insertions(+), 26 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-hnbgw refs/changes/03/29003/1
diff --git a/src/osmo-hnbgw/hnbgw_cn.c b/src/osmo-hnbgw/hnbgw_cn.c index 893ee2a..7cbfcec 100644 --- a/src/osmo-hnbgw/hnbgw_cn.c +++ b/src/osmo-hnbgw/hnbgw_cn.c @@ -373,11 +373,12 @@ }
/* 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 @@ 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 @@ 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)); diff --git a/src/osmo-hnbgw/hnbgw_rua.c b/src/osmo-hnbgw/hnbgw_rua.c index 9234ac4..7d5492f 100644 --- a/src/osmo-hnbgw/hnbgw_rua.c +++ b/src/osmo-hnbgw/hnbgw_rua.c @@ -276,25 +276,37 @@ /* 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);