fw: eliminate fibEntry in Strategy API
Strategy::lookupFib can be used to obtain FIB entry.
FIB lookup is skipped when strategy does not need it.
refs #3205
Change-Id: Icba67229cbc261d9def44ffa91461ea4b09982b2
diff --git a/daemon/fw/best-route-strategy2.cpp b/daemon/fw/best-route-strategy2.cpp
index 0644ba9..ef68175 100644
--- a/daemon/fw/best-route-strategy2.cpp
+++ b/daemon/fw/best-route-strategy2.cpp
@@ -106,13 +106,19 @@
void
BestRouteStrategy2::afterReceiveInterest(const Face& inFace,
const Interest& interest,
- shared_ptr<fib::Entry> fibEntry,
shared_ptr<pit::Entry> pitEntry)
{
- const fib::NextHopList& nexthops = fibEntry->getNextHops();
+ RetxSuppression::Result suppression = m_retxSuppression.decide(inFace, interest, *pitEntry);
+ if (suppression == RetxSuppression::SUPPRESS) {
+ NFD_LOG_DEBUG(interest << " from=" << inFace.getId()
+ << " suppressed");
+ return;
+ }
+
+ const fib::Entry& fibEntry = this->lookupFib(*pitEntry);
+ const fib::NextHopList& nexthops = fibEntry.getNextHops();
fib::NextHopList::const_iterator it = nexthops.end();
- RetxSuppression::Result suppression = m_retxSuppression.decide(inFace, interest, *pitEntry);
if (suppression == RetxSuppression::NEW) {
// forward to nexthop with lowest cost except downstream
it = std::find_if(nexthops.begin(), nexthops.end(),
@@ -137,12 +143,6 @@
return;
}
- if (suppression == RetxSuppression::SUPPRESS) {
- NFD_LOG_DEBUG(interest << " from=" << inFace.getId()
- << " suppressed");
- return;
- }
-
// find an unused upstream with lowest cost except downstream
it = std::find_if(nexthops.begin(), nexthops.end(),
bind(&predicate_NextHop_eligible, pitEntry, _1, inFace.getId(),
@@ -186,7 +186,6 @@
void
BestRouteStrategy2::afterReceiveNack(const Face& inFace, const lp::Nack& nack,
- shared_ptr<fib::Entry> fibEntry,
shared_ptr<pit::Entry> pitEntry)
{
int nOutRecordsNotNacked = 0;