diff --git a/internal/context/datapath.go b/internal/context/datapath.go index 00b232d8..f71af290 100644 --- a/internal/context/datapath.go +++ b/internal/context/datapath.go @@ -33,14 +33,15 @@ var standardGbr5QIs = map[int32]struct{}{ 76: {}, } +type ANInformation struct { + IPAddress net.IP + TEID uint32 +} + type UPTunnel struct { PathIDGenerator *idgenerator.IDGenerator DataPathPool DataPathPool - //InvolvedUPFs map[uuid.UUID]*UPF - ANInformation struct { - IPAddress net.IP - TEID uint32 - } + ANInformation *ANInformation } func (t *UPTunnel) String() string { @@ -624,7 +625,7 @@ func (dataPath *DataPath) ActivateTunnelAndPDR(smContext *SMContext, precedence logger.PduSessLog.Traceln("Current DP Node IP: ", curDataPathNode.UPF.NodeID.ResolveNodeIdToIp().String()) logger.PduSessLog.Traceln("Before DLPDR OuterHeaderCreation") if nextDLDest := curDataPathNode.Prev(); nextDLDest != nil { - logger.PduSessLog.Traceln("In DLPDR OuterHeaderCreation") + logger.PduSessLog.Traceln("In DLPDR OuterHeaderCreation, this is not the AN-UPF node") nextDLTunnel := nextDLDest.DownLinkTunnel // If the flow is disable, the tunnel and the session rules will not be created @@ -652,13 +653,15 @@ func (dataPath *DataPath) ActivateTunnelAndPDR(smContext *SMContext, precedence } } } else { + logger.PduSessLog.Traceln("In DLPDR OuterHeaderCreation, this is the AN-UPF node") ANUPF := dataPath.FirstDPNode DLPDR := ANUPF.DownLinkTunnel.PDR DLFAR := DLPDR.FAR DLFAR.ForwardingParameters = new(ForwardingParameters) DLFAR.ForwardingParameters.DestinationInterface.InterfaceValue = pfcpType.DestinationInterfaceAccess - if anIP := smContext.Tunnel.ANInformation.IPAddress; anIP != nil { + if anInfo := smContext.Tunnel.ANInformation; anInfo != nil { + logger.PduSessLog.Tracef("anIP not nil, set DL FAR OuterHeaderCreation to IP %s and TEID %d", anInfo.IPAddress, anInfo.TEID) DLFAR.ForwardingParameters.NetworkInstance = &pfcpType.NetworkInstance{ NetworkInstance: smContext.Dnn, FQDNEncoding: factory.SmfConfig.Configuration.NwInstFqdnEncoding, @@ -667,8 +670,8 @@ func (dataPath *DataPath) ActivateTunnelAndPDR(smContext *SMContext, precedence dlOuterHeaderCreation := DLFAR.ForwardingParameters.OuterHeaderCreation dlOuterHeaderCreation.OuterHeaderCreationDescription = pfcpType.OuterHeaderCreationGtpUUdpIpv4 - dlOuterHeaderCreation.Teid = smContext.Tunnel.ANInformation.TEID - dlOuterHeaderCreation.Ipv4Address = smContext.Tunnel.ANInformation.IPAddress.To4() + dlOuterHeaderCreation.Teid = anInfo.TEID + dlOuterHeaderCreation.Ipv4Address = anInfo.IPAddress.To4() } } } diff --git a/internal/context/pfcp_rules.go b/internal/context/pfcp_rules.go index 08589e12..4d5d6310 100644 --- a/internal/context/pfcp_rules.go +++ b/internal/context/pfcp_rules.go @@ -296,6 +296,27 @@ func (urr *URR) String(prefix string) string { return str } +func SDFFilterToString(filter *pfcpType.SDFFilter, prefix string) string { + str := prefix + " SDFFilter {\n" + prefix += " " + if filter == nil { + return str + prefix + "}" + } + str += prefix + fmt.Sprintf("SdfFilterId: %d\n", filter.SdfFilterId) + str += prefix + fmt.Sprintf("Bid: %t\n", filter.Bid) + str += prefix + fmt.Sprintf("Fl: %t\n", filter.Fl) + str += prefix + fmt.Sprintf("Spi: %t\n", filter.Spi) + str += prefix + fmt.Sprintf("Ttc: %t\n", filter.Ttc) + str += prefix + fmt.Sprintf("Fd: %t\n", filter.Fd) + str += prefix + fmt.Sprintf("LengthOfFlowDescription: %d\n", filter.LengthOfFlowDescription) + str += prefix + fmt.Sprintf("FlowDescription: %s\n", string(filter.FlowDescription)) + str += prefix + fmt.Sprintf("TosTrafficClass: %v\n", filter.TosTrafficClass) + str += prefix + fmt.Sprintf("SecurityParameterIndex: %v\n", filter.SecurityParameterIndex) + str += prefix + fmt.Sprintf("FlowLabel: %v\n", filter.FlowLabel) + str += prefix + "}" + return str +} + func (pdi *PDI) String(prefix string) string { if pdi == nil { return prefix + "PDI: nil" @@ -308,7 +329,7 @@ func (pdi *PDI) String(prefix string) string { } str += prefix + fmt.Sprintf("NetworkInstance: %+v\n", pdi.NetworkInstance) str += prefix + fmt.Sprintf("UEIPAddress: %+v\n", pdi.UEIPAddress) - str += prefix + fmt.Sprintf("SDFFilter: %+v\n", pdi.SDFFilter) + str += prefix + fmt.Sprintf("SDFFilter: %s\n", SDFFilterToString(pdi.SDFFilter, prefix)) str += prefix + fmt.Sprintf("ApplicationID: %s\n", pdi.ApplicationID) prefix = prefix[:len(prefix)-2] str += prefix + "}" @@ -339,7 +360,11 @@ func (far *FAR) String(prefix string) string { prefix += " " str += prefix + fmt.Sprintf("State: %s\n", far.state) str += prefix + fmt.Sprintf("ApplyAction: %+v\n", far.ApplyAction) - str += prefix + fmt.Sprintf("%s\n", far.ForwardingParameters.String(prefix)) + if far.ForwardingParameters != nil { + str += prefix + fmt.Sprintf("%s\n", far.ForwardingParameters.String(prefix)) + } else { + str += prefix + fmt.Sprintln("ForwardingParameters: nil") + } if far.BAR != nil { str += prefix + fmt.Sprintf("%s\n", far.BAR.String(prefix)) } diff --git a/internal/sbi/producer/pdu_session.go b/internal/sbi/producer/pdu_session.go index 4e2d7007..a608d15f 100644 --- a/internal/sbi/producer/pdu_session.go +++ b/internal/sbi/producer/pdu_session.go @@ -4,7 +4,6 @@ import ( "encoding/hex" "errors" "fmt" - "net" "net/http" "github.com/antihax/optional" @@ -645,10 +644,7 @@ func HandlePDUSessionSMContextUpdate(smContextRef string, body models.UpdateSmCo logger.PduSessLog.Traceln("In case N2SmInfoType_PDU_RES_REL_RSP") // remove an tunnel info smContext.Log.Infoln("Handle N2 PDU Resource Release Response") - smContext.Tunnel.ANInformation = struct { - IPAddress net.IP - TEID uint32 - }{nil, 0} + smContext.Tunnel.ANInformation = &smf_context.ANInformation{} if smContext.PDUSessionRelease_DUE_TO_DUP_PDU_ID { smContext.CheckState(smf_context.InActivePending)