Skip to content

Commit c21e08f

Browse files
authored
Ignore a negative decided precedence instead of wrapping it (#707)
Signed-off-by: Arrobo, Gabriel <gabriel.arrobo@intel.com>
1 parent 150ec8f commit c21e08f

2 files changed

Lines changed: 33 additions & 4 deletions

File tree

‎producer/callback.go‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -573,10 +573,16 @@ func requalifyRule(smContext *smfContext.SMContext, pfcpParam *pfcpParam, node *
573573
tcRef = rule.RefTcData[0]
574574
}
575575
if decided, ok := rule.GetPrecedenceOk(); ok {
576-
// Zero is the top of the order. The SMF reads a PDR's zero as unset, so it is
577-
// programmed as 1, as an added rule's is.
578-
value := max(uint32(*decided), 1)
579-
precedence = &value
576+
if *decided < 0 {
577+
// Out of the range of an unsigned PDR precedence: converted, it would wrap to about
578+
// 4 billion and put the rule last. Left out, so the PDR keeps the one it has.
579+
logger.PduSessLog.Warnf("PCC rule %s: ignoring the negative precedence %d", name, *decided)
580+
} else {
581+
// Zero is the top of the order. The SMF reads a PDR's zero as unset, so it is
582+
// programmed as 1, as an added rule's is.
583+
value := max(uint32(*decided), 1)
584+
precedence = &value
585+
}
580586
}
581587
}
582588

‎producer/policy_update_rule_mapping_test.go‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2361,3 +2361,26 @@ func TestAnAddedUplinkPDRNamesTheInstalledFTEID(t *testing.T) {
23612361
t.Error("the added uplink PDR was sent with no F-TEID")
23622362
}
23632363
}
2364+
2365+
// A negative decided precedence is outside a PDR's unsigned range: converted, it wrapped to about 4
2366+
// billion and put the rule last. It is ignored, and the PDR keeps the precedence it has.
2367+
func TestANegativeDecidedPrecedenceLeavesThePDRsPrecedence(t *testing.T) {
2368+
s := newTwoRuleSession(t, false)
2369+
s.cirUL.Precedence, s.cirDL.Precedence = 200, 200
2370+
decision := s.rateChange()
2371+
rule := decision.PccRules[cirRuleID]
2372+
rule.Precedence = openapi.PtrInt32(-5)
2373+
decision.PccRules[cirRuleID] = rule
2374+
s.sm.SmPolicyUpdates = []*qos.PolicyUpdate{qos.BuildSmPolicyUpdate(&s.sm.SmPolicyData, decision)}
2375+
2376+
param := BuildPfcpParam(s.sm)
2377+
if len(param.unbuilt) != 0 {
2378+
t.Fatalf("not built: %v", param.unbuilt)
2379+
}
2380+
if !param.touches(s.cirUL) || !param.touches(s.cirDL) {
2381+
t.Fatal("the rule's PDRs were not updated")
2382+
}
2383+
if s.cirUL.Precedence != 200 || s.cirDL.Precedence != 200 {
2384+
t.Errorf("precedences are %d and %d, want the 200 the PDRs had", s.cirUL.Precedence, s.cirDL.Precedence)
2385+
}
2386+
}

0 commit comments

Comments
 (0)