From 43f684765b91cc0caa55b6ca10a2c9604e07cc00 Mon Sep 17 00:00:00 2001 From: Kiran Shastri Date: Sun, 1 Sep 2024 17:51:16 -0400 Subject: [PATCH] Out of band config handling Change frequency of tunnel ep advertisement timer, based on out-of-band-config file inserted by host-agent. Signed-off-by: Kiran Shastri --- agent-ovs/Makefile.am | 7 +- agent-ovs/lib/Agent.cpp | 20 ++++- agent-ovs/lib/ExtraConfigManager.cpp | 38 ++++++++ agent-ovs/lib/FSOutOfBandConfigSource.cpp | 87 +++++++++++++++++++ agent-ovs/lib/include/opflexagent/Agent.h | 4 +- .../include/opflexagent/ExtraConfigListener.h | 9 ++ .../include/opflexagent/ExtraConfigManager.h | 20 +++++ .../opflexagent/FSOutOfBandConfigSource.h | 58 +++++++++++++ .../lib/include/opflexagent/OutOfBandConfig.h | 24 +++++ .../lib/include/opflexagent/TunnelEpManager.h | 8 ++ agent-ovs/opflex-agent-ovs.conf.in | 5 ++ agent-ovs/ovs/AdvertManager.cpp | 28 ++++-- agent-ovs/ovs/IntFlowManager.cpp | 10 +++ agent-ovs/ovs/OVSRenderer.cpp | 14 ++- agent-ovs/ovs/include/AccessFlowManager.h | 3 + agent-ovs/ovs/include/AdvertManager.h | 1 + agent-ovs/ovs/include/EndpointTenantMapper.h | 1 + agent-ovs/ovs/include/IntFlowManager.h | 12 +++ agent-ovs/ovs/include/OVSRenderer.h | 2 + genie/MODEL/OWNERSHIP/own.mdl | 1 + genie/MODEL/SPECIFIC/OBSERVER/config.mdl | 20 +++++ genie/MODEL/SPECIFIC/OBSERVER/universe.mdl | 14 +++ 22 files changed, 377 insertions(+), 9 deletions(-) create mode 100644 agent-ovs/lib/FSOutOfBandConfigSource.cpp create mode 100644 agent-ovs/lib/include/opflexagent/FSOutOfBandConfigSource.h create mode 100644 agent-ovs/lib/include/opflexagent/OutOfBandConfig.h diff --git a/agent-ovs/Makefile.am b/agent-ovs/Makefile.am index e6fd06a60..98d88bcbc 100644 --- a/agent-ovs/Makefile.am +++ b/agent-ovs/Makefile.am @@ -133,6 +133,8 @@ libopflex_agent_la_include_HEADERS = \ lib/include/opflexagent/FSNetpolSource.h \ lib/include/opflexagent/FSPacketDropLogConfigSource.h \ lib/include/opflexagent/PacketDropLogConfig.h \ + lib/include/opflexagent/FSOutOfBandConfigSource.h \ + lib/include/opflexagent/OutOfBandConfig.h \ lib/include/opflexagent/Faults.h \ lib/include/opflexagent/PrometheusManager.h @@ -231,6 +233,7 @@ libopflex_agent_la_SOURCES = \ lib/SnatSource.cpp \ lib/FSNetpolSource.cpp \ lib/FSPacketDropLogConfigSource.cpp \ + lib/FSOutOfBandConfigSource.cpp \ lib/AgentPrometheusManager.cpp libopflex_agent_la_LDFLAGS = -shared -version-info ${VERSION_INFO} @@ -695,6 +698,7 @@ pluginconf_DATA = plugin-renderer-openvswitch.conf defepwatchdir=${localstatedir}/lib/opflex-agent-ovs/endpoints defservwatchdir=${localstatedir}/lib/opflex-agent-ovs/services defdroplogwatchdir=${localstatedir}/lib/opflex-agent-ovs/droplog +defoutofbandconfigdir = ${localstatedir}/lib/opflex-agent-ovs/outofband inspectsock=${localstatedir}/run/opflex-agent-inspect.sock notifsock=${localstatedir}/run/opflex-agent-notif.sock cacertdir=${sysconfdir}/ssl/certs @@ -709,7 +713,8 @@ opflex-agent-ovs.conf: $(top_srcdir)/opflex-agent-ovs.conf.in -e "s|DEFAULT_CA_CERT_DIR|${cacertdir}|" \ -e "s|DEFAULT_CLIENT_CERT_PATH|${clientcertpath}|" \ -e "s|DEFAULT_DROP_LOG_DIR|${defdroplogwatchdir}|" \ - -e "s|DEFAULT_FS_FAULT_DIR|${deffaultwatchdir}|" \ + -e "s|DEFAULT_FS_FAULT_DIR|${deffaultwatchdir}|" \ + -e "s|DEFAULT_OOB_CONFIG_DIR|${defoutofbandconfigdir}|" \ $< > $@ flowidcachedir=${localstatedir}/lib/opflex-agent-ovs/ids diff --git a/agent-ovs/lib/Agent.cpp b/agent-ovs/lib/Agent.cpp index f069fd81f..86cf733c3 100644 --- a/agent-ovs/lib/Agent.cpp +++ b/agent-ovs/lib/Agent.cpp @@ -153,6 +153,7 @@ void Agent::setProperties(const boost::property_tree::ptree& properties) { static const std::string SNAT_SOURCE_PATH("snat-sources.filesystem"); static const std::string NETPOL_SOURCE_PATH("netpol-sources.filesystem"); static const std::string DROP_LOG_CFG_SOURCE_FSPATH("drop-log-config-sources.filesystem"); + static const std::string OUT_OF_BAND_CFG_SOURCE_FSPATH("out-of-band-config-sources.filesystem"); static const std::string FAULT_SOURCE_FSPATH("host-agent-fault-sources.filesystem"); static const std::string PACKET_EVENT_NOTIF_SOCK("packet-event-notif.socket-name"); static const std::string OPFLEX_PEERS("opflex.peers"); @@ -346,7 +347,15 @@ void Agent::setProperties(const boost::property_tree::ptree& properties) { for (const ptree::value_type &v : dropLogCfgSrc.get()) dropLogCfgSourcePath = v.second.data(); } - + + optional outOfBandCfgSrc = + properties.get_child_optional(OUT_OF_BAND_CFG_SOURCE_FSPATH); + + if (outOfBandCfgSrc) { + for (const ptree::value_type &v : outOfBandCfgSrc.get()) + oobCfgSourcePath = v.second.data(); + } + optional hostAgentFaultSrc = properties.get_child_optional(FAULT_SOURCE_FSPATH); @@ -740,6 +749,14 @@ void Agent::start() { dropLogCfgSource.reset(new FSPacketDropLogConfigSource(&extraConfigManager, fsWatcher, dropLogCfgSourcePath, uri)); } + if(!oobCfgSourcePath.empty()) { + opflex::modb::URI uri = (opflex::modb::URIBuilder() + .addElement("PolicyUniverse").addElement("ObserverOutOfBandConfig") + .build()); + oobCfgSource.reset(new FSOutOfBandConfigSource(&extraConfigManager, + fsWatcher, oobCfgSourcePath, uri)); + } + for (const std::string& path : hostAgentFaultPaths) { FaultSource* source = new FSFaultSource(&faultManager, fsWatcher, path, *this); @@ -857,6 +874,7 @@ void Agent::createUniverse (std::shared_ptr root) root->addObserverSvcStatUniverse(); root->addObserverPolicyStatUniverse(); root->addObserverDropFlowConfigUniverse(); + root->addObserverOutOfBandConfigUniverse(); root->addSpanUniverse(); root->addEpdrExternalDiscovered(); root->addEpdrLocalRouteDiscovered(); diff --git a/agent-ovs/lib/ExtraConfigManager.cpp b/agent-ovs/lib/ExtraConfigManager.cpp index 553c377c5..fb691d89a 100644 --- a/agent-ovs/lib/ExtraConfigManager.cpp +++ b/agent-ovs/lib/ExtraConfigManager.cpp @@ -15,6 +15,8 @@ #include #include #include +#include +#include #include #include @@ -102,6 +104,42 @@ void ExtraConfigManager::notifyPacketDropPruneConfigListeners(const std::string } } +void ExtraConfigManager::notifyOutOfBandConfigListeners(std::shared_ptr &oobSptr) { + unique_lock guard(listener_mutex); + for (ExtraConfigListener* listener : extraConfigListeners) { + listener->outOfBandConfigUpdated(oobSptr); + } +} + +void ExtraConfigManager::outOfBandConfigUpdated(const OutOfBandConfigSpec &outOfBandCfg) { + using modelgbp::observer::OutOfBandConfigUniverse; + using modelgbp::observer::OutOfBandConfig; + Mutator mutator(framework, "policyelement"); + optional> oobCfgUni = + OutOfBandConfigUniverse::resolve(framework); + shared_ptr oobCfg = + oobCfgUni.get()->addObserverOutOfBandConfig(); + oobCfg->setTunnelEpAdvertisementInterval(outOfBandCfg.tunnelEpAdvInterval); + mutator.commit(); + shared_ptr oobSptr(new OutOfBandConfigSpec(outOfBandCfg.tunnelEpAdvInterval)); + notifyOutOfBandConfigListeners(oobSptr); +} + +void ExtraConfigManager::outOfBandConfigDeleted() { + using modelgbp::observer::OutOfBandConfigUniverse; + using modelgbp::observer::OutOfBandConfig; + Mutator mutator(framework, "policyelement"); + optional> oobCfgUni = + OutOfBandConfigUniverse::resolve(framework); + opflex::modb::URI oobCfgURI = + opflex::modb::URIBuilder(oobCfgUni.get()->getURI()) + .addElement("ObserverOutOfBandConfig").build(); + OutOfBandConfig::remove(framework, oobCfgURI); + mutator.commit(); + shared_ptr oobSptr; + notifyOutOfBandConfigListeners(oobSptr); +} + void ExtraConfigManager::packetDropLogConfigUpdated(PacketDropLogConfig &dropCfg) { using modelgbp::observer::DropLogConfig; diff --git a/agent-ovs/lib/FSOutOfBandConfigSource.cpp b/agent-ovs/lib/FSOutOfBandConfigSource.cpp new file mode 100644 index 000000000..8092f5719 --- /dev/null +++ b/agent-ovs/lib/FSOutOfBandConfigSource.cpp @@ -0,0 +1,87 @@ +/* -*- C++ -*-; c-basic-offset: 4; indent-tabs-mode: nil */ +/* + * Implementation for FSOutOfBandConfigSource class. + * + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#if defined(HAVE_SYS_INOTIFY_H) && defined(HAVE_SYS_EVENTFD_H) +#define USE_INOTIFY +#endif + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace opflexagent { + +using boost::optional; +namespace fs = boost::filesystem; +using std::string; +using std::make_pair; +using std::runtime_error; +using opflex::modb::URI; +using boost::asio::ip::address; +using modelgbp::observer::DropLogModeEnumT; + +FSOutOfBandConfigSource::FSOutOfBandConfigSource(ExtraConfigManager* manager_, + FSWatcher& listener, + const std::string& serviceDir, + const opflex::modb::URI &uri) + : manager(manager_) { + listener.addWatch(serviceDir, *this); +} + +static bool isOutOfBandConfig(const fs::path& filePath) { + string fstr = filePath.filename().string(); + return (fstr == "aci-containers-system.oob"); +} + +void FSOutOfBandConfigSource::updated(const fs::path& filePath) { + using boost::property_tree::ptree; + ptree properties; + try { + if (isOutOfBandConfig(filePath)) { + const string& pathStr = filePath.string(); + read_json(pathStr, properties); + const std::string TUNNEL_ADV_INTVL("tunnel-ep-advertisement-interval"); + OutOfBandConfigSpec oobSpec(properties.get(TUNNEL_ADV_INTVL, 300)); + manager->outOfBandConfigUpdated(oobSpec); + } + } catch (const std::exception& ex) { + LOG(ERROR) << "Could not update out of band config for " + << filePath << ": " + << ex.what(); + } + +} + +void FSOutOfBandConfigSource::deleted(const fs::path& filePath) { + try { + string pathStr = filePath.string(); + if (isOutOfBandConfig(filePath)) { + manager->outOfBandConfigDeleted(); + } + } catch (const std::exception& ex) { + LOG(ERROR) << "Could not delete out of band config for " + << filePath << ": " + << ex.what(); + } +} + +} /* namespace opflexagent */ diff --git a/agent-ovs/lib/include/opflexagent/Agent.h b/agent-ovs/lib/include/opflexagent/Agent.h index 107df0738..e7787b272 100644 --- a/agent-ovs/lib/include/opflexagent/Agent.h +++ b/agent-ovs/lib/include/opflexagent/Agent.h @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -396,10 +397,11 @@ typedef opflex::ofcore::OFConstants::OpflexElementMode opflex_elem_t; std::vector> rdConfigSources; std::vector> learningBridgeSources; std::string dropLogCfgSourcePath; + std::string oobCfgSourcePath; std::set hostAgentFaultPaths; std::string packetEventNotifSockPath; std::unique_ptr dropLogCfgSource; - + std::unique_ptr oobCfgSource; std::set serviceSourcePaths; std::vector> serviceSources; diff --git a/agent-ovs/lib/include/opflexagent/ExtraConfigListener.h b/agent-ovs/lib/include/opflexagent/ExtraConfigListener.h index ac2b317c5..4ab59c229 100644 --- a/agent-ovs/lib/include/opflexagent/ExtraConfigListener.h +++ b/agent-ovs/lib/include/opflexagent/ExtraConfigListener.h @@ -14,6 +14,7 @@ #define OPFLEXAGENT_EXTRACONFIGLISTENER_H #include +#include namespace opflexagent { @@ -60,6 +61,14 @@ class ExtraConfigListener { * @param filterName Prune filter name */ virtual void packetDropPruneConfigUpdated(const std::string &filterName) = 0; + + /** + * Called when an out of band config is updated + * + * @param oobSptr out of band config shared pointer + */ + virtual void outOfBandConfigUpdated(std::shared_ptr &oobSptr) = 0; + }; } /* namespace opflexagent */ diff --git a/agent-ovs/lib/include/opflexagent/ExtraConfigManager.h b/agent-ovs/lib/include/opflexagent/ExtraConfigManager.h index 57d2317ad..0807c7f38 100644 --- a/agent-ovs/lib/include/opflexagent/ExtraConfigManager.h +++ b/agent-ovs/lib/include/opflexagent/ExtraConfigManager.h @@ -127,6 +127,25 @@ class ExtraConfigManager : private boost::noncopyable { */ void notifyPacketDropPruneConfigListeners(const std::string &dropPruneFilterName); + /** + * Notify listeners for out of band config object + * + * @param oobSptr shared ptr to OutOfBandConfig + */ + void notifyOutOfBandConfigListeners(std::shared_ptr &oobSptr); + + /** + * Add or update an out of band config object + * + * @param oobCfg Out Of Band Config object + */ + void outOfBandConfigUpdated(const OutOfBandConfigSpec &oobCfg); + + /** + * Delete an out of band config object + */ + void outOfBandConfigDeleted(); + /** * Add or update a packet drop log config object * @@ -167,6 +186,7 @@ class ExtraConfigManager : private boost::noncopyable { friend class FSRDConfigSource; friend class FSPacketDropLogConfigSource; + friend class FSOutOfBandConfigSource; }; } /* namespace opflexagent */ diff --git a/agent-ovs/lib/include/opflexagent/FSOutOfBandConfigSource.h b/agent-ovs/lib/include/opflexagent/FSOutOfBandConfigSource.h new file mode 100644 index 000000000..206f6cc54 --- /dev/null +++ b/agent-ovs/lib/include/opflexagent/FSOutOfBandConfigSource.h @@ -0,0 +1,58 @@ +/* -*- C++ -*-; c-basic-offset: 4; indent-tabs-mode: nil */ +/* + * Include file for filesystem out of band config source + * + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +#pragma once +#ifndef OPFLEXAGENT_OUTOFBANDCONFIGSOURCE_H +#define OPFLEXAGENT_OUTOFBANDCONFIGSOURCE_H + +#include +#include + +#include + +#include + +namespace opflexagent { + +class ExtraConfigManager; + +/** + * An out of band config source that gets information for + * out of band config from the filesystem. + */ +class FSOutOfBandConfigSource : public FSWatcher::Watcher { +public: + /** + * Instantiate a new out of band config source. It will set a + * watch on the given path. + */ + FSOutOfBandConfigSource(ExtraConfigManager* manager, + FSWatcher& listener, + const std::string& OutOfBandConfigDir, + const opflex::modb::URI& uri); + + /** + * Destroy the out of band config source and clean up all state + */ + virtual ~FSOutOfBandConfigSource() {} + + // See Watcher + virtual void updated(const boost::filesystem::path& filePath); + // See Watcher + virtual void deleted(const boost::filesystem::path& filePath); + +private: + ExtraConfigManager* manager; +}; + +} /* namespace opflexagent */ + +#endif /* OPFLEXAGENT_OUTOFBANDCONFIGSOURCE_H */ diff --git a/agent-ovs/lib/include/opflexagent/OutOfBandConfig.h b/agent-ovs/lib/include/opflexagent/OutOfBandConfig.h new file mode 100644 index 000000000..e061a0ce0 --- /dev/null +++ b/agent-ovs/lib/include/opflexagent/OutOfBandConfig.h @@ -0,0 +1,24 @@ +/* -*- C++ -*-; c-basic-offset: 4; indent-tabs-mode: nil */ +/* + * Include file for out of band config + * + * Copyright (c) 2020 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +#pragma once +#ifndef OPFLEXAGENT_OUTOFBANDCONFIG_H +#define OPFLEXAGENT_OUTOFBANDCONFIG_H + +namespace opflexagent { + class OutOfBandConfigSpec { + public: + OutOfBandConfigSpec(long intvl):tunnelEpAdvInterval(intvl) {}; + long tunnelEpAdvInterval; + }; +} /* namespace opflexagent */ + +#endif /* OPFLEXAGENT_OUTOFBANDCONFIG_H */ diff --git a/agent-ovs/lib/include/opflexagent/TunnelEpManager.h b/agent-ovs/lib/include/opflexagent/TunnelEpManager.h index 4a4d2b53c..1bdc14844 100644 --- a/agent-ovs/lib/include/opflexagent/TunnelEpManager.h +++ b/agent-ovs/lib/include/opflexagent/TunnelEpManager.h @@ -138,6 +138,14 @@ class TunnelEpManager : private boost::noncopyable { return (uuid == tunnelEpUUID); } + /** + * Get TunnelEp's UUID + * @return TunnelEp's UUID + */ + std::string getTunnelEpUUID() { + return tunnelEpUUID; + } + private: Agent* agent; Renderer* renderer; diff --git a/agent-ovs/opflex-agent-ovs.conf.in b/agent-ovs/opflex-agent-ovs.conf.in index 5ad9c37aa..cffd06888 100644 --- a/agent-ovs/opflex-agent-ovs.conf.in +++ b/agent-ovs/opflex-agent-ovs.conf.in @@ -219,6 +219,11 @@ // Default: no drop log service "filesystem": ["DEFAULT_DROP_LOG_DIR"] }, + + "out-of-band-config-sources": { + // Default: no out of band config + "filesystem": ["DEFAULT_OOB_CONFIG_DIR"] + }, // Files system to manage Host Agent faults "host-agent-fault-sources": { diff --git a/agent-ovs/ovs/AdvertManager.cpp b/agent-ovs/ovs/AdvertManager.cpp index d6e3cc1df..7eb3d64a6 100644 --- a/agent-ovs/ovs/AdvertManager.cpp +++ b/agent-ovs/ovs/AdvertManager.cpp @@ -673,8 +673,6 @@ void AdvertManager::sendTunnelEpRarp(const string& uuid) { if (error < 0) { LOG(ERROR) << "Could not send tunnel advertisement: " << error; - } else { - LOG(DEBUG) << "Sent RARP advertisement for TunnelEp: " << tunnelMac << " " << tunnelIp; } close(sockfd); #endif @@ -744,8 +742,6 @@ void AdvertManager::sendTunnelEpGarp(const string& uuid) { if (error < 0) { LOG(ERROR) << "Could not send tunnel advertisement: " << error; - } else { - LOG(DEBUG) << "Sent GARP advertisement for TunnelEp: " << tunnelMac << " " << tunnelIp; } close(sockfd); #endif @@ -791,7 +787,7 @@ void AdvertManager::scheduleTunnelEpAdv(const std::string& uuid) { if (tunnelEpAdvTimer && (tunnelEndpointAdv != EPADV_DISABLED)) { #ifdef __linux__ - LOG(DEBUG) << "Scheduling Tunnel Ep advertisement"; + LOG(DEBUG) << "Scheduling Tunnel Ep advertisement with interval " << tunnelEpAdvInterval; unique_lock guard(tunnelep_mutex); pendingTunnelEps[uuid] = 5; doScheduleTunnelEpAdv(); @@ -801,4 +797,26 @@ void AdvertManager::scheduleTunnelEpAdv(const std::string& uuid) { } } +void AdvertManager::restartTunnelEndpointAdv(const std::string& uuid) { + #ifdef __linux__ + + unique_lock guard(tunnelep_mutex); + try { + if(tunnelEpAdvTimer) { + tunnelEpAdvTimer->cancel(); + } + } catch(const std::exception &e) { + LOG(WARNING) << "Failed to cancel advertisement timer: " << e.what(); + } + tunnelEpAdvTimer.reset(new deadline_timer(*ioService)); + if (tunnelEndpointAdv != EPADV_DISABLED) { + LOG(DEBUG) << "Scheduling Tunnel Ep advertisement with interval " << tunnelEpAdvInterval; + pendingTunnelEps[uuid] = 5; + doScheduleTunnelEpAdv(); + } + #else + LOG(ERROR) << "Tunnel advertisement not supported for non-linux platforms"; + #endif +} + } /* namespace opflexagent */ diff --git a/agent-ovs/ovs/IntFlowManager.cpp b/agent-ovs/ovs/IntFlowManager.cpp index e6f41f08d..67fa1a0b9 100644 --- a/agent-ovs/ovs/IntFlowManager.cpp +++ b/agent-ovs/ovs/IntFlowManager.cpp @@ -346,6 +346,16 @@ void IntFlowManager::setEndpointAdv(AdvertManager::EndpointAdvMode mode, advertManager.enableTunnelEndpointAdv(tunnelMode, tunnelAdvIntvl); } +void IntFlowManager::restartTunnelEndpointAdv(AdvertManager::EndpointAdvMode tunnelMode, + uint64_t tunnelAdvIntvl) { + advertManager.enableTunnelEndpointAdv(tunnelMode, tunnelAdvIntvl); + string uplinkIface; + tunnelEpManager.getUplinkIface(uplinkIface); + if(!uplinkIface.empty()) { + advertManager.restartTunnelEndpointAdv(tunnelEpManager.getTunnelEpUUID()); + } +} + void IntFlowManager::setMulticastGroupFile(const string& mcastGroupFile) { this->mcastGroupFile = mcastGroupFile; } diff --git a/agent-ovs/ovs/OVSRenderer.cpp b/agent-ovs/ovs/OVSRenderer.cpp index fe8fe6bc0..83b57aefa 100644 --- a/agent-ovs/ovs/OVSRenderer.cpp +++ b/agent-ovs/ovs/OVSRenderer.cpp @@ -254,7 +254,7 @@ void OVSRenderer::start() { ovsdbConnection->start(); ovsdbConnection->connect(); - //Register with extraconfig manager for drop prune handling + //Register with extraconfig manager for drop prune and out of band config handling getAgent().getExtraConfigManager().registerListener(this); if (getAgent().isFeatureEnabled(FeatureList::ERSPAN)) @@ -670,6 +670,18 @@ void OVSRenderer::packetDropPruneConfigUpdated(const std::string& filterName) { pktLogger.updatePruneFilter(filterName, filter); } +void OVSRenderer::outOfBandConfigUpdated(std::shared_ptr &sptr) { + using namespace std; + using namespace boost; + if (!sptr) { + intFlowManager.restartTunnelEndpointAdv(tunnelEndpointAdvMode, + tunnelEndpointAdvIntvl); + return; + } + intFlowManager.restartTunnelEndpointAdv(AdvertManager::EPADV_GARP_RARP_BROADCAST, + sptr->tunnelEpAdvInterval); +} + void OVSRenderer::stopPacketLogger() { pktLogger.stopListener(); pktLogger.stopExporter(); diff --git a/agent-ovs/ovs/include/AccessFlowManager.h b/agent-ovs/ovs/include/AccessFlowManager.h index c03378e75..ae266b411 100644 --- a/agent-ovs/ovs/include/AccessFlowManager.h +++ b/agent-ovs/ovs/include/AccessFlowManager.h @@ -88,6 +88,9 @@ class AccessFlowManager : public EndpointListener, virtual void packetDropFlowConfigUpdated(const opflex::modb::URI& dropFlowCfgURI); virtual void packetDropPruneConfigUpdated(const std::string& filterName) { /*Do nothing as of now*/ } + virtual void outOfBandConfigUpdated(std::shared_ptr &oobSptr) { + /*Do nothing as of now*/ + } ///@} /* Interface: EndpointListener */ diff --git a/agent-ovs/ovs/include/AdvertManager.h b/agent-ovs/ovs/include/AdvertManager.h index 1c14da4bf..a5325cc55 100644 --- a/agent-ovs/ovs/include/AdvertManager.h +++ b/agent-ovs/ovs/include/AdvertManager.h @@ -105,6 +105,7 @@ class AdvertManager : private boost::noncopyable { { tunnelEndpointAdv = tunnelMode; tunnelEpAdvInterval = delay;} + void restartTunnelEndpointAdv(const std::string& uuid); /** * Module start */ diff --git a/agent-ovs/ovs/include/EndpointTenantMapper.h b/agent-ovs/ovs/include/EndpointTenantMapper.h index e1c00e410..993ae830d 100644 --- a/agent-ovs/ovs/include/EndpointTenantMapper.h +++ b/agent-ovs/ovs/include/EndpointTenantMapper.h @@ -99,6 +99,7 @@ class EndpointTenantMapper : public EndpointListener, virtual void packetDropLogConfigUpdated(const opflex::modb::URI& dropLogCfgURI); virtual void packetDropFlowConfigUpdated(const opflex::modb::URI& dropFlowCfgURI){} virtual void packetDropPruneConfigUpdated(const std::string& pruneFilter){} + virtual void outOfBandConfigUpdated(std::shared_ptr &oobSptr) {} /* Interface: PortStatusListener */ virtual void portStatusUpdate(const std::string& portName, diff --git a/agent-ovs/ovs/include/IntFlowManager.h b/agent-ovs/ovs/include/IntFlowManager.h index f14421475..0e0b4358a 100644 --- a/agent-ovs/ovs/include/IntFlowManager.h +++ b/agent-ovs/ovs/include/IntFlowManager.h @@ -209,6 +209,15 @@ class IntFlowManager : public SwitchStateHandler, void setEndpointAdv(AdvertManager::EndpointAdvMode mode, AdvertManager::EndpointAdvMode tunnelMode, uint64_t tunnelAdvIntvl=600); + + /** + * Enable or disable tunnel endpoint advertisements and set the mode + * + * @param tunnelMode the tunnel endpoint advertisement mode + * @param tunnelAdvIntvl the tunnel endpoint advertisement interval + */ + void restartTunnelEndpointAdv(AdvertManager::EndpointAdvMode tunnelMode, + uint64_t tunnelAdvIntvl); /** * Set the multicast group file @@ -302,6 +311,9 @@ class IntFlowManager : public SwitchStateHandler, virtual void packetDropPruneConfigUpdated(const std::string& pruneFilter){ /*Do nothing as of now*/ } + virtual void outOfBandConfigUpdated(std::shared_ptr &oobSptr) { + /*Do nothing as of now*/ + } /* Interface: LearningBridgeListener */ virtual void lbIfaceUpdated(const std::string& uuid); diff --git a/agent-ovs/ovs/include/OVSRenderer.h b/agent-ovs/ovs/include/OVSRenderer.h index 6280b95d9..541e63cfe 100644 --- a/agent-ovs/ovs/include/OVSRenderer.h +++ b/agent-ovs/ovs/include/OVSRenderer.h @@ -29,6 +29,7 @@ #include "PacketLogHandler.h" #include "QosRenderer.h" #include "NatStatsManager.h" +#include #include @@ -163,6 +164,7 @@ class OVSRenderer : public Renderer, virtual void packetDropLogConfigUpdated(const opflex::modb::URI& dropLogCfgURI){} virtual void packetDropFlowConfigUpdated(const opflex::modb::URI& dropFlowCfgURI){} virtual void packetDropPruneConfigUpdated(const std::string& pruneFilter); + virtual void outOfBandConfigUpdated(std::shared_ptr &sptr); /** * Start packet logger diff --git a/genie/MODEL/OWNERSHIP/own.mdl b/genie/MODEL/OWNERSHIP/own.mdl index c18fb133c..63fe690e0 100644 --- a/genie/MODEL/OWNERSHIP/own.mdl +++ b/genie/MODEL/OWNERSHIP/own.mdl @@ -99,4 +99,5 @@ owner[policyelement] class[observer/DropLogConfig] class[observer/DropFlowConfig] class[observer/DropPruneConfig] + class[observer/OutOfBandConfig] } diff --git a/genie/MODEL/SPECIFIC/OBSERVER/config.mdl b/genie/MODEL/SPECIFIC/OBSERVER/config.mdl index 1e7393a58..c5108fd27 100644 --- a/genie/MODEL/SPECIFIC/OBSERVER/config.mdl +++ b/genie/MODEL/SPECIFIC/OBSERVER/config.mdl @@ -61,6 +61,7 @@ module[observer] } } } + class[DropPruneConfig; super=policy/Definition; concrete; @@ -90,4 +91,23 @@ module[observer] } } } + + class[OutOfBandConfig; + super=policy/Definition; + concrete; + ] + { + contained + { + parent[class=observer/OutOfBandConfigUniverse] + } + member[tunnelEpAdvertisementInterval; type=scalar/UInt64] + named + { + parent[class=*;] + { + component[prefix="oob-cfg"] + } + } + } } diff --git a/genie/MODEL/SPECIFIC/OBSERVER/universe.mdl b/genie/MODEL/SPECIFIC/OBSERVER/universe.mdl index 5902764c0..ffc3065a6 100644 --- a/genie/MODEL/SPECIFIC/OBSERVER/universe.mdl +++ b/genie/MODEL/SPECIFIC/OBSERVER/universe.mdl @@ -71,4 +71,18 @@ module[observer] } } } + + class[OutOfBandConfigUniverse; + super=observer/Universe; + concrete; + ] + { + named + { + parent[class=*;] + { + component[prefix=outOfBandCfg;] + } + } + } }