Free5gc DownlinkNASTransport, Registration reject (UE identity cannot be derived by the network)

The free5gc received “InitialUEMessage, Registration request, Registration request” and responded with “DownlinkNASTransport, Registration reject (UE identity cannot be derived by the network)”.
The reason seems to be that the context of the UE and the amfid of free5gc are different.
The following was output to the log, but the procedure still proceeded.

Does “Registration reject (UE identity cannot be derived by the network)” have an impact on “Registration reject (Protocol error, unspecified)”?

2022-02-02T10:58:40+09:00 [INFO][AMF][GIN] | 404 | 127.0.0.1 | POST | /namf-comm/v1/ue-contexts/5g-guti-0010107050400000008/transfer |
2022-02-02T10:58:40+09:00 [ERRO][AMF][GMM][AMF_UE_NGAP_ID:5] UE Context Transfer Request Error[404 is not a valid status code in UEContextTransfer]
2022-02-02T10:58:40+09:00 [INFO][AMF][GMM][AMF_UE_NGAP_ID:5] Send Registration Reject

amfid_071404_console_log.zip (16.8 KB)


Core_0202-1_amdif_071404.pcap (15.7 KB)

#amfid
UE : 070504
free5gc : 071404

#IP
RAN:192.168.45.3
AMF:192.168.45.25

#version
free5gc version is 3.0.6.

#UE,RAN
UERANSIM is not used.
UE is Oneplus8.
I can’t answer the vendor of the RAN.(confidentiality)

#Cause (please tell me if I’m wrong)

Although free5gc tried to communicate with new AMF and old AMF via NRF, free5gc could not obtain the information of old AMF from NRF. (Data could not be acquired from NRF because old AMF is undefined.)

#soure code

free5gc/NFs/amf/gmm/handler.go

    // TODO (TS 23.502 4.2.2.2 step 4): if UE's 5g-GUTI is included & serving AMF has changed
    // since last registration procedure, new AMF may invoke Namf_Communication_UEContextTransfer
    // to old AMF, including the complete registration request nas msg, to request UE's SUPI & UE Context
    if ue.ServingAmfChanged {
            var transferReason models.TransferReason
            switch ue.RegistrationType5GS {
            case nasMessage.RegistrationType5GSInitialRegistration:
                    transferReason = models.TransferReason_INIT_REG
            case nasMessage.RegistrationType5GSMobilityRegistrationUpdating:
                    fallthrough
            case nasMessage.RegistrationType5GSPeriodicRegistrationUpdating:
                    transferReason = models.TransferReason_MOBI_REG
            }

            searchOpt := Nnrf_NFDiscovery.SearchNFInstancesParamOpts{
                    Guami: optional.NewInterface(util.MarshToJsonString(guamiFromUeGuti)),
            }
            err := consumer.SearchAmfCommunicationInstance(ue, amfSelf.NrfUri, models.NfType_AMF, models.NfType_AMF, &searchOpt)
            if err != nil {
                    ue.GmmLog.Errorf("[GMM] %+v", err)
                    gmm_message.SendRegistrationReject(ue.RanUe[anType], nasMessage.Cause5GMMUEIdentityCannotBeDerivedByTheNetwork, "") 
                    return err
            }

            ueContextTransferRspData, problemDetails, err := consumer.UEContextTransferRequest(ue, anType, transferReason)
            if problemDetails != nil {
                    if problemDetails.Cause == "INTEGRITY_CHECK_FAIL" || problemDetails.Cause == "CONTEXT_NOT_FOUND" {
                            ue.GmmLog.Warnf("Can not retrieve UE Context from old AMF[Cause: %s]", problemDetails.Cause)
                    } else {
                            ue.GmmLog.Warnf("UE Context Transfer Request Failed Problem[%+v]", problemDetails)
                    }
                    ue.SecurityContextAvailable = false // need to start authentication procedure later
            } else if err != nil {
                    ue.GmmLog.Errorf("UE Context Transfer Request Error[%+v]", err)
                    gmm_message.SendRegistrationReject(ue.RanUe[anType], nasMessage.Cause5GMMUEIdentityCannotBeDerivedByTheNetwork, "")
            } else {
                    ue.CopyDataFromUeContextModel(*ueContextTransferRspData.UeContext)
            }
    }
    return nil

free5gc/NFs/amf/consumer/nf_discovery.go

func SearchAmfCommunicationInstance(ue *amf_context.AmfUe, nrfUri string, targetNfType,
requestNfType models.NfType, param *Nnrf_NFDiscovery.SearchNFInstancesParamOpts) (err error) {
resp, localErr := SendSearchNFInstances(nrfUri, targetNfType, requestNfType, param)
if localErr != nil {
err = localErr
return
}

    // select the first AMF, TODO: select base on other info
    var amfUri string
    for _, nfProfile := range resp.NfInstances {
            ue.TargetAmfProfile = &nfProfile
            amfUri = util.SearchNFServiceUri(nfProfile, models.ServiceName_NAMF_COMM, models.NfServiceStatus_REGISTERED)
            if amfUri != "" {
                    break
            }
    }
    ue.TargetAmfUri = amfUri
    if ue.TargetAmfUri == "" {
            err = fmt.Errorf("AMF can not select an target AMF by NRF")
    }
    return

}

#3gpp

TS 23.502 4.2.2.2
step 4(Namf_Communication_UEContextTransfer)