rib: remote prefix registration
resolve 3 bugs:
There are redundant registrations/unregistrations if loading the
config file multiple times.
Remote registration/unregistration will fail if localhop_security
is enabled.
Unstable RemoteRegistrator/UnregisterAdvanced test case.
Change-Id: I4437292e9f6c0e340c761ef7556a9bdc703ac06c
refs: #2294
diff --git a/rib/rib-manager.cpp b/rib/rib-manager.cpp
index 491739a..7d0f5b3 100644
--- a/rib/rib-manager.cpp
+++ b/rib/rib-manager.cpp
@@ -144,6 +144,8 @@
bool isDryRun,
const std::string& filename)
{
+ bool isRemoteRegisterEnabled = false;
+
for (ConfigSection::const_iterator i = configSection.begin();
i != configSection.end(); ++i)
{
@@ -157,21 +159,23 @@
else if (i->first == "remote_register")
{
m_remoteRegistrator.loadConfig(i->second);
+ isRemoteRegisterEnabled = true;
+ // avoid other actions when isDryRun == true
+ if (isDryRun)
+ {
+ continue;
+ }
- // register callback to the RIB.
- // do remote registration after an entry is inserted into the RIB.
- // do remote unregistration after an entry is erased from the RIB.
- m_managedRib.afterInsertEntry += [this] (const Name& prefix) {
- m_remoteRegistrator.registerPrefix(prefix);
- };
-
- m_managedRib.afterEraseEntry += [this] (const Name& prefix) {
- m_remoteRegistrator.unregisterPrefix(prefix);
- };
+ m_remoteRegistrator.enable();
}
else
throw Error("Unrecognized rib property: " + i->first);
}
+
+ if (!isRemoteRegisterEnabled)
+ {
+ m_remoteRegistrator.disable();
+ }
}
void
@@ -200,16 +204,7 @@
RibManager::onLocalhostRequest(const Interest& request)
{
const Name& command = request.getName();
-
- if (command.size() <= COMMAND_PREFIX.size())
- {
- // command is too short to have a verb
- NFD_LOG_DEBUG("command result: malformed");
- sendResponse(command, 400, "Malformed command");
- return;
- }
-
- const Name::Component& verb = command.at(COMMAND_PREFIX.size());
+ const Name::Component& verb = command.get(COMMAND_PREFIX.size());
UnsignedVerbDispatchTable::const_iterator unsignedVerbProcessor = m_unsignedVerbDispatch.find(verb);