Skip to content
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
14 changes: 10 additions & 4 deletions producer/callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -573,10 +573,16 @@ func requalifyRule(smContext *smfContext.SMContext, pfcpParam *pfcpParam, node *
tcRef = rule.RefTcData[0]
}
if decided, ok := rule.GetPrecedenceOk(); ok {
// Zero is the top of the order. The SMF reads a PDR's zero as unset, so it is
// programmed as 1, as an added rule's is.
value := max(uint32(*decided), 1)
precedence = &value
if *decided < 0 {
// Out of the range of an unsigned PDR precedence: converted, it would wrap to about
// 4 billion and put the rule last. Left out, so the PDR keeps the one it has.
logger.PduSessLog.Warnf("PCC rule %s: ignoring the negative precedence %d", name, *decided)
} else {
// Zero is the top of the order. The SMF reads a PDR's zero as unset, so it is
// programmed as 1, as an added rule's is.
value := max(uint32(*decided), 1)
precedence = &value
}
}
}

Expand Down
23 changes: 23 additions & 0 deletions producer/policy_update_rule_mapping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2361,3 +2361,26 @@ func TestAnAddedUplinkPDRNamesTheInstalledFTEID(t *testing.T) {
t.Error("the added uplink PDR was sent with no F-TEID")
}
}

// A negative decided precedence is outside a PDR's unsigned range: converted, it wrapped to about 4
// billion and put the rule last. It is ignored, and the PDR keeps the precedence it has.
func TestANegativeDecidedPrecedenceLeavesThePDRsPrecedence(t *testing.T) {
s := newTwoRuleSession(t, false)
s.cirUL.Precedence, s.cirDL.Precedence = 200, 200
decision := s.rateChange()
rule := decision.PccRules[cirRuleID]
rule.Precedence = openapi.PtrInt32(-5)
decision.PccRules[cirRuleID] = rule
s.sm.SmPolicyUpdates = []*qos.PolicyUpdate{qos.BuildSmPolicyUpdate(&s.sm.SmPolicyData, decision)}

param := BuildPfcpParam(s.sm)
if len(param.unbuilt) != 0 {
t.Fatalf("not built: %v", param.unbuilt)
}
if !param.touches(s.cirUL) || !param.touches(s.cirDL) {
t.Fatal("the rule's PDRs were not updated")
}
if s.cirUL.Precedence != 200 || s.cirDL.Precedence != 200 {
t.Errorf("precedences are %d and %d, want the 200 the PDRs had", s.cirUL.Precedence, s.cirDL.Precedence)
}
}
Loading