src: onFaceEventNotification only proceed if face id was zero or updated

refs: #5010

Change-Id: Ie5b1f8a5ca2a372890a9ef2a28dc00e1a7c0a366
diff --git a/src/adjacent.cpp b/src/adjacent.cpp
index 4afe6d7..af1f926 100644
--- a/src/adjacent.cpp
+++ b/src/adjacent.cpp
@@ -53,7 +53,7 @@
   {
   }
 
-Adjacent::Adjacent(const ndn::Name& an, const ndn::FaceUri& faceUri,  double lc,
+Adjacent::Adjacent(const ndn::Name& an, const ndn::FaceUri& faceUri, double lc,
                    Status s, uint32_t iton, uint64_t faceId)
     : m_name(an)
     , m_faceUri(faceUri)
diff --git a/src/hello-protocol.hpp b/src/hello-protocol.hpp
index 94330e2..ff87a3b 100644
--- a/src/hello-protocol.hpp
+++ b/src/hello-protocol.hpp
@@ -167,12 +167,6 @@
   onRegistrationSuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
                         const ndn::Name& neighbor, const ndn::time::milliseconds& timeout);
 
-  /*! \brief Create a Face for an adjacency
-   * \sa HelloProtocol::onRegistrationSuccess
-   */
-  void
-  registerPrefixes(const ndn::Name& adjName, const std::string& faceUri,
-                   double linkCost, const ndn::time::milliseconds& timeout);
 private:
   ndn::Face& m_face;
   ndn::Scheduler m_scheduler;
diff --git a/src/nlsr.cpp b/src/nlsr.cpp
index a6da9a0..9a62a24 100644
--- a/src/nlsr.cpp
+++ b/src/nlsr.cpp
@@ -483,14 +483,16 @@
         return;
       }
       auto adjacent = m_adjacencyList.findAdjacent(faceUri);
+      uint64_t faceId = faceEventNotification.getFaceId();
 
-      // If we have a neighbor by that FaceUri and it has no FaceId, we
-      // have a match.
-      if (adjacent != m_adjacencyList.end()) {
+      // If we have a neighbor by that FaceUri and it has no FaceId or
+      // the FaceId is different from ours, we have a match.
+      if (adjacent != m_adjacencyList.end() &&
+          (adjacent->getFaceId() == 0 || adjacent->getFaceId() != faceId))
+      {
         NLSR_LOG_DEBUG("Face creation event matches neighbor: " << adjacent->getName()
-                   << ". New Face ID: " << faceEventNotification.getFaceId()
-                   << ". Registering prefixes.");
-        adjacent->setFaceId(faceEventNotification.getFaceId());
+                        << ". New Face ID: " << faceId << ". Registering prefixes.");
+        adjacent->setFaceId(faceId);
 
         registerAdjacencyPrefixes(*adjacent, ndn::time::milliseconds::max());
 
diff --git a/src/route/fib.cpp b/src/route/fib.cpp
index 7d08e12..9ee14c7 100644
--- a/src/route/fib.cpp
+++ b/src/route/fib.cpp
@@ -199,8 +199,7 @@
 
 void
 Fib::registerPrefix(const ndn::Name& namePrefix, const ndn::FaceUri& faceUri,
-                    uint64_t faceCost,
-                    const ndn::time::milliseconds& timeout,
+                    uint64_t faceCost, const ndn::time::milliseconds& timeout,
                     uint64_t flags, uint8_t times)
 {
   uint64_t faceId = m_adjacencyList.getFaceId(ndn::FaceUri(faceUri));