Skip to content

Commit d2a466d

Browse files
author
Shuotian Cheng
authored
[routeorch]: Checking if a temp route is already there before adding a new one (sonic-net#232)
- Do not add a temporary route when there existing a route whose next hop is part of the next hop group to sync. This could prevent excessive route updates when routes fail to be inserted due to next hop group creat failure.
1 parent f9d9f18 commit d2a466d

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

orchagent/routeorch.cpp

+19-2
Original file line numberDiff line numberDiff line change
@@ -552,11 +552,28 @@ bool RouteOrch::addRoute(IpPrefix ipPrefix, IpAddresses nextHops)
552552
/* The route is pointing to a next hop group */
553553
else
554554
{
555-
if (!hasNextHopGroup(nextHops)) /* Create a new next hop group */
555+
/* Check if there is already an existing next hop group */
556+
if (!hasNextHopGroup(nextHops))
556557
{
558+
/* Try to create a new next hop group */
557559
if (!addNextHopGroup(nextHops))
558560
{
559-
/* Add a temporary route when a next hop group cannot be added */
561+
/* Failed to create the next hop group and check if a temporary route is needed */
562+
563+
/* If the current next hop is part of the next hop group to sync,
564+
* then return false and no need to add another temporary route. */
565+
if (it_route != m_syncdRoutes.end() && it_route->second.getSize() == 1)
566+
{
567+
IpAddress ip_address(it_route->second.to_string());
568+
if (nextHops.contains(ip_address))
569+
{
570+
return false;
571+
}
572+
}
573+
574+
/* Add a temporary route when a next hop group cannot be added,
575+
* and there is no temporary route right now or the current temporary
576+
* route is not pointing to a member of the next hop group to sync. */
560577
addTempRoute(ipPrefix, nextHops);
561578
/* Return false since the original route is not successfully added */
562579
return false;

0 commit comments

Comments
 (0)