@@ -574,7 +574,7 @@ void RouteOrch::doTask(Consumer& consumer)
574
574
* way is to create loopback interface and then create
575
575
* route pointing to it, so that we can traps packets to
576
576
* CPU */
577
- if (alias == " eth0" || alias == " docker0" || alias == " tun0 " ||
577
+ if (alias == " eth0" || alias == " docker0" ||
578
578
alias == " lo" || !alias.compare (0 , strlen (LOOPBACK_PREFIX), LOOPBACK_PREFIX))
579
579
{
580
580
excp_intfs_flag = true ;
@@ -599,10 +599,18 @@ void RouteOrch::doTask(Consumer& consumer)
599
599
600
600
if (overlay_nh == false )
601
601
{
602
+ if (alsv[0 ] == " tun0" && !(IpAddress (ipv[0 ]).isZero ()))
603
+ {
604
+ alsv[0 ] = gIntfsOrch ->getRouterIntfsAlias (ipv[0 ]);
605
+ }
602
606
nhg_str = ipv[0 ] + NH_DELIMITER + alsv[0 ];
603
607
604
608
for (uint32_t i = 1 ; i < ipv.size (); i++)
605
609
{
610
+ if (alsv[i] == " tun0" && !(IpAddress (ipv[i]).isZero ()))
611
+ {
612
+ alsv[i] = gIntfsOrch ->getRouterIntfsAlias (ipv[i]);
613
+ }
606
614
nhg_str += NHG_DELIMITER + ipv[i] + NH_DELIMITER + alsv[i];
607
615
}
608
616
@@ -628,6 +636,11 @@ void RouteOrch::doTask(Consumer& consumer)
628
636
/* add addBlackholeRoute or addRoute support empty nhg */
629
637
it = consumer.m_toSync .erase (it);
630
638
}
639
+ /* skip direct routes to tun0 */
640
+ else if (alsv[0 ] == " tun0" )
641
+ {
642
+ it = consumer.m_toSync .erase (it);
643
+ }
631
644
/* directly connected route to VRF interface which come from kernel */
632
645
else if (!alsv[0 ].compare (0 , strlen (VRF_PREFIX), VRF_PREFIX))
633
646
{
@@ -1009,6 +1022,7 @@ bool RouteOrch::addNextHopGroup(const NextHopGroupKey &nexthops)
1009
1022
vector<sai_object_id_t > next_hop_ids;
1010
1023
set<NextHopKey> next_hop_set = nexthops.getNextHops ();
1011
1024
std::map<sai_object_id_t , NextHopKey> nhopgroup_members_set;
1025
+ std::map<sai_object_id_t , set<NextHopKey>> nhopgroup_shared_set;
1012
1026
1013
1027
/* Assert each IP address exists in m_syncdNextHops table,
1014
1028
* and add the corresponding next_hop_id to next_hop_ids. */
@@ -1029,7 +1043,14 @@ bool RouteOrch::addNextHopGroup(const NextHopGroupKey &nexthops)
1029
1043
1030
1044
sai_object_id_t next_hop_id = m_neighOrch->getNextHopId (it);
1031
1045
next_hop_ids.push_back (next_hop_id);
1032
- nhopgroup_members_set[next_hop_id] = it;
1046
+ if (nhopgroup_members_set.find (next_hop_id) == nhopgroup_members_set.end ())
1047
+ {
1048
+ nhopgroup_members_set[next_hop_id] = it;
1049
+ }
1050
+ else
1051
+ {
1052
+ nhopgroup_shared_set[next_hop_id].insert (it);
1053
+ }
1033
1054
}
1034
1055
1035
1056
sai_attribute_t nhg_attr;
@@ -1103,8 +1124,20 @@ bool RouteOrch::addNextHopGroup(const NextHopGroupKey &nexthops)
1103
1124
gCrmOrch ->incCrmResUsedCounter (CrmResourceType::CRM_NEXTHOP_GROUP_MEMBER);
1104
1125
1105
1126
// Save the membership into next hop structure
1106
- next_hop_group_entry.nhopgroup_members [nhopgroup_members_set.find (nhid)->second ] =
1107
- nhgm_id;
1127
+ if (nhopgroup_shared_set.find (nhid) != nhopgroup_shared_set.end ())
1128
+ {
1129
+ auto it = nhopgroup_shared_set[nhid].begin ();
1130
+ next_hop_group_entry.nhopgroup_members [*it] = nhgm_id;
1131
+ nhopgroup_shared_set[nhid].erase (it);
1132
+ if (nhopgroup_shared_set[nhid].empty ())
1133
+ {
1134
+ nhopgroup_shared_set.erase (nhid);
1135
+ }
1136
+ }
1137
+ else
1138
+ {
1139
+ next_hop_group_entry.nhopgroup_members [nhopgroup_members_set.find (nhid)->second ] = nhgm_id;
1140
+ }
1108
1141
}
1109
1142
1110
1143
/* Increment the ref_count for the next hops used by the next hop group. */
@@ -1118,7 +1151,6 @@ bool RouteOrch::addNextHopGroup(const NextHopGroupKey &nexthops)
1118
1151
next_hop_group_entry.ref_count = 0 ;
1119
1152
m_syncdNextHopGroups[nexthops] = next_hop_group_entry;
1120
1153
1121
-
1122
1154
return true ;
1123
1155
}
1124
1156
0 commit comments