Skip to content

Commit 02b263a

Browse files
[voq/inbandif] Voq inbandif port (sonic-net#1363)
Inband port can be made available in PORT table. But regular port handlngs are not applicable for Inband port. This PR has change to avoid regular port handling for inband port for route_check and sfpshow script.
1 parent 0539789 commit 02b263a

File tree

7 files changed

+122
-3
lines changed

7 files changed

+122
-3
lines changed

scripts/route_check.py

+33
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,36 @@ def filter_out_local_interfaces(keys):
354354
return rt
355355

356356

357+
def filter_out_voq_neigh_routes(keys):
358+
"""
359+
helper to filter out voq neigh routes. These are the
360+
routes statically added for the voq neighbors. We skip
361+
writing route entries in asic db for these. We filter
362+
out reporting error on all the host routes written on
363+
inband interface prefixed with "Ethernte-IB"
364+
:param keys: APPL-DB:ROUTE_TABLE Routes to check.
365+
:return keys filtered out for voq neigh routes
366+
"""
367+
rt = []
368+
local_if_re = [r'Ethernet-IB\d+']
369+
370+
db = swsscommon.DBConnector(APPL_DB_NAME, 0)
371+
tbl = swsscommon.Table(db, 'ROUTE_TABLE')
372+
373+
for k in keys:
374+
prefix = k.split("/")
375+
e = dict(tbl.get(k)[1])
376+
if not e:
377+
# Prefix might have been added. So try w/o it.
378+
e = dict(tbl.get(prefix[0])[1])
379+
if not e or all([not (re.match(x, e['ifname']) and
380+
((prefix[1] == "32" and e['nexthop'] == "0.0.0.0") or
381+
(prefix[1] == "128" and e['nexthop'] == "::"))) for x in local_if_re]):
382+
rt.append(k)
383+
384+
return rt
385+
386+
357387
def filter_out_default_routes(lst):
358388
"""
359389
helper to filter out default routes
@@ -411,6 +441,9 @@ def check_routes():
411441
if rt_appl_miss:
412442
rt_appl_miss = filter_out_local_interfaces(rt_appl_miss)
413443

444+
if rt_appl_miss:
445+
rt_appl_miss = filter_out_voq_neigh_routes(rt_appl_miss)
446+
414447
if rt_appl_miss or rt_asic_miss:
415448
# Look for subscribe updates for a second
416449
adds, deletes = get_subscribe_updates(selector, subs)

scripts/sfpshow

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import sys
1212

1313
import click
1414
from natsort import natsorted
15-
from sonic_py_common.interface import front_panel_prefix, backplane_prefix
15+
from sonic_py_common.interface import front_panel_prefix, backplane_prefix, inband_prefix
1616
from sonic_py_common import multi_asic
1717
from tabulate import tabulate
1818
from utilities_common import multi_asic as multi_asic_util
@@ -411,7 +411,7 @@ class SFPShow(object):
411411
sorted_table_keys = natsorted(port_table_keys)
412412
for i in sorted_table_keys:
413413
interface = re.split(':', i, maxsplit=1)[-1].strip()
414-
if interface and interface.startswith(front_panel_prefix()) and not interface.startswith(backplane_prefix()):
414+
if interface and interface.startswith(front_panel_prefix()) and not interface.startswith(backplane_prefix()) and not interface.startswith(inband_prefix()):
415415
presence = self.db.exists(self.db.STATE_DB, 'TRANSCEIVER_INFO|{}'.format(interface))
416416
if presence:
417417
self.output += self.convert_interface_sfp_info_to_cli_output_string(
@@ -435,7 +435,7 @@ class SFPShow(object):
435435
port_table_keys = self.db.keys(self.db.APPL_DB, "PORT_TABLE:*")
436436
for i in port_table_keys:
437437
key = re.split(':', i, maxsplit=1)[-1].strip()
438-
if key and key.startswith(front_panel_prefix()) and not key.startswith(backplane_prefix()):
438+
if key and key.startswith(front_panel_prefix()) and not key.startswith(backplane_prefix()) and not key.startswith(inband_prefix()):
439439
presence = self.db.exists(self.db.STATE_DB, 'TRANSCEIVER_INFO|{}'.format(key))
440440
if presence:
441441
port_table.append((key, 'Present'))

tests/mock_tables/appl_db.json

+12
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,18 @@
108108
"pfc_asym": "off",
109109
"admin_status": "up"
110110
},
111+
"PORT_TABLE:Ethernet-IB0": {
112+
"admin_status": "up",
113+
"alias": "Ethernet-IB0",
114+
"asic_port_name": "Rcy-ASIC0",
115+
"description": "",
116+
"index": "148",
117+
"lanes": "109,0,0,0,0,0,0,0",
118+
"mtu": "9100",
119+
"oper_status": "up",
120+
"role": "Int",
121+
"speed": "100000"
122+
},
111123
"INTF_TABLE:Ethernet0.10": {
112124
"admin_status": "up"
113125
},

tests/mock_tables/asic0/appl_db.json

+12
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@
4747
"speed": "40000",
4848
"asic_port_name": "Eth17-ASIC0"
4949
},
50+
"PORT_TABLE:Ethernet-IB0": {
51+
"admin_status": "up",
52+
"alias": "Ethernet-IB0",
53+
"asic_port_name": "Rcy-ASIC0",
54+
"description": "",
55+
"index": "148",
56+
"lanes": "109,0,0,0,0,0,0,0",
57+
"mtu": "9100",
58+
"oper_status": "up",
59+
"role": "Int",
60+
"speed": "100000"
61+
},
5062
"LAG_MEMBER_TABLE:PortChannel1002:Ethernet0": {
5163
"status": "disabled"
5264
},

tests/mock_tables/asic1/appl_db.json

+12
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@
3333
"speed": "40000",
3434
"asic_port_name": "Eth1-ASIC1"
3535
},
36+
"PORT_TABLE:Ethernet-IB1": {
37+
"admin_status": "up",
38+
"alias": "Ethernet-IB1",
39+
"asic_port_name": "Rcy-ASIC1",
40+
"description": "",
41+
"index": "152",
42+
"lanes": "109,0,0,0,0,0,0,0",
43+
"mtu": "9100",
44+
"oper_status": "up",
45+
"role": "Int",
46+
"speed": "100000"
47+
},
3648
"LAG_TABLE:PortChannel4009": {
3749
"admin_status": "up",
3850
"oper_status": "up",

tests/mock_tables/asic2/appl_db.json

+12
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@
4747
"speed": "40000",
4848
"asic_port_name": "Eth17-ASIC2"
4949
},
50+
"PORT_TABLE:Ethernet-IB2": {
51+
"admin_status": "up",
52+
"alias": "Ethernet-IB2",
53+
"asic_port_name": "Rcy-ASIC2",
54+
"description": "",
55+
"index": "156",
56+
"lanes": "109,0,0,0,0,0,0,0",
57+
"mtu": "9100",
58+
"oper_status": "up",
59+
"role": "Int",
60+
"speed": "100000"
61+
},
5062
"LAG_MEMBER_TABLE:PortChannel1015:Ethernet20": {
5163
"status": "enabled"
5264
},

tests/route_check_test.py

+38
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,44 @@
180180
}
181181
}
182182
}
183+
},
184+
"4": {
185+
DESCR: "Good one with routes on voq inband interface",
186+
ARGS: "route_check",
187+
PRE: {
188+
APPL_DB: {
189+
ROUTE_TABLE: {
190+
"0.0.0.0/0" : { "ifname": "portchannel0" },
191+
"10.10.196.12/31" : { "ifname": "portchannel0" },
192+
"10.10.196.20/31" : { "ifname": "portchannel0" },
193+
"10.10.196.30/31" : { "ifname": "lo" },
194+
"10.10.197.1" : { "ifname": "Ethernet-IB0", "nexthop": "0.0.0.0"},
195+
"2603:10b0:503:df5::1" : { "ifname": "Ethernet-IB0", "nexthop": "::"},
196+
"100.0.0.2/32" : { "ifname": "Ethernet-IB0", "nexthop": "0.0.0.0" },
197+
"2064:100::2/128" : { "ifname": "Ethernet-IB0", "nexthop": "::" },
198+
"101.0.0.0/24" : { "ifname": "Ethernet-IB0", "nexthop": "100.0.0.2"}
199+
},
200+
INTF_TABLE: {
201+
"PortChannel1013:10.10.196.24/31": {},
202+
"PortChannel1023:2603:10b0:503:df4::5d/126": {},
203+
"PortChannel1024": {},
204+
"Ethernet-IB0:10.10.197.1/24": {},
205+
"Ethernet-IB0:2603:10b0:503:df5::1/64": {}
206+
}
207+
},
208+
ASIC_DB: {
209+
RT_ENTRY_TABLE: {
210+
RT_ENTRY_KEY_PREFIX + "10.10.196.12/31" + RT_ENTRY_KEY_SUFFIX: {},
211+
RT_ENTRY_KEY_PREFIX + "10.10.196.20/31" + RT_ENTRY_KEY_SUFFIX: {},
212+
RT_ENTRY_KEY_PREFIX + "10.10.196.24/32" + RT_ENTRY_KEY_SUFFIX: {},
213+
RT_ENTRY_KEY_PREFIX + "2603:10b0:503:df4::5d/128" + RT_ENTRY_KEY_SUFFIX: {},
214+
RT_ENTRY_KEY_PREFIX + "0.0.0.0/0" + RT_ENTRY_KEY_SUFFIX: {},
215+
RT_ENTRY_KEY_PREFIX + "10.10.197.1/32" + RT_ENTRY_KEY_SUFFIX: {},
216+
RT_ENTRY_KEY_PREFIX + "2603:10b0:503:df5::1/128" + RT_ENTRY_KEY_SUFFIX: {},
217+
RT_ENTRY_KEY_PREFIX + "101.0.0.0/24" + RT_ENTRY_KEY_SUFFIX: {}
218+
}
219+
}
220+
}
183221
}
184222
}
185223

0 commit comments

Comments
 (0)