amf: Revise local release flow as suggested

This commit is contained in:
LSKhappychild 2026-03-12 05:12:24 +00:00 committed by Sukchan Lee
parent 6899c0f066
commit 88116fd1c6
3 changed files with 33 additions and 33 deletions

View file

@ -4902,30 +4902,34 @@ void ngap_handle_error_indication(amf_gnb_t *gnb, ogs_ngap_message_t *message)
if (ran_ue) {
amf_ue_t *amf_ue = NULL;
int xact_count = 0;
ogs_warn(" Performing local release for"
" RAN_UE_NGAP_ID[%lld] AMF_UE_NGAP_ID[%lld]",
ogs_warn(" Performing local release for "
"RAN_UE_NGAP_ID[%lld] AMF_UE_NGAP_ID[%lld]",
(long long)ran_ue->ran_ue_ngap_id,
(long long)ran_ue->amf_ue_ngap_id);
amf_ue = amf_ue_find_by_id(ran_ue->amf_ue_id);
if (amf_ue) {
int xact_count = amf_sess_xact_count(amf_ue);
CLEAR_AMF_UE_ALL_TIMERS(amf_ue);
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);
AMF_REMOVE_N2_CONTEXT_BY_ERROR_INDICATION,
Cause->present, (int)Cause->choice.radioNetwork);
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);
ogs_debug(" SUPI[%s]", amf_ue->supi);
amf_ue_deassociate_ran_ue(amf_ue, ran_ue);
ran_ue_remove(ran_ue);
ogs_timer_start(amf_ue->mobile_reachable.timer,
ogs_time_from_sec(
amf_self()->time.t3512.value + 240));
}
} 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,7 +19,6 @@
#include "nsmf-handler.h"
#include "nas-path.h"
#include "ngap-handler.h"
#include "ngap-path.h"
#include "sbi-path.h"
@ -636,26 +635,6 @@ 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 */
@ -819,6 +798,23 @@ int amf_nsmf_pdusession_handle_update_sm_context(
amf_self()->time.t3512.value + 240));
}
} else if (state == AMF_REMOVE_N2_CONTEXT_BY_ERROR_INDICATION) {
if (AMF_SESSION_SYNC_DONE(amf_ue, state)) {
if (ran_ue) {
ogs_debug(" SUPI[%s]", amf_ue->supi);
amf_ue_deassociate_ran_ue(amf_ue, ran_ue);
ran_ue_remove(ran_ue);
} else {
ogs_warn("[%s] RAN-NG Context has already been removed",
amf_ue->supi);
}
ogs_timer_start(amf_ue->mobile_reachable.timer,
ogs_time_from_sec(
amf_self()->time.t3512.value + 240));
}
} else if (state == AMF_REMOVE_S1_CONTEXT_BY_RESET_ALL) {
if (AMF_SESSION_SYNC_DONE(amf_ue, state)) {

View file

@ -57,7 +57,6 @@ 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
@ -75,6 +74,7 @@ bool amf_sbi_send_request(
#define AMF_REMOVE_S1_CONTEXT_BY_LO_CONNREFUSED 51
#define AMF_REMOVE_S1_CONTEXT_BY_RESET_ALL 52
#define AMF_REMOVE_S1_CONTEXT_BY_RESET_PARTIAL 53
#define AMF_REMOVE_N2_CONTEXT_BY_ERROR_INDICATION 54
/*
* TS23.502