amf: Refactor local release flow

This commit is contained in:
LSKhappychild 2026-03-11 06:54:23 +00:00 committed by Sukchan Lee
parent d54ab9ee6a
commit 6899c0f066
3 changed files with 38 additions and 2 deletions

View file

@ -4910,8 +4910,22 @@ void ngap_handle_error_indication(amf_gnb_t *gnb, ogs_ngap_message_t *message)
amf_ue = amf_ue_find_by_id(ran_ue->amf_ue_id);
if (amf_ue) {
amf_ue_deassociate_ran_ue(amf_ue, ran_ue);
int xact_count = amf_sess_xact_count(amf_ue);
amf_sbi_send_deactivate_all_sessions(
ran_ue, amf_ue,
AMF_UPDATE_SM_CONTEXT_DEACTIVATED_LOCAL,
NGAP_Cause_PR_nas,
NGAP_CauseNas_normal_release);
if (amf_sess_xact_count(amf_ue) == xact_count) {
ran_ue->ue_ctx_rel_action =
NGAP_UE_CTX_REL_NG_REMOVE_AND_UNLINK;
ngap_handle_ue_context_release_action(ran_ue);
}
} else {
ran_ue->ue_ctx_rel_action = NGAP_UE_CTX_REL_NG_CONTEXT_REMOVE;
ngap_handle_ue_context_release_action(ran_ue);
}
ran_ue_remove(ran_ue);
}
}

View file

@ -19,6 +19,7 @@
#include "nsmf-handler.h"
#include "nas-path.h"
#include "ngap-handler.h"
#include "ngap-path.h"
#include "sbi-path.h"
@ -635,6 +636,26 @@ int amf_nsmf_pdusession_handle_update_sm_context(
}
}
} else if (state ==
AMF_UPDATE_SM_CONTEXT_DEACTIVATED_LOCAL) {
/*
* ErrorIndication-triggered local release:
* Sessions have been deactivated; perform the release
* action directly without sending UEContextReleaseCommand
* since the RAN context is already considered lost.
*/
if (AMF_SESSION_SYNC_DONE(amf_ue, state)) {
if (ran_ue) {
ran_ue->ue_ctx_rel_action =
NGAP_UE_CTX_REL_NG_REMOVE_AND_UNLINK;
ngap_handle_ue_context_release_action(ran_ue);
} else {
ogs_warn("[%s] RAN-NG Context has already been removed",
amf_ue->supi);
}
}
} else if (state == AMF_UPDATE_SM_CONTEXT_REGISTRATION_REQUEST) {
/* Not reached here */

View file

@ -57,6 +57,7 @@ bool amf_sbi_send_request(
#define AMF_UPDATE_SM_CONTEXT_ACTIVATED 11
#define AMF_UPDATE_SM_CONTEXT_SETUP_FAIL 12
#define AMF_UPDATE_SM_CONTEXT_DEACTIVATED 13
#define AMF_UPDATE_SM_CONTEXT_DEACTIVATED_LOCAL 25
#define AMF_UPDATE_SM_CONTEXT_REGISTRATION_REQUEST 14
#define AMF_UPDATE_SM_CONTEXT_SERVICE_REQUEST 15
#define AMF_UPDATE_SM_CONTEXT_MODIFIED 16