Fix backend port channels and routes being displayed (#14479)

* 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 #13660.
Fix these issues by switching to reading from PORTCHANNEL_MEMBERS table
instead.
Fixes #14459.
* Replace table name with constant

Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
This commit is contained in:
Saikrishna Arcot 2023-04-14 19:54:02 -07:00 committed by GitHub
parent d014b03849
commit 070a64af89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,7 +18,7 @@ EXTERNAL_PORT = 'Ext'
INTERNAL_PORT = 'Int' INTERNAL_PORT = 'Int'
INBAND_PORT = 'Inb' INBAND_PORT = 'Inb'
RECIRC_PORT ='Rec' RECIRC_PORT ='Rec'
PORT_CHANNEL_CFG_DB_TABLE = 'PORTCHANNEL' PORT_CHANNEL_MEMBER_CFG_DB_TABLE = 'PORTCHANNEL_MEMBER'
PORT_CFG_DB_TABLE = 'PORT' PORT_CFG_DB_TABLE = 'PORT'
BGP_NEIGH_CFG_DB_TABLE = 'BGP_NEIGHBOR' BGP_NEIGH_CFG_DB_TABLE = 'BGP_NEIGHBOR'
BGP_INTERNAL_NEIGH_CFG_DB_TABLE = 'BGP_INTERNAL_NEIGHBOR' BGP_INTERNAL_NEIGH_CFG_DB_TABLE = 'BGP_INTERNAL_NEIGHBOR'
@ -354,13 +354,12 @@ def is_port_channel_internal(port_channel, namespace=None):
for ns in ns_list: for ns in ns_list:
config_db = connect_config_db_for_ns(ns) 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: for port_channel_member in port_channel_members:
if 'members' in port_channels: if port_channel_member[0] != port_channel:
members = port_channels['members'] continue
if is_port_internal(members[0], namespace): return is_port_internal(port_channel_member[1], namespace)
return True
return False return False
@ -380,14 +379,14 @@ def get_back_end_interface_set(namespace=None):
ns_list = get_namespace_list(namespace) ns_list = get_namespace_list(namespace)
for ns in ns_list: for ns in ns_list:
config_db = connect_config_db_for_ns(ns) 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. # 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. # 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 # 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 # 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]. # 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()\ bk_end_intf_list.extend(set([port_channel_member[0] for port_channel_member in port_channel_members\
if 'members' in lag_info and lag_info['members'][0] in bk_end_intf_list]) if port_channel_member[1] in bk_end_intf_list]))
a = set() a = set()
a.update(bk_end_intf_list) a.update(bk_end_intf_list)
return a return a