Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About the problems encountered when using nlsrc withdraw <name> #13

Open
Morningstar678 opened this issue Dec 21, 2021 · 1 comment
Open

Comments

@Morningstar678
Copy link

Morningstar678 commented Dec 21, 2021

Problem Description:On a simple NFD-connected topology, after a prefix is withdrawn using nlsrc withdraw , all routing information for that prefix on adjacent NFDs is removed.
Cause of the problem: NLSR calculates routing information according to LSDB, forms FIB table, specifically: prefix+NextHops (faceID, cost), and registers routing information to NFD through Interest-Data, where the formal parameters of register() method are prefix, faceURI, Cost, and The formal parameters of the unregister() method are prefix, faceURI, and Cost, and the formal parameters of the unregister() method are prefix, faceURI, so it can be assumed that when NLSR registers the route with NFD, it registers all the route information under a certain prefix.
Solution: Modify void Fib::update(const ndn::Name& name, const NexthopList& allHops) in the fib.cpp file in the NLSR-0.4.3\src\route directory(In fact every version of NLSR has this problem, version 0.4.3 has been tested)The code is modified as follows:

`void Fib::update(const ndn::Name& name, const NexthopList& allHops)
{
NLSR_LOG_DEBUG("Fib::update called");

// Get the max possible faces which is the minumum of the configuration setting and
// the length of the list of all next hops.
unsigned int maxFaces = getNumberOfFacesForName(allHops);

NexthopList hopsToAdd;
unsigned int nFaces = 0;

// Create a list of next hops to be installed with length == maxFaces
for (NexthopList::iterator it = allHops.cbegin(); it != allHops.cend() && nFaces < maxFaces;
++it, ++nFaces) {
hopsToAdd.addNextHop(*it);
}

std::map<ndn::Name, FibEntry>::iterator entryIt = m_table.find(name);

// New FIB entry that has nextHops
if (entryIt == m_table.end() && hopsToAdd.size() != 0) {
NLSR_LOG_DEBUG("New FIB Entry");

FibEntry entry(name);

addNextHopsToFibEntryAndNfd(entry, hopsToAdd);

m_table.emplace(name, entry);

entryIt = m_table.find(name);

}
// Existing FIB entry that may or may not have nextHops
else {
// Existing FIB entry
NLSR_LOG_DEBUG("Existing FIB Entry");

// Remove empty FIB entry
if (hopsToAdd.size() == 0) {
  remove(name);
  return;
}

FibEntry& entry = (entryIt->second);//

//**addNextHopsToFibEntryAndNfd(entry, hopsToAdd);**//Adjust the position of the row

std::set<NextHop, NextHopComparator> hopsToRemove;
std::set_difference(entry.getNexthopList().begin(), entry.getNexthopList().end(),
                    hopsToAdd.begin(), hopsToAdd.end(),
                    std::inserter(hopsToRemove, hopsToRemove.end()), NextHopComparator());

bool isUpdatable = isPrefixUpdatable(entry.getName());
// Remove the uninstalled next hops from NFD and FIB entry
for (const auto& hop: hopsToRemove){
  if (isUpdatable) {
    unregisterPrefix(entry.getName(), hop.getConnectingFaceUri());
  }
  NLSR_LOG_DEBUG("Removing " << hop.getConnectingFaceUri() << " from " << entry.getName());
  entry.getNexthopList().removeNextHop(hop);
}
  addNextHopsToFibEntryAndNfd(entry, hopsToAdd);         //  Adjust here
// Increment sequence number
entry.setSeqNo(entry.getSeqNo() + 1);

entryIt = m_table.find(name);

}
if (entryIt != m_table.end() && !entryIt->second.getRefreshEventId()) {
scheduleEntryRefresh(entryIt->second,
[this] (FibEntry& entry) {
scheduleLoop(entry);
});
}
}

@agawande
Copy link
Contributor

Does this happen with the latest commit from github?
I had fixed a similar bug earlier which is not part of any release yet I think:
https://redmine.named-data.net/issues/5179
6f0f35d
https://github.com/named-data/NLSR/blob/master/tests/route/test-fib.cpp#L361

Can you please write a unit test against the latest commit from github documenting the problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants