Revert "fib: add EndpointId field in NextHop record"

This reverts commit 3ad49db6eaef0d3f4a0a9bdd3356c6bb9845db57.

refs: #4973

Change-Id: I3216a55a8c4ed52cd9181f790f8ab72e44330a38
diff --git a/daemon/table/cleanup.cpp b/daemon/table/cleanup.cpp
index d45b363..a62304b 100644
--- a/daemon/table/cleanup.cpp
+++ b/daemon/table/cleanup.cpp
@@ -36,7 +36,7 @@
   for (const name_tree::Entry& nte : nt) {
     fib::Entry* fibEntry = nte.getFibEntry();
     if (fibEntry != nullptr) {
-      fib.removeNextHopByFace(*fibEntry, face);
+      fib.removeNextHop(*fibEntry, face);
     }
 
     for (const auto& pitEntry : nte.getPitEntries()) {
diff --git a/daemon/table/fib-entry.cpp b/daemon/table/fib-entry.cpp
index bb49979..ff5c125 100644
--- a/daemon/table/fib-entry.cpp
+++ b/daemon/table/fib-entry.cpp
@@ -34,52 +34,43 @@
 }
 
 NextHopList::iterator
-Entry::findNextHop(const Face& face, EndpointId endpointId)
+Entry::findNextHop(const Face& face)
 {
   return std::find_if(m_nextHops.begin(), m_nextHops.end(),
-                      [&face, endpointId] (const NextHop& nexthop) {
-                        return &nexthop.getFace() == &face && nexthop.getEndpointId() == endpointId;
+                      [&face] (const NextHop& nexthop) {
+                        return &nexthop.getFace() == &face;
                       });
 }
 
 bool
-Entry::hasNextHop(const Face& face, EndpointId endpointId) const
+Entry::hasNextHop(const Face& face) const
 {
-  return const_cast<Entry*>(this)->findNextHop(face, endpointId) != m_nextHops.end();
+  return const_cast<Entry*>(this)->findNextHop(face) != m_nextHops.end();
 }
 
 void
-Entry::addOrUpdateNextHop(Face& face, EndpointId endpointId, uint64_t cost)
+Entry::addOrUpdateNextHop(Face& face, uint64_t cost)
 {
-  auto it = this->findNextHop(face, endpointId);
+  auto it = this->findNextHop(face);
   if (it == m_nextHops.end()) {
-    m_nextHops.emplace_back(face, endpointId);
+    m_nextHops.emplace_back(face);
     it = std::prev(m_nextHops.end());
   }
+
   it->setCost(cost);
   this->sortNextHops();
 }
 
 void
-Entry::removeNextHop(const Face& face, EndpointId endpointId)
+Entry::removeNextHop(const Face& face)
 {
-  auto it = this->findNextHop(face, endpointId);
+  auto it = this->findNextHop(face);
   if (it != m_nextHops.end()) {
     m_nextHops.erase(it);
   }
 }
 
 void
-Entry::removeNextHopByFace(const Face& face)
-{
-  auto it = std::remove_if(m_nextHops.begin(), m_nextHops.end(),
-                           [&face] (const NextHop& nexthop) {
-                             return &nexthop.getFace() == &face;
-                           });
-  m_nextHops.erase(it, m_nextHops.end());
-}
-
-void
 Entry::sortNextHops()
 {
   std::sort(m_nextHops.begin(), m_nextHops.end(),
diff --git a/daemon/table/fib-entry.hpp b/daemon/table/fib-entry.hpp
index e0edcc0..52dfbd8 100644
--- a/daemon/table/fib-entry.hpp
+++ b/daemon/table/fib-entry.hpp
@@ -74,36 +74,32 @@
     return !m_nextHops.empty();
   }
 
-  /** \return whether there is a NextHop record for \p face with the given \p endpointId
+  /** \return whether there is a NextHop record for \p face
    */
   bool
-  hasNextHop(const Face& face, EndpointId endpointId) const;
+  hasNextHop(const Face& face) const;
 
   /** \brief adds a NextHop record
    *
-   *  If a NextHop record for \p face and \p endpointId already exists,
-   *  its cost is updated.
+   *  If a NextHop record for \p face already exists, its cost is updated.
    */
   void
-  addOrUpdateNextHop(Face& face, EndpointId endpointId, uint64_t cost);
+  addOrUpdateNextHop(Face& face, uint64_t cost);
 
-  /** \brief removes the NextHop record for \p face with the given \p endpointId
+  /** \brief removes a NextHop record
+   *
+   *  If no NextHop record for face exists, do nothing.
    */
   void
-  removeNextHop(const Face& face, EndpointId endpointId);
-
-  /** \brief removes all NextHop records on \p face for any \p endpointId
-   */
-  void
-  removeNextHopByFace(const Face& face);
+  removeNextHop(const Face& face);
 
 private:
   /** \note This method is non-const because mutable iterators are needed by callers.
    */
   NextHopList::iterator
-  findNextHop(const Face& face, EndpointId endpointId);
+  findNextHop(const Face& face);
 
-  /** \brief sorts the nexthop list by cost
+  /** \brief sorts the nexthop list
    */
   void
   sortNextHops();
diff --git a/daemon/table/fib-nexthop.hpp b/daemon/table/fib-nexthop.hpp
index 80609ba..e03efda 100644
--- a/daemon/table/fib-nexthop.hpp
+++ b/daemon/table/fib-nexthop.hpp
@@ -37,9 +37,9 @@
 class NextHop
 {
 public:
-  NextHop(Face& face, EndpointId endpointId)
+  explicit
+  NextHop(Face& face)
     : m_face(&face)
-    , m_endpointId(endpointId)
   {
   }
 
@@ -49,12 +49,6 @@
     return *m_face;
   }
 
-  EndpointId
-  getEndpointId() const
-  {
-    return m_endpointId;
-  }
-
   uint64_t
   getCost() const
   {
@@ -69,7 +63,6 @@
 
 private:
   Face* m_face; // pointer instead of reference so that NextHop is movable
-  EndpointId m_endpointId;
   uint64_t m_cost = 0;
 };
 
diff --git a/daemon/table/fib.cpp b/daemon/table/fib.cpp
index 2f3deab..62938e0 100644
--- a/daemon/table/fib.cpp
+++ b/daemon/table/fib.cpp
@@ -133,28 +133,16 @@
 }
 
 void
-Fib::eraseIfEmpty(Entry& entry)
+Fib::removeNextHop(Entry& entry, const Face& face)
 {
+  entry.removeNextHop(face);
+
   if (!entry.hasNextHops()) {
     name_tree::Entry* nte = m_nameTree.getEntry(entry);
     this->erase(nte, false);
   }
 }
 
-void
-Fib::removeNextHop(Entry& entry, const Face& face, EndpointId endpointId)
-{
-  entry.removeNextHop(face, endpointId);
-  this->eraseIfEmpty(entry);
-}
-
-void
-Fib::removeNextHopByFace(Entry& entry, const Face& face)
-{
-  entry.removeNextHopByFace(face);
-  this->eraseIfEmpty(entry);
-}
-
 Fib::Range
 Fib::getRange() const
 {
diff --git a/daemon/table/fib.hpp b/daemon/table/fib.hpp
index 462a29b..8543440 100644
--- a/daemon/table/fib.hpp
+++ b/daemon/table/fib.hpp
@@ -103,15 +103,10 @@
   void
   erase(const Entry& entry);
 
-  /** \brief Remove the NextHop record for the given \p face and \p endpointId
+  /** \brief Remove the NextHop record for \p face
    */
   void
-  removeNextHop(Entry& entry, const Face& face, EndpointId endpointId);
-
-  /** \brief Remove all NextHop records for \p face
-   */
-  void
-  removeNextHopByFace(Entry& entry, const Face& face);
+  removeNextHop(Entry& entry, const Face& face);
 
 public: // enumeration
   typedef boost::transformed_range<name_tree::GetTableEntry<Entry>, const name_tree::Range> Range;
@@ -147,11 +142,6 @@
   void
   erase(name_tree::Entry* nte, bool canDeleteNte = true);
 
-  /** \brief Erase \p entry if it contains no nexthop records
-   */
-  void
-  eraseIfEmpty(Entry& entry);
-
   Range
   getRange() const;