Skip to content

Commit

Permalink
[chassis][routecheck]filter out the chassis internal interfaces (#1798)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlok-nokia authored Oct 14, 2021
1 parent 4d732c6 commit 827fcee
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scripts/route_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import traceback

from swsscommon import swsscommon
from utilities_common import chassis

APPL_DB_NAME = 'APPL_DB'
ASIC_DB_NAME = 'ASIC_DB'
Expand Down Expand Up @@ -348,6 +349,9 @@ def filter_out_local_interfaces(keys):
local_if_lst = {'eth0', 'docker0'}
local_if_lo = [r'tun0', r'lo', r'Loopback\d+']

chassis_local_intfs = chassis.get_chassis_local_interfaces()
local_if_lst.update(set(chassis_local_intfs))

db = swsscommon.DBConnector(APPL_DB_NAME, 0)
tbl = swsscommon.Table(db, 'ROUTE_TABLE')

Expand Down
18 changes: 18 additions & 0 deletions utilities_common/chassis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import os
from sonic_py_common import device_info

def get_chassis_local_interfaces():
lst = []
platform = device_info.get_platform()
chassisdb_conf=os.path.join('/usr/share/sonic/device/', platform, "chassisdb.conf")
if os.path.exists(chassisdb_conf):
lines=[]
with open(chassisdb_conf, 'r') as f:
lines = f.readlines()
for line in lines:
line = line.strip()
if "chassis_internal_intfs" in line:
data = line.split("=")
lst = data[1].split(",")
return lst
return lst

0 comments on commit 827fcee

Please sign in to comment.