Skip to content

[copp]: Added CoPP show configuration commands#3863

Merged
qiluo-msft merged 2 commits intosonic-net:masterfrom
rminnikanti:neighbor_miss
Jun 13, 2025
Merged

[copp]: Added CoPP show configuration commands#3863
qiluo-msft merged 2 commits intosonic-net:masterfrom
rminnikanti:neighbor_miss

Conversation

@rminnikanti
Copy link
Contributor

@rminnikanti rminnikanti commented Apr 23, 2025

What I did:

Added CoPP show commands:

  • show copp configuration
  • show copp configuration detailed --trapid <trap_id>
  • show copp configuration detailed --group <group>

Added UT for the CLI commands.

Why I did it

Details in HLD: sonic-net/SONiC#1943

How to verify it

Verified with UT

Previous command output (if the output of a command-line utility has changed)

New command output (if the output of a command-line utility has changed)

admin@sonic:~$ show copp configuration
TrapId           Trap Group     Action      CBS    CIR  Meter Type    Mode    HW Status
---------------  -------------  --------  -----  -----  ------------  ------  -------------
arp_req          queue4_group2  copy        600    600  packets       sr_tcm  installed
arp_resp         queue4_group2  copy        600    600  packets       sr_tcm  installed
bgp              queue4_group1  trap       6000   6000  packets       sr_tcm  not-installed
bgpv6            queue4_group1  trap       6000   6000  packets       sr_tcm  not-installed
dest_nat_miss    queue1_group2  trap        600    600  packets       sr_tcm  installed
dhcp             queue4_group3  trap        100    100  packets       sr_tcm  installed
dhcpv6           queue4_group3  trap        100    100  packets       sr_tcm  installed
eapol            queue4_group1  trap       6000   6000  packets       sr_tcm  installed
ip2me            queue1_group1  trap       6000   6000  packets       sr_tcm  installed
lacp             queue4_group1  trap       6000   6000  packets       sr_tcm  installed
lldp             queue4_group3  trap        100    100  packets       sr_tcm  installed
neigh_discovery  queue4_group2  copy        600    600  packets       sr_tcm  installed
neighbor_miss    queue1_group3  trap        200    200  packets       sr_tcm  installed
sample_packet    queue2_group1  trap       1000   1000  packets       sr_tcm  not-installed
src_nat_miss     queue1_group2  trap        600    600  packets       sr_tcm  installed
udld             queue4_group3  trap        100    100  packets       sr_tcm  installed
admin@sonic:~$ show copp configuration detailed --trapid neighbor_miss
Trap Group.................. queue1_group3
Trap Action................. trap
Trap Priority............... 1
Queue....................... 1
CBS......................... 200
CIR......................... 200
Meter Type.................. packets
Mode........................ sr_tcm
Yellow Action............... forward
Green Action................ forward
Red Action.................. drop
HW Status................... installed
admin@sonic:~$ show copp configuration detailed --group queue1_group3
Trap Id(s).................. neighbor_miss
Queue....................... 1
Trap Priority............... 1
Trap Action................. trap
Meter Type.................. packets
Mode........................ sr_tcm
CBS......................... 200
CIR......................... 200
Yellow Action............... forward
Green Action................ forward
Red Action.................. drop

Signed-off-by: Ravi Minnikanti rminnikanti@marvell.com

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@rminnikanti
Copy link
Contributor Author

@prabhataravind @prsunny please review.

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@rminnikanti
Copy link
Contributor Author

/AzurePipelines run Azure.sonic-utilities

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 3863 in repo sonic-net/sonic-utilities

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@prsunny
Copy link
Contributor

prsunny commented Jun 9, 2025

@rminnikanti , can you please resolve conflicts

@prsunny
Copy link
Contributor

prsunny commented Jun 9, 2025

Also, please share a command output as per description template

prsunny
prsunny previously approved these changes Jun 9, 2025
Copy link
Contributor

@prsunny prsunny left a comment

Choose a reason for hiding this comment

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

lgtm, @qiluo-msft to merge

@qiluo-msft
Copy link
Contributor

@rminnikanti Could you resolve conflict?

What I did:
CoPP show commands:
* show copp configuration
* show copp configuration detailed --trapid <trap_id>
* show copp configuration detailed --group <group>

Added UT for the CLI commands.

HLD: sonic-net/SONiC#1943

Signed-off-by: Ravi Minnikanti <rminnikanti@marvell.com>
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@rminnikanti
Copy link
Contributor Author

@rminnikanti Could you resolve conflict?

@qiluo-msft Done.

@qiluo-msft qiluo-msft enabled auto-merge (squash) June 10, 2025 04:12
@qiluo-msft qiluo-msft requested a review from Copilot June 10, 2025 04:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds CoPP (Control Plane Policing) CLI support, including show configuration and detailed views, with unit tests and documentation updates.

  • Introduces show copp configuration and show copp configuration detailed commands
  • Adds mock DB entries and unit tests for the new CLI paths
  • Updates dump plugin mapping and command reference documentation

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/mock_tables/state_db.json Added mock state entries for CoPP traps
tests/mock_tables/config_db.json Added mock CONFIG_DB entries for CoPP groups/traps
tests/copp_test.py New pytest cases for CoPP CLI
tests/copp_input/mock_config/mock_copp_cfg.json Mock CoPP JSON config data
show/main.py Registered copp commands in main CLI
show/copp.py Implemented CoPP show commands and merge logic
dump/plugins/copp.py Added neighbor_miss trap mapping
doc/Command-Reference.md Documented CoPP commands in command reference
Comments suppressed due to low confidence (3)

doc/Command-Reference.md:14900

  • The sample output uses lowercase queue here, but the CLI prints Queue with an uppercase Q. Update the doc to match the actual output.
queue....................... 1

doc/Command-Reference.md:14910

  • The sample uses Oper Status, but the implementation prints HW Status. Align the documentation to show HW Status for consistency.
Oper Status................. installed

show/copp.py:149

  • There is no unit test covering the FileNotFoundError branch when the config file is missing. Add a test to verify that the warning is printed as expected.
with open(COPP_INIT_CFG_JSON_FILE, 'r') as file:

Signed-off-by: Ravi Minnikanti <rminnikanti@marvell.com>
auto-merge was automatically disabled June 10, 2025 14:47

Head branch was pushed to by a user without write access

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@rminnikanti rminnikanti requested a review from qiluo-msft June 10, 2025 17:07
@qiluo-msft qiluo-msft merged commit 5ea861d into sonic-net:master Jun 13, 2025
7 checks passed
nmoray pushed a commit to nmoray/sonic-utilities that referenced this pull request Jun 25, 2025
What I did:

Added CoPP show commands:

show copp configuration
show copp configuration detailed --trapid <trap_id>
show copp configuration detailed --group <group>
Added UT for the CLI commands.

Why I did it

Details in HLD: sonic-net/SONiC#1943

How to verify it

Verified with UT
@yejianquan
Copy link
Contributor

Hi @rminnikanti , please create PR and fix conflict to 202505 branch

@rminnikanti
Copy link
Contributor Author

@yejianquan, created PR for 202505 #3955

@rminnikanti
Copy link
Contributor Author

@qiluo-msft @yejianquan to have this PR included in sonic master image we need to update the git submodule of src/sonic-utilties in sonic-buildimage.

Can we please update submodule of src/sonic-utilities in master branch? This will help sonic-mgmt PR of this feature.

Below is the last submodule update of sonic-utilities in sonic-buildimage master:

commit c19ece7106b30d941aff8774f1742486eebc1ec3
Author: mssonicbld <79238446+mssonicbld@users.noreply.github.com>
Date:   Thu May 22 19:01:49 2025 +0800

    [submodule] Update submodule sonic-utilities to the latest HEAD automatically (#22614)

YairRaviv pushed a commit to YairRaviv/sonic-utilities that referenced this pull request Jan 12, 2026
What I did:

Added CoPP show commands:

show copp configuration
show copp configuration detailed --trapid <trap_id>
show copp configuration detailed --group <group>
Added UT for the CLI commands.

Why I did it

Details in HLD: sonic-net/SONiC#1943

How to verify it

Verified with UT
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.

8 participants