From 30b37986d7b6741d426527ed5721ed9fb9e76233 Mon Sep 17 00:00:00 2001 From: donald1218 Date: Mon, 16 Sep 2024 11:33:46 +0000 Subject: [PATCH] fix: release twice uecontext when handover --- internal/gmm/common/user_profile.go | 14 ++++++++++++++ internal/ngap/handler.go | 4 +--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/internal/gmm/common/user_profile.go b/internal/gmm/common/user_profile.go index 00b08a2..cd2cd7f 100644 --- a/internal/gmm/common/user_profile.go +++ b/internal/gmm/common/user_profile.go @@ -69,6 +69,20 @@ func AttachRanUeToAmfUeAndReleaseOldIfAny(amfUe *context.AmfUe, ranUe *context.R amfUe.AttachRanUe(ranUe) } +func AttachRanUeToAmfUeAndReleaseOldIfHandover(amfUe *context.AmfUe, ranUe *context.RanUe) { + if oldRanUe := amfUe.RanUe[ranUe.Ran.AnType]; oldRanUe != nil { + oldRanUe.DetachAmfUe() + if amfUe.T3550 != nil { + amfUe.State[ranUe.Ran.AnType].Set(context.Registered) + } + StopAll5GSMMTimers(amfUe) + causeGroup := ngapType.CausePresentNas + causeValue := ngapType.CauseNasPresentNormalRelease + ngap_message.SendUEContextReleaseCommand(oldRanUe, context.UeContextReleaseHandover, causeGroup, causeValue) + } + amfUe.AttachRanUe(ranUe) +} + func ClearHoldingRanUe(ranUe *context.RanUe) { if ranUe != nil { ranUe.DetachAmfUe() diff --git a/internal/ngap/handler.go b/internal/ngap/handler.go index d10116d..3924139 100644 --- a/internal/ngap/handler.go +++ b/internal/ngap/handler.go @@ -1211,10 +1211,8 @@ func handleHandoverNotifyMain(ran *context.AmfRan, ran.Log.Errorf("Send UpdateSmContextN2HandoverComplete Error[%s]", err.Error()) } } - gmm_common.AttachRanUeToAmfUeAndReleaseOldIfAny(amfUe, targetUe) - ngap_message.SendUEContextReleaseCommand(sourceUe, context.UeContextReleaseHandover, ngapType.CausePresentNas, - ngapType.CauseNasPresentNormalRelease) + gmm_common.AttachRanUeToAmfUeAndReleaseOldIfHandover(amfUe, targetUe) } // TODO: The UE initiates Mobility Registration Update procedure as described in clause 4.2.2.2.2.