diff --git a/scripts/route_check.py b/scripts/route_check.py index efc144c2d342..fe870ab0769d 100755 --- a/scripts/route_check.py +++ b/scripts/route_check.py @@ -354,6 +354,36 @@ def filter_out_local_interfaces(keys): return rt +def filter_out_voq_neigh_routes(keys): + """ + helper to filter out voq neigh routes. These are the + routes statically added for the voq neighbors. We skip + writing route entries in asic db for these. We filter + out reporting error on all the host routes written on + inband interface prefixed with "Ethernte-IB" + :param keys: APPL-DB:ROUTE_TABLE Routes to check. + :return keys filtered out for voq neigh routes + """ + rt = [] + local_if_re = [r'Ethernet-IB\d+'] + + db = swsscommon.DBConnector(APPL_DB_NAME, 0) + tbl = swsscommon.Table(db, 'ROUTE_TABLE') + + for k in keys: + prefix = k.split("/") + e = dict(tbl.get(k)[1]) + if not e: + # Prefix might have been added. So try w/o it. + e = dict(tbl.get(prefix[0])[1]) + if not e or all([not (re.match(x, e['ifname']) and + ((prefix[1] == "32" and e['nexthop'] == "0.0.0.0") or + (prefix[1] == "128" and e['nexthop'] == "::"))) for x in local_if_re]): + rt.append(k) + + return rt + + def filter_out_default_routes(lst): """ helper to filter out default routes @@ -411,6 +441,9 @@ def check_routes(): if rt_appl_miss: rt_appl_miss = filter_out_local_interfaces(rt_appl_miss) + if rt_appl_miss: + rt_appl_miss = filter_out_voq_neigh_routes(rt_appl_miss) + if rt_appl_miss or rt_asic_miss: # Look for subscribe updates for a second adds, deletes = get_subscribe_updates(selector, subs) diff --git a/scripts/sfpshow b/scripts/sfpshow index 119e1252e921..3ee80ea2c068 100755 --- a/scripts/sfpshow +++ b/scripts/sfpshow @@ -12,7 +12,7 @@ import sys import click from natsort import natsorted -from sonic_py_common.interface import front_panel_prefix, backplane_prefix +from sonic_py_common.interface import front_panel_prefix, backplane_prefix, inband_prefix from sonic_py_common import multi_asic from tabulate import tabulate from utilities_common import multi_asic as multi_asic_util @@ -411,7 +411,7 @@ class SFPShow(object): sorted_table_keys = natsorted(port_table_keys) for i in sorted_table_keys: interface = re.split(':', i, maxsplit=1)[-1].strip() - if interface and interface.startswith(front_panel_prefix()) and not interface.startswith(backplane_prefix()): + if interface and interface.startswith(front_panel_prefix()) and not interface.startswith(backplane_prefix()) and not interface.startswith(inband_prefix()): presence = self.db.exists(self.db.STATE_DB, 'TRANSCEIVER_INFO|{}'.format(interface)) if presence: self.output += self.convert_interface_sfp_info_to_cli_output_string( @@ -435,7 +435,7 @@ class SFPShow(object): port_table_keys = self.db.keys(self.db.APPL_DB, "PORT_TABLE:*") for i in port_table_keys: key = re.split(':', i, maxsplit=1)[-1].strip() - if key and key.startswith(front_panel_prefix()) and not key.startswith(backplane_prefix()): + if key and key.startswith(front_panel_prefix()) and not key.startswith(backplane_prefix()) and not key.startswith(inband_prefix()): presence = self.db.exists(self.db.STATE_DB, 'TRANSCEIVER_INFO|{}'.format(key)) if presence: port_table.append((key, 'Present')) diff --git a/tests/mock_tables/appl_db.json b/tests/mock_tables/appl_db.json index 803473b9c483..a73fbb0e55bb 100644 --- a/tests/mock_tables/appl_db.json +++ b/tests/mock_tables/appl_db.json @@ -108,6 +108,18 @@ "pfc_asym": "off", "admin_status": "up" }, + "PORT_TABLE:Ethernet-IB0": { + "admin_status": "up", + "alias": "Ethernet-IB0", + "asic_port_name": "Rcy-ASIC0", + "description": "", + "index": "148", + "lanes": "109,0,0,0,0,0,0,0", + "mtu": "9100", + "oper_status": "up", + "role": "Int", + "speed": "100000" + }, "INTF_TABLE:Ethernet0.10": { "admin_status": "up" }, diff --git a/tests/mock_tables/asic0/appl_db.json b/tests/mock_tables/asic0/appl_db.json index cfe085962f1a..875a89fc8bc1 100644 --- a/tests/mock_tables/asic0/appl_db.json +++ b/tests/mock_tables/asic0/appl_db.json @@ -47,6 +47,18 @@ "speed": "40000", "asic_port_name": "Eth17-ASIC0" }, + "PORT_TABLE:Ethernet-IB0": { + "admin_status": "up", + "alias": "Ethernet-IB0", + "asic_port_name": "Rcy-ASIC0", + "description": "", + "index": "148", + "lanes": "109,0,0,0,0,0,0,0", + "mtu": "9100", + "oper_status": "up", + "role": "Int", + "speed": "100000" + }, "LAG_MEMBER_TABLE:PortChannel1002:Ethernet0": { "status": "disabled" }, diff --git a/tests/mock_tables/asic1/appl_db.json b/tests/mock_tables/asic1/appl_db.json index 3ac977cb02ee..ed5fbb2c3c50 100644 --- a/tests/mock_tables/asic1/appl_db.json +++ b/tests/mock_tables/asic1/appl_db.json @@ -33,6 +33,18 @@ "speed": "40000", "asic_port_name": "Eth1-ASIC1" }, + "PORT_TABLE:Ethernet-IB1": { + "admin_status": "up", + "alias": "Ethernet-IB1", + "asic_port_name": "Rcy-ASIC1", + "description": "", + "index": "152", + "lanes": "109,0,0,0,0,0,0,0", + "mtu": "9100", + "oper_status": "up", + "role": "Int", + "speed": "100000" + }, "LAG_TABLE:PortChannel4009": { "admin_status": "up", "oper_status": "up", diff --git a/tests/mock_tables/asic2/appl_db.json b/tests/mock_tables/asic2/appl_db.json index a9c630228b02..56eaf377bbe8 100644 --- a/tests/mock_tables/asic2/appl_db.json +++ b/tests/mock_tables/asic2/appl_db.json @@ -47,6 +47,18 @@ "speed": "40000", "asic_port_name": "Eth17-ASIC2" }, + "PORT_TABLE:Ethernet-IB2": { + "admin_status": "up", + "alias": "Ethernet-IB2", + "asic_port_name": "Rcy-ASIC2", + "description": "", + "index": "156", + "lanes": "109,0,0,0,0,0,0,0", + "mtu": "9100", + "oper_status": "up", + "role": "Int", + "speed": "100000" + }, "LAG_MEMBER_TABLE:PortChannel1015:Ethernet20": { "status": "enabled" }, diff --git a/tests/route_check_test.py b/tests/route_check_test.py index cf271f666956..f981275314a4 100644 --- a/tests/route_check_test.py +++ b/tests/route_check_test.py @@ -180,6 +180,44 @@ } } } + }, + "4": { + DESCR: "Good one with routes on voq inband interface", + ARGS: "route_check", + PRE: { + APPL_DB: { + ROUTE_TABLE: { + "0.0.0.0/0" : { "ifname": "portchannel0" }, + "10.10.196.12/31" : { "ifname": "portchannel0" }, + "10.10.196.20/31" : { "ifname": "portchannel0" }, + "10.10.196.30/31" : { "ifname": "lo" }, + "10.10.197.1" : { "ifname": "Ethernet-IB0", "nexthop": "0.0.0.0"}, + "2603:10b0:503:df5::1" : { "ifname": "Ethernet-IB0", "nexthop": "::"}, + "100.0.0.2/32" : { "ifname": "Ethernet-IB0", "nexthop": "0.0.0.0" }, + "2064:100::2/128" : { "ifname": "Ethernet-IB0", "nexthop": "::" }, + "101.0.0.0/24" : { "ifname": "Ethernet-IB0", "nexthop": "100.0.0.2"} + }, + INTF_TABLE: { + "PortChannel1013:10.10.196.24/31": {}, + "PortChannel1023:2603:10b0:503:df4::5d/126": {}, + "PortChannel1024": {}, + "Ethernet-IB0:10.10.197.1/24": {}, + "Ethernet-IB0:2603:10b0:503:df5::1/64": {} + } + }, + ASIC_DB: { + RT_ENTRY_TABLE: { + RT_ENTRY_KEY_PREFIX + "10.10.196.12/31" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "10.10.196.20/31" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "10.10.196.24/32" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "2603:10b0:503:df4::5d/128" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "0.0.0.0/0" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "10.10.197.1/32" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "2603:10b0:503:df5::1/128" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "101.0.0.0/24" + RT_ENTRY_KEY_SUFFIX: {} + } + } + } } }