table: add Fib::afterNewNextHop signal
Refs: #4931
Change-Id: I68915b5f5688ad2f62147069fea86956a22672b6
diff --git a/daemon/table/fib-entry.cpp b/daemon/table/fib-entry.cpp
index ff5c125..ade4c9f 100644
--- a/daemon/table/fib-entry.cpp
+++ b/daemon/table/fib-entry.cpp
@@ -48,26 +48,32 @@
return const_cast<Entry*>(this)->findNextHop(face) != m_nextHops.end();
}
-void
+std::pair<NextHopList::iterator, bool>
Entry::addOrUpdateNextHop(Face& face, uint64_t cost)
{
auto it = this->findNextHop(face);
+ bool isNew = false;
if (it == m_nextHops.end()) {
m_nextHops.emplace_back(face);
it = std::prev(m_nextHops.end());
+ isNew = true;
}
it->setCost(cost);
this->sortNextHops();
+
+ return std::make_pair(it, isNew);
}
-void
+bool
Entry::removeNextHop(const Face& face)
{
auto it = this->findNextHop(face);
if (it != m_nextHops.end()) {
m_nextHops.erase(it);
+ return true;
}
+ return false;
}
void