**breaking change** nlsr.conf: rename seq-dir as state-dir
update: conf file in seperate directory for runtime modification refs: #4823 Change-Id: I5378d831294814e382ad23a9e522d0b576180f20
This commit is contained in:
1 parent
85998a1dc9
commit
82a34c2cd8
12 files changed
+61
-35
No files matched your search
@@ -95,7 +95,7 @@ configuration commands follows:
|
||||
; InterestLifetime (in seconds) for LSA fetching
|
||||
lsa-interest-lifetime 4 ; default value 4. Valid values 1-60
|
||||
|
||||
seq-dir /var/lib/nlsr/
|
||||
state-dir /var/lib/nlsr/ ; state directory to store all dynamic changes to NLSR
|
||||
}
|
||||
|
||||
; the neighbors section contains the configuration for router's neighbors and hello's behavior
|
||||
@@ -209,7 +209,7 @@ To avoid this, the directory can be set in a user-owned directory. For example:
|
||||
{
|
||||
...
|
||||
|
||||
seq-dir /home/username/nlsr/log ; path for sequence directory (Absolute path)
|
||||
state-dir /home/username/nlsr/log ; path for sequence directory and other dynamic changes (Absolute path)
|
||||
|
||||
}
|
||||
...
|
||||
|
||||
@@ -46,7 +46,7 @@ Options
|
||||
``advertise <name> save``
|
||||
|
||||
``save``
|
||||
Advertise a prefix and also save it to the nlsr.conf file for the next start of NLSR
|
||||
Advertise a prefix and also save it to the nlsr.conf file residing in the state-dir for the next start of NLSR that operator may copy and use for the next start of NLSR
|
||||
|
||||
``withdraw``
|
||||
Remove a Name prefix advertised through NLSR
|
||||
@@ -59,7 +59,7 @@ Options
|
||||
``withdraw <name> delete``
|
||||
|
||||
``delete``
|
||||
Withdraw a prefix and also delete it from the nlsr.conf file
|
||||
Withdraw a prefix and also delete it from the nlsr.conf file residing in the state-dir
|
||||
|
||||
Notes
|
||||
-----
|
||||
|
||||
@@ -25,7 +25,7 @@ general
|
||||
; sync interest lifetime of ChronoSync/PSync in milliseconds
|
||||
sync-interest-lifetime 60000 ; default value 60000. Valid values 1000-120,000
|
||||
|
||||
seq-dir /var/lib/nlsr ; path for sequence directory (Absolute path)
|
||||
state-dir /var/lib/nlsr ; path for intermediate state files including sequence directory (Absolute path)
|
||||
}
|
||||
|
||||
; the neighbor's section contains the configuration for router's neighbors and hellos behavior
|
||||
|
||||
+21
-12
@@ -322,17 +322,26 @@ ConfFileProcessor::processConfSectionGeneral(const ConfigSection& section)
|
||||
}
|
||||
|
||||
try {
|
||||
std::string seqDir = section.get<std::string>("seq-dir");
|
||||
if (boost::filesystem::exists(seqDir)) {
|
||||
if (boost::filesystem::is_directory(seqDir)) {
|
||||
std::string testFileName=seqDir+"/test.seq";
|
||||
std::ofstream testOutFile;
|
||||
testOutFile.open(testFileName.c_str());
|
||||
if (testOutFile.is_open() && testOutFile.good()) {
|
||||
m_confParam.setSeqFileDir(seqDir);
|
||||
std::string stateDir = section.get<std::string>("state-dir");
|
||||
if (boost::filesystem::exists(stateDir)) {
|
||||
if (boost::filesystem::is_directory(stateDir)) {
|
||||
|
||||
// copying nlsr.conf file to a user define directory for possible modification
|
||||
std::string conFileDynamic = (boost::filesystem::path(stateDir) / "nlsr.conf").c_str();
|
||||
m_confParam.setConfFileNameDynamic(conFileDynamic);
|
||||
try {
|
||||
copy_file(m_confFileName, conFileDynamic, boost::filesystem::copy_option::overwrite_if_exists);
|
||||
}
|
||||
catch (const boost::filesystem::filesystem_error& e) {
|
||||
std::cerr << "Error copying conf file to the state directory: " << e.what() << std::endl;
|
||||
}
|
||||
std::string testFileName = (boost::filesystem::path(stateDir) / "test.seq").c_str();
|
||||
std::ofstream testOutFile(testFileName);
|
||||
if (testOutFile) {
|
||||
m_confParam.setStateFileDir(stateDir);
|
||||
}
|
||||
else {
|
||||
std::cerr << "User does not have read and write permission on the directory";
|
||||
std::cerr << "User does not have read and write permission on the state directory";
|
||||
std::cerr << std::endl;
|
||||
return false;
|
||||
}
|
||||
@@ -340,17 +349,17 @@ ConfFileProcessor::processConfSectionGeneral(const ConfigSection& section)
|
||||
remove(testFileName.c_str());
|
||||
}
|
||||
else {
|
||||
std::cerr << "Provided path is not a directory" << std::endl;
|
||||
std::cerr << "Provided: " << stateDir << "is not a directory" << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
std::cerr << "Provided sequence directory <" << seqDir << "> does not exist" << std::endl;
|
||||
std::cerr << "Provided state directory <" << stateDir << "> does not exist" << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (const std::exception& ex) {
|
||||
std::cerr << "You must configure sequence directory" << std::endl;
|
||||
std::cerr << "You must configure state directory" << std::endl;
|
||||
std::cerr << ex.what() << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ ConfParameter::writeLog()
|
||||
for (auto const& value: m_corTheta) {
|
||||
NLSR_LOG_INFO("Hyp Angle " << i++ << ": "<< value);
|
||||
}
|
||||
NLSR_LOG_INFO("Seq Directory: " << m_seqFileDir);
|
||||
NLSR_LOG_INFO("State Directory: " << m_stateFileDir);
|
||||
|
||||
// Event Intervals
|
||||
NLSR_LOG_INFO("Adjacency LSA build interval: " << m_adjLsaBuildInterval);
|
||||
|
||||
+19
-5
@@ -404,15 +404,26 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
setSeqFileDir(const std::string& ssfd)
|
||||
setStateFileDir(const std::string& ssfd)
|
||||
{
|
||||
m_seqFileDir = ssfd;
|
||||
m_stateFileDir = ssfd;
|
||||
}
|
||||
|
||||
const std::string&
|
||||
getSeqFileDir() const
|
||||
getStateFileDir() const
|
||||
{
|
||||
return m_seqFileDir;
|
||||
return m_stateFileDir;
|
||||
}
|
||||
|
||||
void setConfFileNameDynamic(const std::string& confFileDynamic)
|
||||
{
|
||||
m_confFileNameDynamic = confFileDynamic;
|
||||
}
|
||||
|
||||
const std::string&
|
||||
getConfFileNameDynamic() const
|
||||
{
|
||||
return m_confFileNameDynamic;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -497,11 +508,14 @@ private:
|
||||
|
||||
uint32_t m_maxFacesPerPrefix;
|
||||
|
||||
std::string m_seqFileDir;
|
||||
std::string m_stateFileDir;
|
||||
|
||||
ndn::time::milliseconds m_syncInterestLifetime;
|
||||
|
||||
int32_t m_syncProtocol;
|
||||
|
||||
std::string m_confFileNameDynamic;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
static const uint64_t SYNC_VERSION;
|
||||
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ Lsdb::Lsdb(ndn::Face& face, ndn::KeyChain& keyChain,
|
||||
, m_lsaRefreshTime(ndn::time::seconds(m_confParam.getLsaRefreshTime()))
|
||||
, m_thisRouterPrefix(m_confParam.getRouterPrefix().toUri())
|
||||
, m_adjLsaBuildInterval(m_confParam.getAdjLsaBuildInterval())
|
||||
, m_sequencingManager(m_confParam.getSeqFileDir(), m_confParam.getHyperbolicState())
|
||||
, m_sequencingManager(m_confParam.getStateFileDir(), m_confParam.getHyperbolicState())
|
||||
, m_onNewLsaConnection(m_sync.onNewLsa->connect(
|
||||
[this] (const ndn::Name& updateName, uint64_t sequenceNumber) {
|
||||
ndn::Name lsaInterest{updateName};
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ Nlsr::Nlsr(ndn::Face& face, ndn::KeyChain& keyChain, ConfParameter& confParam)
|
||||
m_confParam.getPrefixUpdateValidator(),
|
||||
m_namePrefixList,
|
||||
m_lsdb,
|
||||
m_confParam.getConfFileName())
|
||||
m_confParam.getConfFileNameDynamic())
|
||||
, m_nfdRibCommandProcessor(m_dispatcher,
|
||||
m_namePrefixList,
|
||||
m_lsdb)
|
||||
|
||||
@@ -56,7 +56,7 @@ PrefixUpdateProcessor::PrefixUpdateProcessor(ndn::mgmt::Dispatcher& dispatcher,
|
||||
Lsdb& lsdb, const std::string& configFileName)
|
||||
: CommandManagerBase(dispatcher, namePrefixList, lsdb, "prefix-update")
|
||||
, m_validator(validator)
|
||||
, m_configFileName(configFileName)
|
||||
, m_confFileNameDynamic(configFileName)
|
||||
{
|
||||
NLSR_LOG_DEBUG("Setting dispatcher to capture Interests for: "
|
||||
<< ndn::Name(Nlsr::LOCALHOST_PREFIX).append("prefix-update"));
|
||||
@@ -108,7 +108,7 @@ bool
|
||||
PrefixUpdateProcessor::checkForPrefixInFile(const std::string prefix)
|
||||
{
|
||||
std::string line;
|
||||
std::fstream fp(m_configFileName);
|
||||
std::fstream fp(m_confFileNameDynamic);
|
||||
if (!fp.good() || !fp.is_open()) {
|
||||
NLSR_LOG_ERROR("Failed to open configuration file for parsing");
|
||||
return true;
|
||||
@@ -130,7 +130,7 @@ PrefixUpdateProcessor::addOrDeletePrefix(const ndn::Name& prefix, bool addPrefix
|
||||
std::string fileString;
|
||||
std::string line;
|
||||
std::string trimedLine;
|
||||
std::fstream input(m_configFileName, input.in);
|
||||
std::fstream input(m_confFileNameDynamic, input.in);
|
||||
if (!input.good() || !input.is_open()) {
|
||||
NLSR_LOG_ERROR("Failed to open configuration file for parsing");
|
||||
return false;
|
||||
@@ -171,7 +171,7 @@ PrefixUpdateProcessor::addOrDeletePrefix(const ndn::Name& prefix, bool addPrefix
|
||||
}
|
||||
}
|
||||
input.close();
|
||||
std::ofstream output(m_configFileName);
|
||||
std::ofstream output(m_confFileNameDynamic);
|
||||
output << fileString;
|
||||
output.close();
|
||||
return true;
|
||||
|
||||
@@ -96,7 +96,7 @@ private:
|
||||
|
||||
private:
|
||||
ndn::security::ValidatorConfig& m_validator;
|
||||
const std::string& m_configFileName;
|
||||
const std::string& m_confFileNameDynamic;
|
||||
};
|
||||
|
||||
} // namespace update
|
||||
|
||||
@@ -45,7 +45,7 @@ const std::string SECTION_GENERAL =
|
||||
" router-dead-interval 86400\n"
|
||||
" sync-protocol psync\n"
|
||||
" sync-interest-lifetime 10000\n"
|
||||
" seq-dir /tmp\n"
|
||||
" state-dir /tmp\n"
|
||||
"}\n\n";
|
||||
|
||||
const std::string SECTION_NEIGHBORS =
|
||||
@@ -176,7 +176,7 @@ BOOST_AUTO_TEST_CASE(LinkState)
|
||||
BOOST_CHECK_EQUAL(conf.getLsaInterestLifetime(), ndn::time::seconds(3));
|
||||
BOOST_CHECK_EQUAL(conf.getRouterDeadInterval(), 86400);
|
||||
BOOST_CHECK_EQUAL(conf.getSyncInterestLifetime(), ndn::time::milliseconds(10000));
|
||||
BOOST_CHECK_EQUAL(conf.getSeqFileDir(), "/tmp");
|
||||
BOOST_CHECK_EQUAL(conf.getStateFileDir(), "/tmp");
|
||||
|
||||
// Neighbors
|
||||
BOOST_CHECK_EQUAL(conf.getInterestRetryNumber(), 3);
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "../control-commands.hpp"
|
||||
#include "../test-common.hpp"
|
||||
#include "conf-parameter.hpp"
|
||||
|
||||
#include <ndn-cxx/mgmt/nfd/control-response.hpp>
|
||||
#include <ndn-cxx/security/command-interest-signer.hpp>
|
||||
@@ -58,6 +59,7 @@ public:
|
||||
source.close();
|
||||
destination.close();
|
||||
|
||||
conf.setConfFileNameDynamic(testConfFile);
|
||||
siteIdentity = addIdentity(siteIdentityName);
|
||||
saveCertificate(siteIdentity, SITE_CERT_PATH.string());
|
||||
|
||||
@@ -80,6 +82,7 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inputFile.close();
|
||||
|
||||
// Site cert
|
||||
@@ -172,7 +175,7 @@ BOOST_FIXTURE_TEST_SUITE(TestAdvertiseWithdrawPrefix, PrefixSaveDeleteFixture)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Basic)
|
||||
{
|
||||
// only advertise
|
||||
|
||||
face.receive(advertiseWithdraw("/prefix/to/save", "advertise", false));
|
||||
this->advanceClocks(ndn::time::milliseconds(10));
|
||||
BOOST_CHECK_EQUAL(checkPrefix("/prefix/to/save"), false);
|
||||
@@ -208,7 +211,7 @@ BOOST_AUTO_TEST_CASE(PrefixStillSavedAfterJustWithdrawn)
|
||||
BOOST_CHECK_EQUAL(checkPrefix("/prefix/to/save"), true);
|
||||
|
||||
// trying to advertise same name prefix
|
||||
/*face.receive(advertiseWithdraw("/prefix/to/save", "advertise", true));
|
||||
face.receive(advertiseWithdraw("/prefix/to/save", "advertise", true));
|
||||
this->advanceClocks(ndn::time::milliseconds(10));
|
||||
BOOST_REQUIRE(counter == 1);
|
||||
BOOST_CHECK_EQUAL(getResponseCode(), 406);
|
||||
@@ -226,7 +229,7 @@ BOOST_AUTO_TEST_CASE(PrefixStillSavedAfterJustWithdrawn)
|
||||
this->advanceClocks(ndn::time::milliseconds(10));
|
||||
// after withdrawn delete prefix should be deleted from the file
|
||||
BOOST_CHECK_EQUAL(getResponseCode(), 205);
|
||||
BOOST_CHECK_EQUAL(checkPrefix("/prefix/to/save"), false);*/
|
||||
BOOST_CHECK_EQUAL(checkPrefix("/prefix/to/save"), false);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
Reference in new issue
Block a user