Skip to content

Commit

Permalink
Routes that are in APP DB but not in STATE DB are nowtreated as active.
Browse files Browse the repository at this point in the history
Signed-off-by: Mahdi Ramezani <[email protected]>
  • Loading branch information
mramezani95 committed Feb 18, 2025
1 parent cf90228 commit b30a43a
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 4 deletions.
8 changes: 4 additions & 4 deletions scripts/vnet_route_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ def get_sdk_vnet_routes_diff(routes):
def filter_active_vnet_routes(vnet_routes: dict):
""" Filters a dictionary containing VNet routes configured for each VNet in APP_DB.
For each VNet in "vnet_routes", only active routes are included in the returned dictionary.
The return value of None indicates an error, while {} means no active routes were in vnet_routes.
Format (for both input and output):
{ <vnet_name>: { 'routes': [ <pfx/pfx_len> ], 'vrf_oid': <oid> } }
"""
Expand All @@ -373,8 +372,9 @@ def filter_active_vnet_routes(vnet_routes: dict):
key = f"{vnet_name}|{prefix}"
status, fvs = vnet_route_tunnel_table.get(key)
if not status:
print_message(syslog.LOG_ERR, f"VNET_ROUTE_TUNNEL_TABLE|{key} does not exist in STATE DB.")
return None
print_message(syslog.LOG_WARNING, f"VNET_ROUTE_TUNNEL_TABLE|{key} does not exist in STATE DB.")
active_routes.append(prefix) # Treating "prefix" as an active route
continue
for field, value in fvs:
if field == "state" and value == "active":
active_routes.append(prefix)
Expand Down Expand Up @@ -414,7 +414,7 @@ def main():
active_app_db_vnet_routes = filter_active_vnet_routes(app_db_vnet_routes)
asic_db_vnet_routes = get_vnet_routes_from_asic_db()

if use_all_routes or active_app_db_vnet_routes is None:
if use_all_routes:
missed_in_asic_db_routes = get_vnet_routes_diff(asic_db_vnet_routes, app_db_vnet_routes, True)
else:
missed_in_asic_db_routes = get_vnet_routes_diff(asic_db_vnet_routes, active_app_db_vnet_routes, True)
Expand Down
78 changes: 78 additions & 0 deletions tests/vnet_route_check_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,84 @@
}
}
},
"12": {
DESCR: "An IPv6 VNET route that is missing in STATE DB and ASIC DB",
ARGS: "vnet_route_check",
RET: -1,
PRE: {
APPL_DB: {
VXLAN_TUNNEL_TABLE: {
"tunnel_v6": {"src_ip": "3001:2000::1"}
},
VNET_TABLE: {
"Vnet_v6": [("vxlan_tunnel", "tunnel_v6"), ("scope", "default"), ("vni", "10002"),
("peer_list", "")]
},
VNET_ROUTE_TABLE: {
"Vnet_v6:fd01:fc00::1/128": {"endpoint": "fc02:1000::1,fc02:1000::2"}
}
},
ASIC_DB: {
ASIC_STATE: {
"SAI_OBJECT_TYPE_ROUTER_INTERFACE:oid:0x6000000000d76": {
"SAI_ROUTER_INTERFACE_ATTR_VIRTUAL_ROUTER_ID": "oid:0x3000000000d4b"
},
"SAI_OBJECT_TYPE_VIRTUAL_ROUTER": {
"oid:0x3000000000d4b": {"": ""}
},
}
}
},
RESULT: {
"results": {
"missed_in_asic_db_routes": {
"Vnet_v6": {
"routes": [
"fd01:fc00::1/128"
]
}
}
}
}
},
"13": {
DESCR: "A VNET route is missing in ASIC DB and STATE DB, and another inactive route is missing in ASIC DB",
ARGS: "vnet_route_check",
PRE: {
APPL_DB: {
VXLAN_TUNNEL_TABLE: {
"tunnel_v4": {"src_ip": "10.1.0.32"}
},
VNET_TABLE: {
"Vnet1": {"vxlan_tunnel": "tunnel_v4", "vni": "10001"}
},
INTF_TABLE: {
"Vlan3001": {"vnet_name": "Vnet1"},
"Vlan3001:30.1.10.1/24": {}
},
VNET_ROUTE_TABLE: {
"Vnet1:30.1.10.0/24": {"ifname": "Vlan3001"},
"Vnet1:50.1.1.0/24": {"ifname": "Vlan3001"},
}
},
ASIC_DB: {
ASIC_STATE: {
RT_ENTRY_KEY_PREFIX + "30.1.10.0/24" + RT_ENTRY_KEY_SUFFIX: {},
"SAI_OBJECT_TYPE_ROUTER_INTERFACE:oid:0x6000000000d76": {
"SAI_ROUTER_INTERFACE_ATTR_VIRTUAL_ROUTER_ID": "oid:0x3000000000d4b"
}
}
},
CNTR_DB: {
"COUNTERS_RIF_NAME_MAP": {"Vlan3001": "oid:0x6000000000d76"}
},
STATE_DB: {
VNET_ROUTE_TUNNEL_TABLE: {
"Vnet1|50.1.1.0/24": [("active_endpoints", ""), ("state", "inactive")]
}
}
}
}
}


Expand Down

0 comments on commit b30a43a

Please sign in to comment.