@@ -805,10 +805,13 @@ bool VNetBitmapObject::addRoute(IpPrefix& ipPrefix, nextHop& nh)
805
805
vector<sai_attribute_t > attrs;
806
806
sai_ip_prefix_t pfx;
807
807
sai_object_id_t tunnelRouteTableEntryId;
808
+ sai_object_id_t nh_id = SAI_NULL_OBJECT_ID;
808
809
uint32_t peerBitmap = vnet_id_;
809
810
Port port;
810
811
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)))
812
815
{
813
816
SWSS_LOG_WARN (" Port/RIF %s doesn't exist" , nh.ifname .c_str ());
814
817
return false ;
@@ -828,9 +831,44 @@ bool VNetBitmapObject::addRoute(IpPrefix& ipPrefix, nextHop& nh)
828
831
/* Local route */
829
832
copy (pfx, ipPrefix);
830
833
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
+ }
834
872
835
873
attr.id = SAI_TABLE_BITMAP_ROUTER_ENTRY_ATTR_PRIORITY;
836
874
attr.value .u32 = getFreeTunnelRouteTableOffset ();
@@ -848,10 +886,6 @@ bool VNetBitmapObject::addRoute(IpPrefix& ipPrefix, nextHop& nh)
848
886
attr.value .ipprefix = pfx;
849
887
attrs.push_back (attr);
850
888
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
-
855
889
status = sai_bmtor_api->create_table_bitmap_router_entry (
856
890
&tunnelRouteTableEntryId,
857
891
gSwitchId ,
0 commit comments