From 51806982f73c174ea23b0238847fb82a971f4e27 Mon Sep 17 00:00:00 2001 From: Francisco Date: Mon, 18 Oct 2021 22:11:46 +0100 Subject: [PATCH] nr,gnb,rrc: correctly release NR RNTI user after Reestablishment --- srsenb/hdr/stack/rrc/rrc_endc.h | 25 ++++++++++++++----------- srsenb/src/stack/rrc/rrc.cc | 2 +- srsenb/src/stack/rrc/rrc_endc.cc | 25 ++++++++++++++++--------- srsenb/src/stack/rrc/rrc_nr.cc | 6 +++++- 4 files changed, 36 insertions(+), 22 deletions(-) diff --git a/srsenb/hdr/stack/rrc/rrc_endc.h b/srsenb/hdr/stack/rrc/rrc_endc.h index 5975199f4..a1f81433a 100644 --- a/srsenb/hdr/stack/rrc/rrc_endc.h +++ b/srsenb/hdr/stack/rrc/rrc_endc.h @@ -126,11 +126,13 @@ private: struct endc_disabled_st {}; // EN-DC disabled // FSM guards + bool requires_rel_req(const sgnb_rel_req_ev& ev); + bool skip_rel_req(const sgnb_rel_req_ev& ev); // FSM transition handlers void handle_sgnb_add_req_ack(wait_sgnb_add_req_resp_st& s, const sgnb_add_req_ack_ev& ev); - void handle_sgnb_rel_req(endc_activated_st& s, const sgnb_rel_req_ev& ev); - void handle_rrc_reest(const rrc_reest_rx_ev& ev); + void handle_sgnb_rel_req(const sgnb_rel_req_ev& ev); + void handle_rrc_reest(endc_activated_st& s, const rrc_reest_rx_ev& ev); void handle_endc_disabled(const disable_endc_ev& ev); protected: @@ -157,17 +159,18 @@ protected: using transitions = transition_table< // Start Target Event Action Guard // +---------------------------+--------------------------+------------------------+------------------------------+-------------------------+ - row< endc_deactivated_st, wait_sgnb_add_req_resp_st, sgnb_add_req_sent_ev, nullptr >, + row< endc_deactivated_st, wait_sgnb_add_req_resp_st, sgnb_add_req_sent_ev, nullptr >, // +---------------------------+--------------------------+------------------------+------------------------------+-------------------------+ - row< wait_sgnb_add_req_resp_st, prepare_recfg_st, sgnb_add_req_ack_ev, &fsm::handle_sgnb_add_req_ack >, - row< wait_sgnb_add_req_resp_st, endc_deactivated_st, sgnb_add_req_reject_ev >, - row< prepare_recfg_st, wait_add_complete_st, rrc_recfg_sent_ev >, - row< wait_add_complete_st, endc_activated_st, sgnb_add_complete_ev >, + row< wait_sgnb_add_req_resp_st, prepare_recfg_st, sgnb_add_req_ack_ev, &fsm::handle_sgnb_add_req_ack >, + row< wait_sgnb_add_req_resp_st, endc_deactivated_st, sgnb_add_req_reject_ev >, + row< prepare_recfg_st, wait_add_complete_st, rrc_recfg_sent_ev >, + row< wait_add_complete_st, endc_activated_st, sgnb_add_complete_ev >, + upd< endc_activated_st, rrc_reest_rx_ev, &fsm::handle_rrc_reest >, // +---------------------------+--------------------------+------------------------+------------------------------+-------------------------+ - row< endc_activated_st, wait_sgnb_rel_req_resp_st, sgnb_rel_req_ev, &fsm::handle_sgnb_rel_req >, - to_state< endc_deactivated_st, rrc_reest_rx_ev, &fsm::handle_rrc_reest >, - row< wait_sgnb_rel_req_resp_st, endc_deactivated_st, sgnb_rel_req_ack_ev >, - to_state< endc_disabled_st, disable_endc_ev, &fsm::handle_endc_disabled > + to_state< wait_sgnb_rel_req_resp_st, sgnb_rel_req_ev, &fsm::handle_sgnb_rel_req, &fsm::requires_rel_req >, + to_state< endc_deactivated_st, sgnb_rel_req_ev, &fsm::handle_sgnb_rel_req, &fsm::skip_rel_req >, + row< wait_sgnb_rel_req_resp_st, endc_deactivated_st, sgnb_rel_req_ack_ev >, + to_state< endc_disabled_st, disable_endc_ev, &fsm::handle_endc_disabled > >; // clang-format on }; diff --git a/srsenb/src/stack/rrc/rrc.cc b/srsenb/src/stack/rrc/rrc.cc index f4fbd6245..31cbae59e 100644 --- a/srsenb/src/stack/rrc/rrc.cc +++ b/srsenb/src/stack/rrc/rrc.cc @@ -569,7 +569,7 @@ void rrc::set_erab_status(uint16_t rnti, const asn1::s1ap::bearers_subject_to_st void rrc::sgnb_addition_ack(uint16_t eutra_rnti, sgnb_addition_ack_params_t params) { - logger.info("Received SgNB addition acknowledgement for rnti=%d", eutra_rnti); + logger.info("Received SgNB addition acknowledgement for rnti=0x%x", eutra_rnti); auto ue_it = users.find(eutra_rnti); if (ue_it == users.end()) { logger.warning("rnti=0x%x does not exist", eutra_rnti); diff --git a/srsenb/src/stack/rrc/rrc_endc.cc b/srsenb/src/stack/rrc/rrc_endc.cc index 8baeb1ac7..119464d2f 100644 --- a/srsenb/src/stack/rrc/rrc_endc.cc +++ b/srsenb/src/stack/rrc/rrc_endc.cc @@ -312,7 +312,7 @@ void rrc::ue::rrc_endc::start_sgnb_addition() rrc_nr_interface_rrc::sgnb_addition_req_params_t params = {}; params.eps_bearer_id = rrc_enb->bearer_manager.get_lcid_bearer(rrc_ue->rnti, drb_to_lcid((lte_drb)eutra_drb_id)).eps_bearer_id; - logger.info("Triggering SgNB addition"); + logger.info("Triggering SgNB addition for E-UTRA rnti=0x%x", rrc_ue->rnti); rrc_enb->rrc_nr->sgnb_addition_request(rrc_ue->rnti, params); sgnb_add_req_sent_ev sgnb_add_req{}; @@ -358,9 +358,10 @@ void rrc::ue::rrc_endc::handle_sgnb_add_req_ack(wait_sgnb_add_req_resp_st& s, co nr_rnti = ev.params.nr_rnti; } -void rrc::ue::rrc_endc::handle_sgnb_rel_req(endc_activated_st& s, const sgnb_rel_req_ev& ev) +void rrc::ue::rrc_endc::handle_sgnb_rel_req(const sgnb_rel_req_ev& ev) { - logger.info("Triggering SgNB release"); + logger.info("Triggering SgNB release for E-UTRA rnti=0x%x", rrc_ue->rnti); + rrc_enb->bearer_manager.rem_user(nr_rnti); rrc_enb->rrc_nr->sgnb_release_request(nr_rnti); } @@ -369,14 +370,10 @@ bool rrc::ue::rrc_endc::is_endc_supported() return not is_in_state(); } -void rrc::ue::rrc_endc::handle_rrc_reest(const rrc_reest_rx_ev& ev) +void rrc::ue::rrc_endc::handle_rrc_reest(endc_activated_st& s, const rrc_reest_rx_ev& ev) { - auto& sgnb_config = get_state()->sgnb_config; - // Transition GTPU tunnel rnti back from NR RNTI to LTE RNTI, given that the reconfiguration failed - rrc_enb->gtpu->mod_bearer_rnti(sgnb_config.nr_rnti, rrc_ue->rnti); - - rrc_enb->bearer_manager.rem_user(sgnb_config.nr_rnti); + rrc_enb->gtpu->mod_bearer_rnti(nr_rnti, rrc_ue->rnti); } void rrc::ue::rrc_endc::handle_endc_disabled(const disable_endc_ev& ev) @@ -384,4 +381,14 @@ void rrc::ue::rrc_endc::handle_endc_disabled(const disable_endc_ev& ev) logger.info("Disabling NR EN-DC support for rnti=0x%x", nr_rnti); } +bool rrc::ue::rrc_endc::requires_rel_req(const sgnb_rel_req_ev& ev) +{ + return not is_in_state() and not is_in_state(); +} + +bool rrc::ue::rrc_endc::skip_rel_req(const sgnb_rel_req_ev& ev) +{ + return not requires_rel_req(ev) and not is_in_state(); +} + } // namespace srsenb diff --git a/srsenb/src/stack/rrc/rrc_nr.cc b/srsenb/src/stack/rrc/rrc_nr.cc index f2d70e741..d03968ee1 100644 --- a/srsenb/src/stack/rrc/rrc_nr.cc +++ b/srsenb/src/stack/rrc/rrc_nr.cc @@ -538,8 +538,12 @@ int rrc_nr::sgnb_release_request(uint16_t nr_rnti) { task_sched.defer_task([this, nr_rnti]() { // remove user + auto it = users.find(nr_rnti); + uint16_t eutra_rnti = it != users.end() ? it->second->get_eutra_rnti() : SRSRAN_INVALID_RNTI; rem_user(nr_rnti); - rrc_eutra->sgnb_release_ack(nr_rnti); + if (eutra_rnti != SRSRAN_INVALID_RNTI) { + rrc_eutra->sgnb_release_ack(eutra_rnti); + } }); return SRSRAN_SUCCESS; }