Skip to content

sonic-yang-models: add POLICER_ACTION leafref to ACL_RULE#27859

Open
AnantKishorSharma wants to merge 1 commit into
sonic-net:masterfrom
AnantKishorSharma:feature/acl-policer-action-yang
Open

sonic-yang-models: add POLICER_ACTION leafref to ACL_RULE#27859
AnantKishorSharma wants to merge 1 commit into
sonic-net:masterfrom
AnantKishorSharma:feature/acl-policer-action-yang

Conversation

@AnantKishorSharma

@AnantKishorSharma AnantKishorSharma commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Why I did it

A CONFIG_DB ACL rule cannot carry a policer action. ACL_RULE in the sonic-acl YANG model has no policer leaf, so a rule referencing a policer is rejected at YANG validation (config reload, GCU, load_minigraph) before it ever reaches orchagent. This adds the model support that the SET_POLICER ACL action (sonic-swss companion PR) needs to be configurable from config_db.json.

Work item tracking
  • Microsoft ADO (number only):

How I did it

  • src/sonic-yang-models/yang-templates/sonic-acl.yang.j2: import sonic-policer and add leaf POLICER_ACTION to ACL_RULE as a leafref to /policer:sonic policer/policer:POLICER/policer:POLICER_LIST/policer:name (modeled on the existing MIRROR_INGRESS_ACTION leafref to mirror sessions).
  • Added positive case ACL_RULE_WITH_VALID_POLICER_ACTION (rule + matching POLICER entry) and negative ACL_RULE_WITH_INVALID_POLICER_ACTION (non-existent policer -> LeafRef error) in tests/yang_model_tests/tests/acl.json and .../tests_config/acl.json.

How to verify it

  • cd src/sonic-yang-models && pytest tests/ (yang_model_tests).
  • Locally validated leafref resolution with pyang against the rendered
    sonic-policer.yang (exit 0).

Which release branch to backport (provide reason below if selected)

  • 202305
  • 202311
  • 202405
  • 202411
  • 202505
  • 202511
  • 202605

Tested branch (Please provide the tested image version)

Description for the changelog

sonic-yang-models: add POLICER_ACTION leafref to ACL_RULE (policer action support).

Link to config_db schema for YANG module changes

https://github.com/sonic-net/sonic-buildimage/blob/master/src/sonic-yang-models/doc/Configuration.md#acl_rule

A picture of a cute animal (not mandatory but encouraged)

Add a POLICER_ACTION leaf to ACL_RULE in the sonic-acl YANG model as a
leafref to /sonic-policer/POLICER/POLICER_LIST/name, so that an ACL rule
with a policer action passes config validation (config reload, GCU,
load_minigraph). Without it, a CONFIG_DB rule carrying POLICER_ACTION is
rejected at YANG validation before reaching orchagent.

Add positive (valid policer reference) and negative (non-existent policer
-> LeafRef error) test cases.

Signed-off-by: AnantKishorSharma <AnantKishorSharma@users.noreply.github.com>
@AnantKishorSharma AnantKishorSharma force-pushed the feature/acl-policer-action-yang branch from 532a167 to ab53324 Compare June 12, 2026 17:35
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown
Collaborator

This PR has backport request for branch(es): 202511,202605.
Added label(s) for branch(es) 202511,202605.

---Powered by SONiC BuildBot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants