Пример #1
0
void NeighborUpdater::stateUpdated(const StateDelta& delta) {
  CHECK(sw_->getUpdateEVB()->inRunningEventBaseThread());
  for (const auto& entry : delta.getVlansDelta()) {
    sendNeighborUpdates(entry);
    auto oldEntry = entry.getOld();
    auto newEntry = entry.getNew();

    if (!newEntry) {
      vlanDeleted(oldEntry.get());
    } else if (!oldEntry) {
      vlanAdded(delta.newState().get(), newEntry.get());
    } else {
      vlanChanged(oldEntry.get(), newEntry.get());
    }
  }

  const auto& oldState = delta.oldState();
  const auto& newState = delta.newState();
  if (oldState->getArpTimeout() != newState->getArpTimeout() ||
      oldState->getNdpTimeout() != newState->getNdpTimeout() ||
      oldState->getMaxNeighborProbes() != newState->getMaxNeighborProbes() ||
      oldState->getStaleEntryInterval() != newState->getStaleEntryInterval()) {
    std::lock_guard<std::mutex> g(cachesMutex_);
    for (auto& vlanAndCaches : caches_) {
      auto& arpCache = vlanAndCaches.second->arpCache;
      auto& ndpCache = vlanAndCaches.second->ndpCache;
      arpCache->setTimeout(newState->getArpTimeout());
      arpCache->setMaxNeighborProbes(newState->getMaxNeighborProbes());
      arpCache->setStaleEntryInterval(newState->getStaleEntryInterval());
      ndpCache->setTimeout(newState->getNdpTimeout());
      ndpCache->setMaxNeighborProbes(newState->getMaxNeighborProbes());
      ndpCache->setStaleEntryInterval(newState->getStaleEntryInterval());
    }
  }
}
void LinkAggregationManager::stateUpdated(const StateDelta& delta) {
  CHECK(sw_->getUpdateEvb()->inRunningEventBaseThread());

  folly::SharedMutexWritePriority::WriteHolder writeGuard(&controllersLock_);

  if (!initialized_) {
    bool inserted;
    for (const auto& port : *(delta.newState()->getPorts())) {
      // TODO(samank): use try_emplace once OSS build uses boost >1.63.0
      std::tie(std::ignore, inserted) = portToController_.insert(std::make_pair(
          port->getID(),
          std::make_shared<LacpController>(
              port->getID(), sw_->getLacpEvb(), this)));
      CHECK(inserted);
    }

    for (const auto& portAndController : portToController_) {
      portAndController.second->startMachines();
    }
    initialized_ = true;
  }

  DeltaFunctions::forEachChanged(
      delta.getAggregatePortsDelta(),
      &LinkAggregationManager::aggregatePortChanged,
      &LinkAggregationManager::aggregatePortAdded,
      &LinkAggregationManager::aggregatePortRemoved,
      this);

  // Downgrade to a reader lock
  folly::SharedMutexWritePriority::ReadHolder readGuard(std::move(writeGuard));

  DeltaFunctions::forEachChanged(
      delta.getPortsDelta(), &LinkAggregationManager::portChanged, this);
}
Пример #3
0
void TunManager::stateUpdated(const StateDelta& delta) {
  // TODO(aeckert): We currently compare the entire interface map instead
  // of using the iterator in this delta because some of the interfaces may get
  // get probed from hardware, before they are in the SwitchState. It would be
  // nicer if we did a little more work at startup to sync the state, perhaps
  // updating the SwitchState with the probed interfaces. This would allow us
  // to reuse the iterator in the delta for more readable code and also not
  // have to worry about waiting to listen to updates until the SwSwitch is in
  // the configured state. t4155406 should also help with that.

  auto state = delta.newState();
  evb_->runInEventBaseThread([this, state]() {
      this->sync(state);
    });
}
Пример #4
0
void NeighborUpdater::stateUpdated(const StateDelta& delta) {
  CHECK(sw_->getUpdateEVB()->inRunningEventBaseThread());
  for (const auto& entry : delta.getVlansDelta()) {
    sendNeighborUpdates(entry);
    auto oldEntry = entry.getOld();
    auto newEntry = entry.getNew();

    if (!newEntry) {
      vlanDeleted(oldEntry.get());
    } else if (!oldEntry) {
      vlanAdded(delta.newState().get(), newEntry.get());
    } else {
      vlanChanged(oldEntry.get(), newEntry.get());
    }
  }
  unresolvedNhopsProber_->stateChanged(delta);
}