From 96ab16f1c7bed71e011b931896bdd5e4165e459a Mon Sep 17 00:00:00 2001 From: Francisco Date: Wed, 12 May 2021 15:38:38 +0100 Subject: [PATCH] s1ap fix - release old rnti (instead of new one) when a new rnti with the same tmsi is found. Furthermore, we now make sure to warn log if the enb is unable to release the old rnti --- srsenb/src/stack/rrc/rrc_ue.cc | 6 ++---- srsenb/src/stack/upper/s1ap.cc | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/srsenb/src/stack/rrc/rrc_ue.cc b/srsenb/src/stack/rrc/rrc_ue.cc index c947693c4..aed5cbe57 100644 --- a/srsenb/src/stack/rrc/rrc_ue.cc +++ b/srsenb/src/stack/rrc/rrc_ue.cc @@ -391,10 +391,8 @@ void rrc::ue::handle_rrc_con_req(rrc_conn_request_s* msg) for (auto& user : parent->users) { if (user.first != rnti && user.second->has_tmsi && user.second->mmec == mmec && user.second->m_tmsi == m_tmsi) { parent->logger.info("RRC connection request: UE context already exists. M-TMSI=%d", m_tmsi); - if (parent->s1ap->user_release(rnti, asn1::s1ap::cause_radio_network_opts::radio_conn_with_ue_lost)) { - // Do not wait for MME response - parent->rem_user_thread(user.first); - } + user.second->state = RRC_STATE_IDLE; // Set old rnti to IDLE so that enb doesn't send RRC Connection Release + parent->s1ap->user_release(user.first, asn1::s1ap::cause_radio_network_opts::radio_conn_with_ue_lost); break; } } diff --git a/srsenb/src/stack/upper/s1ap.cc b/srsenb/src/stack/upper/s1ap.cc index 7755a4aae..1b7314de3 100644 --- a/srsenb/src/stack/upper/s1ap.cc +++ b/srsenb/src/stack/upper/s1ap.cc @@ -411,24 +411,21 @@ void s1ap::write_pdu(uint16_t rnti, srsran::unique_byte_buffer_t pdu) bool s1ap::user_release(uint16_t rnti, asn1::s1ap::cause_radio_network_e cause_radio) { - logger.info("User inactivity - RNTI:0x%x", rnti); - ue* u = users.find_ue_rnti(rnti); if (u == nullptr) { + logger.warning("Released UE with rnti=0x%x not found", rnti); return false; } - if (u->was_uectxtrelease_requested() or not u->ctxt.mme_ue_s1ap_id.has_value()) { - logger.warning("UE context for RNTI:0x%x is in zombie state. Releasing...", rnti); + cause_c cause; + cause.set_radio_network().value = cause_radio.value; + + if (not u->send_uectxtreleaserequest(cause)) { users.erase(u); rrc->release_ue(rnti); return false; } - - cause_c cause; - cause.set_radio_network().value = cause_radio.value; - - return u->send_uectxtreleaserequest(cause); + return true; } bool s1ap::user_exists(uint16_t rnti) @@ -1402,6 +1399,10 @@ bool s1ap::ue::send_ulnastransport(srsran::unique_byte_buffer_t pdu) bool s1ap::ue::send_uectxtreleaserequest(const cause_c& cause) { + if (was_uectxtrelease_requested()) { + logger.warning("UE context for RNTI:0x%x is in zombie state. Releasing...", ctxt.rnti); + return false; + } if (not ctxt.mme_ue_s1ap_id.has_value()) { logger.error("Cannot send UE context release request without a MME-UE-S1AP-Id allocated."); return false;