Skip to content

Commit 7d9ec5d

Browse files
authored
Fix issue that namespace is not correctly fetched in Multi ASIC environment for mirror capability checking (#4159)
- What I did Fix issue sonic-net/sonic-mgmt#21690 - How I did it The logic to check the mirror capability is: orchagent exposes capability to SWITCH_CAPABILITY table in STATE_DB during initialization CLI (config mirror) fetches capability from the table when a CLI command is issued by a user. On the multi ASIC environment, the table is in ASIC's namespace. But the CLI command fetches the capability from the host. As a result it always treats mirror is unsupported and fails the test. Fixed by checking the mirror capability from the namespaces based on source and destination ports. - How to verify it Manual test. Signed-off-by: Stephen Sun <[email protected]>
1 parent f473b4f commit 7d9ec5d

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

config/main.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,10 @@ def validate_mirror_session_config(config_db, session_name, dst_port, src_port,
11791179
mirror_table = config_db.get_table('MIRROR_SESSION')
11801180
portchannel_member_table = config_db.get_table('PORTCHANNEL_MEMBER')
11811181

1182+
# Determine namespaces to validate: always include None (single-ASIC/back-compat),
1183+
# and for multi-ASIC include namespaces for dst/src ports if present.
1184+
namespace_set = set()
1185+
11821186
if dst_port:
11831187
if not interface_name_is_valid(config_db, dst_port):
11841188
ctx.fail("Error: Destination Interface {} is invalid".format(dst_port))
@@ -1195,13 +1199,17 @@ def validate_mirror_session_config(config_db, session_name, dst_port, src_port,
11951199
if clicommon.is_port_router_interface(config_db, dst_port):
11961200
ctx.fail("Error: Destination Interface {} is a L3 interface".format(dst_port))
11971201

1202+
namespace_set.add(get_port_namespace(dst_port))
1203+
11981204
if src_port:
11991205
for port in src_port.split(","):
12001206
if not interface_name_is_valid(config_db, port):
12011207
ctx.fail("Error: Source Interface {} is invalid".format(port))
12021208
if dst_port and dst_port == port:
12031209
ctx.fail("Error: Destination Interface cant be same as Source Interface")
12041210

1211+
namespace_set.add(get_port_namespace(port))
1212+
12051213
if interface_has_mirror_config(ctx, mirror_table, dst_port, src_port, direction):
12061214
return False
12071215

@@ -1211,9 +1219,11 @@ def validate_mirror_session_config(config_db, session_name, dst_port, src_port,
12111219

12121220
# Check port mirror capability before allowing configuration
12131221
# If direction is provided, check the specific direction
1214-
if not is_port_mirror_capability_supported(direction):
1215-
ctx.fail("Error: Port mirror direction '{}' is not supported by the ASIC".format(
1216-
direction if direction else 'both'))
1222+
1223+
for ns in namespace_set:
1224+
if not is_port_mirror_capability_supported(direction, namespace=ns):
1225+
ctx.fail("Error: Port mirror direction '{}' is not supported by the ASIC".format(
1226+
direction if direction else 'both'))
12171227

12181228
return True
12191229

0 commit comments

Comments
 (0)