Commit 9ebb6655 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Avoid redundant UE ContextReleaseCommand with consecutive Service Request

parent a3f0eb72
......@@ -1017,9 +1017,10 @@ void amf_n1::service_request_handle(
std::string guti = conv::tmsi_to_guti(
uc->tai.mcc, uc->tai.mnc, amf_cfg.guami.regionID,
std::to_string(amf_set_id), std::to_string(amf_pointer), tmsi);
// nc->guti = std::make_optional<std::string>(guti);
Logger::amf_app().debug(
"GUTI %s, 5G-TMSI %s", guti.c_str(), tmsi.c_str());
// Get Security Context from old NAS Context if neccesary
std::shared_ptr<nas_context> old_nc = {};
if (guti_2_nas_context(guti, old_nc)) {
......@@ -1100,33 +1101,37 @@ void amf_n1::service_request_handle(
"Send UEContextReleaseCommand to release the old NAS connection if "
"necessary");
std::shared_ptr<ue_ngap_context> unc = {};
string ue_context_key = conv::get_ue_context_key(
// Get UE Context
string ue_context_key = conv::get_ue_context_key(
nc->old_ran_ue_ngap_id, nc->old_amf_ue_ngap_id);
if (!amf_n2_inst->ran_ue_id_2_ue_ngap_context(
nc->old_ran_ue_ngap_id, ue_context_key, unc)) {
Logger::amf_n1().warn(
"No UE NGAP context with ran_ue_ngap_id (" GNB_UE_NGAP_ID_FMT ")",
nc->old_ran_ue_ngap_id);
std::shared_ptr<ue_context> uc = {};
if (!amf_app_inst->ran_amf_id_2_ue_context(ue_context_key, uc)) {
Logger::amf_app().error(
"No UE context for ran_amf_id %s, exit", ue_context_key.c_str());
} else {
std::shared_ptr<gnb_context> gc = {};
if (!amf_n2_inst->assoc_id_2_gnb_context(unc->gnb_assoc_id, gc)) {
Logger::amf_n1().error(
"No existed gNB context with assoc_id (%d)", unc->gnb_assoc_id);
}
std::shared_ptr<itti_ue_context_release_command> itti_msg =
std::make_shared<itti_ue_context_release_command>(
TASK_AMF_N1, TASK_AMF_N2);
itti_msg->amf_ue_ngap_id = nc->old_amf_ue_ngap_id;
itti_msg->ran_ue_ngap_id = nc->old_ran_ue_ngap_id;
itti_msg->cause.setChoiceOfCause(Ngap_Cause_PR_radioNetwork);
itti_msg->cause.setValue(3); // TODO: remove hardcoded value cause nas(3)
int ret = itti_inst->send_msg(itti_msg);
if (0 != ret) {
Logger::amf_n1().error(
"Could not send ITTI message %s to task TASK_AMF_N2",
itti_msg->get_msg_name());
std::shared_ptr<ue_ngap_context> unc = {};
if (!amf_n2_inst->ran_ue_id_2_ue_ngap_context(
nc->old_ran_ue_ngap_id, uc->gnb_id, unc)) {
Logger::amf_n1().warn(
"No UE NGAP context with ran_ue_ngap_id (" GNB_UE_NGAP_ID_FMT ")",
nc->old_ran_ue_ngap_id);
} else {
std::shared_ptr<itti_ue_context_release_command> itti_msg =
std::make_shared<itti_ue_context_release_command>(
TASK_AMF_N1, TASK_AMF_N2);
itti_msg->amf_ue_ngap_id = nc->old_amf_ue_ngap_id;
itti_msg->ran_ue_ngap_id = nc->old_ran_ue_ngap_id;
itti_msg->cause.setChoiceOfCause(Ngap_Cause_PR_radioNetwork);
itti_msg->cause.setValue(
3); // TODO: remove hardcoded value cause nas(3)
int ret = itti_inst->send_msg(itti_msg);
if (0 != ret) {
Logger::amf_n1().error(
"Could not send ITTI message %s to task TASK_AMF_N2",
itti_msg->get_msg_name());
}
}
}
}
......
......@@ -1366,7 +1366,8 @@ void amf_n2::handle_itti_message(itti_ue_context_release_complete& itti_msg) {
if (nc != nullptr) {
// Do nothing in case of old NAS Context (Service Request handling)
if (nc->old_amf_ue_ngap_id != INVALID_AMF_UE_NGAP_ID) {
if ((nc->old_amf_ue_ngap_id != INVALID_AMF_UE_NGAP_ID) and
(!nc->guti.has_value())) {
Logger::amf_n2().debug("UE Context Release Complete for the old context");
return;
}
......
......@@ -21,6 +21,8 @@
#include "PDUSessionResourceFailedToSetupItemSURes.hpp"
#include "conversions.hpp"
namespace ngap {
//------------------------------------------------------------------------------
......@@ -56,9 +58,10 @@ bool PDUSessionResourceFailedToSetupItemSURes::encode(
if (!pdu_session_id_.encode(
pdu_session_resource_failed_to_setup_item_su_res->pDUSessionID))
return false;
pdu_session_resource_failed_to_setup_item_su_res
->pDUSessionResourceSetupUnsuccessfulTransfer =
pdu_session_resource_setup_unsuccessful_transfer_;
conv::octet_string_copy(
pdu_session_resource_failed_to_setup_item_su_res
->pDUSessionResourceSetupUnsuccessfulTransfer,
pdu_session_resource_setup_unsuccessful_transfer_);
return true;
}
......@@ -70,10 +73,10 @@ bool PDUSessionResourceFailedToSetupItemSURes::decode(
if (!pdu_session_id_.decode(
pdu_session_resource_failed_to_setup_item_su_res->pDUSessionID))
return false;
pdu_session_resource_setup_unsuccessful_transfer_ =
conv::octet_string_copy(
pdu_session_resource_setup_unsuccessful_transfer_,
pdu_session_resource_failed_to_setup_item_su_res
->pDUSessionResourceSetupUnsuccessfulTransfer;
->pDUSessionResourceSetupUnsuccessfulTransfer);
return true;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment