Skip to content

Commit

Permalink
Send Deregistration Notify before UDM modifies the UE context (#25)
Browse files Browse the repository at this point in the history
* Send Deregistration Notify before UDM modifies the UE context
* If sending Deregistration Notify after UDM modifies the UE context, old AMF can't deregister for the UE.

* Fix lint error

* Modify RegistrationAmf3gppAccessProcedure
* Compare the old UECM context with the new one to determine whether to send a deregistration notification.
* Use goroutine to send a deregistration notification to old AMF.

* Modify HandleRegistrationAmf3gppAccessRequest and SendOnDeregistrationNotification
* Supplement the missed patch.
* Add query parameters to differentiate whether the type is implicit or explicit.

* Modify RegistrationAmf3gppAccessProcedure
- Remove the query parameter
- Replace the DeregReason with UE_INITIAL_REGISTRATION, since it's triggered during the registration procedure

* deregReason should be DeregistrationReason_UE_INITIAL_REGISTRATION if InitialRegistrationInd is true

---------

Co-authored-by: Tim Liu <[email protected]>
  • Loading branch information
YouShengLiu and tim-ywliu authored Oct 12, 2023
1 parent a0d6353 commit 0f91e05
Showing 1 changed file with 32 additions and 11 deletions.
43 changes: 32 additions & 11 deletions internal/sbi/producer/ue_context_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,11 @@ func HandleRegistrationAmf3gppAccessRequest(request *httpwrapper.Request) *httpw

// step 4: process the return value from step 3
if response != nil {
// status code is based on SPEC, and option headers
return httpwrapper.NewResponse(http.StatusCreated, header, response)
if header != nil {
// status code is based on SPEC, and option headers
return httpwrapper.NewResponse(http.StatusCreated, header, response)
}
return httpwrapper.NewResponse(http.StatusOK, nil, response)
} else if problemDetails != nil {
return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails)
} else {
Expand All @@ -213,8 +216,10 @@ func RegistrationAmf3gppAccessProcedure(registerRequest models.Amf3GppAccessRegi
) {
// TODO: EPS interworking with N26 is not supported yet in this stage
var oldAmf3GppAccessRegContext *models.Amf3GppAccessRegistration
var ue *udm_context.UdmUeContext

if udm_context.Getself().UdmAmf3gppRegContextExists(ueID) {
ue, _ := udm_context.Getself().UdmUeFindBySupi(ueID)
ue, _ = udm_context.Getself().UdmUeFindBySupi(ueID)
oldAmf3GppAccessRegContext = ue.Amf3GppAccessRegistration
}

Expand Down Expand Up @@ -248,14 +253,30 @@ func RegistrationAmf3gppAccessProcedure(registerRequest models.Amf3GppAccessRegi
// TS 23.502 4.2.2.2.2 14d: UDM initiate a Nudm_UECM_DeregistrationNotification to the old AMF
// corresponding to the same (e.g. 3GPP) access, if one exists
if oldAmf3GppAccessRegContext != nil {
deregistData := models.DeregistrationData{
DeregReason: models.DeregistrationReason_SUBSCRIPTION_WITHDRAWN,
AccessType: models.AccessType__3_GPP_ACCESS,
}
callback.SendOnDeregistrationNotification(ueID, oldAmf3GppAccessRegContext.DeregCallbackUri,
deregistData) // Deregistration Notify Triggered
if !ue.SameAsStoredGUAMI3gpp(*oldAmf3GppAccessRegContext.Guami) {
// Based on TS 23.502 4.2.2.2.2, If the serving NF removal reason indicated by the UDM is Initial Registration,
// the old AMF invokes the Nsmf_PDUSession_ReleaseSMContext (SM Context ID). Thus we give different
// dereg cause based on registration parameter from serving AMF
deregReason := models.DeregistrationReason_UE_REGISTRATION_AREA_CHANGE
if registerRequest.InitialRegistrationInd {
deregReason = models.DeregistrationReason_UE_INITIAL_REGISTRATION
}
deregistData := models.DeregistrationData{
DeregReason: deregReason,
AccessType: models.AccessType__3_GPP_ACCESS,
}

return nil, nil, nil
go func() {
logger.UecmLog.Infof("Send DeregNotify to old AMF GUAMI=%v", oldAmf3GppAccessRegContext.Guami)
pd := callback.SendOnDeregistrationNotification(ueID,
oldAmf3GppAccessRegContext.DeregCallbackUri,
deregistData) // Deregistration Notify Triggered
if pd != nil {
logger.UecmLog.Errorf("RegistrationAmf3gppAccess: send DeregNotify fail %v", pd)
}
}()
}
return nil, &registerRequest, nil
} else {
header = make(http.Header)
udmUe, _ := udm_context.Getself().UdmUeFindBySupi(ueID)
Expand Down Expand Up @@ -326,7 +347,7 @@ func RegisterAmfNon3gppAccessProcedure(registerRequest models.AmfNon3GppAccessRe
// corresponding to the same (e.g. 3GPP) access, if one exists
if oldAmfNon3GppAccessRegContext != nil {
deregistData := models.DeregistrationData{
DeregReason: models.DeregistrationReason_SUBSCRIPTION_WITHDRAWN,
DeregReason: models.DeregistrationReason_UE_INITIAL_REGISTRATION,
AccessType: models.AccessType_NON_3_GPP_ACCESS,
}
callback.SendOnDeregistrationNotification(ueID, oldAmfNon3GppAccessRegContext.DeregCallbackUri,
Expand Down

0 comments on commit 0f91e05

Please sign in to comment.