Skip to content

Commit c903b5d

Browse files
Volodymyr Samotiyprsunny
Volodymyr Samotiy
authored andcommitted
[vnetorch]: Add support of nexthop routes for Bitmap VNET implementation (#805)
Signed-off-by: Volodymyr Samotiy <[email protected]>
1 parent 3b34b21 commit c903b5d

File tree

1 file changed

+42
-8
lines changed

1 file changed

+42
-8
lines changed

orchagent/vnetorch.cpp

+42-8
Original file line numberDiff line numberDiff line change
@@ -805,10 +805,13 @@ bool VNetBitmapObject::addRoute(IpPrefix& ipPrefix, nextHop& nh)
805805
vector<sai_attribute_t> attrs;
806806
sai_ip_prefix_t pfx;
807807
sai_object_id_t tunnelRouteTableEntryId;
808+
sai_object_id_t nh_id = SAI_NULL_OBJECT_ID;
808809
uint32_t peerBitmap = vnet_id_;
809810
Port port;
810811

811-
if ((!gPortsOrch->getPort(nh.ifname, port) || (port.m_rif_id == SAI_NULL_OBJECT_ID)))
812+
bool is_subnet = (!nh.ips.getSize()) ? true : false;
813+
814+
if (is_subnet && (!gPortsOrch->getPort(nh.ifname, port) || (port.m_rif_id == SAI_NULL_OBJECT_ID)))
812815
{
813816
SWSS_LOG_WARN("Port/RIF %s doesn't exist", nh.ifname.c_str());
814817
return false;
@@ -828,9 +831,44 @@ bool VNetBitmapObject::addRoute(IpPrefix& ipPrefix, nextHop& nh)
828831
/* Local route */
829832
copy(pfx, ipPrefix);
830833

831-
attr.id = SAI_TABLE_BITMAP_ROUTER_ENTRY_ATTR_ACTION;
832-
attr.value.s32 = SAI_TABLE_BITMAP_ROUTER_ENTRY_ACTION_TO_LOCAL;
833-
attrs.push_back(attr);
834+
if (is_subnet)
835+
{
836+
attr.id = SAI_TABLE_BITMAP_ROUTER_ENTRY_ATTR_ACTION;
837+
attr.value.s32 = SAI_TABLE_BITMAP_ROUTER_ENTRY_ACTION_TO_LOCAL;
838+
attrs.push_back(attr);
839+
840+
attr.id = SAI_TABLE_BITMAP_ROUTER_ENTRY_ATTR_ROUTER_INTERFACE;
841+
attr.value.oid = port.m_rif_id;
842+
attrs.push_back(attr);
843+
}
844+
else if (nh.ips.getSize() == 1)
845+
{
846+
IpAddress ip_address(nh.ips.to_string());
847+
if (gNeighOrch->hasNextHop(ip_address))
848+
{
849+
nh_id = gNeighOrch->getNextHopId(ip_address);
850+
}
851+
else
852+
{
853+
SWSS_LOG_INFO("Failed to get next hop %s for %s",
854+
ip_address.to_string().c_str(), ipPrefix.to_string().c_str());
855+
return false;
856+
}
857+
858+
attr.id = SAI_TABLE_BITMAP_ROUTER_ENTRY_ATTR_ACTION;
859+
attr.value.s32 = SAI_TABLE_BITMAP_ROUTER_ENTRY_ACTION_TO_NEXTHOP;
860+
attrs.push_back(attr);
861+
862+
attr.id = SAI_TABLE_BITMAP_ROUTER_ENTRY_ATTR_NEXT_HOP;
863+
attr.value.oid = nh_id;
864+
attrs.push_back(attr);
865+
}
866+
else
867+
{
868+
/* FIXME - Handle ECMP routes */
869+
SWSS_LOG_WARN("VNET ECMP NHs not implemented for '%s'", ipPrefix.to_string().c_str());
870+
return true;
871+
}
834872

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

851-
attr.id = SAI_TABLE_BITMAP_ROUTER_ENTRY_ATTR_ROUTER_INTERFACE;
852-
attr.value.oid = port.m_rif_id;
853-
attrs.push_back(attr);
854-
855889
status = sai_bmtor_api->create_table_bitmap_router_entry(
856890
&tunnelRouteTableEntryId,
857891
gSwitchId,

0 commit comments

Comments
 (0)