Commit 4f851ff4 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Merge branch 'fix_n2_ho_uectxrelease' into 'fix_n2_handover'

Fix: ue nas context deleted after successful handover

See merge request oai/cn5g/oai-cn5g-amf!204
parents b1e2bcae 5ec6988a
...@@ -1309,6 +1309,28 @@ void amf_n2::handle_itti_message(itti_ue_context_release_complete& itti_msg) { ...@@ -1309,6 +1309,28 @@ void amf_n2::handle_itti_message(itti_ue_context_release_complete& itti_msg) {
return; return;
} }
std::shared_ptr<ue_ngap_context> unc = {};
if (!amf_ue_id_2_ue_ngap_context(amf_ue_ngap_id, unc)) {
Logger::amf_app().error(
"No UE NGAP context for amf_ngap_id %s, exit", amf_ue_ngap_id);
return;
}
std::shared_ptr<gnb_context> gc = {};
if (!assoc_id_2_gnb_context(itti_msg.assoc_id, gc)) {
Logger::amf_n2().error(
"gNB with assoc_id (%d) is illegal", itti_msg.assoc_id);
return;
}
//verify release cause -> if HandoverSuccessful no further operations required
if(unc->release_cause == Ngap_CauseRadioNetwork_successful_handover && gc->gnb_id == unc->release_gnb){
remove_ran_ue_ngap_id_2_ngap_context(ran_ue_ngap_id, gc->gnb_id);
unc->release_cause = 0;
return;
}
// Change UE status from CM-CONNECTED to CM-IDLE // Change UE status from CM-CONNECTED to CM-IDLE
std::shared_ptr<nas_context> nc = {}; std::shared_ptr<nas_context> nc = {};
if (!amf_n1_inst->amf_ue_id_2_nas_context(amf_ue_ngap_id, nc)) { if (!amf_n1_inst->amf_ue_id_2_nas_context(amf_ue_ngap_id, nc)) {
...@@ -2024,17 +2046,30 @@ void amf_n2::handle_itti_message(itti_handover_notify& itti_msg) { ...@@ -2024,17 +2046,30 @@ void amf_n2::handle_itti_message(itti_handover_notify& itti_msg) {
sctp_s_38412.sctp_send_msg(unc->gnb_assoc_id, 0, &b); sctp_s_38412.sctp_send_msg(unc->gnb_assoc_id, 0, &b);
bdestroy_wrapper(&b); bdestroy_wrapper(&b);
if (!amf_ue_id_2_ue_ngap_context(amf_ue_ngap_id, unc)) { string ue_context_key =
Logger::amf_n2().error( conv::get_ue_context_key(unc->ran_ue_ngap_id, amf_ue_ngap_id);
"No UE NGAP context with amf_ue_ngap_id (" AMF_UE_NGAP_ID_FMT ")", std::shared_ptr<ue_context> uc = {};
amf_ue_ngap_id); 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());
return; return;
} }
//update the NGAP Context
unc->release_cause = Ngap_CauseRadioNetwork_successful_handover;
unc->release_gnb = uc->gnb_id;
unc->ran_ue_ngap_id = ran_ue_ngap_id; // store new RAN ID unc->ran_ue_ngap_id = ran_ue_ngap_id; // store new RAN ID
unc->target_ran_ue_ngap_id = 0; // Clear target RAN ID unc->target_ran_ue_ngap_id = 0; // Clear target RAN ID
unc->ng_ue_state = NGAP_UE_CONNECTED; unc->ng_ue_state = NGAP_UE_CONNECTED;
unc->gnb_assoc_id = itti_msg.assoc_id; // update serving gNB unc->gnb_assoc_id = itti_msg.assoc_id; // update serving gNB
//update NAS Context
nc->ran_ue_ngap_id = ran_ue_ngap_id;
//update User Context
uc->ran_ue_ngap_id = ran_ue_ngap_id;
uc->gnb_id = gc->gnb_id;
set_ran_ue_ngap_id_2_ue_ngap_context(ran_ue_ngap_id, gc->gnb_id, unc); set_ran_ue_ngap_id_2_ue_ngap_context(ran_ue_ngap_id, gc->gnb_id, unc);
} }
......
...@@ -48,6 +48,8 @@ class ue_ngap_context { ...@@ -48,6 +48,8 @@ class ue_ngap_context {
sctp_stream_recv = {}; sctp_stream_recv = {};
sctp_stream_send = {}; sctp_stream_send = {};
release_gnb = {};
release_cause = {};
gnb_assoc_id = {}; gnb_assoc_id = {};
target_gnb_assoc_id = {}; target_gnb_assoc_id = {};
ueContextRequest = false; ueContextRequest = false;
...@@ -91,6 +93,10 @@ class ue_ngap_context { ...@@ -91,6 +93,10 @@ class ue_ngap_context {
uint8_t ncc; // Next Hop Chaining Counter uint8_t ncc; // Next Hop Chaining Counter
OCTET_STRING_t initialUEMsg; OCTET_STRING_t initialUEMsg;
//Release Command Cause and source gNB ID in case of HO
Ngap_CauseRadioNetwork_t release_cause;
uint32_t release_gnb;
}; };
#endif #endif
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