Пример #1
0
void RouteUpdateLogger::stateUpdated(const StateDelta& delta) {
  for (const auto& rtDelta : delta.getRouteTablesDelta()) {
    DeltaFunctions::forEachChanged(
        rtDelta.getRoutesV4Delta(),
        &handleChangedRoute<folly::IPAddressV4>,
        &handleAddedRoute<folly::IPAddressV4>,
        &handleRemovedRoute<folly::IPAddressV4>,
        prefixTracker_,
        routeLoggerV4_);
    DeltaFunctions::forEachChanged(
        rtDelta.getRoutesV6Delta(),
        &handleChangedRoute<folly::IPAddressV6>,
        &handleAddedRoute<folly::IPAddressV6>,
        &handleRemovedRoute<folly::IPAddressV6>,
        prefixTracker_,
        routeLoggerV6_);
  }
}
Пример #2
0
void NexthopToRouteCount::stateChanged(const StateDelta& delta) {
   for (auto const& rtDelta : delta.getRouteTablesDelta()) {
      // Do add/changed first so we don't remove next hops due to decrements
      // in ref count via removed routes, only to add them back again if these
      // next hops show up in added/changed routes
     if (rtDelta.getNew()) {
       RouterID id = rtDelta.getNew()->getID();
       forEachChanged(
           rtDelta.getRoutesV4Delta(),
           &NexthopToRouteCount::processChangedRoute<RouteV4>,
           &NexthopToRouteCount::processAddedRoute<RouteV4>,
           [&](NexthopToRouteCount *, RouterID, const shared_ptr<RouteV4>&) {},
           this,
           id);
       forEachChanged(
           rtDelta.getRoutesV6Delta(),
           &NexthopToRouteCount::processChangedRoute<RouteV6>,
           &NexthopToRouteCount::processAddedRoute<RouteV6>,
           [&](NexthopToRouteCount *, RouterID, const shared_ptr<RouteV6>&) {},
           this,
           id);
    }
    // Process removed routes
    if (rtDelta.getOld()) {
      RouterID id = rtDelta.getOld()->getID();
      forEachRemoved(
          rtDelta.getRoutesV4Delta(),
          &NexthopToRouteCount::processRemovedRoute<RouteV4>,
          this,
          id);
      forEachRemoved(
          rtDelta.getRoutesV6Delta(),
          &NexthopToRouteCount::processRemovedRoute<RouteV6>,
          this,
          id);
    }
  }
}