Skip to content

Conversation

@stephenxs
Copy link
Collaborator

@stephenxs stephenxs commented Oct 11, 2025

What I did

Fetch capability of ingress/egress mirror before configuring it and avoid configuring ingress/egress mirror on a platform that does not support it.

How I did it

Check the capability in PORT_INGRESS_MIRROR_CAPABLE and PORT_EGRESS_MIRROR_CAPABLE in STATE_DB table SWITCH_CAPABILITY.
The capability of ingress/egress mirror is inserted to STATE_DB by orchagent during initialization.

How to verify it

Manual test and unit test

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)

Signed-off-by: Stephen Sun <stephens@nvidia.com>
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Stephen Sun <stephens@nvidia.com>
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@stephenxs
Copy link
Collaborator Author

Failure is caused by rebasing the commit to the latest master. Investigating.

@stephenxs
Copy link
Collaborator Author

Failure is caused by rebasing the commit to the latest master. Investigating.

Depends on sonic-net/sonic-swss#3934

Signed-off-by: Stephen Sun <stephens@nvidia.com>
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@stephenxs stephenxs changed the title Fetch capability of mirror before configuring it. Fetch capability of mirror before configuring it Oct 20, 2025
@stephenxs stephenxs marked this pull request as ready for review October 23, 2025 06:03
@stephenxs stephenxs requested a review from bingwang-ms October 24, 2025 06:07
bingwang-ms
bingwang-ms previously approved these changes Nov 4, 2025
@bingwang-ms
Copy link
Contributor

Depends on sonic-net/sonic-swss#3934

@bingwang-ms
Copy link
Contributor

@qiluo-msft Can you help review this change? Thanks

config/main.py Outdated
def is_port_mirror_capability_supported(direction, namespace=None):
""" Check if port mirror capability is supported for the given direction """
try:
state_db = SonicV2Connector(host='127.0.0.1')
Copy link
Contributor

@qiluo-msft qiluo-msft Nov 4, 2025

Choose a reason for hiding this comment

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

Could you use unix socket which has better performance? #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

config/main.py Outdated
return False

return True
except Exception:
Copy link
Contributor

@qiluo-msft qiluo-msft Nov 4, 2025

Choose a reason for hiding this comment

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

Could you use more specific exception type? #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed as we do not expect any exception here.

@qiluo-msft qiluo-msft requested a review from Copilot November 4, 2025 01:08
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

This PR adds ASIC capability checking for port mirror direction support before allowing mirror session configuration. The change prevents users from configuring mirror sessions with directions (rx/tx/both) that are not supported by the underlying ASIC hardware.

  • Added is_port_mirror_capability_supported() function to query STATE_DB for ASIC capabilities
  • Integrated capability validation into validate_mirror_session_config()
  • Added comprehensive test coverage for capability checking functionality

Reviewed Changes

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

File Description
config/main.py Added capability checking function and validation logic to prevent unsupported mirror directions
tests/config_mirror_session_test.py Added test cases for capability checking and removed trailing whitespace

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Stephen Sun <stephens@nvidia.com>
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@stephenxs stephenxs requested a review from qiluo-msft November 4, 2025 07:20
@stephenxs
Copy link
Collaborator Author

It's weird that pretest passed locally but failed in the github

stephens@675ff3c81f2e:/sonic/src/sonic-utilities/config$ git commit -s
[INFO] Initializing environment for https://github.com/PyCQA/flake8.
[INFO] Installing environment for https://github.com/PyCQA/flake8.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
flake8...................................................................Passed
[detached HEAD 8bf2b0d7] Fix community review comments
 1 file changed, 19 insertions(+), 23 deletions(-)
stephens@675ff3c81f2e:/sonic/src/sonic-utilities/config$ git log

Signed-off-by: Stephen Sun <stephens@nvidia.com>
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Stephen Sun <stephens@nvidia.com>
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@liat-grozovik
Copy link
Collaborator

@qiluo-msft can you please check if you are ok with comments handling and approve this PR?

@qiluo-msft qiluo-msft merged commit ad0a3d3 into sonic-net:master Nov 17, 2025
7 checks passed
@stephenxs stephenxs deleted the mirror_capability_check branch November 18, 2025 01:08
gordon-nexthop pushed a commit to nexthop-ai/sonic-utilities that referenced this pull request Nov 25, 2025
What I did
Fetch capability of ingress/egress mirror before configuring it and avoid configuring ingress/egress mirror on a platform that does not support it.

How I did it
Check the capability in PORT_INGRESS_MIRROR_CAPABLE and PORT_EGRESS_MIRROR_CAPABLE in STATE_DB table SWITCH_CAPABILITY.
The capability of ingress/egress mirror is inserted to STATE_DB by orchagent during initialization.

How to verify it
Manual test and unit test
yxieca added a commit to yxieca/sonic-utilities that referenced this pull request Dec 13, 2025
yxieca added a commit that referenced this pull request Dec 14, 2025
@yxieca
Copy link
Contributor

yxieca commented Dec 14, 2025

@stephenxs this change causes test failure when advancing sonic-utilities submodule. We need to revert to move forward.

@yxieca
Copy link
Contributor

yxieca commented Dec 14, 2025

@stephenxs this change is causing show_techsupport/test_techsupport.py to fail at multi-asic deployment. But this is a good change to have. I will see if that is the only failure. if it is, then I am leaning towards file an issue to xfail it and let you work on a fix. Please stay tuned.

@stephenxs
Copy link
Collaborator Author

@stephenxs this change is causing show_techsupport/test_techsupport.py to fail at multi-asic deployment. But this is a good change to have. I will see if that is the only failure. if it is, then I am leaning towards file an issue to xfail it and let you work on a fix. Please stay tuned.

Could you please share the test link? Thanks

@yxieca
Copy link
Contributor

yxieca commented Dec 14, 2025

Issue: sonic-net/sonic-mgmt#21690

Test failure: https://elastictest.org/scheduler/testplan/693d87a8be086527515c111d

@stephenxs
Copy link
Collaborator Author

YairRaviv pushed a commit to YairRaviv/sonic-utilities that referenced this pull request Jan 12, 2026
What I did
Fetch capability of ingress/egress mirror before configuring it and avoid configuring ingress/egress mirror on a platform that does not support it.

How I did it
Check the capability in PORT_INGRESS_MIRROR_CAPABLE and PORT_EGRESS_MIRROR_CAPABLE in STATE_DB table SWITCH_CAPABILITY.
The capability of ingress/egress mirror is inserted to STATE_DB by orchagent during initialization.

How to verify it
Manual test and unit test
@mssonicbld
Copy link
Collaborator

Cherry-pick PR to 202511: #4204

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.

9 participants