Skip to content

Commit ece4049

Browse files
authored
Fix bug with checking VRF's routes in route_check.py (sonic-net#2301)
* Create route_check.py compatible with VRF Signed-off-by: Petro Bratash <[email protected]>
1 parent 20c6d18 commit ece4049

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

scripts/route_check.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,10 @@ def get_routes():
281281

282282
valid_rt = []
283283
for k in keys:
284-
if not is_vrf(k) and not is_local(k):
284+
if (is_vrf(k)):
285+
k = k.split(":", 1)[1]
286+
287+
if not is_local(k):
285288
valid_rt.append(add_prefix_ifnot(k.lower()))
286289

287290
print_message(syslog.LOG_DEBUG, json.dumps({"ROUTE_TABLE": sorted(valid_rt)}, indent=4))

tests/route_check_test.py

+27
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,33 @@
293293
}
294294
}
295295
}
296+
},
297+
"7": {
298+
DESCR: "Good one with VRF routes",
299+
ARGS: "route_check",
300+
PRE: {
301+
APPL_DB: {
302+
ROUTE_TABLE: {
303+
"Vrf1:0.0.0.0/0" : { "ifname": "portchannel0" },
304+
"Vrf1:10.10.196.12/31" : { "ifname": "portchannel0" },
305+
"Vrf1:10.10.196.20/31" : { "ifname": "portchannel0" }
306+
},
307+
INTF_TABLE: {
308+
"PortChannel1013:10.10.196.24/31": {},
309+
"PortChannel1023:2603:10b0:503:df4::5d/126": {},
310+
"PortChannel1024": {}
311+
}
312+
},
313+
ASIC_DB: {
314+
RT_ENTRY_TABLE: {
315+
RT_ENTRY_KEY_PREFIX + "10.10.196.12/31" + RT_ENTRY_KEY_SUFFIX: {},
316+
RT_ENTRY_KEY_PREFIX + "10.10.196.20/31" + RT_ENTRY_KEY_SUFFIX: {},
317+
RT_ENTRY_KEY_PREFIX + "10.10.196.24/32" + RT_ENTRY_KEY_SUFFIX: {},
318+
RT_ENTRY_KEY_PREFIX + "2603:10b0:503:df4::5d/128" + RT_ENTRY_KEY_SUFFIX: {},
319+
RT_ENTRY_KEY_PREFIX + "0.0.0.0/0" + RT_ENTRY_KEY_SUFFIX: {}
320+
}
321+
}
322+
}
296323
}
297324
}
298325

0 commit comments

Comments
 (0)