Skip to content

Commit eebaf97

Browse files
[routeorch] Wait for the VRF to be created (#3652)
Why I did it With VRF configuration and route getting added in the startup, the orchangent crashes. How I did it addRoutePost() assumes the VRF is already added and attempts to get the VRF ID for the same and used it to lookup the route entry. Since the VRF is not yet created, exception gets thrown. When the VRF is not yet created, the route add can be postponed for the VRF to be created first. How to verify it Running the tests/vrf/test_vrf.py, the orchagent doesnt crash anymore and the route gets created in the ASIC
1 parent 7dd3be9 commit eebaf97

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

orchagent/routeorch.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2323,6 +2323,15 @@ bool RouteOrch::addRoutePost(const RouteBulkContext& ctx, const NextHopGroupKey
23232323
return false;
23242324
}
23252325

2326+
// Ensure VRF exists in m_syncdRoutes
2327+
auto routeTableIter = m_syncdRoutes.find(vrf_id);
2328+
if (routeTableIter == m_syncdRoutes.end())
2329+
{
2330+
SWSS_LOG_INFO("VRF 0x%" PRIx64 " doesn't exist in syncd routes for route %s, will retry later",
2331+
vrf_id, ipPrefix.to_string().c_str());
2332+
return false;
2333+
}
2334+
23262335
if (m_fgNhgOrch->isRouteFineGrained(vrf_id, ipPrefix, nextHops))
23272336
{
23282337
/* Route is pointing to Fine Grained ECMP nexthop group */
@@ -2383,11 +2392,11 @@ bool RouteOrch::addRoutePost(const RouteBulkContext& ctx, const NextHopGroupKey
23832392
}
23842393

23852394
auto it_status = object_statuses.begin();
2386-
auto it_route = m_syncdRoutes.at(vrf_id).find(ipPrefix);
2395+
auto it_route = routeTableIter->second.find(ipPrefix);
23872396
MuxOrch* mux_orch = gDirectory.get<MuxOrch*>();
23882397
if (isFineGrained)
23892398
{
2390-
if (it_route == m_syncdRoutes.at(vrf_id).end())
2399+
if (it_route == routeTableIter->second.end())
23912400
{
23922401
/* First time route addition pointing to FG nhg */
23932402
if (*it_status++ != SAI_STATUS_SUCCESS)
@@ -2429,7 +2438,7 @@ bool RouteOrch::addRoutePost(const RouteBulkContext& ctx, const NextHopGroupKey
24292438
ipPrefix.to_string().c_str(), nextHops.to_string().c_str());
24302439
}
24312440
}
2432-
else if (it_route == m_syncdRoutes.at(vrf_id).end())
2441+
else if (it_route == routeTableIter->second.end())
24332442
{
24342443
sai_status_t status = *it_status++;
24352444
if (status != SAI_STATUS_SUCCESS)
@@ -2626,7 +2635,7 @@ bool RouteOrch::addRoutePost(const RouteBulkContext& ctx, const NextHopGroupKey
26262635
updateDefRouteState(ipPrefix.to_string(), true);
26272636
}
26282637

2629-
if (it_route == m_syncdRoutes.at(vrf_id).end())
2638+
if (it_route == routeTableIter->second.end())
26302639
{
26312640
gFlowCounterRouteOrch->handleRouteAdd(vrf_id, ipPrefix);
26322641
}

0 commit comments

Comments
 (0)