blob: c67d1723c0ca6a43fcd65737bb681a8cb7a2fba7 [file] [log] [blame]
Alexander Afanasyev3ecec502014-04-16 13:42:44 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesaventoa3148082018-04-12 18:21:54 -04002/*
Davide Pesaventoc2442be2025-01-11 17:25:40 -05003 * Copyright (c) 2014-2025, Regents of the University of California,
Alexander Afanasyev7c10b3b2015-01-20 12:24:27 -08004 * Arizona Board of Regents,
5 * Colorado State University,
6 * University Pierre & Marie Curie, Sorbonne University,
7 * Washington University in St. Louis,
8 * Beijing Institute of Technology,
9 * The University of Memphis.
Alexander Afanasyev3ecec502014-04-16 13:42:44 -070010 *
11 * This file is part of NFD (Named Data Networking Forwarding Daemon).
12 * See AUTHORS.md for complete list of NFD authors and contributors.
13 *
14 * NFD is free software: you can redistribute it and/or modify it under the terms
15 * of the GNU General Public License as published by the Free Software Foundation,
16 * either version 3 of the License, or (at your option) any later version.
17 *
18 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20 * PURPOSE. See the GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along with
23 * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
Vince12e49462014-06-09 13:29:32 -050024 */
Alexander Afanasyev3ecec502014-04-16 13:42:44 -070025
26#include "rib.hpp"
Vince Lehman76c751c2014-11-18 17:36:38 -060027#include "fib-updater.hpp"
Davide Pesavento2cae8ca2019-04-18 20:48:05 -040028#include "common/logger.hpp"
Vince Lehman281ded72014-08-21 12:17:08 -050029
Davide Pesaventoe422f9e2022-06-03 01:30:23 -040030namespace nfd::rib {
Alexander Afanasyev3ecec502014-04-16 13:42:44 -070031
Davide Pesaventoa3148082018-04-12 18:21:54 -040032NFD_LOG_INIT(Rib);
33
Vince Lehman4387e782014-06-19 16:57:45 -050034static inline bool
Vince Lehman218be0a2015-01-15 17:25:20 -060035sortRoutes(const Route& lhs, const Route& rhs)
Vince Lehman4387e782014-06-19 16:57:45 -050036{
Vince Lehman218be0a2015-01-15 17:25:20 -060037 return lhs.faceId < rhs.faceId;
Vince Lehman4387e782014-06-19 16:57:45 -050038}
39
Vince Lehman76c751c2014-11-18 17:36:38 -060040void
41Rib::setFibUpdater(FibUpdater* updater)
42{
43 m_fibUpdater = updater;
44}
45
Alexander Afanasyev3ecec502014-04-16 13:42:44 -070046Rib::const_iterator
Vince12e49462014-06-09 13:29:32 -050047Rib::find(const Name& prefix) const
Alexander Afanasyev3ecec502014-04-16 13:42:44 -070048{
Vince12e49462014-06-09 13:29:32 -050049 return m_rib.find(prefix);
50}
51
Vince Lehman218be0a2015-01-15 17:25:20 -060052Route*
53Rib::find(const Name& prefix, const Route& route) const
Vince12e49462014-06-09 13:29:32 -050054{
Davide Pesaventoe4b22382018-06-10 14:37:24 -040055 auto ribIt = m_rib.find(prefix);
Vince12e49462014-06-09 13:29:32 -050056
57 // Name prefix exists
Vince Lehman76c751c2014-11-18 17:36:38 -060058 if (ribIt != m_rib.end()) {
59 shared_ptr<RibEntry> entry = ribIt->second;
Davide Pesaventoe4b22382018-06-10 14:37:24 -040060 auto routeIt = entry->findRoute(route);
Vince Lehman76c751c2014-11-18 17:36:38 -060061 if (routeIt != entry->end()) {
Davide Pesaventoe4b22382018-06-10 14:37:24 -040062 return &*routeIt;
Alexander Afanasyev3ecec502014-04-16 13:42:44 -070063 }
Vince Lehman76c751c2014-11-18 17:36:38 -060064 }
Vince Lehman218be0a2015-01-15 17:25:20 -060065
66 return nullptr;
Alexander Afanasyev3ecec502014-04-16 13:42:44 -070067}
68
Teng Lianga4e6ec32018-10-21 09:25:00 -070069Route*
70Rib::findLongestPrefix(const Name& prefix, const Route& route) const
71{
72 Route* existingRoute = find(prefix, route);
73 if (existingRoute == nullptr) {
74 auto parent = findParent(prefix);
75 if (parent) {
76 existingRoute = find(parent->getName(), route);
77 }
78 }
79
80 return existingRoute;
81}
82
Alexander Afanasyev3ecec502014-04-16 13:42:44 -070083void
Vince Lehman218be0a2015-01-15 17:25:20 -060084Rib::insert(const Name& prefix, const Route& route)
Alexander Afanasyev3ecec502014-04-16 13:42:44 -070085{
Davide Pesaventoe4b22382018-06-10 14:37:24 -040086 auto ribIt = m_rib.find(prefix);
Vince12e49462014-06-09 13:29:32 -050087
88 // Name prefix exists
Vince Lehman76c751c2014-11-18 17:36:38 -060089 if (ribIt != m_rib.end()) {
90 shared_ptr<RibEntry> entry(ribIt->second);
Davide Pesaventoa3a7a4e2022-05-29 16:06:22 -040091 auto [entryIt, didInsert] = entry->insertRoute(route);
Vince12e49462014-06-09 13:29:32 -050092
Nick Gordon89c4cca2016-11-02 15:42:32 +000093 if (didInsert) {
94 // The route was new and we successfully inserted it.
Vince Lehman76c751c2014-11-18 17:36:38 -060095 m_nItems++;
Vince12e49462014-06-09 13:29:32 -050096
Nick Gordon89c4cca2016-11-02 15:42:32 +000097 afterAddRoute(RibRouteRef{entry, entryIt});
98
Vince12e49462014-06-09 13:29:32 -050099 // Register with face lookup table
Junxiao Shi17a70012019-06-25 10:50:32 +0000100 m_faceEntries.emplace(route.faceId, entry);
Alexander Afanasyev3ecec502014-04-16 13:42:44 -0700101 }
Vince Lehman76c751c2014-11-18 17:36:38 -0600102 else {
103 // Route exists, update fields
104 // First cancel old scheduled event, if any, then set the EventId to new one
Davide Pesaventoe1bdc082018-10-11 21:20:23 -0400105 if (entryIt->getExpirationEvent()) {
106 NFD_LOG_TRACE("Cancelling expiration event for " << entry->getName() << " " << *entryIt);
107 entryIt->cancelExpirationEvent();
Vince Lehman76c751c2014-11-18 17:36:38 -0600108 }
109
Junxiao Shid47cd632018-09-11 03:10:00 +0000110 *entryIt = route;
Vince Lehman76c751c2014-11-18 17:36:38 -0600111 }
112 }
113 else {
114 // New name prefix
Davide Pesaventoe4b22382018-06-10 14:37:24 -0400115 auto entry = make_shared<RibEntry>();
Vince Lehman76c751c2014-11-18 17:36:38 -0600116
117 m_rib[prefix] = entry;
118 m_nItems++;
119
120 entry->setName(prefix);
Davide Pesaventoe4b22382018-06-10 14:37:24 -0400121 auto routeIt = entry->insertRoute(route).first;
Vince Lehman76c751c2014-11-18 17:36:38 -0600122
123 // Find prefix's parent
124 shared_ptr<RibEntry> parent = findParent(prefix);
125
126 // Add self to parent's children
127 if (parent != nullptr) {
128 parent->addChild(entry);
129 }
130
Davide Pesaventoa3a7a4e2022-05-29 16:06:22 -0400131 auto children = findDescendants(prefix);
Vince Lehman76c751c2014-11-18 17:36:38 -0600132 for (const auto& child : children) {
133 if (child->getParent() == parent) {
134 // Remove child from parent and inherit parent's child
135 if (parent != nullptr) {
136 parent->removeChild(child);
137 }
Vince Lehman76c751c2014-11-18 17:36:38 -0600138 entry->addChild(child);
139 }
140 }
141
142 // Register with face lookup table
Junxiao Shi17a70012019-06-25 10:50:32 +0000143 m_faceEntries.emplace(route.faceId, entry);
Vince Lehman76c751c2014-11-18 17:36:38 -0600144
145 // do something after inserting an entry
146 afterInsertEntry(prefix);
Nick Gordon89c4cca2016-11-02 15:42:32 +0000147 afterAddRoute(RibRouteRef{entry, routeIt});
Vince Lehman76c751c2014-11-18 17:36:38 -0600148 }
Alexander Afanasyev3ecec502014-04-16 13:42:44 -0700149}
150
Alexander Afanasyev3ecec502014-04-16 13:42:44 -0700151void
Vince Lehman218be0a2015-01-15 17:25:20 -0600152Rib::erase(const Name& prefix, const Route& route)
Alexander Afanasyev3ecec502014-04-16 13:42:44 -0700153{
Davide Pesaventoe4b22382018-06-10 14:37:24 -0400154 auto ribIt = m_rib.find(prefix);
Junxiao Shi17a70012019-06-25 10:50:32 +0000155 if (ribIt == m_rib.end()) {
156 // Name prefix does not exist
157 return;
158 }
Vince12e49462014-06-09 13:29:32 -0500159
Junxiao Shi17a70012019-06-25 10:50:32 +0000160 shared_ptr<RibEntry> entry = ribIt->second;
161 auto routeIt = entry->findRoute(route);
Vince Lehman4387e782014-06-19 16:57:45 -0500162
Junxiao Shi17a70012019-06-25 10:50:32 +0000163 if (routeIt != entry->end()) {
164 beforeRemoveRoute(RibRouteRef{entry, routeIt});
Nick Gordon89c4cca2016-11-02 15:42:32 +0000165
Junxiao Shi17a70012019-06-25 10:50:32 +0000166 auto faceId = route.faceId;
167 entry->eraseRoute(routeIt);
168 m_nItems--;
Vince Lehman4387e782014-06-19 16:57:45 -0500169
Junxiao Shi17a70012019-06-25 10:50:32 +0000170 // If this RibEntry no longer has this faceId, unregister from face lookup table
171 if (!entry->hasFaceId(faceId)) {
172 auto range = m_faceEntries.equal_range(faceId);
173 for (auto it = range.first; it != range.second; ++it) {
174 if (it->second == entry) {
175 m_faceEntries.erase(it);
176 break;
177 }
Vince Lehman76c751c2014-11-18 17:36:38 -0600178 }
Junxiao Shi17a70012019-06-25 10:50:32 +0000179 }
Syed Obaid3313a372014-07-01 01:31:33 -0500180
Junxiao Shi17a70012019-06-25 10:50:32 +0000181 // If a RibEntry's route list is empty, remove it from the tree
Davide Pesaventoc2442be2025-01-11 17:25:40 -0500182 if (entry->empty()) {
Junxiao Shi17a70012019-06-25 10:50:32 +0000183 eraseEntry(ribIt);
Vince12e49462014-06-09 13:29:32 -0500184 }
Vince Lehman76c751c2014-11-18 17:36:38 -0600185 }
Vince12e49462014-06-09 13:29:32 -0500186}
187
188void
Vince Lehman76c751c2014-11-18 17:36:38 -0600189Rib::onRouteExpiration(const Name& prefix, const Route& route)
Vince12e49462014-06-09 13:29:32 -0500190{
Vince Lehman76c751c2014-11-18 17:36:38 -0600191 NFD_LOG_DEBUG(route << " for " << prefix << " has expired");
Davide Pesaventoc2442be2025-01-11 17:25:40 -0500192 beginApplyUpdate({RibUpdate::UNREGISTER, prefix, route}, nullptr, nullptr);
Vince12e49462014-06-09 13:29:32 -0500193}
194
195shared_ptr<RibEntry>
196Rib::findParent(const Name& prefix) const
197{
Vince Lehman76c751c2014-11-18 17:36:38 -0600198 for (int i = prefix.size() - 1; i >= 0; i--) {
Davide Pesaventoe4b22382018-06-10 14:37:24 -0400199 auto it = m_rib.find(prefix.getPrefix(i));
Vince Lehman76c751c2014-11-18 17:36:38 -0600200 if (it != m_rib.end()) {
Davide Pesaventoe4b22382018-06-10 14:37:24 -0400201 return it->second;
Vince12e49462014-06-09 13:29:32 -0500202 }
Vince Lehman76c751c2014-11-18 17:36:38 -0600203 }
Vince12e49462014-06-09 13:29:32 -0500204
Davide Pesaventoe4b22382018-06-10 14:37:24 -0400205 return nullptr;
Vince12e49462014-06-09 13:29:32 -0500206}
207
Davide Pesaventoe4b22382018-06-10 14:37:24 -0400208std::list<shared_ptr<RibEntry>>
Vince12e49462014-06-09 13:29:32 -0500209Rib::findDescendants(const Name& prefix) const
210{
Davide Pesaventoe4b22382018-06-10 14:37:24 -0400211 std::list<shared_ptr<RibEntry>> children;
Vince12e49462014-06-09 13:29:32 -0500212
Davide Pesaventoa3a7a4e2022-05-29 16:06:22 -0400213 auto it = m_rib.find(prefix);
Vince Lehman76c751c2014-11-18 17:36:38 -0600214 if (it != m_rib.end()) {
215 ++it;
216 for (; it != m_rib.end(); ++it) {
217 if (prefix.isPrefixOf(it->first)) {
Davide Pesaventoa3a7a4e2022-05-29 16:06:22 -0400218 children.push_back(it->second);
Vince Lehman76c751c2014-11-18 17:36:38 -0600219 }
220 else {
221 break;
222 }
Alexander Afanasyev3ecec502014-04-16 13:42:44 -0700223 }
Vince Lehman76c751c2014-11-18 17:36:38 -0600224 }
225
226 return children;
227}
228
229std::list<shared_ptr<RibEntry>>
230Rib::findDescendantsForNonInsertedName(const Name& prefix) const
231{
232 std::list<shared_ptr<RibEntry>> children;
233
Davide Pesaventoa3a7a4e2022-05-29 16:06:22 -0400234 for (const auto& [name, ribEntry] : m_rib) {
235 if (prefix.isPrefixOf(name)) {
236 children.push_back(ribEntry);
Vince Lehman76c751c2014-11-18 17:36:38 -0600237 }
238 }
Vince12e49462014-06-09 13:29:32 -0500239
240 return children;
Alexander Afanasyev3ecec502014-04-16 13:42:44 -0700241}
242
Vince12e49462014-06-09 13:29:32 -0500243Rib::RibTable::iterator
244Rib::eraseEntry(RibTable::iterator it)
Alexander Afanasyev3ecec502014-04-16 13:42:44 -0700245{
Vince12e49462014-06-09 13:29:32 -0500246 // Entry does not exist
Vince Lehman76c751c2014-11-18 17:36:38 -0600247 if (it == m_rib.end()) {
248 return m_rib.end();
249 }
Vince12e49462014-06-09 13:29:32 -0500250
251 shared_ptr<RibEntry> entry(it->second);
Vince12e49462014-06-09 13:29:32 -0500252 shared_ptr<RibEntry> parent = entry->getParent();
253
254 // Remove self from parent's children
Vince Lehman76c751c2014-11-18 17:36:38 -0600255 if (parent != nullptr) {
256 parent->removeChild(entry);
257 }
258
259 for (auto childIt = entry->getChildren().begin(); childIt != entry->getChildren().end(); ) {
260 shared_ptr<RibEntry> child = *childIt;
261
262 // Advance iterator so it is not invalidated by removal
263 ++childIt;
264
265 // Remove children from self
266 entry->removeChild(child);
267
268 // Update parent's children
269 if (parent != nullptr) {
270 parent->addChild(child);
Vince12e49462014-06-09 13:29:32 -0500271 }
Vince Lehman76c751c2014-11-18 17:36:38 -0600272 }
Vince12e49462014-06-09 13:29:32 -0500273
Davide Pesaventoe4b22382018-06-10 14:37:24 -0400274 auto nextIt = m_rib.erase(it);
Vince12e49462014-06-09 13:29:32 -0500275
Davide Pesaventoa3a7a4e2022-05-29 16:06:22 -0400276 // do something after erasing an entry
Yanbiao Lic17de832014-11-21 17:51:45 -0800277 afterEraseEntry(entry->getName());
278
Vince12e49462014-06-09 13:29:32 -0500279 return nextIt;
Alexander Afanasyev3ecec502014-04-16 13:42:44 -0700280}
281
Vince Lehman218be0a2015-01-15 17:25:20 -0600282Rib::RouteSet
283Rib::getAncestorRoutes(const RibEntry& entry) const
Vince Lehman4387e782014-06-19 16:57:45 -0500284{
Vince Lehman218be0a2015-01-15 17:25:20 -0600285 RouteSet ancestorRoutes(&sortRoutes);
Vince Lehman4387e782014-06-19 16:57:45 -0500286
Davide Pesaventoa3a7a4e2022-05-29 16:06:22 -0400287 auto parent = entry.getParent();
Vince Lehman76c751c2014-11-18 17:36:38 -0600288 while (parent != nullptr) {
Davide Pesaventoa3a7a4e2022-05-29 16:06:22 -0400289 for (const auto& route : parent->getRoutes()) {
Vince Lehman76c751c2014-11-18 17:36:38 -0600290 if (route.isChildInherit()) {
291 ancestorRoutes.insert(route);
Vince Lehman4387e782014-06-19 16:57:45 -0500292 }
Vince Lehman4387e782014-06-19 16:57:45 -0500293 }
294
Vince Lehman76c751c2014-11-18 17:36:38 -0600295 if (parent->hasCapture()) {
296 break;
Vince Lehman4387e782014-06-19 16:57:45 -0500297 }
Vince Lehman76c751c2014-11-18 17:36:38 -0600298
299 parent = parent->getParent();
300 }
301
302 return ancestorRoutes;
303}
304
305Rib::RouteSet
306Rib::getAncestorRoutes(const Name& name) const
307{
308 RouteSet ancestorRoutes(&sortRoutes);
309
Davide Pesaventoa3a7a4e2022-05-29 16:06:22 -0400310 auto parent = findParent(name);
Vince Lehman76c751c2014-11-18 17:36:38 -0600311 while (parent != nullptr) {
Davide Pesaventoa3a7a4e2022-05-29 16:06:22 -0400312 for (const auto& route : parent->getRoutes()) {
Vince Lehman76c751c2014-11-18 17:36:38 -0600313 if (route.isChildInherit()) {
314 ancestorRoutes.insert(route);
315 }
316 }
317
318 if (parent->hasCapture()) {
319 break;
320 }
321
322 parent = parent->getParent();
323 }
324
325 return ancestorRoutes;
326}
327
328void
329Rib::beginApplyUpdate(const RibUpdate& update,
330 const Rib::UpdateSuccessCallback& onSuccess,
331 const Rib::UpdateFailureCallback& onFailure)
332{
333 BOOST_ASSERT(m_fibUpdater != nullptr);
Vince Lehman76c751c2014-11-18 17:36:38 -0600334 addUpdateToQueue(update, onSuccess, onFailure);
Vince Lehman76c751c2014-11-18 17:36:38 -0600335 sendBatchFromQueue();
336}
337
338void
339Rib::beginRemoveFace(uint64_t faceId)
340{
Junxiao Shi17a70012019-06-25 10:50:32 +0000341 auto range = m_faceEntries.equal_range(faceId);
342 for (auto it = range.first; it != range.second; ++it) {
343 enqueueRemoveFace(*it->second, faceId);
344 }
345 sendBatchFromQueue();
346}
347
348void
349Rib::beginRemoveFailedFaces(const std::set<uint64_t>& activeFaceIds)
350{
Davide Pesaventoa3a7a4e2022-05-29 16:06:22 -0400351 for (const auto& [faceId, ribEntry] : m_faceEntries) {
352 if (activeFaceIds.count(faceId) > 0) {
Junxiao Shi17a70012019-06-25 10:50:32 +0000353 continue;
354 }
Davide Pesaventoa3a7a4e2022-05-29 16:06:22 -0400355 enqueueRemoveFace(*ribEntry, faceId);
Junxiao Shi17a70012019-06-25 10:50:32 +0000356 }
357 sendBatchFromQueue();
358}
359
360void
361Rib::enqueueRemoveFace(const RibEntry& entry, uint64_t faceId)
362{
363 for (const Route& route : entry) {
364 if (route.faceId != faceId) {
365 continue;
366 }
Davide Pesaventoc2442be2025-01-11 17:25:40 -0500367 addUpdateToQueue({RibUpdate::REMOVE_FACE, entry.getName(), route}, nullptr, nullptr);
Vince Lehman76c751c2014-11-18 17:36:38 -0600368 }
Vince Lehman76c751c2014-11-18 17:36:38 -0600369}
370
371void
372Rib::addUpdateToQueue(const RibUpdate& update,
373 const Rib::UpdateSuccessCallback& onSuccess,
374 const Rib::UpdateFailureCallback& onFailure)
375{
Davide Pesaventoc2442be2025-01-11 17:25:40 -0500376 RibUpdateBatch batch(update.route.faceId);
Vince Lehman76c751c2014-11-18 17:36:38 -0600377 batch.add(update);
378
379 UpdateQueueItem item{batch, onSuccess, onFailure};
380 m_updateBatches.push_back(std::move(item));
381}
382
383void
384Rib::sendBatchFromQueue()
385{
386 if (m_updateBatches.empty() || m_isUpdateInProgress) {
387 return;
388 }
389
390 m_isUpdateInProgress = true;
391
392 UpdateQueueItem item = std::move(m_updateBatches.front());
393 m_updateBatches.pop_front();
394
Vince Lehman76c751c2014-11-18 17:36:38 -0600395 // Until task #1698, each RibUpdateBatch contains exactly one RIB update
Davide Pesaventoae430302023-05-11 01:42:46 -0400396 BOOST_ASSERT(item.batch.size() == 1);
Vince Lehman76c751c2014-11-18 17:36:38 -0600397
Davide Pesaventoae430302023-05-11 01:42:46 -0400398 m_fibUpdater->computeAndSendFibUpdates(item.batch,
399 [this, batch = item.batch, successCb = item.managerSuccessCallback] (const auto& routes) {
400 onFibUpdateSuccess(batch, routes, successCb);
401 },
402 [this, failureCb = item.managerFailureCallback] (const auto& code, const auto& error) {
403 onFibUpdateFailure(failureCb, code, error);
404 });
Vince Lehman76c751c2014-11-18 17:36:38 -0600405}
406
407void
408Rib::onFibUpdateSuccess(const RibUpdateBatch& batch,
409 const RibUpdateList& inheritedRoutes,
410 const Rib::UpdateSuccessCallback& onSuccess)
411{
412 for (const RibUpdate& update : batch) {
Davide Pesaventoc2442be2025-01-11 17:25:40 -0500413 switch (update.action) {
Vince Lehman76c751c2014-11-18 17:36:38 -0600414 case RibUpdate::REGISTER:
Davide Pesaventoc2442be2025-01-11 17:25:40 -0500415 insert(update.name, update.route);
Vince Lehman76c751c2014-11-18 17:36:38 -0600416 break;
417 case RibUpdate::UNREGISTER:
418 case RibUpdate::REMOVE_FACE:
Davide Pesaventoc2442be2025-01-11 17:25:40 -0500419 erase(update.name, update.route);
Vince Lehman76c751c2014-11-18 17:36:38 -0600420 break;
421 }
422 }
423
424 // Add and remove precalculated inherited routes to RibEntries
425 modifyInheritedRoutes(inheritedRoutes);
426
427 m_isUpdateInProgress = false;
428
429 if (onSuccess != nullptr) {
430 onSuccess();
431 }
432
433 // Try to advance the batch queue
434 sendBatchFromQueue();
435}
436
437void
438Rib::onFibUpdateFailure(const Rib::UpdateFailureCallback& onFailure,
439 uint32_t code, const std::string& error)
440{
441 m_isUpdateInProgress = false;
442
443 if (onFailure != nullptr) {
444 onFailure(code, error);
445 }
446
447 // Try to advance the batch queue
448 sendBatchFromQueue();
449}
450
451void
452Rib::modifyInheritedRoutes(const RibUpdateList& inheritedRoutes)
453{
454 for (const RibUpdate& update : inheritedRoutes) {
Davide Pesaventoc2442be2025-01-11 17:25:40 -0500455 auto ribIt = m_rib.find(update.name);
Vince Lehman76c751c2014-11-18 17:36:38 -0600456 BOOST_ASSERT(ribIt != m_rib.end());
457 shared_ptr<RibEntry> entry(ribIt->second);
458
Davide Pesaventoc2442be2025-01-11 17:25:40 -0500459 switch (update.action) {
Vince Lehman76c751c2014-11-18 17:36:38 -0600460 case RibUpdate::REGISTER:
Davide Pesaventoc2442be2025-01-11 17:25:40 -0500461 entry->addInheritedRoute(update.route);
Vince Lehman76c751c2014-11-18 17:36:38 -0600462 break;
463 case RibUpdate::UNREGISTER:
Davide Pesaventoc2442be2025-01-11 17:25:40 -0500464 entry->removeInheritedRoute(update.route);
Vince Lehman76c751c2014-11-18 17:36:38 -0600465 break;
466 case RibUpdate::REMOVE_FACE:
467 break;
468 }
469 }
470}
471
Alexander Afanasyev20d31442014-04-19 17:00:53 -0700472std::ostream&
Vince12e49462014-06-09 13:29:32 -0500473operator<<(std::ostream& os, const Rib& rib)
Alexander Afanasyev20d31442014-04-19 17:00:53 -0700474{
Vince Lehman76c751c2014-11-18 17:36:38 -0600475 for (const auto& item : rib) {
Weiwei Liuaaa58a62016-11-28 23:15:15 -0700476 os << *item.second << "\n";
Vince Lehman76c751c2014-11-18 17:36:38 -0600477 }
Alexander Afanasyev20d31442014-04-19 17:00:53 -0700478 return os;
479}
480
Davide Pesaventoe422f9e2022-06-03 01:30:23 -0400481} // namespace nfd::rib