From 3daaf9b356d8c412fb9db2732a6cb060e503054c Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Fri, 9 Dec 2022 12:50:22 +0100 Subject: [PATCH] Allow NAS PDUs to be cleared only after the Reconfiguration Complete is received by the eNB --- srsenb/hdr/stack/rrc/rrc_bearer_cfg.h | 4 ++++ srsenb/src/stack/rrc/rrc_bearer_cfg.cc | 18 +++++++++++++++++- srsenb/src/stack/rrc/rrc_ue.cc | 3 +++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/srsenb/hdr/stack/rrc/rrc_bearer_cfg.h b/srsenb/hdr/stack/rrc/rrc_bearer_cfg.h index 11abfa4cd..fb8e8fc7a 100644 --- a/srsenb/hdr/stack/rrc/rrc_bearer_cfg.h +++ b/srsenb/hdr/stack/rrc/rrc_bearer_cfg.h @@ -114,6 +114,7 @@ public: const gtpu_interface_rrc::bearer_props* props = nullptr); void rem_gtpu_bearer(uint32_t erab_id); void fill_pending_nas_info(asn1::rrc::rrc_conn_recfg_r8_ies_s* msg); + void clear_pending_nas_info(); const std::map& get_erabs() const { return erabs; } const asn1::rrc::drb_to_add_mod_list_l& get_established_drbs() const { return current_drbs; } @@ -127,6 +128,9 @@ private: const rrc_cfg_t* cfg = nullptr; gtpu_interface_rrc* gtpu = nullptr; + // NAS PDUs being currently sent. + std::vector erab_ids_with_pending_nas_pdus; + // last cfg asn1::rrc::drb_to_add_mod_list_l current_drbs; }; diff --git a/srsenb/src/stack/rrc/rrc_bearer_cfg.cc b/srsenb/src/stack/rrc/rrc_bearer_cfg.cc index cb1fb3ee2..8d54b0301 100644 --- a/srsenb/src/stack/rrc/rrc_bearer_cfg.cc +++ b/srsenb/src/stack/rrc/rrc_bearer_cfg.cc @@ -417,6 +417,8 @@ void bearer_cfg_handler::fill_pending_nas_info(asn1::rrc::rrc_conn_recfg_r8_ies_ // DRBs have already been configured in GTPU during bearer setup // Add E-RAB info message for the E-RABs if (msg->rr_cfg_ded.drb_to_add_mod_list_present) { + erab_ids_with_pending_nas_pdus.clear(); + for (const drb_to_add_mod_s& drb : msg->rr_cfg_ded.drb_to_add_mod_list) { uint32_t lcid = drb_to_lcid((lte_drb)drb.drb_id); auto erab_it = std::find_if( @@ -429,7 +431,7 @@ void bearer_cfg_handler::fill_pending_nas_info(asn1::rrc::rrc_conn_recfg_r8_ies_ msg->ded_info_nas_list.push_back({}); msg->ded_info_nas_list.back().resize(erab_info.size()); memcpy(msg->ded_info_nas_list.back().data(), &erab_info[0], erab_info.size()); - erab_info_list.erase(info_it); + erab_ids_with_pending_nas_pdus.push_back(erab_id); } else { logger->warning("Not adding NAS message to connection reconfiguration. E-RAB id %d", erab_id); } @@ -438,4 +440,18 @@ void bearer_cfg_handler::fill_pending_nas_info(asn1::rrc::rrc_conn_recfg_r8_ies_ } } +void bearer_cfg_handler::clear_pending_nas_info() +{ + for (uint32_t erab_id : erab_ids_with_pending_nas_pdus) { + auto info_it = erab_info_list.find(erab_id); + if (info_it == erab_info_list.end()) { + logger->warning("NAS PDU with ERAB id={} went missing", erab_id); + continue; + } + erab_info_list.erase(info_it); + } + + erab_ids_with_pending_nas_pdus.clear(); +} + } // namespace srsenb diff --git a/srsenb/src/stack/rrc/rrc_ue.cc b/srsenb/src/stack/rrc/rrc_ue.cc index 922b5e5a2..a0073c3f9 100644 --- a/srsenb/src/stack/rrc/rrc_ue.cc +++ b/srsenb/src/stack/rrc/rrc_ue.cc @@ -961,6 +961,9 @@ void rrc::ue::handle_rrc_reconf_complete(rrc_conn_recfg_complete_s* msg, srsran: // If performing handover, signal its completion mobility_handler->trigger(*msg); + // Clear pending NAS PDUs + bearer_list.clear_pending_nas_info(); + // 2> if the UE has radio link failure or handover failure information available const auto& complete_r8 = msg->crit_exts.rrc_conn_recfg_complete_r8(); if (complete_r8.non_crit_ext.non_crit_ext.rlf_info_available_r10_present or rlf_info_pending) {