Skip to content

Commit

Permalink
[routeorch]: Checking if a temp route is already there before adding …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
Shuotian Cheng authored Jun 1, 2017
1 parent f9d9f18 commit d2a466d
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions orchagent/routeorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,11 +552,28 @@ bool RouteOrch::addRoute(IpPrefix ipPrefix, IpAddresses nextHops)
/* The route is pointing to a next hop group */
else
{
if (!hasNextHopGroup(nextHops)) /* Create a new next hop group */
/* Check if there is already an existing next hop group */
if (!hasNextHopGroup(nextHops))
{
/* Try to create a new next hop group */
if (!addNextHopGroup(nextHops))
{
/* Add a temporary route when a next hop group cannot be added */
/* Failed to create the next hop group and check if a temporary route is needed */

/* If the current next hop is part of the next hop group to sync,
* then return false and no need to add another temporary route. */
if (it_route != m_syncdRoutes.end() && it_route->second.getSize() == 1)
{
IpAddress ip_address(it_route->second.to_string());
if (nextHops.contains(ip_address))
{
return false;
}
}

/* Add a temporary route when a next hop group cannot be added,
* and there is no temporary route right now or the current temporary
* route is not pointing to a member of the next hop group to sync. */
addTempRoute(ipPrefix, nextHops);
/* Return false since the original route is not successfully added */
return false;
Expand Down

0 comments on commit d2a466d

Please sign in to comment.