Skip to content

Commit 070a64a

Browse files
authored
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 <[email protected]>
1 parent d014b03 commit 070a64a

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/sonic-py-common/sonic_py_common/multi_asic.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
INTERNAL_PORT = 'Int'
1919
INBAND_PORT = 'Inb'
2020
RECIRC_PORT ='Rec'
21-
PORT_CHANNEL_CFG_DB_TABLE = 'PORTCHANNEL'
21+
PORT_CHANNEL_MEMBER_CFG_DB_TABLE = 'PORTCHANNEL_MEMBER'
2222
PORT_CFG_DB_TABLE = 'PORT'
2323
BGP_NEIGH_CFG_DB_TABLE = 'BGP_NEIGHBOR'
2424
BGP_INTERNAL_NEIGH_CFG_DB_TABLE = 'BGP_INTERNAL_NEIGHBOR'
@@ -354,13 +354,12 @@ def is_port_channel_internal(port_channel, namespace=None):
354354

355355
for ns in ns_list:
356356
config_db = connect_config_db_for_ns(ns)
357-
port_channels = config_db.get_entry(PORT_CHANNEL_CFG_DB_TABLE, port_channel)
357+
port_channel_members = config_db.get_keys(PORT_CHANNEL_MEMBER_CFG_DB_TABLE)
358358

359-
if port_channels:
360-
if 'members' in port_channels:
361-
members = port_channels['members']
362-
if is_port_internal(members[0], namespace):
363-
return True
359+
for port_channel_member in port_channel_members:
360+
if port_channel_member[0] != port_channel:
361+
continue
362+
return is_port_internal(port_channel_member[1], namespace)
364363

365364
return False
366365

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

0 commit comments

Comments
 (0)