Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: interface type with Core/Access #110

Merged
merged 3 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions internal/context/datapath.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@ func (node *DataPathNode) Prev() *DataPathNode {
}

func (node *DataPathNode) ActivateUpLinkTunnel(smContext *SMContext) error {
var err error
logger.CtxLog.Traceln("In ActivateUpLinkTunnel")

var err error
node.UpLinkTunnel.SrcEndPoint = node.Prev()
node.UpLinkTunnel.DestEndPoint = node

Expand All @@ -150,6 +151,8 @@ func (node *DataPathNode) ActivateUpLinkTunnel(smContext *SMContext) error {
}

func (node *DataPathNode) ActivateDownLinkTunnel(smContext *SMContext) error {
logger.CtxLog.Traceln("In ActivateDownLinkTunnel")

var err error
node.DownLinkTunnel.SrcEndPoint = node.Next()
node.DownLinkTunnel.DestEndPoint = node
Expand Down Expand Up @@ -316,14 +319,17 @@ func (dataPath *DataPath) String() string {
for curDPNode := firstDPNode; curDPNode != nil; curDPNode = curDPNode.Next() {
str += strconv.Itoa(index) + "th Node in the Path\n"
str += "Current UPF IP: " + curDPNode.GetNodeIP() + "\n"
str += "Current UPF ID: " + curDPNode.UPF.GetUPFID() + "\n"
if curDPNode.Prev() != nil {
str += "Previous UPF IP: " + curDPNode.Prev().GetNodeIP() + "\n"
str += "Previous UPF ID: " + curDPNode.Prev().UPF.GetUPFID() + "\n"
} else {
str += "Previous UPF IP: None\n"
}

if curDPNode.Next() != nil {
str += "Next UPF IP: " + curDPNode.Next().GetNodeIP() + "\n"
str += "Next UPF ID: " + curDPNode.Next().UPF.GetUPFID() + "\n"
} else {
str += "Next UPF IP: None\n"
}
Expand Down Expand Up @@ -420,7 +426,8 @@ func (dataPath *DataPath) ActivateTunnelAndPDR(smContext *SMContext, precedence
// Note: This should be after Activate Tunnels
if smContext.UrrReportTime != 0 || smContext.UrrReportThreshold != 0 {
dataPath.addUrrToPath(smContext)
logger.PduSessLog.Trace("Create URR")
logger.PduSessLog.Tracef("Create URR: UrrReportTime [%v], UrrReportThreshold: [%v]",
smContext.UrrReportTime, smContext.UrrReportThreshold)
} else {
logger.PduSessLog.Warn("No Create URR")
}
Expand Down Expand Up @@ -548,11 +555,6 @@ func (dataPath *DataPath) ActivateTunnelAndPDR(smContext *SMContext, precedence
},
}

if curDataPathNode.IsAnchorUPF() {
ULFAR.ForwardingParameters.
DestinationInterface.InterfaceValue = pfcpType.DestinationInterfaceSgiLanN6Lan
}

if nextULDest := curDataPathNode.Next(); nextULDest != nil {
nextULTunnel := nextULDest.UpLinkTunnel
iface = nextULTunnel.DestEndPoint.UPF.GetInterface(models.UpInterfaceType_N9, smContext.Dnn)
Expand Down Expand Up @@ -584,7 +586,6 @@ func (dataPath *DataPath) ActivateTunnelAndPDR(smContext *SMContext, precedence

DLPDR.Precedence = precedence

// TODO: Should delete this after FR5GC-1029 is solved
if curDataPathNode.IsAnchorUPF() {
DLPDR.PDI = PDI{
SourceInterface: pfcpType.SourceInterface{
Expand Down Expand Up @@ -741,6 +742,7 @@ func (p *DataPath) GetChargingUrr(smContext *SMContext) []*URR {
}

func (p *DataPath) AddChargingRules(smContext *SMContext, chgLevel ChargingLevel, chgData *models.ChargingData) {
logger.ChargingLog.Tracef("AddChargingRules: type[%v], data:[%+v]", chgLevel, chgData)
if chgData == nil {
return
}
Expand Down Expand Up @@ -803,11 +805,19 @@ func (p *DataPath) AddChargingRules(smContext *SMContext, chgLevel ChargingLevel
if node.UpLinkTunnel != nil && node.UpLinkTunnel.PDR != nil {
if !isUrrExist(node.UpLinkTunnel.PDR.URR, urr) {
node.UpLinkTunnel.PDR.AppendURRs([]*URR{urr})
// nolint
nodeId, _ := node.GetUPFID()
logger.PduSessLog.Tracef("UpLinkTunnel add URR for node %s %+v",
nodeId, node.UpLinkTunnel.PDR)
}
}
if node.DownLinkTunnel != nil && node.DownLinkTunnel.PDR != nil {
if !isUrrExist(node.DownLinkTunnel.PDR.URR, urr) {
node.DownLinkTunnel.PDR.AppendURRs([]*URR{urr})
// nolint
nodeId, _ := node.GetUPFID()
logger.PduSessLog.Tracef("DownLinkTunnel add URR for node %s %+v",
nodeId, node.UpLinkTunnel.PDR)
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions internal/context/sm_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ func (smContext *SMContext) AllocateLocalSEIDForDataPath(dataPath *DataPath) {
func (smContext *SMContext) PutPDRtoPFCPSession(nodeID pfcpType.NodeID, pdr *PDR) error {
NodeIDtoIP := nodeID.ResolveNodeIdToIp().String()
if pfcpSessCtx, exist := smContext.PFCPContext[NodeIDtoIP]; exist {
smContext.Log.Tracef("PutPDRtoPFCPSession [%+v]", pdr)
pfcpSessCtx.PDRs[pdr.PDRID] = pdr
} else {
return fmt.Errorf("Can't find PFCPContext[%s] to put PDR(%d)", NodeIDtoIP, pdr.PDRID)
Expand Down Expand Up @@ -630,6 +631,7 @@ func (c *SMContext) CreatePccRuleDataPath(pccRule *PCCRule,
if createdDataPath == nil {
return fmt.Errorf("fail to create data path for pcc rule[%s]", pccRule.PccRuleId)
}
c.Log.Tracef("CreatePccRuleDataPath: pcc rule: %+v", pccRule)

// Try to use a default pcc rule as default data path
if c.Tunnel.DataPathPool.GetDefaultPath() == nil &&
Expand Down
1 change: 1 addition & 0 deletions internal/context/sm_context_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ func applyFlowInfoOrPFD(pcc *PCCRule) error {
}
return nil
}
logger.CfgLog.Tracef("applyFlowInfoOrPFD %+v", pcc.FlowDescription())

// Find PFD with AppID if no flow description presents
// TODO: Get PFD from NEF (not from config)
Expand Down
2 changes: 2 additions & 0 deletions internal/context/ue_defaultPath.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ type UEDefaultPaths struct {
type DefaultPathPool map[string]*DataPath // key: UPF name

func NewUEDefaultPaths(upi *UserPlaneInformation, topology []factory.UPLink) (*UEDefaultPaths, error) {
logger.MainLog.Traceln("In NewUEDefaultPaths")

defaultPathPool := make(map[string]*DataPath)
source, err := findSourceInTopology(upi, topology)
if err != nil {
Expand Down
109 changes: 55 additions & 54 deletions internal/sbi/processor/charging_trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,71 +79,72 @@ func (p *Processor) ReleaseChargingSession(smContext *smf_context.SMContext) {
func (p *Processor) ReportUsageAndUpdateQuota(smContext *smf_context.SMContext) {
multipleUnitUsage := buildMultiUnitUsageFromUsageReport(smContext)

if len(multipleUnitUsage) != 0 {
rsp, problemDetails, errSendConvergedChargingRequest := p.Consumer().SendConvergedChargingRequest(smContext,
smf_context.CHARGING_UPDATE, multipleUnitUsage)

if problemDetails != nil {
logger.ChargingLog.Errorf("Send Charging Data Request[Update] Failed Problem[%+v]", problemDetails)
} else if errSendConvergedChargingRequest != nil {
logger.ChargingLog.Errorf("Send Charging Data Request[Update] Error[%+v]", errSendConvergedChargingRequest)
} else {
var pfcpResponseStatus smf_context.PFCPSessionResponseStatus
if len(multipleUnitUsage) == 0 {
logger.ChargingLog.Infof("No report need to be charged")
return
}

upfUrrMap := make(map[string][]*smf_context.URR)
rsp, problemDetails, errSendConvergedChargingRequest := p.Consumer().SendConvergedChargingRequest(smContext,
smf_context.CHARGING_UPDATE, multipleUnitUsage)

if problemDetails != nil {
logger.ChargingLog.Errorf("Send Charging Data Request[Update] Failed Problem[%+v]", problemDetails)
} else if errSendConvergedChargingRequest != nil {
logger.ChargingLog.Errorf("Send Charging Data Request[Update] Error[%+v]", errSendConvergedChargingRequest)
} else {
var pfcpResponseStatus smf_context.PFCPSessionResponseStatus

logger.ChargingLog.Infof("Send Charging Data Request[Update] successfully")
smContext.SetState(smf_context.PFCPModification)
upfUrrMap := make(map[string][]*smf_context.URR)

p.updateGrantedQuota(smContext, rsp.MultipleUnitInformation)
// Usually only the anchor UPF need to be updated
for _, urr := range smContext.UrrUpfMap {
upfId := smContext.ChargingInfo[urr.URRID].UpfId
logger.ChargingLog.Infof("Send Charging Data Request[Update] successfully")
smContext.SetState(smf_context.PFCPModification)

if urr.State == smf_context.RULE_UPDATE {
upfUrrMap[upfId] = append(upfUrrMap[upfId], urr)
}
}
p.updateGrantedQuota(smContext, rsp.MultipleUnitInformation)
// Usually only the anchor UPF need to be updated
for _, urr := range smContext.UrrUpfMap {
upfId := smContext.ChargingInfo[urr.URRID].UpfId

if len(upfUrrMap) == 0 {
logger.ChargingLog.Infof("Do not have urr that need to update charging information")
return
if urr.State == smf_context.RULE_UPDATE {
upfUrrMap[upfId] = append(upfUrrMap[upfId], urr)
}
}

for upfId, urrList := range upfUrrMap {
upf := smf_context.GetUpfById(upfId)
if upf == nil {
logger.PduSessLog.Warnf("Cound not find upf %s", upfId)
continue
}
rcvMsg, err_ := pfcp_message.SendPfcpSessionModificationRequest(
upf, smContext, nil, nil, nil, nil, urrList)
if err_ != nil {
logger.PduSessLog.Warnf("Sending PFCP Session Modification Request to AN UPF error: %+v", err_)
pfcpResponseStatus = smf_context.SessionUpdateFailed
} else {
logger.PduSessLog.Infoln("Received PFCP Session Modification Response")
pfcpResponseStatus = smf_context.SessionUpdateSuccess
}
if len(upfUrrMap) == 0 {
logger.ChargingLog.Infof("Do not have urr that need to update charging information")
return
}

rsp := rcvMsg.PfcpMessage.Body.(pfcp.PFCPSessionModificationResponse)
if rsp.Cause == nil || rsp.Cause.CauseValue != pfcpType.CauseRequestAccepted {
logger.PduSessLog.Warn("Received PFCP Session Modification Not Accepted Response from AN UPF")
pfcpResponseStatus = smf_context.SessionUpdateFailed
}
for upfId, urrList := range upfUrrMap {
upf := smf_context.GetUpfById(upfId)
if upf == nil {
logger.PduSessLog.Warnf("Cound not find upf %s", upfId)
continue
}
rcvMsg, err_ := pfcp_message.SendPfcpSessionModificationRequest(
upf, smContext, nil, nil, nil, nil, urrList)
if err_ != nil {
logger.PduSessLog.Warnf("Sending PFCP Session Modification Request to AN UPF error: %+v", err_)
pfcpResponseStatus = smf_context.SessionUpdateFailed
} else {
logger.PduSessLog.Infoln("Received PFCP Session Modification Response")
pfcpResponseStatus = smf_context.SessionUpdateSuccess
}

switch pfcpResponseStatus {
case smf_context.SessionUpdateSuccess:
logger.PfcpLog.Traceln("In case SessionUpdateSuccess")
smContext.SetState(smf_context.Active)
case smf_context.SessionUpdateFailed:
logger.PfcpLog.Traceln("In case SessionUpdateFailed")
smContext.SetState(smf_context.Active)
}
rsp := rcvMsg.PfcpMessage.Body.(pfcp.PFCPSessionModificationResponse)
if rsp.Cause == nil || rsp.Cause.CauseValue != pfcpType.CauseRequestAccepted {
logger.PduSessLog.Warn("Received PFCP Session Modification Not Accepted Response from AN UPF")
pfcpResponseStatus = smf_context.SessionUpdateFailed
}

switch pfcpResponseStatus {
case smf_context.SessionUpdateSuccess:
logger.PfcpLog.Traceln("In case SessionUpdateSuccess")
smContext.SetState(smf_context.Active)
case smf_context.SessionUpdateFailed:
logger.PfcpLog.Traceln("In case SessionUpdateFailed")
smContext.SetState(smf_context.Active)
}
}
} else {
logger.ChargingLog.Infof("No report need to be charged")
}
}

Expand Down
3 changes: 3 additions & 0 deletions internal/sbi/processor/datapath.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ func ActivateUPFSession(
smContext *smf_context.SMContext,
notifyUeHander func(*smf_context.SMContext, bool),
) {
smContext.Log.Traceln("In ActivateUPFSession")

pfcpPool := make(map[string]*PFCPState)

for _, dataPath := range smContext.Tunnel.DataPathPool {
Expand All @@ -60,6 +62,7 @@ func ActivateUPFSession(
if node.DownLinkTunnel != nil && node.DownLinkTunnel.PDR != nil {
pdrList = append(pdrList, node.DownLinkTunnel.PDR)
farList = append(farList, node.DownLinkTunnel.PDR.FAR)
urrList = append(urrList, node.DownLinkTunnel.PDR.URR...)
// skip send QER because uplink and downlink shared one QER
}

Expand Down
3 changes: 2 additions & 1 deletion internal/sbi/processor/ulcl_procedure.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
)

func (p *Processor) AddPDUSessionAnchorAndULCL(smContext *context.SMContext) {
smContext.Log.Infoln("In AddPDUSessionAnchorAndULCL")
bpMGR := smContext.BPManager

switch bpMGR.AddingPSAState {
Expand Down Expand Up @@ -85,7 +86,7 @@ func (p *Processor) EstablishPSA2(smContext *context.SMContext) {
}
}

// According to 32.255 5.2.2.7, Addition of additional PDU Session Anchor is a charging event
// According to 32.255 5.2.2.7, Addition of additional PDU Session Anchor is a charging event
p.UpdateChargingSession(smContext, chgUrrList, models.Trigger{
TriggerType: models.TriggerType_ADDITION_OF_UPF,
TriggerCategory: models.TriggerCategory_IMMEDIATE_REPORT,
Expand Down
Loading