Skip to content

Commit

Permalink
Fix backend port channels and routes being displayed
Browse files Browse the repository at this point in the history
In `show interface portchannel` and `show ip route`, backend port
channels and routes were being displayed. This is due to changes in sonic-net#13660.
Fix these issues by switching to reading from PORTCHANNEL_MEMBERS table
instead.

Fixes sonic-net#14459.

Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
  • Loading branch information
saiarcot895 committed Mar 31, 2023
1 parent 54d6ea7 commit 003f682
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/sonic-py-common/sonic_py_common/multi_asic.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,13 +354,12 @@ def is_port_channel_internal(port_channel, namespace=None):

for ns in ns_list:
config_db = connect_config_db_for_ns(ns)
port_channels = config_db.get_entry(PORT_CHANNEL_CFG_DB_TABLE, port_channel)
port_channel_members = config_db.get_keys("PORTCHANNEL_MEMBER")

if port_channels:
if 'members' in port_channels:
members = port_channels['members']
if is_port_internal(members[0], namespace):
return True
for port_channel_member in port_channel_members:
if port_channel_member[0] != port_channel:
continue
return is_port_internal(port_channel_member[1], namespace)

return False

Expand All @@ -380,14 +379,14 @@ def get_back_end_interface_set(namespace=None):
ns_list = get_namespace_list(namespace)
for ns in ns_list:
config_db = connect_config_db_for_ns(ns)
port_channels = config_db.get_table(PORT_CHANNEL_CFG_DB_TABLE)
port_channel_members = config_db.get_keys("PORTCHANNEL_MEMBER")
# a back-end LAG must be configured with all of its member from back-end interfaces.
# mixing back-end and front-end interfaces is miss configuration and not allowed.
# To determine if a LAG is back-end LAG, just need to check its first member is back-end or not
# is sufficient. Note that a user defined LAG may have empty members so the list expansion logic
# need to ensure there are members before inspecting member[0].
bk_end_intf_list.extend([port_channel for port_channel, lag_info in port_channels.items()\
if 'members' in lag_info and lag_info['members'][0] in bk_end_intf_list])
bk_end_intf_list.extend(set([port_channel_member[0] for port_channel_member in port_channel_members\
if port_channel_member[1] in bk_end_intf_list]))
a = set()
a.update(bk_end_intf_list)
return a
Expand Down

0 comments on commit 003f682

Please sign in to comment.