Skip to content

Commit

Permalink
Minor additions
Browse files Browse the repository at this point in the history
  • Loading branch information
Laura Henning committed May 23, 2024
1 parent 4a76918 commit 270f3cf
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 16 deletions.
21 changes: 12 additions & 9 deletions internal/context/datapath.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand All @@ -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()
}
}
}
Expand Down
29 changes: 27 additions & 2 deletions internal/context/pfcp_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 + "}"
Expand Down Expand Up @@ -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))
}
Expand Down
6 changes: 1 addition & 5 deletions internal/sbi/producer/pdu_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/hex"
"errors"
"fmt"
"net"
"net/http"

"github.com/antihax/optional"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 270f3cf

Please sign in to comment.