From 21aa437ddbe93181c5820fd8eb5f5ecf594a2866 Mon Sep 17 00:00:00 2001 From: squishy me <69491904+Leon777-coder@users.noreply.github.com> Date: Tue, 26 Dec 2023 21:04:38 +0800 Subject: [PATCH] Update handler.go (#113) * Update handler.go * fix: target AMF should not be self * style: linter error * fix: typo * fix: After SendRerouteNasRequest(), it should return err * Update handler.go return error added * Update handler.go line 1235 [return nill] deleted, since it will reach the following return --------- Co-authored-by: brianchennn --- internal/gmm/handler.go | 21 ++++++++++++++++----- internal/sbi/consumer/nf_discovery.go | 3 +++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/internal/gmm/handler.go b/internal/gmm/handler.go index 2c0fa29c..10df56fe 100644 --- a/internal/gmm/handler.go +++ b/internal/gmm/handler.go @@ -1120,6 +1120,16 @@ func handleRequestedNssai(ue *context.AmfUe, anType models.AccessType) error { needSliceSelection = true break } + + reqSnssai := models.Snssai{ + Sst: requestedSnssai.ServingSnssai.Sst, + Sd: requestedSnssai.ServingSnssai.Sd, + } + + if !amfSelf.InPlmnSupportList(reqSnssai) { + needSliceSelection = true + break + } } if needSliceSelection { @@ -1161,12 +1171,12 @@ func handleRequestedNssai(ue *context.AmfUe, anType models.AccessType) error { // Step 6 searchTargetAmfQueryParam := Nnrf_NFDiscovery.SearchNFInstancesParamOpts{} if ue.NetworkSliceInfo != nil { - netwotkSliceInfo := ue.NetworkSliceInfo - if netwotkSliceInfo.TargetAmfSet != "" { + networkSliceInfo := ue.NetworkSliceInfo + if networkSliceInfo.TargetAmfSet != "" { // TS 29.531 // TargetAmfSet format: ^[0-9]{3}-[0-9]{2-3}-[A-Fa-f0-9]{2}-[0-3][A-Fa-f0-9]{2}$ // mcc-mnc-amfRegionId(8 bit)-AmfSetId(10 bit) - targetAmfSetToken := strings.Split(netwotkSliceInfo.TargetAmfSet, "-") + targetAmfSetToken := strings.Split(networkSliceInfo.TargetAmfSet, "-") guami := amfSelf.ServedGuamiList[0] targetAmfPlmnId := models.PlmnId{ Mcc: targetAmfSetToken[0], @@ -1182,9 +1192,9 @@ func handleRequestedNssai(ue *context.AmfUe, anType models.AccessType) error { searchTargetAmfQueryParam.AmfRegionId = optional.NewString(targetAmfSetToken[2]) searchTargetAmfQueryParam.AmfSetId = optional.NewString(targetAmfSetToken[3]) - } else if len(netwotkSliceInfo.CandidateAmfList) > 0 { + } else if len(networkSliceInfo.CandidateAmfList) > 0 { // TODO: select candidate Amf based on local poilcy - searchTargetAmfQueryParam.TargetNfInstanceId = optional.NewInterface(netwotkSliceInfo.CandidateAmfList[0]) + searchTargetAmfQueryParam.TargetNfInstanceId = optional.NewInterface(networkSliceInfo.CandidateAmfList[0]) } } @@ -1226,6 +1236,7 @@ func handleRequestedNssai(ue *context.AmfUe, anType models.AccessType) error { // 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) + return err } return nil } diff --git a/internal/sbi/consumer/nf_discovery.go b/internal/sbi/consumer/nf_discovery.go index ada46d33..aec93638 100644 --- a/internal/sbi/consumer/nf_discovery.go +++ b/internal/sbi/consumer/nf_discovery.go @@ -103,6 +103,9 @@ func SearchAmfCommunicationInstance(ue *amf_context.AmfUe, nrfUri string, target // select the first AMF, TODO: select base on other info var amfUri string for _, nfProfile := range resp.NfInstances { + if nfProfile.NfInstanceId == amf_context.GetSelf().NfId { + continue + } ue.TargetAmfProfile = &nfProfile amfUri = util.SearchNFServiceUri(nfProfile, models.ServiceName_NAMF_COMM, models.NfServiceStatus_REGISTERED) if amfUri != "" {