lynxis lazus has submitted this change. ( https://gerrit.osmocom.org/c/osmo-sgsn/+/40962?usp=email )
(
2 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: Split Iu RANAP conn release over different layers ......................................................................
Split Iu RANAP conn release over different layers
Move and rename functions acting on mmctx to mmctx.{c,h}. From there, call functions acting on ranap ue_ctx.
Change-Id: I4acdbc857df36b7409c8210d364758192dfdb0bb --- M include/osmocom/sgsn/gprs_ranap.h M include/osmocom/sgsn/iu_client.h M include/osmocom/sgsn/mmctx.h M src/sgsn/gprs_gmm.c M src/sgsn/gprs_mm_state_iu_fsm.c M src/sgsn/gprs_ranap.c M src/sgsn/iu_client.c M src/sgsn/mmctx.c M src/sgsn/sccp.c 9 files changed, 54 insertions(+), 59 deletions(-)
Approvals: lynxis lazus: Looks good to me, approved Jenkins Builder: Verified
diff --git a/include/osmocom/sgsn/gprs_ranap.h b/include/osmocom/sgsn/gprs_ranap.h index e2450bd..92b453d 100644 --- a/include/osmocom/sgsn/gprs_ranap.h +++ b/include/osmocom/sgsn/gprs_ranap.h @@ -28,18 +28,11 @@ int ranap_iu_tx_release(struct ranap_ue_conn_ctx *ctx, const struct RANAP_Cause *cause); /* Transmit a Iu Release Command and submit event RANAP_IU_EVENT_IU_RELEASE upon * Release Complete or timeout. Caller is responsible to free the context and - * closing the SCCP connection (ranap_iu_free_ue) upon recieval of the event. */ -void ranap_iu_tx_release_free(struct ranap_ue_conn_ctx *ctx, + * closing the SCCP connection (sgsn_ranap_iu_free_ue) upon recieval of the event. */ +void sgsn_ranap_iu_tx_release_free(struct ranap_ue_conn_ctx *ctx, const struct RANAP_Cause *cause, int timeout);
-/* free the Iu UE context */ -void sgsn_ranap_iu_free(struct sgsn_mm_ctx *ctx); - -/* send a Iu Release Command and free afterwards the UE context */ -void sgsn_ranap_iu_release_free(struct sgsn_mm_ctx *ctx, - const struct RANAP_Cause *cause); - int sgsn_ranap_iu_rx_cl_msg(struct sgsn_sccp_user_iups *scu_iups, const struct osmo_scu_unitdata_param *ud_prim, const uint8_t *data, size_t len); @@ -49,10 +42,7 @@ const uint8_t *data, size_t len); int sgsn_ranap_iu_rx_co_msg(struct ranap_ue_conn_ctx *ue_ctx, const uint8_t *data, size_t len);
-#else /* ifndef BUILD_IU */ -inline static void sgsn_ranap_iu_free(void *ctx) {}; -inline static void sgsn_ranap_iu_release_free(void *ctx, void *cause) {}; -#endif /* BUILD_IU*/ +#endif /* ifdef BUILD_IU */
struct ranap_ue_conn_ctx; /* On RANAP, Returns pointer to he associated ranap_ue_conn_ctx in msg, filled diff --git a/include/osmocom/sgsn/iu_client.h b/include/osmocom/sgsn/iu_client.h index 0dedba4..4e44f03 100644 --- a/include/osmocom/sgsn/iu_client.h +++ b/include/osmocom/sgsn/iu_client.h @@ -91,4 +91,4 @@
/* freeing the UE will release all resources * This will close the SCCP connection connected to the UE */ -void ranap_iu_free_ue(struct ranap_ue_conn_ctx *ue_ctx); +void sgsn_ranap_iu_free_ue(struct ranap_ue_conn_ctx *ue_ctx); diff --git a/include/osmocom/sgsn/mmctx.h b/include/osmocom/sgsn/mmctx.h index 8ee82e0..f1dca9b 100644 --- a/include/osmocom/sgsn/mmctx.h +++ b/include/osmocom/sgsn/mmctx.h @@ -293,5 +293,9 @@ void sgsn_update_subscriber_data(struct sgsn_mm_ctx *mmctx);
#ifdef BUILD_IU +struct RANAP_Cause; void sgsn_mm_ctx_iu_activate_rabs(struct sgsn_mm_ctx *ctx); +void sgsn_mm_ctx_iu_ranap_release_free(struct sgsn_mm_ctx *ctx, + const struct RANAP_Cause *cause); +void sgsn_mm_ctx_iu_ranap_free(struct sgsn_mm_ctx *ctx); #endif /* ifdef BUILD_IU */ diff --git a/src/sgsn/gprs_gmm.c b/src/sgsn/gprs_gmm.c index a409660..f4d3d8b 100644 --- a/src/sgsn/gprs_gmm.c +++ b/src/sgsn/gprs_gmm.c @@ -1839,7 +1839,7 @@ #ifdef BUILD_IU else if (MSG_IU_UE_CTX(msg)) { unsigned long X1001 = osmo_tdef_get(sgsn->cfg.T_defs, -1001, OSMO_TDEF_S, -1); - ranap_iu_tx_release_free(MSG_IU_UE_CTX(msg), NULL, (int) X1001); + sgsn_ranap_iu_tx_release_free(MSG_IU_UE_CTX(msg), NULL, (int) X1001); } #endif
diff --git a/src/sgsn/gprs_mm_state_iu_fsm.c b/src/sgsn/gprs_mm_state_iu_fsm.c index c426678..8c4cc46 100644 --- a/src/sgsn/gprs_mm_state_iu_fsm.c +++ b/src/sgsn/gprs_mm_state_iu_fsm.c @@ -95,12 +95,12 @@
switch(event) { case E_PMM_PS_CONN_RELEASE: - sgsn_ranap_iu_free(ctx); + sgsn_mm_ctx_iu_ranap_free(ctx); mm_state_iu_fsm_state_chg(fi, ST_PMM_IDLE); mmctx_change_gtpu_endpoints_to_sgsn(ctx, NULL); break; case E_PMM_PS_DETACH: - sgsn_ranap_iu_release_free(ctx, NULL); + sgsn_mm_ctx_iu_ranap_release_free(ctx, NULL); mm_state_iu_fsm_state_chg(fi, ST_PMM_DETACHED); break; case E_PMM_RA_UPDATE: @@ -108,7 +108,7 @@ case E_PMM_RX_GGSN_GTPU_DT_EI: /* GTPU Direct Tunnel (RNC<->GGSN): GGSN Received Error Indication when transmitting DL data*/ pctx = (struct sgsn_pdp_ctx *)data; - sgsn_ranap_iu_free(ctx); + sgsn_mm_ctx_iu_ranap_free(ctx); mm_state_iu_fsm_state_chg(fi, ST_PMM_IDLE); mmctx_change_gtpu_endpoints_to_sgsn(ctx, pctx); break; diff --git a/src/sgsn/gprs_ranap.c b/src/sgsn/gprs_ranap.c index 70f369d..e328414 100644 --- a/src/sgsn/gprs_ranap.c +++ b/src/sgsn/gprs_ranap.c @@ -100,7 +100,7 @@ pdp = sgsn_pdp_ctx_by_nsapi(ctx, rab_id); if (!pdp) { LOGP(DRANAP, LOGL_ERROR, "RAB Assignment Response for unknown RAB/NSAPI=%u\n", rab_id); - sgsn_ranap_iu_release_free(ctx, NULL); + sgsn_mm_ctx_iu_ranap_release_free(ctx, NULL); return -1; }
@@ -184,7 +184,7 @@ if (!mm) { LOGIUP(ctx, LOGL_NOTICE, "Cannot find mm ctx for IU event %s\n", iu_client_event_type_str(type)); - ranap_iu_free_ue(ctx); + sgsn_ranap_iu_free_ue(ctx); return rc; }
@@ -199,7 +199,7 @@ LOGMMCTXP(LOGL_INFO, mm, "IU release (cause=%s)\n", iu_client_event_type_str(type)); rc = osmo_fsm_inst_dispatch(mm->iu.mm_state_fsm, E_PMM_PS_CONN_RELEASE, NULL); if (rc < 0) - sgsn_ranap_iu_free(mm); + sgsn_mm_ctx_iu_ranap_free(mm);
/* TODO: move this into FSM */ if (mm->ran_type == MM_CTX_T_UTRAN_Iu && mm->gmm_att_req.fsm->state != ST_INIT) @@ -257,37 +257,6 @@ } }
-void sgsn_ranap_iu_free(struct sgsn_mm_ctx *ctx) -{ - if (!ctx) - return; - - if (!ctx->iu.ue_ctx) - return; - - ranap_iu_free_ue(ctx->iu.ue_ctx); - ctx->iu.ue_ctx = NULL; -} - -void sgsn_ranap_iu_release_free(struct sgsn_mm_ctx *ctx, - const struct RANAP_Cause *cause) -{ - unsigned long X1001; - - if (!ctx) - return; - - if (!ctx->iu.ue_ctx) - return; - - X1001 = osmo_tdef_get(sgsn->cfg.T_defs, -1001, OSMO_TDEF_S, -1); - - ranap_iu_tx_release_free(ctx->iu.ue_ctx, - cause, - (int) X1001); - ctx->iu.ue_ctx = NULL; -} - int sgsn_ranap_iu_tx_rab_ps_ass_req(struct ranap_ue_conn_ctx *ue_ctx, uint8_t rab_id, uint32_t gtp_ip, uint32_t gtp_tei) { @@ -378,9 +347,9 @@ return sgsn_scu_iups_tx_data_req(uectx->scu_iups, uectx->conn_id, msg); }
-void ranap_iu_tx_release_free(struct ranap_ue_conn_ctx *ctx, - const struct RANAP_Cause *cause, - int timeout) +void sgsn_ranap_iu_tx_release_free(struct ranap_ue_conn_ctx *ctx, + const struct RANAP_Cause *cause, + int timeout) { ctx->notification = false; ctx->free_on_release = true; diff --git a/src/sgsn/iu_client.c b/src/sgsn/iu_client.c index 1f36129..950a264 100644 --- a/src/sgsn/iu_client.c +++ b/src/sgsn/iu_client.c @@ -95,7 +95,7 @@ return ctx; }
-void ranap_iu_free_ue(struct ranap_ue_conn_ctx *ue_ctx) +void sgsn_ranap_iu_free_ue(struct ranap_ue_conn_ctx *ue_ctx) { if (!ue_ctx) return; diff --git a/src/sgsn/mmctx.c b/src/sgsn/mmctx.c index 3d3047f..0de0fc3 100644 --- a/src/sgsn/mmctx.c +++ b/src/sgsn/mmctx.c @@ -19,6 +19,8 @@ * */
+#include "config.h" + #include <stdint.h>
#include <osmocom/core/linuxlist.h> @@ -51,6 +53,7 @@ #include <osmocom/sgsn/gprs_mm_state_iu_fsm.h> #include <osmocom/sgsn/gprs_gmm_fsm.h> #include <osmocom/sgsn/gprs_llc.h> +#include <osmocom/sgsn/gprs_ranap.h> #include <osmocom/sgsn/gprs_sndcp.h> #include <osmocom/sgsn/gtp_ggsn.h> #include <osmocom/sgsn/gtp.h> @@ -58,8 +61,6 @@
#include <time.h>
-#include "../../config.h" - const struct value_string sgsn_ran_type_names[] = { { MM_CTX_T_GERAN_Gb, "GPRS/EDGE via Gb" }, { MM_CTX_T_UTRAN_Iu, "UMTS via Iu" }, @@ -619,4 +620,35 @@ llist_for_each_entry(pdp, &ctx->pdp_list, list) sgsn_pdp_ctx_iu_rab_activate(pdp, pdp->nsapi); } + +/* send a Iu Release Command and free afterwards the UE context */ +void sgsn_mm_ctx_iu_ranap_release_free(struct sgsn_mm_ctx *mmctx, + const struct RANAP_Cause *cause) +{ + unsigned long X1001; + + if (!mmctx) + return; + + if (!mmctx->iu.ue_ctx) + return; + + X1001 = osmo_tdef_get(sgsn->cfg.T_defs, -1001, OSMO_TDEF_S, -1); + + sgsn_ranap_iu_tx_release_free(mmctx->iu.ue_ctx, cause, (int) X1001); + mmctx->iu.ue_ctx = NULL; +} + +/* free the Iu UE context */ +void sgsn_mm_ctx_iu_ranap_free(struct sgsn_mm_ctx *mmctx) +{ + if (!mmctx) + return; + + if (!mmctx->iu.ue_ctx) + return; + + sgsn_ranap_iu_free_ue(mmctx->iu.ue_ctx); + mmctx->iu.ue_ctx = NULL; +} #endif diff --git a/src/sgsn/sccp.c b/src/sgsn/sccp.c index 291222f..24b06e7 100644 --- a/src/sgsn/sccp.c +++ b/src/sgsn/sccp.c @@ -155,7 +155,7 @@ if (!ue) return; if (ue->free_on_release) - ranap_iu_free_ue(ue); + sgsn_ranap_iu_free_ue(ue); }
static void handle_notice_ind(struct sgsn_sccp_user_iups *scu_iups, const struct osmo_scu_notice_param *ni)