[Nexthop][fboss2-dev] Add config/delete copp cpu-traffic-policy match action CLI#1379
Open
vybhav-nexthop wants to merge 1 commit into
Open
[Nexthop][fboss2-dev] Add config/delete copp cpu-traffic-policy match action CLI#1379vybhav-nexthop wants to merge 1 commit into
vybhav-nexthop wants to merge 1 commit into
Conversation
Adds a config/delete pair for CPU-plane action fields in
sw.cpuTrafficPolicy.trafficPolicy.matchToAction:
fboss2-dev config copp cpu-traffic-policy match <matcher-name> \
action <action-type> <value>
fboss2-dev delete copp cpu-traffic-policy match <matcher-name> \
action <action-type>
Action types: send-to-queue <queue-id>, counter <name>, set-tc <tc-value>,
user-defined-trap <queue-id>. The config command creates the matchToAction
entry if absent and preserves other action fields; delete removes a single
action field. Both applied HITLESS.
The integration test derives its matcher from an ACL already present in the
running config and exercises the full add -> delete cycle; it only targets
a matcher without a pre-existing action of the tested type, so the delete
phase doubles as the restore.
rabbit-nexthop
force-pushed
the
nos-7164-copp-cpu-traffic-policy
branch
from
July 16, 2026 08:05
5fefbf6 to
b2ee4b1
Compare
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.
Summary
Adds a config/delete command pair for CPU-plane action fields in
sw.cpuTrafficPolicy.trafficPolicy.matchToAction:Supported action types:
send-to-queue <queue-id>,counter <name>,set-tc <tc-value>,user-defined-trap <queue-id>.Each action type sets one field of
cfg::MatchActionand applies to the packets the referenced ACL matches that are punted to the CPU:send-to-queue <queue-id>— steer the matched CPU-bound packets to a specific CPU queue. CPU queues are individually rate-limited/prioritized, so this is meant for isolating control traffic (e.g. BGP) from best-effort punts. (QueueMatchAction.queueId)counter <name>— attach a named packet/byte counter to the matched traffic. Observability only; no forwarding effect. (MatchAction.counter)set-tc <tc-value>— set the internal traffic class on the matched packets; the ASIC's TC→queue map then resolves the destination CPU queue. Today this shares the same hardware primitive assend-to-queue(the queue-id is programmed as the TC value inSaiAclTableManager).tcValueis a thriftbyte, so the accepted range is[0, 127]. (SetTcAction.tcValue)user-defined-trap <queue-id>— bind the match to a dedicated SAI hostif user-defined trap on the given CPU queue, so the ACL rule takes precedence over the default hostif trap rules. Platform-gated onSAI_USER_DEFINED_TRAP. (UserDefinedTrapAction.queueId)Both are applied at HITLESS level: matchToAction is processed through the ACL update path in
ApplyThriftConfig.cpp, and noChangeProhibitedguards exist for these fields.Test Plan
Unit tests
//fboss/cli/fboss2/test/config:cmd_config_test— full suite passes, including:cpuTrafficPolicy*tests inCmdConfigCoppTest.cpp: arg validation (arity, literal tokens, action types, value ranges) and queryClient behavior (add to existing matcher preserving other action fields, create new matcher entry, overwrite same action type, user-defined-trap).CmdDeleteCoppCpuTrafficPolicyMatchActionTest.cpp: arg validation plus delete of each action type, absent-field and absent-matcher handling.Integration test
ConfigCoppCpuTrafficPolicyTest.addAndDeleteActionon an NH-4010-F device exercises the full cycle: picks an ACL from the running config as matcher (one without a pre-existing action of the tested type); if the config has no usable ACL — the default on freshly bootstrapped devices (emptyAclTable1) and the simulator — it injects a test-owned ACL (fboss2-copp-test-acl) through the config session and uses that. Then add → commit → verify present → delete → commit → verify gone.Cleanup is snapshot-based: SetUp captures the running config before any mutation, and TearDown writes it back through the session (hitless commit) only if the committed config drifted — so the test restores the switch on pass or fail, on both the pre-existing-matcher and injected-ACL paths.
Post-run checks: no
fboss2-copp-test-aclleftovers in the committed agent config,fboss_sw_agentNRestarts=0 across all commits.Review Findings
A multi-angle pre-publication review (8 finder passes + adversarial verification) ran on this diff. Two confirmed issues were fixed in this PR:
actioncollision: the delete command models the grammar as subcommand tree nodes, so CLI11 classifies a bareactiontoken as the subcommand before filling the matcher-name positional — a matcher literally namedactionwould be configurable but undeletable. The config command now rejects that name up front (with a unit test).MatchActionprune, so a pre-existing entry with no action fields (hand-edited config) survived. The prune now runs regardless, and the entry is removed (with a unit test).Remaining low-severity notes, documented for reviewer awareness: the four action-type dispatch chains (validate/apply/delete/isValid) are maintained separately and each ends in a bare
elseforuser-defined-trap; the integration test's injected ACL uses a dstIp qualifier that could be rejected on a hypothetical ACL table configured with a restricted qualifier set (current platforms use the full-set fallback).