Skip to content

Commit

Permalink
Fix backend port channels and routes being displayed (sonic-net#14479)
Browse files Browse the repository at this point in the history
* Fix backend port channels and routes being displayed
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.
* Replace table name with constant

Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
  • Loading branch information
saiarcot895 authored and mssonicbld committed Apr 19, 2023
1 parent f409b3d commit e6b2e1d
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/sonic-py-common/sonic_py_common/multi_asic.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
INTERNAL_PORT = 'Int'
INBAND_PORT = 'Inb'
RECIRC_PORT ='Rec'
PORT_CHANNEL_CFG_DB_TABLE = 'PORTCHANNEL'
PORT_CHANNEL_MEMBER_CFG_DB_TABLE = 'PORTCHANNEL_MEMBER'
PORT_CFG_DB_TABLE = 'PORT'
BGP_NEIGH_CFG_DB_TABLE = 'BGP_NEIGHBOR'
BGP_INTERNAL_NEIGH_CFG_DB_TABLE = 'BGP_INTERNAL_NEIGHBOR'
Expand Down Expand Up @@ -355,13 +355,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(PORT_CHANNEL_MEMBER_CFG_DB_TABLE)

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 @@ -381,14 +380,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(PORT_CHANNEL_MEMBER_CFG_DB_TABLE)
# 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 e6b2e1d

Please sign in to comment.