Skip to content

[aclorch] acl set policer action#4666

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

[aclorch] acl set policer action#4666
AnantKishorSharma wants to merge 1 commit into
sonic-net:masterfrom
AnantKishorSharma:feature/acl-set-policer-action

Conversation

@AnantKishorSharma

@AnantKishorSharma AnantKishorSharma commented Jun 12, 2026

Copy link
Copy Markdown

What I did

Added a POLICER_ACTION ACL rule action so a CONFIG_DB ACL_RULE can attach a policer (SAI_ACL_ENTRY_ATTR_ACTION_SET_POLICER), e.g.:

{ "ACL_RULE": { "DATAACL|RULE_1": {
    "PRIORITY": "9999", "SRC_IP": "10.0.0.1/32", "POLICER_ACTION": "test_policer"
} } }

Why I did it
AclOrch (the CONFIG_DB path) had no way to attach a policer to an ACL rule: none of the action maps in orchagent/aclorch.cpp
(aclL3ActionLookup, aclMirrorStageLookup, aclDTelActionLookup, aclOtherActionLookup, aclInnerActionLookup) contained SAI_ACL_ENTRY_ATTR_ACTION_SET_POLICER, and AclRulePacket::validateAddAction() rejects any unrecognized action. The only producer of SAI_ACL_ACTION_TYPE_SET_POLICER today is P4Orch (orchagent/p4orch/acl_table_manager.cpp, gated on a table-definition meter_unit), which is driven by P4RT — not CONFIG_DB. A POLICER table already exists in CONFIG_DB (managed by PolicerOrch) but only mirror sessions, port storm-control, and CoPP trap groups consume it; ACL rules can't.

How I verified it

  • Define a POLICER, an ACL table type whose ACTIONS include POLICER_ACTION, an ACL_TABLE, and an ACL_RULE with "POLICER_ACTION": "<policer>"; confirm SAI_ACL_ENTRY_ATTR_ACTION_SET_POLICER appears on the ASIC_DB ACL entry and the policer ref count increments (and decrements on rule remove).
  • Requires the sonic-yang-models companion PR sonic-yang-models: add POLICER_ACTION leafref to ACL_RULE sonic-buildimage#27859 for the config_db.json path to pass validation.
  • Check that ASIC is programmed

Details if related

  • New POLICER_ACTION -> SAI_ACL_ENTRY_ATTR_ACTION_SET_POLICER lookup, registered in parseAclTableTypeActions (table-type capability) and the AclRule::makeShared dispatch.
  • New AclRulePolicer rule class: resolves the policer OID via gPolicerOrch->getPolicerOid() and holds a PolicerOrch reference for the lifetime of the rule (increaseRefCount/decreaseRefCount on create/remove), analogous to AclRuleMirror. gPolicerOrch is already a global created before gAclOrch, so no constructor plumbing is needed.
  • doAclRuleTask: if a rule references a POLICER not yet created, defer it and rely on the Consumer m_toSync retry — same pattern as the existing "Wait for ACL table" handling — so POLICER-after-ACL_RULE sync ordering works.
  • Depends on: sonic-yang-models: add POLICER_ACTION leafref to ACL_RULE sonic-buildimage#27859 for the `config_db.json

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

@AnantKishorSharma AnantKishorSharma force-pushed the feature/acl-set-policer-action branch from 695d3ce to 518e853 Compare June 12, 2026 17:44
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

@AnantKishorSharma AnantKishorSharma force-pushed the feature/acl-set-policer-action branch from 518e853 to 4fcf225 Compare June 12, 2026 18:13
@AnantKishorSharma AnantKishorSharma marked this pull request as ready for review June 12, 2026 18:13
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

@AnantKishorSharma AnantKishorSharma changed the title Feature/acl set policer action [aclorch] acl set policer action Jun 13, 2026
Classic AclOrch (CONFIG_DB path) had no way to attach a policer to an
ACL rule: no action map contained SAI_ACL_ENTRY_ATTR_ACTION_SET_POLICER
and AclRulePacket::validateAddAction() rejected any unknown action. Only
P4Orch (P4RT) could program SET_POLICER.

Add a POLICER_ACTION rule action backed by a new AclRulePolicer subclass
that resolves the policer OID via gPolicerOrch->getPolicerOid() and holds
a PolicerOrch reference for the lifetime of the rule (increase/decrease
ref count on create/remove), analogous to AclRuleMirror's handling of
mirror sessions. Register the action in the table-type action parser and
the makeShared dispatch.

If the referenced POLICER is synced after the ACL_RULE, defer the rule and
rely on the Consumer m_toSync retry (same pattern as 'Wait for ACL table').

Signed-off-by: AnantKishorSharma <AnantKishorSharma@users.noreply.github.com>
@AnantKishorSharma AnantKishorSharma force-pushed the feature/acl-set-policer-action branch from 4fcf225 to 2dbf8f9 Compare June 14, 2026 14:21
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

@mssonicbld

Copy link
Copy Markdown
Collaborator

Hi, there are workflow run(s) waiting for approval, you may be first-time contributor. I will notify maintainers to help approve once PR is approved. Thanks!

---Powered by SONiC BuildBot

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.

2 participants