rib: Fix TestFibUpdates/EraseFace on Ubuntu 14.04 32-bit
Change-Id: I1381bc3eb813a1afad9b666fba30688216ee38dc
Refs: #2697
diff --git a/rib/fib-updater.cpp b/rib/fib-updater.cpp
index 212bccf..839e5ea 100644
--- a/rib/fib-updater.cpp
+++ b/rib/fib-updater.cpp
@@ -424,15 +424,14 @@
bool captureWasTurnedOn)
{
// Only update if the new route has a lower cost than a previously installed route
- shared_ptr<const Route> prevRoute =
- entry.getRouteWithLowestCostAndChildInheritByFaceId(route.faceId);
+ const Route* prevRoute = entry.getRouteWithLowestCostAndChildInheritByFaceId(route.faceId);
Rib::RouteSet routesToAdd;
if (route.isChildInherit()) {
// Add to children if this new route doesn't override a previous lower cost, or
// add to children if this new route is lower cost than a previous route.
// Less than equal, since entry may find this route
- if (!static_cast<bool>(prevRoute) || route.cost <= prevRoute->cost) {
+ if (prevRoute == nullptr || route.cost <= prevRoute->cost) {
// Add self to children
routesToAdd.insert(route);
}
@@ -452,9 +451,9 @@
// If another route with same faceId and lower cost exists, don't update.
// Must be done last so that add updates replace removal updates
// Create FIB update for new entry
- shared_ptr<const Route> other = entry.getRouteWithLowestCostByFaceId(route.faceId);
+ const Route* other = entry.getRouteWithLowestCostByFaceId(route.faceId);
- if (!other || route.cost <= other->cost) {
+ if (other == nullptr || route.cost <= other->cost) {
addFibUpdate(FibUpdate::createAddUpdate(entry.getName(), route.faceId, route.cost));
}
}
@@ -466,8 +465,7 @@
const bool costDidChange = (route.cost != existingRoute.cost);
// Look for an installed route with the lowest cost and child inherit set
- shared_ptr<const Route> prevRoute =
- entry.getRouteWithLowestCostAndChildInheritByFaceId(route.faceId);
+ const Route* prevRoute = entry.getRouteWithLowestCostAndChildInheritByFaceId(route.faceId);
// No flags changed and cost didn't change, no change in FIB
if (route.flags == existingRoute.flags && !costDidChange) {
@@ -489,7 +487,7 @@
// If another route with same faceId and lower cost and ChildInherit exists,
// don't update children.
- if (!static_cast<bool>(prevRoute) || route.cost <= prevRoute->cost) {
+ if (prevRoute == nullptr || route.cost <= prevRoute->cost) {
// If no flags changed but child inheritance is set, need to update children
// with new cost
if ((route.flags == existingRoute.flags) && route.isChildInherit()) {
@@ -507,7 +505,7 @@
if (!existingRoute.isChildInherit() && route.isChildInherit()) {
// If another route with same faceId and lower cost and ChildInherit exists,
// don't update children.
- if (!static_cast<bool>(prevRoute) || route.cost <= prevRoute->cost) {
+ if (prevRoute == nullptr || route.cost <= prevRoute->cost) {
// Add self to children
Rib::RouteSet routesToAdd;
routesToAdd.insert(route);
@@ -521,7 +519,7 @@
Rib::RouteSet routesToAdd;
// If another route with same faceId and ChildInherit exists, update children with this route.
- if (static_cast<bool>(prevRoute)) {
+ if (prevRoute != nullptr) {
routesToAdd.insert(*prevRoute);
}
else {
diff --git a/rib/rib-entry.cpp b/rib/rib-entry.cpp
index 22b6dee..39c27d0 100644
--- a/rib/rib-entry.cpp
+++ b/rib/rib-entry.cpp
@@ -175,21 +175,21 @@
return false;
}
-shared_ptr<const Route>
+const Route*
RibEntry::getRouteWithLowestCostByFaceId(uint64_t faceId) const
{
- shared_ptr<Route> candidate;
+ const Route* candidate = nullptr;
for (const Route& route : m_routes) {
// Matching face ID
if (route.faceId == faceId) {
// If this is the first route with this Face ID found
if (candidate == nullptr) {
- candidate = make_shared<Route>(route);
+ candidate = &route;
}
else if (route.cost < candidate->cost) {
// Found a route with a lower cost
- candidate = make_shared<Route>(route);
+ candidate = &route;
}
}
}
@@ -218,10 +218,10 @@
return &matches.at(1);
}
-shared_ptr<const Route>
+const Route*
RibEntry::getRouteWithLowestCostAndChildInheritByFaceId(uint64_t faceId) const
{
- shared_ptr<Route> candidate;
+ const Route* candidate = nullptr;
for (const Route& route : m_routes) {
// Correct face ID and Child Inherit flag set
@@ -230,11 +230,11 @@
{
// If this is the first route with this Face ID found
if (candidate == nullptr) {
- candidate = make_shared<Route>(route);
+ candidate = &route;
}
else if (route.cost < candidate->cost) {
// Found a route with a lower cost
- candidate = make_shared<Route>(route);
+ candidate = &route;
}
}
}
diff --git a/rib/rib-entry.hpp b/rib/rib-entry.hpp
index c3efbb7..52f070f 100644
--- a/rib/rib-entry.hpp
+++ b/rib/rib-entry.hpp
@@ -146,10 +146,10 @@
/** \brief Returns the route with the lowest cost that has the passed face ID.
* \return{ The route with the lowest cost that has the passed face ID}
*/
- shared_ptr<const Route>
+ const Route*
getRouteWithLowestCostByFaceId(uint64_t faceId) const;
-const Route*
+ const Route*
getRouteWithSecondLowestCostByFaceId(uint64_t faceId) const;
/** \brief Returns the route with the lowest cost that has the passed face ID
@@ -157,7 +157,7 @@
* \return{ The route with the lowest cost that has the passed face ID
* and its child inherit flag set }
*/
- shared_ptr<const Route>
+ const Route*
getRouteWithLowestCostAndChildInheritByFaceId(uint64_t faceId) const;
const_iterator