Skip to content

Enhance QoS rule builder with explicit operations and triggers#221

Merged
Alonza0314 merged 7 commits into
free5gc:mainfrom
DBGR18:fix/1047
May 18, 2026
Merged

Enhance QoS rule builder with explicit operations and triggers#221
Alonza0314 merged 7 commits into
free5gc:mainfrom
DBGR18:fix/1047

Conversation

@DBGR18

@DBGR18 DBGR18 commented May 12, 2026

Copy link
Copy Markdown
Contributor

fix issue #1047

This pull request introduces several improvements and bug fixes to the handling of QoS rules and PDU session modification requests. The main focus is on more robust parsing and validation of QoS rules and flow descriptions, improved error handling, and correct construction of NAS QoS rules based on policy decisions and previous state. The changes ensure that the system gracefully handles missing or invalid data, accurately determines operation codes, and maintains consistency in rule identifiers.

QoS Rule and Flow Description Handling:

  • Added explicit error handling for parsing failures of QoS rules and QoS flow descriptions in HandlePDUSessionModificationRequest, returning clear error messages if parsing fails.
  • Improved validation logic in SendSMPolicyAssociationUpdateByUERequestModification to handle cases where either QoS rules or flow descriptions are missing, and to prevent processing incomplete UE-initiated requests.

NAS QoS Rule Construction and Operation Code Logic:

  • Enhanced logic for determining the correct operation code (opCode) when building NAS QoS rules, taking into account previous rule state and request contents, and ensuring proper handling of rule creation, modification, and deletion.
  • Updated the BuildNasQoSRule function to use the provided opCode, set the QFI earlier, and return early for delete/modify-without-packet-filter operations.

Session and Policy Consistency:

  • Ensured that smPolicyDecision.PccRules is always initialized to a non-nil map, preventing potential nil pointer dereferences during rule application.
  • Tracked previous PCC rules and QoS rule IDs to support accurate mapping and state restoration during session modification.

UE-Initiated Resource Request Improvements:

  • Only constructs the RequestedQos structure if a flow description is present, avoiding nil dereference and unnecessary allocations.
  • Appends packet filter information to the update request only when appropriate, further improving request construction robustness.

Copilot AI review requested due to automatic review settings May 12, 2026 14:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves SMF handling of UE-initiated PDU Session Modification QoS updates by hardening NAS QoS rule/flow-description parsing, improving PCF update request construction, and making NAS QoS rule building respect explicit operation codes and stable rule identifiers.

Changes:

  • Add explicit parse error handling for Requested QoS Rules / QoS Flow Descriptions and guard SM policy decision maps against nil.
  • Preserve previous PCC/QoS-rule state to derive correct NAS QoS rule operation codes and maintain consistent QoS rule identifiers across modifications.
  • Update PCCRule NAS QoS rule builder to honor the provided operation code and short-circuit for delete / modify-without-packet-filter cases.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
internal/sbi/processor/gsm_handler.go Adds parse validation, decision/map guards, and new op-code + QoS rule ID logic when building Authorized QoS Rules for modification commands.
internal/sbi/consumer/pcf_service.go Adjusts UE-initiated SM policy update trigger/validation logic and makes RequestedQos construction conditional on flow description presence.
internal/context/pcc_rule.go Makes NAS QoS rule construction respect the supplied opCode and returns early for operations that shouldn’t include packet filters.
Comments suppressed due to low confidence (1)

internal/sbi/processor/gsm_handler.go:251

  • The error text PDUSessionSMContextCreate err is misleading in the PDU Session Modification handler. Please update the message to reflect the correct operation (modification) so logs and returned errors are actionable.
	// Update SessionRule from decision
	if errApplySessionRules := smCtx.ApplySessionRules(smPolicyDecision); errApplySessionRules != nil {
		return nil, fmt.Errorf("PDUSessionSMContextCreate err: %v", errApplySessionRules)
	}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/sbi/processor/gsm_handler.go Outdated
smPolicyDecision, err_ := p.Consumer().SendSMPolicyAssociationUpdateByUERequestModification(
smCtx, reqQoSRules, reqQoSFlowDescs)
if err_ != nil {
return nil, fmt.Errorf("sm policy update failed: %s", err_)
Comment on lines +136 to +153
hasQoSRules := len(qosRules) > 0
hasQoSFlowDescs := len(qosFlowDescs) > 0

// UE SHOULD only create ONE QoS Flow in a request (TS 24.501 6.4.2.2)
if len(qosRules) == 0 {
return nil, errors.New("QoS Rule not found")
}
if len(qosFlowDescs) == 0 {
return nil, errors.New("QoS Flow Description not found")
}
if !hasQoSRules && !hasQoSFlowDescs {
// No UE-initiated resource request; update without RES_MO_RE.
} else if !hasQoSRules {
return nil, errors.New("QoS rules missing for UE-initiated request")
} else {
updateSMPolicy.RepPolicyCtrlReqTriggers = []models.PolicyControlRequestTrigger{
models.PolicyControlRequestTrigger_RES_MO_RE,
}

rule := qosRules[0]
flowDesc := qosFlowDescs[0]

var ruleOp models.RuleOperation
switch rule.Operation {
case nasType.OperationCodeCreateNewQoSRule:
ruleOp = models.RuleOperation_CREATE_PCC_RULE
case nasType.OperationCodeDeleteExistingQoSRule:
ruleOp = models.RuleOperation_DELETE_PCC_RULE
case nasType.OperationCodeModifyExistingQoSRuleAndAddPacketFilters:
ruleOp = models.RuleOperation_MODIFY_PCC_RULE_AND_ADD_PACKET_FILTERS
case nasType.OperationCodeModifyExistingQoSRuleAndDeletePacketFilters:
ruleOp = models.RuleOperation_MODIFY_PCC_RULE_AND_DELETE_PACKET_FILTERS
case nasType.OperationCodeModifyExistingQoSRuleAndReplaceAllPacketFilters:
ruleOp = models.RuleOperation_MODIFY_PCC_RULE_AND_REPLACE_PACKET_FILTERS
case nasType.OperationCodeModifyExistingQoSRuleWithoutModifyingPacketFilters:
ruleOp = models.RuleOperation_MODIFY_PCC_RULE_WITHOUT_MODIFY_PACKET_FILTERS
default:
return nil, errors.New("QoS Rule Operation Unknown")
}
// UE SHOULD only create ONE QoS Flow in a request (TS 24.501 6.4.2.2)
rule := qosRules[0]
var flowDesc *nasType.QoSFlowDesc
if hasQoSFlowDescs {
flowDesc = &qosFlowDescs[0]
}

@d11nn d11nn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Alonza0314 LGTM ulcl-ti & mp & chaging PASS, but PTAL!

@Alonza0314 Alonza0314 merged commit 22dda91 into free5gc:main May 18, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants