Skip to content

Commit

Permalink
fix: duplicated URRs in PDR
Browse files Browse the repository at this point in the history
  • Loading branch information
brianchennn committed Nov 28, 2023
1 parent 05b05de commit 4788fdf
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
13 changes: 9 additions & 4 deletions internal/context/datapath.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,10 @@ func (node DataPathNode) addUrrToNode(smContext *SMContext, urrId uint32, isMeas

if urr != nil {
if node.UpLinkTunnel != nil && node.UpLinkTunnel.PDR != nil {
node.UpLinkTunnel.PDR.URR = append(node.UpLinkTunnel.PDR.URR, urr)
node.UpLinkTunnel.PDR.AppendURRs([]*URR{urr})
}
if node.DownLinkTunnel != nil && node.DownLinkTunnel.PDR != nil {
node.DownLinkTunnel.PDR.URR = append(node.DownLinkTunnel.PDR.URR, urr)
node.DownLinkTunnel.PDR.AppendURRs([]*URR{urr})
}
}
}
Expand Down Expand Up @@ -409,6 +409,7 @@ func (datapath *DataPath) addUrrToPath(smContext *SMContext) {
MBQEUrrId = smContext.UrrIdMap[N9N6_MBEQ_URR]
MAQEUrrId = smContext.UrrIdMap[N9N6_MAEQ_URR]
}

curDataPathNode.addUrrToNode(smContext, MBQEUrrId, true, true)
curDataPathNode.addUrrToNode(smContext, MAQEUrrId, true, false)
}
Expand Down Expand Up @@ -817,10 +818,14 @@ func (p *DataPath) AddChargingRules(smContext *SMContext, chgLevel ChargingLevel

smContext.ChargingInfo[urr.URRID] = chgInfo
if node.UpLinkTunnel != nil && node.UpLinkTunnel.PDR != nil {
node.UpLinkTunnel.PDR.URR = append(node.UpLinkTunnel.PDR.URR, urr)
if !isUrrExist(node.UpLinkTunnel.PDR.URR, urr) {
node.UpLinkTunnel.PDR.AppendURRs([]*URR{urr})
}
}
if node.DownLinkTunnel != nil && node.DownLinkTunnel.PDR != nil {
node.DownLinkTunnel.PDR.URR = append(node.DownLinkTunnel.PDR.URR, urr)
if !isUrrExist(node.DownLinkTunnel.PDR.URR, urr) {
node.DownLinkTunnel.PDR.AppendURRs([]*URR{urr})
}
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions internal/context/pfcp_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,23 @@ func MeasureInformation(isMeasurePkt, isMeasureBeforeQos bool) pfcpType.Measurem
return measureInformation
}

func (pdr *PDR) AppendURRs(urrs []*URR) {
for _, urr := range urrs {
if !isUrrExist(pdr.URR, urr) {
pdr.URR = append(pdr.URR, urr)
}
}
}

func isUrrExist(URRs []*URR, urr *URR) bool { // check if urr is in URRs list
for _, URR := range URRs {
if urr.URRID == URR.URRID {
return true
}
}
return false
}

// Packet Detection. 7.5.2.2-2
type PDI struct {
SourceInterface pfcpType.SourceInterface
Expand Down
8 changes: 4 additions & 4 deletions internal/context/sm_context_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ func (c *SMContext) addPduLevelChargingRuleToFlow(pccRules map[string]*PCCRule)
if node.IsAnchorUPF() {
// only the traffic on the PSA UPF will be charged
if node.UpLinkTunnel != nil && node.UpLinkTunnel.PDR != nil {
node.UpLinkTunnel.PDR.URR = append(node.UpLinkTunnel.PDR.URR, pduLevelChargingUrrs...)
node.UpLinkTunnel.PDR.AppendURRs(pduLevelChargingUrrs)
}
if node.DownLinkTunnel != nil && node.DownLinkTunnel.PDR != nil {
node.DownLinkTunnel.PDR.URR = append(node.DownLinkTunnel.PDR.URR, pduLevelChargingUrrs...)
node.DownLinkTunnel.PDR.AppendURRs(pduLevelChargingUrrs)
}
}
}
Expand All @@ -111,10 +111,10 @@ func (c *SMContext) addPduLevelChargingRuleToFlow(pccRules map[string]*PCCRule)
for node := defaultPath.FirstDPNode; node != nil; node = node.Next() {
if node.IsAnchorUPF() {
if node.UpLinkTunnel != nil && node.UpLinkTunnel.PDR != nil {
node.UpLinkTunnel.PDR.URR = append(node.UpLinkTunnel.PDR.URR, pduLevelChargingUrrs...)
node.UpLinkTunnel.PDR.AppendURRs(pduLevelChargingUrrs)
}
if node.DownLinkTunnel != nil && node.DownLinkTunnel.PDR != nil {
node.DownLinkTunnel.PDR.URR = append(node.DownLinkTunnel.PDR.URR, pduLevelChargingUrrs...)
node.DownLinkTunnel.PDR.AppendURRs(pduLevelChargingUrrs)
}
}
}
Expand Down

0 comments on commit 4788fdf

Please sign in to comment.