From 68013ee0b1c958c3abc1508771ce3d6630fab8bf Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Thu, 4 Jan 2024 23:47:44 +0800 Subject: [PATCH] send reroute nas msg if SendN1MessageNotifyAtAMFReAllocation failed (#117) --- internal/gmm/handler.go | 16 +++++++++++++--- internal/sbi/producer/callback/n1n2message.go | 5 ++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/internal/gmm/handler.go b/internal/gmm/handler.go index 10df56fe..1de563a3 100644 --- a/internal/gmm/handler.go +++ b/internal/gmm/handler.go @@ -1096,6 +1096,7 @@ func handleRequestedNssai(ue *context.AmfUe, anType models.AccessType) error { amfSelf := context.GetSelf() if ue.RegistrationRequest.RequestedNSSAI != nil { + logger.GmmLog.Infof("RequestedNssai: %+v", ue.RegistrationRequest.RequestedNSSAI) requestedNssai, err := nasConvert.RequestedNssaiToModels(ue.RegistrationRequest.RequestedNSSAI) if err != nil { return fmt.Errorf("Decode failed at RequestedNSSAI[%s]", err) @@ -1128,6 +1129,7 @@ func handleRequestedNssai(ue *context.AmfUe, anType models.AccessType) error { if !amfSelf.InPlmnSupportList(reqSnssai) { needSliceSelection = true + logger.GmmLog.Warnf("RequestedNssai[%+v] is not supported by AMF", reqSnssai) break } } @@ -1198,6 +1200,7 @@ func handleRequestedNssai(ue *context.AmfUe, anType models.AccessType) error { } } + sendReroute := true err = consumer.SearchAmfCommunicationInstance(ue, amfSelf.NrfUri, models.NfType_AMF, models.NfType_AMF, &searchTargetAmfQueryParam) if err == nil { @@ -1229,10 +1232,17 @@ func handleRequestedNssai(ue *context.AmfUe, anType models.AccessType) error { var n1Message bytes.Buffer err = ue.RegistrationRequest.EncodeRegistrationRequest(&n1Message) if err != nil { - return fmt.Errorf("re-encoding registration request message is failed: %w", err) + logger.GmmLog.Errorf("re-encoding registration request message is failed: %+v", err) + } else { + err = callback.SendN1MessageNotifyAtAMFReAllocation(ue, n1Message.Bytes(), ®isterContext) + if err != nil { + logger.GmmLog.Errorf("send N1MessageNotify failed: %+v", err) + } else { + sendReroute = false + } } - callback.SendN1MessageNotifyAtAMFReAllocation(ue, n1Message.Bytes(), ®isterContext) - } else { + } + if sendReroute { // Condition (B) Step 7: initial AMF can not find Target AMF via NRF -> Send Reroute NAS Request to RAN allowedNssaiNgap := ngapConvert.AllowedNssaiToNgap(ue.AllowedNssai[anType]) ngap_message.SendRerouteNasRequest(ue, anType, nil, ue.RanUe[anType].InitialUEMessage, &allowedNssaiNgap) diff --git a/internal/sbi/producer/callback/n1n2message.go b/internal/sbi/producer/callback/n1n2message.go index 6687c50e..5fec080b 100644 --- a/internal/sbi/producer/callback/n1n2message.go +++ b/internal/sbi/producer/callback/n1n2message.go @@ -88,7 +88,8 @@ func SendN1MessageNotify(ue *amf_context.AmfUe, n1class models.N1MessageClass, n // TS 29.518 5.2.2.3.5.2 func SendN1MessageNotifyAtAMFReAllocation( ue *amf_context.AmfUe, n1Msg []byte, registerContext *models.RegistrationContextContainer, -) { +) error { + logger.CommLog.Infoln("Send N1 Message Notify at AMF Re-allocation") configuration := Namf_Communication.NewConfiguration() client := Namf_Communication.NewAPIClient(configuration) @@ -122,7 +123,9 @@ func SendN1MessageNotifyAtAMFReAllocation( } else if err.Error() != httpResp.Status { HttpLog.Errorln(err.Error()) } + return err } + return nil } func SendN2InfoNotify(ue *amf_context.AmfUe, n2class models.N2InformationClass, n1Msg, n2Msg []byte) {