Skip to content

[pfcwd] Don't abort orchagent when the egress ACL table create fails#4743

Open
rajath-nexthop wants to merge 2 commits into
sonic-net:masterfrom
nexthop-ai:rajath-pfcwd-acl-crash-fix
Open

[pfcwd] Don't abort orchagent when the egress ACL table create fails#4743
rajath-nexthop wants to merge 2 commits into
sonic-net:masterfrom
nexthop-ai:rajath-pfcwd-acl-crash-fix

Conversation

@rajath-nexthop

@rajath-nexthop rajath-nexthop commented Jul 10, 2026

Copy link
Copy Markdown

Why I did it

On platforms where the egress PFC-watchdog ACL table draws from the same
egress PMF banks as configured standard egress ACLs, those banks can be
exhausted. When create_acl_table() then fails, PfcWdAclHandler
swallowed the failed AclOrch::addAclTable() and still built an AclRule
against the missing table; the rule ctor SWSS_LOG_THROWs, which is
uncaught → std::terminate → SIGABRT, taking down the entire swss
container. A single un-creatable ACL table should degrade gracefully, not
crash orchagent.

Work item tracking

  • Microsoft ADO (number only):

How I did it

  • createPfcAclTable() / createPfcAclRule() return bool; on
    addAclTable() failure the half-built m_aclTables entry is erased and
    the call sites skip AclRule construction and roll back what was
    already installed for the queue.
  • ~PfcWdAclHandler() no longer SWSS_LOG_THROWs when a rule/table is
    absent (a destructor is implicitly noexcept; throwing → terminate) —
    it logs and cleans up what exists.
  • startWdActionOnQueue() publishes the queue's INSTORM state only when
    the handler installed successfully (isValid()); an action that could
    not be installed is surfaced to STATE_DB PFC_WD_SW_STATE_TABLE as
    failed and is not replayed on warm reboot. Handler construction is
    wrapped in a try/catch backstop so no PFC event path can abort orchagent.

How to verify it

On a platform whose egress PFCWD ACL shares the egress PMF with standard
egress ACLs: fill the egress ACL banks with egress ACLs, then trigger the
PFCWD drop action on a queue (real storm or debug storm).

  • Before: orchagent SIGABRT + core, swss container down.
  • After: orchagent logs Failed to create PFCWD ACL table ... and stays
    up; the un-mitigated queue is reported as failed in
    STATE_DB|PFC_WD_SW_STATE_TABLE.

Sonic-mgmt test added for the same - sonic-net/sonic-mgmt#26413

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

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205

Description for the changelog

pfcwd: handle egress ACL table creation failure gracefully instead of
aborting orchagent.

@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

@rajath-nexthop

Copy link
Copy Markdown
Author

An issue tagging this is raised -#4748

@rajath-nexthop
rajath-nexthop marked this pull request as ready for review July 13, 2026 04:00
@pinky-nexthop

Copy link
Copy Markdown
Contributor

@vmittal-msft kindly review.

@vmittal-msft

Copy link
Copy Markdown
Contributor

@rajath-nexthop @pinky-nexthop can you please add test case for this ?

@rajath-nexthop

Copy link
Copy Markdown
Author

@vmittal-msft yes, I am working on a sonic-mgmt testcase for this in test_pfcwd_function.py. Will get the PR up soon!

}
}
else
{

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.

add error logs for Create ACL table failures with the error code. Will be good to get the resource exhaustion and other failures in the log

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Added relevant info (the rule itself and sai status for the rule)

if (!createPfcAclRule(newRule, queueId, m_strEgressTable, port))
{
SWSS_LOG_ERROR("Failed to create egress PFCWD drop rule %s", m_strRule.c_str());
removeIngressBinding(port);

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.

Remove egress binding when egress ACL rule create fails?

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.

Could you also check for any ACL CRMs

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Added code to remove the egress binding. ACL CRMs look okay - CRM_ACL_TABLE is incremented only after create() succeeds and is decremented when removeAclTable is invoked - so there should be no inconsistencies from there.

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

@rajath-nexthop

Copy link
Copy Markdown
Author

@rajath-nexthop @pinky-nexthop can you please add test case for this ?

Hi @vmittal-msft , PR raised for the test as well - sonic-net/sonic-mgmt#26413
PTAL and review that as well, thanks!

What I did
==========
PfcWdAclHandler builds an ingress (and, on some platforms, egress) ACL
table + rule when PFC watchdog first acts on a stormed queue. If the ACL
table creation failed (e.g. the egress PMF banks are exhausted by a
configured egress ACL), the failed AclOrch::addAclTable() was swallowed
and an AclRule was still constructed against the missing table; its ctor
SWSS_LOG_THROWs, which is uncaught and calls std::terminate -> SIGABRT,
taking down the whole swss container.

- createPfcAclTable()/createPfcAclRule() now return bool; on failure the
  half-built m_aclTables entry is erased and the call sites skip rule
  construction and roll back what was already installed.
- ~PfcWdAclHandler() no longer SWSS_LOG_THROWs when a rule/table is
  absent (a destructor is implicitly noexcept; throwing -> terminate).
- startWdActionOnQueue() only publishes the queue's INSTORM state when
  the handler installed successfully (isValid()); an un-installable
  action is surfaced to STATE_DB PFC_WD_SW_STATE_TABLE as "failed" and
  is not replayed on warm reboot. Handler construction is wrapped in a
  try/catch backstop so no PFC event path can abort orchagent.

How to verify it
================
On a platform whose egress PFCWD ACL shares the egress PMF with standard
egress ACLs: fill the egress ACL banks, then trigger PFCWD drop action on
a queue (storm or debug storm). Before: orchagent SIGABRT + core, swss
down. After: orchagent logs "Failed to create PFCWD ACL table ..." and
stays up; the queue is reported as "failed" in STATE_DB.

Signed-off-by: Rajath V <rajath@nexthop.ai>
…llback

- Log ACL table-create failures at each call site (ingress: drop action not
  installed; egress: rolling back the ingress drop rule). The exact SAI
  failure status of the table create is logged by the SAI layer adjacent to
  these messages.
- Include the rule's last SAI status (AclRule::getLastSaiStatus()) in all
  rule-create failure logs, so resource exhaustion (e.g.
  SAI_STATUS_TABLE_FULL / INSUFFICIENT_RESOURCES) is visible directly.
- When the egress ACL rule create fails right after this handler created the
  egress table, remove that just-created (empty) egress table as part of the
  rollback instead of leaving it behind. A pre-existing/shared egress table
  is intentionally left in place.

Signed-off-by: Rajath V <rajath@nexthop.ai>
@rajath-nexthop
rajath-nexthop force-pushed the rajath-pfcwd-acl-crash-fix branch from 372745d to d72be06 Compare July 24, 2026 04:48
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

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.

5 participants