route: fix nonexistent router condition in link-state calculator
Previously, if a non-existent source router is passed to the link-state
routing calculator, LinkStateRoutingTableCalculator::calculatePath could
dereference an empty optional. This commit corrects this condition.
Cleanup the test suite.
Add a test case for MaxFacesPerPrefix=1, which has a different code path
in the link-state calculator.
refs #5308
Change-Id: Ieab5a0388d9290095b1eb7924f4d3c693b67d098
diff --git a/src/route/routing-calculator-link-state.cpp b/src/route/routing-calculator-link-state.cpp
index 7d113ee..84ee0bc 100644
--- a/src/route/routing-calculator-link-state.cpp
+++ b/src/route/routing-calculator-link-state.cpp
@@ -401,8 +401,11 @@
auto sourceRouter = pMap.getMappingNoByRouterName(confParam.getRouterPrefix());
allocateParent(); // These two matrices are used in Dijkstra's algorithm.
allocateDistance(); //
- // We only bother to do the calculation if we have a router by that name.
- if (sourceRouter && confParam.getMaxFacesPerPrefix() == 1) {
+
+ if (!sourceRouter) {
+ // We cannot do the calculation if we don't have a router by that name.
+ }
+ else if (confParam.getMaxFacesPerPrefix() == 1) {
// In the single path case we can simply run Dijkstra's algorithm.
doDijkstraPathCalculation(*sourceRouter);
// Inform the routing table of the new next hops.