Skip to content

Commit b30a43a

Browse files
committed
Routes that are in APP DB but not in STATE DB are nowtreated as active.
Signed-off-by: Mahdi Ramezani <[email protected]>
1 parent cf90228 commit b30a43a

File tree

2 files changed

+82
-4
lines changed

2 files changed

+82
-4
lines changed

scripts/vnet_route_check.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,6 @@ def get_sdk_vnet_routes_diff(routes):
359359
def filter_active_vnet_routes(vnet_routes: dict):
360360
""" Filters a dictionary containing VNet routes configured for each VNet in APP_DB.
361361
For each VNet in "vnet_routes", only active routes are included in the returned dictionary.
362-
The return value of None indicates an error, while {} means no active routes were in vnet_routes.
363362
Format (for both input and output):
364363
{ <vnet_name>: { 'routes': [ <pfx/pfx_len> ], 'vrf_oid': <oid> } }
365364
"""
@@ -373,8 +372,9 @@ def filter_active_vnet_routes(vnet_routes: dict):
373372
key = f"{vnet_name}|{prefix}"
374373
status, fvs = vnet_route_tunnel_table.get(key)
375374
if not status:
376-
print_message(syslog.LOG_ERR, f"VNET_ROUTE_TUNNEL_TABLE|{key} does not exist in STATE DB.")
377-
return None
375+
print_message(syslog.LOG_WARNING, f"VNET_ROUTE_TUNNEL_TABLE|{key} does not exist in STATE DB.")
376+
active_routes.append(prefix) # Treating "prefix" as an active route
377+
continue
378378
for field, value in fvs:
379379
if field == "state" and value == "active":
380380
active_routes.append(prefix)
@@ -414,7 +414,7 @@ def main():
414414
active_app_db_vnet_routes = filter_active_vnet_routes(app_db_vnet_routes)
415415
asic_db_vnet_routes = get_vnet_routes_from_asic_db()
416416

417-
if use_all_routes or active_app_db_vnet_routes is None:
417+
if use_all_routes:
418418
missed_in_asic_db_routes = get_vnet_routes_diff(asic_db_vnet_routes, app_db_vnet_routes, True)
419419
else:
420420
missed_in_asic_db_routes = get_vnet_routes_diff(asic_db_vnet_routes, active_app_db_vnet_routes, True)

tests/vnet_route_check_test.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,84 @@
564564
}
565565
}
566566
},
567+
"12": {
568+
DESCR: "An IPv6 VNET route that is missing in STATE DB and ASIC DB",
569+
ARGS: "vnet_route_check",
570+
RET: -1,
571+
PRE: {
572+
APPL_DB: {
573+
VXLAN_TUNNEL_TABLE: {
574+
"tunnel_v6": {"src_ip": "3001:2000::1"}
575+
},
576+
VNET_TABLE: {
577+
"Vnet_v6": [("vxlan_tunnel", "tunnel_v6"), ("scope", "default"), ("vni", "10002"),
578+
("peer_list", "")]
579+
},
580+
VNET_ROUTE_TABLE: {
581+
"Vnet_v6:fd01:fc00::1/128": {"endpoint": "fc02:1000::1,fc02:1000::2"}
582+
}
583+
},
584+
ASIC_DB: {
585+
ASIC_STATE: {
586+
"SAI_OBJECT_TYPE_ROUTER_INTERFACE:oid:0x6000000000d76": {
587+
"SAI_ROUTER_INTERFACE_ATTR_VIRTUAL_ROUTER_ID": "oid:0x3000000000d4b"
588+
},
589+
"SAI_OBJECT_TYPE_VIRTUAL_ROUTER": {
590+
"oid:0x3000000000d4b": {"": ""}
591+
},
592+
}
593+
}
594+
},
595+
RESULT: {
596+
"results": {
597+
"missed_in_asic_db_routes": {
598+
"Vnet_v6": {
599+
"routes": [
600+
"fd01:fc00::1/128"
601+
]
602+
}
603+
}
604+
}
605+
}
606+
},
607+
"13": {
608+
DESCR: "A VNET route is missing in ASIC DB and STATE DB, and another inactive route is missing in ASIC DB",
609+
ARGS: "vnet_route_check",
610+
PRE: {
611+
APPL_DB: {
612+
VXLAN_TUNNEL_TABLE: {
613+
"tunnel_v4": {"src_ip": "10.1.0.32"}
614+
},
615+
VNET_TABLE: {
616+
"Vnet1": {"vxlan_tunnel": "tunnel_v4", "vni": "10001"}
617+
},
618+
INTF_TABLE: {
619+
"Vlan3001": {"vnet_name": "Vnet1"},
620+
"Vlan3001:30.1.10.1/24": {}
621+
},
622+
VNET_ROUTE_TABLE: {
623+
"Vnet1:30.1.10.0/24": {"ifname": "Vlan3001"},
624+
"Vnet1:50.1.1.0/24": {"ifname": "Vlan3001"},
625+
}
626+
},
627+
ASIC_DB: {
628+
ASIC_STATE: {
629+
RT_ENTRY_KEY_PREFIX + "30.1.10.0/24" + RT_ENTRY_KEY_SUFFIX: {},
630+
"SAI_OBJECT_TYPE_ROUTER_INTERFACE:oid:0x6000000000d76": {
631+
"SAI_ROUTER_INTERFACE_ATTR_VIRTUAL_ROUTER_ID": "oid:0x3000000000d4b"
632+
}
633+
}
634+
},
635+
CNTR_DB: {
636+
"COUNTERS_RIF_NAME_MAP": {"Vlan3001": "oid:0x6000000000d76"}
637+
},
638+
STATE_DB: {
639+
VNET_ROUTE_TUNNEL_TABLE: {
640+
"Vnet1|50.1.1.0/24": [("active_endpoints", ""), ("state", "inactive")]
641+
}
642+
}
643+
}
644+
}
567645
}
568646

569647

0 commit comments

Comments
 (0)