table: add Fib::afterNewNextHop signal
Refs: #4931
Change-Id: I68915b5f5688ad2f62147069fea86956a22672b6
diff --git a/daemon/table/fib.cpp b/daemon/table/fib.cpp
index 62938e0..99892e6 100644
--- a/daemon/table/fib.cpp
+++ b/daemon/table/fib.cpp
@@ -133,13 +133,31 @@
}
void
+Fib::addOrUpdateNextHop(Entry& entry, Face& face, uint64_t cost)
+{
+ NextHopList::iterator it;
+ bool isNew;
+ std::tie(it, isNew) = entry.addOrUpdateNextHop(face, cost);
+
+ if (isNew)
+ this->afterNewNextHop(entry.getPrefix(), *it);
+}
+
+Fib::RemoveNextHopResult
Fib::removeNextHop(Entry& entry, const Face& face)
{
- entry.removeNextHop(face);
+ bool isRemoved = entry.removeNextHop(face);
- if (!entry.hasNextHops()) {
+ if (!isRemoved) {
+ return RemoveNextHopResult::NO_SUCH_NEXTHOP;
+ }
+ else if (!entry.hasNextHops()) {
name_tree::Entry* nte = m_nameTree.getEntry(entry);
this->erase(nte, false);
+ return RemoveNextHopResult::FIB_ENTRY_REMOVED;
+ }
+ else {
+ return RemoveNextHopResult::NEXTHOP_REMOVED;
}
}