Skip to content

Commit d89d483

Browse files
lolyuyxieca
authored andcommitted
[route_check][dualtor] Ignore vlan neighbor route miss (#2888)
What I did As the subject. This PR is to leave the vlan neighbor route checking to dualtor_neighbor_check.py script: #2840 Signed-off-by: Longxiang Lyu [email protected] How I did it If any misses are found on dualtor, ignore those vlan neighbor misses. How to verify it UT and verify on testbed.
1 parent 20853a6 commit d89d483

File tree

2 files changed

+104
-0
lines changed

2 files changed

+104
-0
lines changed

scripts/route_check.py

+50
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,51 @@ def filter_out_soc_ip_routes(routes):
530530
return updated_routes
531531

532532

533+
def get_vlan_neighbors():
534+
"""Return a list of VLAN neighbors."""
535+
db = swsscommon.DBConnector(APPL_DB_NAME, 0)
536+
print_message(syslog.LOG_DEBUG, "APPL DB connected for neighbors")
537+
tbl = swsscommon.Table(db, 'NEIGH_TABLE')
538+
neigh_entries = tbl.getKeys()
539+
540+
valid_neighs = []
541+
for neigh_entry in neigh_entries:
542+
if ':' in neigh_entry:
543+
device, prefix = neigh_entry.split(':', 1)
544+
if device.startswith("Vlan"):
545+
valid_neighs.append(add_prefix_ifnot(prefix.lower()))
546+
547+
print_message(syslog.LOG_DEBUG, "Vlan neighbors:", json.dumps(valid_neighs, indent=4))
548+
return valid_neighs
549+
550+
551+
def filter_out_vlan_neigh_route_miss(rt_appl_miss, rt_asic_miss):
552+
"""Ignore any route miss for vlan neighbor IPs."""
553+
554+
def _filter_out_neigh_route(routes, neighs):
555+
updated_routes = []
556+
ignored_routes = []
557+
for route in routes:
558+
if route in neighs:
559+
ignored_routes.append(route)
560+
else:
561+
updated_routes.append(route)
562+
return updated_routes, ignored_routes
563+
564+
config_db = swsscommon.ConfigDBConnector()
565+
config_db.connect()
566+
567+
print_message(syslog.LOG_DEBUG, "Ignore vlan neighbor route miss")
568+
if is_dualtor(config_db):
569+
vlan_neighs = set(get_vlan_neighbors())
570+
rt_appl_miss, ignored_rt_appl_miss = _filter_out_neigh_route(rt_appl_miss, vlan_neighs)
571+
print_message(syslog.LOG_DEBUG, "Ignored appl route miss:", json.dumps(ignored_rt_appl_miss, indent=4))
572+
rt_asic_miss, ignored_rt_asic_miss = _filter_out_neigh_route(rt_asic_miss, vlan_neighs)
573+
print_message(syslog.LOG_DEBUG, "Ignored asic route miss:", json.dumps(ignored_rt_asic_miss, indent=4))
574+
575+
return rt_appl_miss, rt_asic_miss
576+
577+
533578
def check_routes():
534579
"""
535580
The heart of this script which runs the checks.
@@ -578,6 +623,11 @@ def check_routes():
578623
if rt_appl_miss:
579624
rt_appl_miss = filter_out_voq_neigh_routes(rt_appl_miss)
580625

626+
# NOTE: On dualtor environment, ignore any route miss for the
627+
# neighbors learned from the vlan subnet.
628+
if rt_appl_miss or rt_asic_miss:
629+
rt_appl_miss, rt_asic_miss = filter_out_vlan_neigh_route_miss(rt_appl_miss, rt_asic_miss)
630+
581631
if rt_appl_miss or rt_asic_miss:
582632
# Look for subscribe updates for a second
583633
adds, deletes = get_subscribe_updates(selector, subs)

tests/route_check_test_data.py

+54
Original file line numberDiff line numberDiff line change
@@ -351,4 +351,58 @@
351351
}
352352
}
353353
},
354+
"11": {
355+
DESCR: "dualtor ignore vlan neighbor route miss case",
356+
ARGS: "route_check -i 15",
357+
RET: -1,
358+
PRE: {
359+
CONFIG_DB: {
360+
DEVICE_METADATA: {
361+
LOCALHOST: {"subtype": "DualToR"}
362+
}
363+
},
364+
APPL_DB: {
365+
ROUTE_TABLE: {
366+
"10.10.196.12/31" : { "ifname": "portchannel0" },
367+
"10.10.196.20/31" : { "ifname": "portchannel0" },
368+
"192.168.0.101/32": { "ifname": "tun0" },
369+
"192.168.0.103/32": { "ifname": "tun0" },
370+
},
371+
INTF_TABLE: {
372+
"PortChannel1013:90.10.196.24/31": {},
373+
"PortChannel1023:9603:10b0:503:df4::5d/126": {},
374+
},
375+
NEIGH_TABLE: {
376+
"Vlan1000:192.168.0.100": {},
377+
"Vlan1000:192.168.0.101": {},
378+
"Vlan1000:192.168.0.102": {},
379+
"Vlan1000:192.168.0.103": {},
380+
}
381+
},
382+
ASIC_DB: {
383+
RT_ENTRY_TABLE: {
384+
RT_ENTRY_KEY_PREFIX + "20.10.196.12/31" + RT_ENTRY_KEY_SUFFIX: {},
385+
RT_ENTRY_KEY_PREFIX + "20.10.196.20/31" + RT_ENTRY_KEY_SUFFIX: {},
386+
RT_ENTRY_KEY_PREFIX + "20.10.196.24/32" + RT_ENTRY_KEY_SUFFIX: {},
387+
RT_ENTRY_KEY_PREFIX + "192.168.0.101/32" + RT_ENTRY_KEY_SUFFIX: {},
388+
RT_ENTRY_KEY_PREFIX + "192.168.0.102/32" + RT_ENTRY_KEY_SUFFIX: {},
389+
}
390+
}
391+
},
392+
RESULT: {
393+
"missed_ROUTE_TABLE_routes": [
394+
"10.10.196.12/31",
395+
"10.10.196.20/31"
396+
],
397+
"missed_INTF_TABLE_entries": [
398+
"90.10.196.24/32",
399+
"9603:10b0:503:df4::5d/128"
400+
],
401+
"Unaccounted_ROUTE_ENTRY_TABLE_entries": [
402+
"20.10.196.12/31",
403+
"20.10.196.20/31",
404+
"20.10.196.24/32",
405+
]
406+
}
407+
},
354408
}

0 commit comments

Comments
 (0)