diff --git a/openr/config/Config.h b/openr/config/Config.h index 62f86dba1f9..b9d9c93bb65 100644 --- a/openr/config/Config.h +++ b/openr/config/Config.h @@ -111,11 +111,6 @@ class Config { return config_.enable_v4().value_or(false); } - bool - isSegmentRoutingEnabled() const { - return config_.enable_segment_routing().value_or(false); - } - bool isNetlinkFibHandlerEnabled() const { return config_.enable_netlink_fib_handler().value_or(false); diff --git a/openr/config/tests/ConfigTest.cpp b/openr/config/tests/ConfigTest.cpp index ec6be5c6b02..a75ddc2a155 100644 --- a/openr/config/tests/ConfigTest.cpp +++ b/openr/config/tests/ConfigTest.cpp @@ -461,8 +461,6 @@ TEST(ConfigTest, GeneralGetter) { // enable_v4 EXPECT_TRUE(config.isV4Enabled()); - // enable_segment_routing - EXPECT_FALSE(config.isSegmentRoutingEnabled()); // enable_best_route_selection EXPECT_FALSE(config.isBestRouteSelectionEnabled()); // enable_v4_over_v6_nexthop diff --git a/openr/decision/SpfSolver.cpp b/openr/decision/SpfSolver.cpp index b7e2d31c1fc..41336e888ee 100644 --- a/openr/decision/SpfSolver.cpp +++ b/openr/decision/SpfSolver.cpp @@ -37,21 +37,6 @@ DecisionRouteDb::calculateUpdate(DecisionRouteDb&& newDb) const { delta.unicastRoutesToDelete.emplace_back(prefix); } } - - // mplsRoutesToUpdate - for (auto& [label, entry] : newDb.mplsRoutes) { - const auto& search = mplsRoutes.find(label); - if (search == mplsRoutes.end() || search->second != entry) { - delta.addMplsRouteToUpdate(std::move(entry)); - } - } - - // mplsRoutesToDelete - for (auto const& [label, _] : mplsRoutes) { - if (!newDb.mplsRoutes.count(label)) { - delta.mplsRoutesToDelete.emplace_back(label); - } - } return delta; } @@ -63,12 +48,6 @@ DecisionRouteDb::update(DecisionRouteUpdate const& update) { for (auto const& [_, entry] : update.unicastRoutesToUpdate) { unicastRoutes.insert_or_assign(entry.prefix, entry); } - for (auto const& label : update.mplsRoutesToDelete) { - mplsRoutes.erase(label); - } - for (auto const& [_, entry] : update.mplsRoutesToUpdate) { - mplsRoutes.insert_or_assign(entry.label, entry); - } } SpfSolver::SpfSolver( @@ -479,7 +458,6 @@ SpfSolver::selectBestPathsSpf( routeSelectionResult.allNodeAreas, prefix.first.isV4(), /* isV4Prefix */ nextHopsWithMetric, - std::nullopt /* swapLabel */, area, linkState); @@ -587,7 +565,6 @@ SpfSolver::getNextHopsThrift( const std::set& dstNodeAreas, bool isV4, const BestNextHopMetrics& bestNextHopMetrics, - std::optional swapLabel, const std::string& area, const LinkState& linkState) const { // Use reference to avoid copy @@ -636,23 +613,12 @@ SpfSolver::getNextHopsThrift( continue; } - // Create associated mpls action if swapLabel is provided - std::optional mplsAction; - if (swapLabel.has_value()) { - CHECK(not mplsAction.has_value()); - bool isNextHopAlsoDst = dstNodeAreas.count({neighborNode, area}); - mplsAction = createMplsAction( - isNextHopAlsoDst ? thrift::MplsActionCode::PHP - : thrift::MplsActionCode::SWAP, - isNextHopAlsoDst ? std::nullopt : swapLabel); - } - nextHops.emplace(createNextHop( isV4 and not v4OverV6Nexthop_ ? link->getNhV4FromNode(myNodeName) : link->getNhV6FromNode(myNodeName), link->getIfaceFromNode(myNodeName), distOverLink, - mplsAction, + std::nullopt, /* mplsAction */ link->getArea(), link->getOtherNodeName(myNodeName), 0 /* ucmp weight */)); diff --git a/openr/decision/SpfSolver.h b/openr/decision/SpfSolver.h index 45205cae7a5..1d6793f77ab 100644 --- a/openr/decision/SpfSolver.h +++ b/openr/decision/SpfSolver.h @@ -19,7 +19,6 @@ namespace openr { -using StaticMplsRoutes = std::unordered_map; using StaticUnicastRoutes = std::unordered_map; using Metric = openr::LinkStateMetric; @@ -35,13 +34,20 @@ using BestNextHopMetrics = std::pair< * - All selected entries `list>` */ struct RouteSelectionResult { - // Representing the selected set of ``. - // NOTE: Using `std::set` helps ensuring uniqueness and ease code for electing - // unique `` in some-cases. + /* + * Representing the selected set of ``. + * + * NOTE: + * It is intentional to use `std::set` to preserve the order of node + area + * combination. This ensures the uniqueness and ease code for electing + * the unique `` when tie-breaking is needed. + */ std::set allNodeAreas; - // The `pair` with best metrics. This should be used for - // redistribution across areas. + /* + * The `pair` with best metrics. + * This will be used for redistribution across areas. + */ NodeAndArea bestNodeArea; /* @@ -69,11 +75,13 @@ class DecisionRouteDb { public: std::unordered_map unicastRoutes; - std::unordered_map mplsRoutes; - // calculate the delta between this and newDb. Note, this method is const; - // We are not actually updating here. We may mutate the DecisionRouteUpdate in - // some way before calling update with it + /* + * Function to calculate the delta between this and newDb. + * + * NOTE: this method is const. We are not actually updating here. + * We may mutate the `DecisionRouteUpdate` in some way before calling update. + */ DecisionRouteUpdate calculateUpdate(DecisionRouteDb&& newDb) const; // update the state of this with the DecisionRouteUpdate passed @@ -86,10 +94,6 @@ class DecisionRouteDb { for (const auto& [_, entry] : unicastRoutes) { tRouteDb.unicastRoutes()->emplace_back(entry.toThrift()); } - // mpls routes - for (const auto& [_, entry] : mplsRoutes) { - tRouteDb.mplsRoutes()->emplace_back(entry.toThrift()); - } return tRouteDb; } @@ -99,13 +103,6 @@ class DecisionRouteDb { auto key = entry.prefix; CHECK(unicastRoutes.emplace(key, std::move(entry)).second); } - - // Assertion: no route for this label may already exist in the db - void - addMplsRoute(RibMplsEntry&& entry) { - auto key = entry.label; - CHECK(mplsRoutes.emplace(key, std::move(entry)).second); - } }; // The class to compute shortest-paths using Dijkstra algorithm @@ -123,7 +120,6 @@ class SpfSolver { // // util function to update IP static route // - void updateStaticUnicastRoutes( const std::unordered_map& unicastRoutesToUpdate, @@ -236,22 +232,19 @@ class SpfSolver { const std::set& dstNodeAreas, const LinkState& linkState); - // This function converts best nexthop nodes to best nexthop adjacencies - // which can then be passed to FIB for programming. It considers and - // parallel link logic (tested by our UT) - // If swap label is provided then it will be used to associate SWAP or PHP - // mpls action + /* + * This function converts best nexthop nodes to best nexthop adjacencies + * which can then be passed to FIB for programming. + */ std::unordered_set getNextHopsThrift( const std::string& myNodeName, const std::set& dstNodeAreas, bool isV4, const BestNextHopMetrics& bestNextHopMetrics, - std::optional swapLabel, const std::string& area, const LinkState& linkState) const; - // Collection to store static IP/MPLS routes - StaticMplsRoutes staticMplsRoutes_; + // Collection to store static IP UNICAST routes StaticUnicastRoutes staticUnicastRoutes_; // Cache of best route selection. @@ -265,8 +258,6 @@ class SpfSolver { // nexthops to Fib module for programming. Else it will just drop them. const bool enableV4_{false}; - const bool enableNodeSegmentLabel_{true}; - const bool enableBestRouteSelection_{false}; // is v4 over v6 nexthop enabled. If yes then Decision will forward v4 diff --git a/openr/decision/tests/DecisionTestUtils.cpp b/openr/decision/tests/DecisionTestUtils.cpp index 6b60452e886..ba5f6b4da21 100644 --- a/openr/decision/tests/DecisionTestUtils.cpp +++ b/openr/decision/tests/DecisionTestUtils.cpp @@ -88,14 +88,6 @@ fillRouteMap( routeMap[make_pair(node, prefix)].emplace(nextHop); } } - for (auto const& [_, entry] : routeDb.mplsRoutes) { - auto topLabelStr = std::to_string(entry.label); - for (const auto& nextHop : entry.nexthops) { - VLOG(4) << "node: " << node << " label: " << topLabelStr << " -> " - << toString(nextHop); - routeMap[make_pair(node, topLabelStr)].emplace(nextHop); - } - } } void @@ -112,14 +104,6 @@ fillRouteMap( routeMap[make_pair(node, prefix)].emplace(nextHop); } } - for (auto const& route : *routeDb.mplsRoutes()) { - auto topLabelStr = std::to_string(*route.topLabel()); - for (const auto& nextHop : *route.nextHops()) { - VLOG(4) << "node: " << node << " label: " << topLabelStr << " -> " - << toString(nextHop); - routeMap[make_pair(node, topLabelStr)].emplace(nextHop); - } - } } } // namespace openr diff --git a/openr/decision/tests/SpfSolverTest.cpp b/openr/decision/tests/SpfSolverTest.cpp index 889522078d3..f09422c81aa 100644 --- a/openr/decision/tests/SpfSolverTest.cpp +++ b/openr/decision/tests/SpfSolverTest.cpp @@ -132,7 +132,6 @@ TEST(ShortestPathTest, UnreachableNodes) { auto routeDb = spfSolver.buildRouteDb(node, areaLinkStates, prefixState); ASSERT_TRUE(routeDb.has_value()); EXPECT_EQ(0, routeDb->unicastRoutes.size()); - EXPECT_EQ(0, routeDb->mplsRoutes.size()); // No label routes } } @@ -288,7 +287,6 @@ TEST(ShortestPathTest, MissingNeighborAdjacencyDb) { auto routeDb = spfSolver.buildRouteDb("1", areaLinkStates, prefixState); ASSERT_TRUE(routeDb.has_value()); EXPECT_EQ(0, routeDb->unicastRoutes.size()); - EXPECT_EQ(0, routeDb->mplsRoutes.size()); } // diff --git a/openr/link-monitor/LinkMonitor.cpp b/openr/link-monitor/LinkMonitor.cpp index 48848b93dca..0c0a76e5201 100644 --- a/openr/link-monitor/LinkMonitor.cpp +++ b/openr/link-monitor/LinkMonitor.cpp @@ -116,7 +116,6 @@ LinkMonitor::LinkMonitor( enableLinkStatusMeasurement_( *config->getLinkMonitorConfig().enable_link_status_measurement()), enableV4_(config->isV4Enabled()), - enableSegmentRouting_(config->isSegmentRoutingEnabled()), prefixForwardingType_(*config->getConfig().prefix_forwarding_type()), prefixForwardingAlgorithm_( *config->getConfig().prefix_forwarding_algorithm()), @@ -999,13 +998,6 @@ LinkMonitor::buildAdjacencyDatabase(const std::string& area) { adjDb.area() = area; adjDb.nodeLabel() = 0; - if (enableSegmentRouting_) { - auto it = state_.nodeLabelMap()->find(area); - if (it != state_.nodeLabelMap()->end()) { - adjDb.nodeLabel() = it->second; - } - } - // [Hard-Drain] set node overload bit adjDb.isOverloaded() = *state_.isOverloaded(); diff --git a/openr/link-monitor/LinkMonitor.h b/openr/link-monitor/LinkMonitor.h index 12ba4957448..7772c727206 100644 --- a/openr/link-monitor/LinkMonitor.h +++ b/openr/link-monitor/LinkMonitor.h @@ -328,8 +328,6 @@ class LinkMonitor final : public OpenrEventBase { const bool enableLinkStatusMeasurement_{false}; // enable v4 bool enableV4_{false}; - // [TO_BE_DEPRECATED] enable segment routing - bool enableSegmentRouting_{false}; // [TO_BE_DEPRECATED] prefix forwarding type and algorithm thrift::PrefixForwardingType prefixForwardingType_; thrift::PrefixForwardingAlgorithm prefixForwardingAlgorithm_;