@@ -566,7 +566,7 @@ void RouteOrch::doTask(Consumer& consumer)
566
566
* way is to create loopback interface and then create
567
567
* route pointing to it, so that we can traps packets to
568
568
* CPU */
569
- if (alias == " eth0" || alias == " docker0" || alias == " tun0 " ||
569
+ if (alias == " eth0" || alias == " docker0" ||
570
570
alias == " lo" || !alias.compare (0 , strlen (LOOPBACK_PREFIX), LOOPBACK_PREFIX))
571
571
{
572
572
excp_intfs_flag = true ;
@@ -591,10 +591,18 @@ void RouteOrch::doTask(Consumer& consumer)
591
591
592
592
if (overlay_nh == false )
593
593
{
594
+ if (alsv[0 ] == " tun0" && !(IpAddress (ipv[0 ]).isZero ()))
595
+ {
596
+ alsv[0 ] = gIntfsOrch ->getRouterIntfsAlias (ipv[0 ]);
597
+ }
594
598
nhg_str = ipv[0 ] + NH_DELIMITER + alsv[0 ];
595
599
596
600
for (uint32_t i = 1 ; i < ipv.size (); i++)
597
601
{
602
+ if (alsv[i] == " tun0" && !(IpAddress (ipv[i]).isZero ()))
603
+ {
604
+ alsv[i] = gIntfsOrch ->getRouterIntfsAlias (ipv[i]);
605
+ }
598
606
nhg_str += NHG_DELIMITER + ipv[i] + NH_DELIMITER + alsv[i];
599
607
}
600
608
@@ -620,6 +628,11 @@ void RouteOrch::doTask(Consumer& consumer)
620
628
/* add addBlackholeRoute or addRoute support empty nhg */
621
629
it = consumer.m_toSync .erase (it);
622
630
}
631
+ /* skip direct routes to tun0 */
632
+ else if (alsv[0 ] == " tun0" )
633
+ {
634
+ it = consumer.m_toSync .erase (it);
635
+ }
623
636
/* directly connected route to VRF interface which come from kernel */
624
637
else if (!alsv[0 ].compare (0 , strlen (VRF_PREFIX), VRF_PREFIX))
625
638
{
@@ -993,6 +1006,7 @@ bool RouteOrch::addNextHopGroup(const NextHopGroupKey &nexthops)
993
1006
vector<sai_object_id_t > next_hop_ids;
994
1007
set<NextHopKey> next_hop_set = nexthops.getNextHops ();
995
1008
std::map<sai_object_id_t , NextHopKey> nhopgroup_members_set;
1009
+ std::map<sai_object_id_t , set<NextHopKey>> nhopgroup_shared_set;
996
1010
997
1011
/* Assert each IP address exists in m_syncdNextHops table,
998
1012
* and add the corresponding next_hop_id to next_hop_ids. */
@@ -1013,7 +1027,14 @@ bool RouteOrch::addNextHopGroup(const NextHopGroupKey &nexthops)
1013
1027
1014
1028
sai_object_id_t next_hop_id = m_neighOrch->getNextHopId (it);
1015
1029
next_hop_ids.push_back (next_hop_id);
1016
- nhopgroup_members_set[next_hop_id] = it;
1030
+ if (nhopgroup_members_set.find (next_hop_id) == nhopgroup_members_set.end ())
1031
+ {
1032
+ nhopgroup_members_set[next_hop_id] = it;
1033
+ }
1034
+ else
1035
+ {
1036
+ nhopgroup_shared_set[next_hop_id].insert (it);
1037
+ }
1017
1038
}
1018
1039
1019
1040
sai_attribute_t nhg_attr;
@@ -1083,8 +1104,20 @@ bool RouteOrch::addNextHopGroup(const NextHopGroupKey &nexthops)
1083
1104
gCrmOrch ->incCrmResUsedCounter (CrmResourceType::CRM_NEXTHOP_GROUP_MEMBER);
1084
1105
1085
1106
// Save the membership into next hop structure
1086
- next_hop_group_entry.nhopgroup_members [nhopgroup_members_set.find (nhid)->second ] =
1087
- nhgm_id;
1107
+ if (nhopgroup_shared_set.find (nhid) != nhopgroup_shared_set.end ())
1108
+ {
1109
+ auto it = nhopgroup_shared_set[nhid].begin ();
1110
+ next_hop_group_entry.nhopgroup_members [*it] = nhgm_id;
1111
+ nhopgroup_shared_set[nhid].erase (it);
1112
+ if (nhopgroup_shared_set[nhid].empty ())
1113
+ {
1114
+ nhopgroup_shared_set.erase (nhid);
1115
+ }
1116
+ }
1117
+ else
1118
+ {
1119
+ next_hop_group_entry.nhopgroup_members [nhopgroup_members_set.find (nhid)->second ] = nhgm_id;
1120
+ }
1088
1121
}
1089
1122
1090
1123
/* Increment the ref_count for the next hops used by the next hop group. */
@@ -1098,7 +1131,6 @@ bool RouteOrch::addNextHopGroup(const NextHopGroupKey &nexthops)
1098
1131
next_hop_group_entry.ref_count = 0 ;
1099
1132
m_syncdNextHopGroups[nexthops] = next_hop_group_entry;
1100
1133
1101
-
1102
1134
return true ;
1103
1135
}
1104
1136
0 commit comments