Skip to content

Commit e6b2e1d

Browse files
saiarcot895mssonicbld
authored andcommitted
Fix backend port channels and routes being displayed (sonic-net#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 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 <[email protected]>
1 parent f409b3d commit e6b2e1d

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

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'
@@ -355,13 +355,12 @@ def is_port_channel_internal(port_channel, namespace=None):
355355

356356
for ns in ns_list:
357357
config_db = connect_config_db_for_ns(ns)
358-
port_channels = config_db.get_entry(PORT_CHANNEL_CFG_DB_TABLE, port_channel)
358+
port_channel_members = config_db.get_keys(PORT_CHANNEL_MEMBER_CFG_DB_TABLE)
359359

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

366365
return False
367366

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

0 commit comments

Comments
 (0)