Enhance QoS rule builder with explicit operations and triggers#221
Merged
Conversation
Contributor
There was a problem hiding this comment.
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 erris 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.
| 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
approved these changes
May 13, 2026
d11nn
left a comment
Contributor
There was a problem hiding this comment.
@Alonza0314 LGTM ulcl-ti & mp & chaging PASS, but PTAL!
Alonza0314
approved these changes
May 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
HandlePDUSessionModificationRequest, returning clear error messages if parsing fails.SendSMPolicyAssociationUpdateByUERequestModificationto 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:
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.BuildNasQoSRulefunction to use the providedopCode, set theQFIearlier, and return early for delete/modify-without-packet-filter operations.Session and Policy Consistency:
smPolicyDecision.PccRulesis always initialized to a non-nil map, preventing potential nil pointer dereferences during rule application.UE-Initiated Resource Request Improvements:
RequestedQosstructure if a flow description is present, avoiding nil dereference and unnecessary allocations.