Skip to content

Commit fd6ba4e

Browse files
FabianEckermannFabian Eckermann
authored andcommitted
cu_cp,ngap: store error indication when release procedure is already scheduled
1 parent b7b09da commit fd6ba4e

File tree

5 files changed

+74
-25
lines changed

5 files changed

+74
-25
lines changed

lib/ngap/ngap_error_indication_helper.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
namespace srsran {
2020
namespace srs_cu_cp {
2121

22+
struct error_indication_request_t {
23+
ngap_cause_t cause;
24+
optional<ran_ue_id_t> ran_ue_id;
25+
optional<amf_ue_id_t> amf_ue_id;
26+
};
27+
2228
/// \brief Send an Error Indication message to the AMF.
2329
/// \param[in] ngap_notifier The message notifier to send the message to the AMF.
2430
/// \param[in] logger The logger to log the message.

lib/ngap/ngap_impl.cpp

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -264,15 +264,22 @@ void ngap_impl::handle_dl_nas_transport_message(const asn1::ngap::dl_nas_transpo
264264
logger.warning("ran_ue_id={} amf_ue_id={}: Dropping DlNasTransportMessage. UE context does not exist",
265265
msg->ran_ue_ngap_id,
266266
msg->amf_ue_ngap_id);
267-
send_error_indication(ngap_notifier, logger, {}, {}, ngap_cause_radio_network_t::unknown_local_ue_ngap_id);
267+
send_error_indication(ngap_notifier,
268+
logger,
269+
{},
270+
uint_to_amf_ue_id(msg->amf_ue_ngap_id),
271+
ngap_cause_radio_network_t::unknown_local_ue_ngap_id);
268272
return;
269273
}
270274

271275
ngap_ue_context& ue_ctxt = ue_ctxt_list[uint_to_ran_ue_id(msg->ran_ue_ngap_id)];
272276

273277
if (ue_ctxt.release_scheduled) {
274278
ue_ctxt.logger.log_info("Dropping DlNasTransportMessage. UE is already scheduled for release");
275-
schedule_error_indication(ue_ctxt.ue_ids.ue_index, ngap_cause_radio_network_t::unknown_local_ue_ngap_id);
279+
stored_error_indications.emplace(ue_ctxt.ue_ids.ue_index,
280+
error_indication_request_t{ngap_cause_radio_network_t::unknown_local_ue_ngap_id,
281+
ue_ctxt.ue_ids.ran_ue_id,
282+
uint_to_amf_ue_id(msg->amf_ue_ngap_id)});
276283
return;
277284
}
278285

@@ -311,7 +318,10 @@ void ngap_impl::handle_initial_context_setup_request(const asn1::ngap::init_cont
311318

312319
if (ue_ctxt.release_scheduled) {
313320
ue_ctxt.logger.log_info("Dropping InitialContextSetup. UE is already scheduled for release");
314-
schedule_error_indication(ue_ctxt.ue_ids.ue_index, ngap_cause_radio_network_t::unknown_local_ue_ngap_id);
321+
stored_error_indications.emplace(ue_ctxt.ue_ids.ue_index,
322+
error_indication_request_t{ngap_cause_radio_network_t::unknown_local_ue_ngap_id,
323+
ue_ctxt.ue_ids.ran_ue_id,
324+
uint_to_amf_ue_id(request->amf_ue_ngap_id)});
315325
return;
316326
}
317327

@@ -384,7 +394,10 @@ void ngap_impl::handle_pdu_session_resource_setup_request(const asn1::ngap::pdu_
384394

385395
if (ue_ctxt.release_scheduled) {
386396
ue_ctxt.logger.log_info("Dropping PduSessionResourceSetupRequest. UE is already scheduled for release");
387-
schedule_error_indication(ue_ctxt.ue_ids.ue_index, ngap_cause_radio_network_t::unknown_local_ue_ngap_id);
397+
stored_error_indications.emplace(ue_ctxt.ue_ids.ue_index,
398+
error_indication_request_t{ngap_cause_radio_network_t::unknown_local_ue_ngap_id,
399+
ue_ctxt.ue_ids.ran_ue_id,
400+
uint_to_amf_ue_id(request->amf_ue_ngap_id)});
388401
return;
389402
}
390403

@@ -448,7 +461,10 @@ void ngap_impl::handle_pdu_session_resource_modify_request(const asn1::ngap::pdu
448461
ngap_ue_context& ue_ctxt = ue_ctxt_list[uint_to_ran_ue_id(request->ran_ue_ngap_id)];
449462
if (ue_ctxt.release_scheduled) {
450463
ue_ctxt.logger.log_info("Dropping PduSessionResourceModifyRequest. UE is already scheduled for release");
451-
schedule_error_indication(ue_ctxt.ue_ids.ue_index, ngap_cause_radio_network_t::unknown_local_ue_ngap_id);
464+
stored_error_indications.emplace(ue_ctxt.ue_ids.ue_index,
465+
error_indication_request_t{ngap_cause_radio_network_t::unknown_local_ue_ngap_id,
466+
ue_ctxt.ue_ids.ran_ue_id,
467+
uint_to_amf_ue_id(request->amf_ue_ngap_id)});
452468
return;
453469
}
454470

@@ -511,7 +527,10 @@ void ngap_impl::handle_pdu_session_resource_release_command(const asn1::ngap::pd
511527

512528
if (ue_ctxt.release_scheduled) {
513529
ue_ctxt.logger.log_info("Dropping PduSessionResourceReleaseCommand. UE is already scheduled for release");
514-
schedule_error_indication(ue_ctxt.ue_ids.ue_index, ngap_cause_radio_network_t::unknown_local_ue_ngap_id);
530+
stored_error_indications.emplace(ue_ctxt.ue_ids.ue_index,
531+
error_indication_request_t{ngap_cause_radio_network_t::unknown_local_ue_ngap_id,
532+
ue_ctxt.ue_ids.ran_ue_id,
533+
uint_to_amf_ue_id(command->amf_ue_ngap_id)});
515534
return;
516535
}
517536

@@ -590,7 +609,10 @@ void ngap_impl::handle_ue_context_release_command(const asn1::ngap::ue_context_r
590609

591610
if (ue_ctxt.release_scheduled) {
592611
ue_ctxt.logger.log_info("Dropping UeContextReleaseCommand. UE is already scheduled for release");
593-
schedule_error_indication(ue_ctxt.ue_ids.ue_index, ngap_cause_radio_network_t::unknown_local_ue_ngap_id, amf_ue_id);
612+
stored_error_indications.emplace(ue_ctxt.ue_ids.ue_index,
613+
error_indication_request_t{ngap_cause_radio_network_t::unknown_local_ue_ngap_id,
614+
ue_ctxt.ue_ids.ran_ue_id,
615+
amf_ue_id});
594616
return;
595617
}
596618

@@ -622,8 +644,12 @@ void ngap_impl::handle_ue_context_release_command(const asn1::ngap::ue_context_r
622644
// start routine
623645
task_sched.schedule_async_task(
624646
ue_ctxt.ue_ids.ue_index,
625-
launch_async<ngap_ue_context_release_procedure>(
626-
msg, ue_ctxt.ue_ids, ue->get_du_processor_control_notifier(), ngap_notifier, ue_ctxt.logger));
647+
launch_async<ngap_ue_context_release_procedure>(msg,
648+
ue_ctxt.ue_ids,
649+
stored_error_indications,
650+
ue->get_du_processor_control_notifier(),
651+
ngap_notifier,
652+
ue_ctxt.logger));
627653
}
628654

629655
void ngap_impl::handle_paging(const asn1::ngap::paging_s& msg)

lib/ngap/ngap_impl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#pragma once
1212

1313
#include "ngap_context.h"
14+
#include "ngap_error_indication_helper.h"
1415
#include "procedures/ngap_transaction_manager.h"
1516
#include "ue_context/ngap_ue_context.h"
1617
#include "srsran/asn1/ngap/ngap.h"
@@ -137,6 +138,8 @@ class ngap_impl final : public ngap_interface
137138
/// Repository of UE Contexts.
138139
ngap_ue_context_list ue_ctxt_list;
139140

141+
std::unordered_map<ue_index_t, error_indication_request_t> stored_error_indications;
142+
140143
ngap_cu_cp_ue_creation_notifier& cu_cp_ue_creation_notifier;
141144
ngap_cu_cp_du_repository_notifier& cu_cp_du_repository_notifier;
142145
ngap_ue_task_scheduler& task_sched;

lib/ngap/procedures/ngap_ue_context_release_procedure.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ using namespace srsran::srs_cu_cp;
1818
using namespace asn1::ngap;
1919

2020
ngap_ue_context_release_procedure::ngap_ue_context_release_procedure(
21-
const cu_cp_ue_context_release_command& command_,
22-
const ngap_ue_ids& ue_ids_,
23-
ngap_du_processor_control_notifier& du_processor_ctrl_notifier_,
24-
ngap_message_notifier& amf_notifier_,
25-
ngap_ue_logger& logger_) :
21+
const cu_cp_ue_context_release_command& command_,
22+
const ngap_ue_ids& ue_ids_,
23+
std::unordered_map<ue_index_t, error_indication_request_t>& stored_error_indications_,
24+
ngap_du_processor_control_notifier& du_processor_ctrl_notifier_,
25+
ngap_message_notifier& amf_notifier_,
26+
ngap_ue_logger& logger_) :
2627
command(command_),
2728
ue_ids(ue_ids_),
29+
stored_error_indications(stored_error_indications_),
2830
du_processor_ctrl_notifier(du_processor_ctrl_notifier_),
2931
amf_notifier(amf_notifier_),
3032
logger(logger_)
@@ -50,6 +52,14 @@ void ngap_ue_context_release_procedure::operator()(coro_context<async_task<void>
5052

5153
send_ue_context_release_complete();
5254

55+
// Send ErrorIndication if it was stored for this UE
56+
if (stored_error_indications.find(ue_ids.ue_index) != stored_error_indications.end()) {
57+
const auto& req = stored_error_indications.at(ue_ids.ue_index);
58+
send_error_indication(amf_notifier, logger.get_basic_logger(), req.ran_ue_id, req.amf_ue_id, req.cause);
59+
// Remove stored error indication
60+
stored_error_indications.erase(ue_ids.ue_index);
61+
}
62+
5363
logger.log_debug("\"{}\" finalized", name());
5464
CORO_RETURN();
5565
}

lib/ngap/procedures/ngap_ue_context_release_procedure.h

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#pragma once
1212

13+
#include "../ngap_error_indication_helper.h"
1314
#include "../ue_context/ngap_ue_context.h"
1415
#include "srsran/ngap/ngap.h"
1516
#include "srsran/support/async/async_task.h"
@@ -20,11 +21,13 @@ namespace srs_cu_cp {
2021
class ngap_ue_context_release_procedure
2122
{
2223
public:
23-
ngap_ue_context_release_procedure(const cu_cp_ue_context_release_command& command_,
24-
const ngap_ue_ids& ue_ids_,
25-
ngap_du_processor_control_notifier& du_processor_ctrl_notifier_,
26-
ngap_message_notifier& amf_notifier_,
27-
ngap_ue_logger& logger_);
24+
ngap_ue_context_release_procedure(
25+
const cu_cp_ue_context_release_command& command_,
26+
const ngap_ue_ids& ue_ids_,
27+
std::unordered_map<ue_index_t, error_indication_request_t>& stored_error_indications_,
28+
ngap_du_processor_control_notifier& du_processor_ctrl_notifier_,
29+
ngap_message_notifier& amf_notifier_,
30+
ngap_ue_logger& logger_);
2831

2932
void operator()(coro_context<async_task<void>>& ctx);
3033

@@ -34,12 +37,13 @@ class ngap_ue_context_release_procedure
3437
// results senders
3538
void send_ue_context_release_complete();
3639

37-
cu_cp_ue_context_release_command command;
38-
const ngap_ue_ids ue_ids;
39-
cu_cp_ue_context_release_complete ue_context_release_complete;
40-
ngap_du_processor_control_notifier& du_processor_ctrl_notifier;
41-
ngap_message_notifier& amf_notifier;
42-
ngap_ue_logger logger;
40+
cu_cp_ue_context_release_command command;
41+
const ngap_ue_ids ue_ids;
42+
std::unordered_map<ue_index_t, error_indication_request_t>& stored_error_indications;
43+
cu_cp_ue_context_release_complete ue_context_release_complete;
44+
ngap_du_processor_control_notifier& du_processor_ctrl_notifier;
45+
ngap_message_notifier& amf_notifier;
46+
ngap_ue_logger logger;
4347
};
4448

4549
} // namespace srs_cu_cp

0 commit comments

Comments
 (0)