Skip to content

Commit

Permalink
[vnetorch] Add ECMP support for vnet tunnel routes (sonic-net#1960)
Browse files Browse the repository at this point in the history
What I did
Add functions to create/remove next hop groups for vnet tunnel routes.
Count the reference count of next hop groups to create and remove as needed.
Share the counter of next hop groups with routeorch.
Add vs test

Why I did it
To add support for overlay ECMP.

How I verified it
Verify ECMP groups are properly created and removed with the functions.
Verify vs test passes
  • Loading branch information
shi-su authored and Shi Su committed Jan 21, 2022
1 parent 320591a commit 3ef3a46
Show file tree
Hide file tree
Showing 6 changed files with 639 additions and 59 deletions.
2 changes: 2 additions & 0 deletions orchagent/nexthopkey.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ struct NextHopKey
mac_address = keys[3];
}

NextHopKey(const IpAddress &ip, const MacAddress &mac, const uint32_t &vni, bool overlay_nh) : ip_address(ip), alias(""), vni(vni), mac_address(mac){}

const std::string to_string() const
{
return ip_address.to_string() + NH_DELIMITER + alias;
Expand Down
14 changes: 14 additions & 0 deletions orchagent/routeorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2186,3 +2186,17 @@ bool RouteOrch::removeOverlayNextHops(sai_object_id_t vrf_id, const NextHopGroup
return true;
}

void RouteOrch::increaseNextHopGroupCount()
{
m_nextHopGroupCount ++;
}

void RouteOrch::decreaseNextHopGroupCount()
{
m_nextHopGroupCount --;
}

bool RouteOrch::checkNextHopGroupCount()
{
return m_nextHopGroupCount < m_maxNextHopGroupCount;
}
4 changes: 4 additions & 0 deletions orchagent/routeorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ class RouteOrch : public Orch, public Subject
bool createFineGrainedNextHopGroup(sai_object_id_t &next_hop_group_id, vector<sai_attribute_t> &nhg_attrs);
bool removeFineGrainedNextHopGroup(sai_object_id_t &next_hop_group_id);

void increaseNextHopGroupCount();
void decreaseNextHopGroupCount();
bool checkNextHopGroupCount();

private:
SwitchOrch *m_switchOrch;
NeighOrch *m_neighOrch;
Expand Down
Loading

0 comments on commit 3ef3a46

Please sign in to comment.