rib: Disable FaceId check for self-registrations

Change-Id: I9e022d3067c5c4ecb3ec0a10a4446e9af49c68eb
Refs: #1852
diff --git a/rib/rib-manager.cpp b/rib/rib-manager.cpp
index d4be75d..80a3fa2 100644
--- a/rib/rib-manager.cpp
+++ b/rib/rib-manager.cpp
@@ -253,13 +253,15 @@
       return;
     }
 
-  if (!parameters.hasFaceId() || parameters.getFaceId() == 0)
+  bool isSelfRegistration = (!parameters.hasFaceId() || parameters.getFaceId() == 0);
+  if (isSelfRegistration)
     {
       parameters.setFaceId(request->getIncomingFaceId());
     }
 
   // Is the face valid?
-  if (activeFaces.find(parameters.getFaceId()) == activeFaces.end())
+  // Issue 1852: There is no need to check (and it can easily fail) for self-registrations
+  if (!isSelfRegistration && activeFaces.find(parameters.getFaceId()) == activeFaces.end())
     {
       NFD_LOG_DEBUG("register result: FAIL reason: unknown faceId");
 
@@ -327,13 +329,15 @@
       return;
     }
 
-  if (!parameters.hasFaceId() || parameters.getFaceId() == 0)
+  bool isSelfRegistration = (!parameters.hasFaceId() || parameters.getFaceId() == 0);
+  if (isSelfRegistration)
     {
       parameters.setFaceId(request->getIncomingFaceId());
     }
 
   // Is the face valid?
-  if (activeFaces.find(parameters.getFaceId()) == activeFaces.end())
+  // Issue 1852: There is no need to check (and it can easily fail) for self-registrations
+  if (!isSelfRegistration && activeFaces.find(parameters.getFaceId()) == activeFaces.end())
     {
       NFD_LOG_DEBUG("register result: FAIL reason: unknown faceId");