Skip to content

[action] [PR:4323] fix: skip PORT_INGRESS/EGRESS_MIRROR_CAPABLE check for ERSPAN mirror sessions#4368

Merged
bingwang-ms merged 1 commit intosonic-net:202511from
mssonicbld:cherry/202511/4323
Mar 18, 2026
Merged

[action] [PR:4323] fix: skip PORT_INGRESS/EGRESS_MIRROR_CAPABLE check for ERSPAN mirror sessions#4368
bingwang-ms merged 1 commit intosonic-net:202511from
mssonicbld:cherry/202511/4323

Conversation

@mssonicbld
Copy link
Collaborator

What I did

Fixed is_port_mirror_capability_supported() so that ERSPAN sessions (direction=None) are not blocked by the PORT_INGRESS_MIRROR_CAPABLE / PORT_EGRESS_MIRROR_CAPABLE capability check.

Root cause

PR #4089 added a capability check that reads PORT_INGRESS_MIRROR_CAPABLE and PORT_EGRESS_MIRROR_CAPABLE from STATE_DB SWITCH_CAPABILITY|switch. For ERSPAN sessions, direction=None was treated as 'check both', but:

  1. These capability flags only apply to SPAN (port mirror) sessions, not ERSPAN (which uses source/destination IPs, not ports)
  2. Platforms that don't populate these STATE_DB keys return None, which != 'true', so the function incorrectly returns False (unsupported)

PR #4159 partially addressed the multi-ASIC namespace issue but did not fix the fundamental problem for ERSPAN sessions with no src/dst port specified.

How I fixed it

  • For ERSPAN (direction=None): Return True immediately. PORT_INGRESS/EGRESS_MIRROR_CAPABLE does not apply to ERSPAN sessions.
  • For SPAN (direction != None): Treat absent STATE_DB key (None value) as 'supported' for backward compatibility with platforms that don't populate SWITCH_CAPABILITY table entries.

How to verify it

Unit tests updated in ests/config_mirror_session_test.py:

  • Added Test 4 to verify behavior when STATE_DB keys are absent (all return True)
  • Updated Test 2 and Test 3 assertions for direction=None to expect True

Fixes: sonic-net/sonic-mgmt#21690
Signed-off-by: Sonic Build Admin [email protected]

…sessions

## What I did

Fixed is_port_mirror_capability_supported() so that ERSPAN sessions (direction=None) are not blocked by the PORT_INGRESS_MIRROR_CAPABLE / PORT_EGRESS_MIRROR_CAPABLE capability check.

## Root cause

PR sonic-net#4089 added a capability check that reads PORT_INGRESS_MIRROR_CAPABLE and PORT_EGRESS_MIRROR_CAPABLE from STATE_DB SWITCH_CAPABILITY|switch. For ERSPAN sessions, direction=None was treated as 'check both', but:
1. These capability flags only apply to SPAN (port mirror) sessions, not ERSPAN (which uses source/destination IPs, not ports)
2. Platforms that don't populate these STATE_DB keys return None, which != 'true', so the function incorrectly returns False (unsupported)

PR sonic-net#4159 partially addressed the multi-ASIC namespace issue but did not fix the fundamental problem for ERSPAN sessions with no src/dst port specified.

## How I fixed it

- **For ERSPAN (direction=None)**: Return True immediately. PORT_INGRESS/EGRESS_MIRROR_CAPABLE does not apply to ERSPAN sessions.
- **For SPAN (direction != None)**: Treat absent STATE_DB key (None value) as 'supported' for backward compatibility with platforms that don't populate SWITCH_CAPABILITY table entries.

## How to verify it

Unit tests updated in 	ests/config_mirror_session_test.py:
- Added Test 4 to verify behavior when STATE_DB keys are absent (all return True)
- Updated Test 2 and Test 3 assertions for direction=None to expect True

Fixes: sonic-net/sonic-mgmt#21690
Signed-off-by: Sonic Build Admin <[email protected]>
@mssonicbld
Copy link
Collaborator Author

Original PR: #4323

@mssonicbld
Copy link
Collaborator Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@bingwang-ms bingwang-ms enabled auto-merge (squash) March 18, 2026 03:24
@bingwang-ms bingwang-ms merged commit beeaad6 into sonic-net:202511 Mar 18, 2026
9 checks passed
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.

2 participants