Skip to content

Commit

Permalink
[vnetorch]: Add support of nexthop routes for Bitmap VNET implementat…
Browse files Browse the repository at this point in the history
…ion (#805)

Signed-off-by: Volodymyr Samotiy <volodymyrs@mellanox.com>
  • Loading branch information
Volodymyr Samotiy authored and prsunny committed Mar 5, 2019
1 parent 3b34b21 commit c903b5d
Showing 1 changed file with 42 additions and 8 deletions.
50 changes: 42 additions & 8 deletions orchagent/vnetorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -805,10 +805,13 @@ bool VNetBitmapObject::addRoute(IpPrefix& ipPrefix, nextHop& nh)
vector<sai_attribute_t> attrs;
sai_ip_prefix_t pfx;
sai_object_id_t tunnelRouteTableEntryId;
sai_object_id_t nh_id = SAI_NULL_OBJECT_ID;
uint32_t peerBitmap = vnet_id_;
Port port;

if ((!gPortsOrch->getPort(nh.ifname, port) || (port.m_rif_id == SAI_NULL_OBJECT_ID)))
bool is_subnet = (!nh.ips.getSize()) ? true : false;

if (is_subnet && (!gPortsOrch->getPort(nh.ifname, port) || (port.m_rif_id == SAI_NULL_OBJECT_ID)))
{
SWSS_LOG_WARN("Port/RIF %s doesn't exist", nh.ifname.c_str());
return false;
Expand All @@ -828,9 +831,44 @@ bool VNetBitmapObject::addRoute(IpPrefix& ipPrefix, nextHop& nh)
/* Local route */
copy(pfx, ipPrefix);

attr.id = SAI_TABLE_BITMAP_ROUTER_ENTRY_ATTR_ACTION;
attr.value.s32 = SAI_TABLE_BITMAP_ROUTER_ENTRY_ACTION_TO_LOCAL;
attrs.push_back(attr);
if (is_subnet)
{
attr.id = SAI_TABLE_BITMAP_ROUTER_ENTRY_ATTR_ACTION;
attr.value.s32 = SAI_TABLE_BITMAP_ROUTER_ENTRY_ACTION_TO_LOCAL;
attrs.push_back(attr);

attr.id = SAI_TABLE_BITMAP_ROUTER_ENTRY_ATTR_ROUTER_INTERFACE;
attr.value.oid = port.m_rif_id;
attrs.push_back(attr);
}
else if (nh.ips.getSize() == 1)
{
IpAddress ip_address(nh.ips.to_string());
if (gNeighOrch->hasNextHop(ip_address))
{
nh_id = gNeighOrch->getNextHopId(ip_address);
}
else
{
SWSS_LOG_INFO("Failed to get next hop %s for %s",
ip_address.to_string().c_str(), ipPrefix.to_string().c_str());
return false;
}

attr.id = SAI_TABLE_BITMAP_ROUTER_ENTRY_ATTR_ACTION;
attr.value.s32 = SAI_TABLE_BITMAP_ROUTER_ENTRY_ACTION_TO_NEXTHOP;
attrs.push_back(attr);

attr.id = SAI_TABLE_BITMAP_ROUTER_ENTRY_ATTR_NEXT_HOP;
attr.value.oid = nh_id;
attrs.push_back(attr);
}
else
{
/* FIXME - Handle ECMP routes */
SWSS_LOG_WARN("VNET ECMP NHs not implemented for '%s'", ipPrefix.to_string().c_str());
return true;
}

attr.id = SAI_TABLE_BITMAP_ROUTER_ENTRY_ATTR_PRIORITY;
attr.value.u32 = getFreeTunnelRouteTableOffset();
Expand All @@ -848,10 +886,6 @@ bool VNetBitmapObject::addRoute(IpPrefix& ipPrefix, nextHop& nh)
attr.value.ipprefix = pfx;
attrs.push_back(attr);

attr.id = SAI_TABLE_BITMAP_ROUTER_ENTRY_ATTR_ROUTER_INTERFACE;
attr.value.oid = port.m_rif_id;
attrs.push_back(attr);

status = sai_bmtor_api->create_table_bitmap_router_entry(
&tunnelRouteTableEntryId,
gSwitchId,
Expand Down

0 comments on commit c903b5d

Please sign in to comment.