Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions orchagent/vnetorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,55 @@ bool VNetVrfObject::addRoute(IpPrefix& ipPrefix, tunnelEndpoint& endp)
return true;
}

void VNetVrfObject::increaseNextHopRefCount(const nextHop& nh)
{
/* Return when there is no next hop (dropped) */
if (nh.ips.getSize() == 0)
{
return;
}
else if (nh.ips.getSize() == 1)
{
NextHopKey nexthop(nh.ips.to_string(), nh.ifname);
if (nexthop.ip_address.isZero())
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment - can you provide open and closing braces here and the below "if" condition?

{
gIntfsOrch->increaseRouterIntfsRefCount(nexthop.alias);
}
else
{
gNeighOrch->increaseNextHopRefCount(nexthop);
}
}
else
{
/* Handle ECMP routes */
}
}
void VNetVrfObject::decreaseNextHopRefCount(const nextHop& nh)
{
/* Return when there is no next hop (dropped) */
if (nh.ips.getSize() == 0)
{
return;
}
else if (nh.ips.getSize() == 1)
{
NextHopKey nexthop(nh.ips.to_string(), nh.ifname);
if (nexthop.ip_address.isZero())
{
gIntfsOrch->decreaseRouterIntfsRefCount(nexthop.alias);
}
else
{
gNeighOrch->decreaseNextHopRefCount(nexthop);
}
}
else
{
/* Handle ECMP routes */
}
}

bool VNetVrfObject::addRoute(IpPrefix& ipPrefix, nextHop& nh)
{
if (hasRoute(ipPrefix))
Expand All @@ -171,6 +220,7 @@ bool VNetVrfObject::addRoute(IpPrefix& ipPrefix, nextHop& nh)
return false;
}

increaseNextHopRefCount(nh);
routes_[ipPrefix] = nh;
return true;
}
Expand All @@ -194,6 +244,8 @@ bool VNetVrfObject::removeRoute(IpPrefix& ipPrefix)
}
else
{
nextHop nh = routes_[ipPrefix];
decreaseNextHopRefCount(nh);
routes_.erase(ipPrefix);
}
return true;
Expand Down
2 changes: 2 additions & 0 deletions orchagent/vnetorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ class VNetVrfObject : public VNetObject

sai_object_id_t getTunnelNextHop(tunnelEndpoint& endp);
bool removeTunnelNextHop(tunnelEndpoint& endp);
void increaseNextHopRefCount(const nextHop&);
void decreaseNextHopRefCount(const nextHop&);

~VNetVrfObject();

Expand Down