From 6f4e77e00107546a376ae68d390d609b7edb4e90 Mon Sep 17 00:00:00 2001 From: YouSheng Date: Sun, 8 Oct 2023 18:43:14 +0800 Subject: [PATCH] Modify DeregistrationNotificationProcedure - Remove the query parameter - DeregistrationNotifcation and UECM_Deregistration are mutually exclusive --- .../api_handle_dereg_notification.go | 107 +++++++----------- 1 file changed, 40 insertions(+), 67 deletions(-) diff --git a/internal/sbi/httpcallback/api_handle_dereg_notification.go b/internal/sbi/httpcallback/api_handle_dereg_notification.go index df1da38a..a7a649a0 100644 --- a/internal/sbi/httpcallback/api_handle_dereg_notification.go +++ b/internal/sbi/httpcallback/api_handle_dereg_notification.go @@ -44,7 +44,6 @@ func HTTPHandleDeregistrationNotification(c *gin.Context) { } ueid := c.Param("ueid") - deregType := c.Query("type") ue, ok := amf_context.GetSelf().AmfUeFindByUeContextID(ueid) if !ok { logger.CallbackLog.Errorf("AmfUe Context[%s] not found", ueid) @@ -56,7 +55,7 @@ func HTTPHandleDeregistrationNotification(c *gin.Context) { return } - problemDetails, err := DeregistrationNotificationProcedure(ue, deregType, deregData) + problemDetails, err := DeregistrationNotificationProcedure(ue, deregData) if problemDetails != nil { ue.GmmLog.Errorf("Deregistration Notification Procedure Failed Problem[%+v]", problemDetails) } else if err != nil { @@ -70,81 +69,55 @@ func HTTPHandleDeregistrationNotification(c *gin.Context) { // TS 23.502 - 4.2.2.3.3 Network-initiated Deregistration // The AMF can initiate this procedure for either explicit (e.g. by O&M intervention) or // implicit (e.g. expiring of Implicit Deregistration timer) -func DeregistrationNotificationProcedure(ue *amf_context.AmfUe, deregType string, deregData models.DeregistrationData) ( +func DeregistrationNotificationProcedure(ue *amf_context.AmfUe, deregData models.DeregistrationData) ( problemDetails *models.ProblemDetails, err error, ) { - var doUecmDereg bool = true - - if deregType == "implicit" { - // The AMF does not send the Deregistration Request message to the UE for Implicit Deregistration. - switch deregData.DeregReason { - case models.DeregistrationReason_UE_INITIAL_REGISTRATION: - // TS 23.502 - 4.2.2.2.2 General Registration - // Invokes the Nsmf_PDUSession_ReleaseSMContext for the corresponding access type - ue.SmContextList.Range(func(key, value interface{}) bool { - smContext := value.(*amf_context.SmContext) - if smContext.AccessType() == deregData.AccessType { - problemDetails, err = consumer.SendReleaseSmContextRequest(ue, smContext, nil, "", nil) - if problemDetails != nil { - ue.GmmLog.Errorf("Release SmContext Failed Problem[%+v]", problemDetails) - } else if err != nil { - ue.GmmLog.Errorf("Release SmContext Error[%v]", err.Error()) - } - } - return true - }) - case models.DeregistrationReason_SUBSCRIPTION_WITHDRAWN: - // The notification is triggered by the new AMF executing UECM registration, - // UDM will use the new data to replace the old context. - // Therefore old AMF doesn't need to execute UECM de-registration to clean the old context stored in UDM. - doUecmDereg = false - } - // TS 23.502 - 4.2.2.2.2 General Registration - 14e - // TODO: (R16) If old AMF does not have UE context for another access type (i.e. non-3GPP access), - // the Old AMF unsubscribes with the UDM for subscription data using Nudm_SDM_unsubscribe - if ue.SdmSubscriptionId != "" { - problemDetails, err = consumer.SDMUnsubscribe(ue) - if problemDetails != nil { - logger.GmmLog.Errorf("SDM Unubscribe Failed Problem[%+v]", problemDetails) - } else if err != nil { - logger.GmmLog.Errorf("SDM Unubscribe Error[%+v]", err) - } - ue.SdmSubscriptionId = "" - } - - if doUecmDereg { - if ue.UeCmRegistered[deregData.AccessType] { - problemDetails, err := consumer.UeCmDeregistration(ue, deregData.AccessType) + // The AMF does not send the Deregistration Request message to the UE for Implicit Deregistration. + switch deregData.DeregReason { + case models.DeregistrationReason_UE_INITIAL_REGISTRATION: + // TS 23.502 - 4.2.2.2.2 General Registration + // Invokes the Nsmf_PDUSession_ReleaseSMContext for the corresponding access type + ue.SmContextList.Range(func(key, value interface{}) bool { + smContext := value.(*amf_context.SmContext) + if smContext.AccessType() == deregData.AccessType { + problemDetails, err = consumer.SendReleaseSmContextRequest(ue, smContext, nil, "", nil) if problemDetails != nil { - logger.GmmLog.Errorf("UECM Deregistration Failed Problem[%+v]", problemDetails) + ue.GmmLog.Errorf("Release SmContext Failed Problem[%+v]", problemDetails) } else if err != nil { - logger.GmmLog.Errorf("UECM Deregistration Error[%+v]", err) + ue.GmmLog.Errorf("Release SmContext Error[%v]", err.Error()) } - ue.UeCmRegistered[deregData.AccessType] = false } + return true + }) + } + // TS 23.502 - 4.2.2.2.2 General Registration - 14e + // TODO: (R16) If old AMF does not have UE context for another access type (i.e. non-3GPP access), + // the Old AMF unsubscribes with the UDM for subscription data using Nudm_SDM_unsubscribe + if ue.SdmSubscriptionId != "" { + problemDetails, err = consumer.SDMUnsubscribe(ue) + if problemDetails != nil { + logger.GmmLog.Errorf("SDM Unubscribe Failed Problem[%+v]", problemDetails) + } else if err != nil { + logger.GmmLog.Errorf("SDM Unubscribe Error[%+v]", err) } + ue.SdmSubscriptionId = "" + } - // TS 23.502 - 4.2.2.2.2 General Registration - 20 - if ue.PolicyAssociationId != "" { - // TODO: It also needs to check if the PCF ID is tranfered to new AMF - // Currently, old AMF will transfer the PCF ID but new AMF will not utilize the PCF ID - problemDetails, err := consumer.AMPolicyControlDelete(ue) - if problemDetails != nil { - logger.GmmLog.Errorf("Delete AM policy Failed Problem[%+v]", problemDetails) - } else if err != nil { - logger.GmmLog.Errorf("Delete AM policy Error[%+v]", err) - } + // TS 23.502 - 4.2.2.2.2 General Registration - 20 AMF-Initiated Policy Association Termination + if ue.PolicyAssociationId != "" { + // TODO: It also needs to check if the PCF ID is tranfered to new AMF + // Currently, old AMF will transfer the PCF ID but new AMF will not utilize the PCF ID + problemDetails, err := consumer.AMPolicyControlDelete(ue) + if problemDetails != nil { + logger.GmmLog.Errorf("Delete AM policy Failed Problem[%+v]", problemDetails) + } else if err != nil { + logger.GmmLog.Errorf("Delete AM policy Error[%+v]", err) } - - // The old AMF should clean the UE context - // TODO: (R16) Only remove the target access UE context - ue.Remove() - } else if deregType == "explicit" { - // TODO: TS 23.502 - 4.2.2.3.3 Network-initiated Deregistration - // AMF may need to send Deregistration Request message to the UE. - } else { - logger.CallbackLog.Errorf("Deregistration Notification Procedure: unknown deregistration type: %v", deregType) } + // The old AMF should clean the UE context + // TODO: (R16) Only remove the target access UE context + ue.Remove() + return nil, nil }