From de69cbe1abb47c07b77d634498021c2aab14deaa Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Tue, 9 Aug 2022 17:38:13 +0200 Subject: [PATCH] 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 --- src/osmo-hnbgw/hnbgw_cn.c | 36 +++++++++++++++++++++++------------- src/osmo-hnbgw/hnbgw_rua.c | 38 +++++++++++++++++++++++++------------- 2 files changed, 48 insertions(+), 26 deletions(-) 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 @@ 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)); 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 @@ 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);