From 163c078c427dcddb683e19ec3a68b61c99ce6189 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Wed, 24 Jun 2020 12:37:14 +0100 Subject: [PATCH] srsEPC: Using bearer state to decide weather to send release bearer request or not. --- srsepc/src/mme/nas.cc | 11 +++++++++++ srsepc/src/mme/s1ap_ctx_mngmt_proc.cc | 13 +++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/srsepc/src/mme/nas.cc b/srsepc/src/mme/nas.cc index d4ebc0255..a9bff4d90 100644 --- a/srsepc/src/mme/nas.cc +++ b/srsepc/src/mme/nas.cc @@ -759,6 +759,11 @@ bool nas::handle_detach_request(uint32_t m_tmsi, emm_ctx->state = EMM_STATE_DEREGISTERED; sec_ctx->ul_nas_count++; + // Mark E-RABs as de-activated + for (esm_ctx_t& esm_ctx : nas_ctx->m_esm_ctx) { + esm_ctx.state = ERAB_DEACTIVATED; + } + nas_log->console("Received. M-TMSI 0x%x\n", m_tmsi); // Received detach request as an initial UE message // eNB created new ECM context to send the detach request; this needs to be cleared. @@ -1242,6 +1247,12 @@ bool nas::handle_detach_request(srslte::byte_buffer_t* nas_msg) m_gtpc->send_delete_session_request(m_emm_ctx.imsi); m_emm_ctx.state = EMM_STATE_DEREGISTERED; + + // Mark E-RABs as de-activated + for (esm_ctx_t& esm_ctx : m_esm_ctx) { + esm_ctx.state = ERAB_DEACTIVATED; + } + if (m_ecm_ctx.mme_ue_s1ap_id != 0) { m_s1ap->send_ue_context_release_command(m_ecm_ctx.mme_ue_s1ap_id); } diff --git a/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc b/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc index 70c3ee670..e58f0c926 100644 --- a/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc +++ b/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc @@ -287,9 +287,18 @@ bool s1ap_ctx_mngmt_proc::send_ue_context_release_command(nas* nas_ctx, bool sen return false; } + // Detect weather there are active E-RABs + bool active_erabs = false; + for (esm_ctx_t& esm_ctx : nas_ctx->m_esm_ctx) { + if (esm_ctx.state != ERAB_DEACTIVATED) { + active_erabs = true; + break; + } + } + // On some circumstances, such as the NAS Detach, the UE context has already been cleared from // the SPGW. In such cases, there is no need to send the GTP-C Release Access Bearers Request. - if (send_release_erabs) { + if (active_erabs) { // There are active E-RABs, send release access mearers request m_s1ap_log->console("There are active E-RABs, send release access bearers request\n"); m_s1ap_log->info("There are active E-RABs, send release access bearers request\n"); @@ -299,7 +308,7 @@ bool s1ap_ctx_mngmt_proc::send_ue_context_release_command(nas* nas_ctx, bool sen m_mme_gtpc->send_release_access_bearers_request(emm_ctx->imsi); } - // Mark ECM state as IDLE + // Mark ECM state as IDLE and de-activate E-RABs ecm_ctx->state = ECM_STATE_IDLE; for (esm_ctx_t& esm_ctx : nas_ctx->m_esm_ctx) { esm_ctx.state = ERAB_DEACTIVATED;