LCOV - code coverage report
Current view: top level - bgp - bgp_config_ifmap.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 47 47 100.0 %
Date: 2026-11-09 02:10:49 Functions: 41 41 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
       3             :  * Copyright Contributors to the OpenSDN project
       4             :  */
       5             : 
       6             : #ifndef SRC_BGP_BGP_CONFIG_IFMAP_H__
       7             : #define SRC_BGP_BGP_CONFIG_IFMAP_H__
       8             : 
       9             : #include <boost/function.hpp>
      10             : #include <boost/scoped_ptr.hpp>
      11             : 
      12             : #include <map>
      13             : #include <set>
      14             : #include <string>
      15             : #include <utility>
      16             : #include <vector>
      17             : 
      18             : #include "base/task_trigger.h"
      19             : #include "base/util.h"
      20             : #include "base/index_map.h"
      21             : #include "bgp/bgp_config.h"
      22             : #include "ifmap/ifmap_config_listener.h"
      23             : #include "ifmap/ifmap_node_proxy.h"
      24             : 
      25             : #define EVPN_ES_IMPORT_ROUTE_TARGET_AS2 (BGP_RTGT_MIN_ID_AS2 - 1) // 7999999
      26             : #define EVPN_ES_IMPORT_ROUTE_TARGET_AS4 (BGP_RTGT_MIN_ID_AS4 - 1) // 7999
      27             : 
      28             : class BgpConfigListener;
      29             : typedef struct IFMapConfigListener::ConfigDelta BgpConfigDelta;
      30             : class BgpIfmapConfigManager;
      31             : class BgpIfmapInstanceConfig;
      32             : class BgpIfmapRoutingPolicyConfig;
      33             : class BgpServer;
      34             : class DB;
      35             : class DBGraph;
      36             : 
      37             : namespace autogen {
      38             : class BgpPeering;
      39             : class BgpRouter;
      40             : class RoutingInstance;
      41             : class RoutingPolicy;
      42             : class RoutingPolicyRoutingInstance;
      43             : struct BgpRouterParams;
      44             : }
      45             : 
      46             : //
      47             : // A BgpIfmapPeeringConfig corresponds to a bgp-peering link in the
      48             : // schema. Since a bgp-peering is a link with attributes, it's
      49             : // represented as a node in the configuration database. There's a
      50             : // single BgpIfmapPeeringConfig between a given pair of bgp-routers in
      51             : // a particular routing-instance.
      52             : //
      53             : // A bgp-peering link is represented in IFMap DB using a autogen::BgpPeering
      54             : // object. This object has a vector of autogen::BgpSessions, with each entry
      55             : // corresponding to a single session. A BgpNeighborConfig is created for each
      56             : // session.
      57             : //
      58             : // The NeighborMap keeps pointers to all the BgpNeighborConfig objects
      59             : // for a BgpIfmapPeeringConfig. There's typically just a single entry
      60             : // in this map, but we allow for multiple entries if there's more than
      61             : // 1 autogen::BgpSesssion in the autogen::BgpPeering.
      62             : //
      63             : // A BgpIfmapPeeringConfig gets created/updated/deleted when the
      64             : // IFMapNode for the bgp-peering is created/updated/deleted.
      65             : //
      66             : // There's no direct operational object corresponding to
      67             : // BgpIfmapPeeringConfig. A BgpIfmapPeeringConfig results in the
      68             : // creation of one or more BgpNeighborConfigs each of which is
      69             : // associated with a BgpPeer.
      70             : //
      71             : // The instance_ field is a back pointer to the BgpInstanceConfig object for
      72             : // the routing-instance to which this bgp-peering belongs.
      73             : // The IFMapNodeProxy maintains a reference to the IFMapNode object for the
      74             : // bgp-peering in the ifmap metadata table.
      75             : //
      76             : class BgpIfmapPeeringConfig {
      77             : public:
      78             :     typedef std::map<std::string, BgpNeighborConfig *> NeighborMap;
      79             : 
      80             :     explicit BgpIfmapPeeringConfig(BgpIfmapInstanceConfig *instance);
      81             :     ~BgpIfmapPeeringConfig();
      82             : 
      83             :     void SetNodeProxy(IFMapNodeProxy *proxy);
      84             :     void Update(BgpIfmapConfigManager *manager,
      85             :                 const autogen::BgpPeering *peering);
      86             :     void Delete(BgpIfmapConfigManager *manager);
      87             : 
      88             :     static bool GetRouterPair(DBGraph *db_graph, const std::string  &localname,
      89             :                               IFMapNode *node,
      90             :                               std::pair<IFMapNode *, IFMapNode *> *pair);
      91             : 
      92       18575 :     const IFMapNode *node() const { return node_proxy_.node(); }
      93        8554 :     BgpIfmapInstanceConfig *instance() { return instance_; }
      94           6 :     const BgpIfmapInstanceConfig *instance() const { return instance_; }
      95       19961 :     std::string name() const { return name_; }
      96        1548 :     size_t size() const { return neighbors_.size(); }
      97       18097 :     const autogen::BgpPeering *bgp_peering() const {
      98       18097 :         return bgp_peering_.get();
      99             :     }
     100             : 
     101             : private:
     102             :     void BuildNeighbors(BgpIfmapConfigManager *manager,
     103             :                         const autogen::BgpRouter *local_rt_config,
     104             :                         const std::string &peername,
     105             :                         const autogen::BgpRouter *remote_rt_config,
     106             :                         const autogen::BgpPeering *peering, NeighborMap *map);
     107             : 
     108             :     BgpIfmapInstanceConfig *instance_;
     109             :     std::string name_;
     110             :     IFMapNodeProxy node_proxy_;
     111             :     NeighborMap neighbors_;
     112             :     boost::intrusive_ptr<const autogen::BgpPeering> bgp_peering_;
     113             : 
     114             :     DISALLOW_COPY_AND_ASSIGN(BgpIfmapPeeringConfig);
     115             : };
     116             : 
     117             : //
     118             : // Represents a local IFMap bgp-router node in a specific routing-instance.
     119             : //
     120             : // A BgpProtocolConfig is created/updated/deleted when the IFMapNode for the
     121             : // bgp-router is created/updated/deleted.
     122             : //
     123             : // The instance_ field is a back pointer to the BgpInstanceConfig object for
     124             : // the routing-instance to which this bgp-router belongs.
     125             : // The IFMapNodeProxy maintains a reference to the IFMapNode object for the
     126             : // bgp-router in the ifmap bgp-router table.
     127             : //
     128             : class BgpIfmapProtocolConfig {
     129             : public:
     130             :     explicit BgpIfmapProtocolConfig(BgpIfmapInstanceConfig *instance);
     131             :     ~BgpIfmapProtocolConfig();
     132             : 
     133             :     void SetNodeProxy(IFMapNodeProxy *proxy);
     134             : 
     135             :     void Update(BgpIfmapConfigManager *manager,
     136             :                 const autogen::BgpRouter *router);
     137             :     void Delete(BgpIfmapConfigManager *manager);
     138             : 
     139             :     const std::string &InstanceName() const;
     140             : 
     141             :     const autogen::BgpRouterParams &router_params() const;
     142       61642 :     const autogen::BgpRouter *bgp_router() const { return bgp_router_.get(); }
     143             : 
     144        8616 :     IFMapNode *node() { return node_proxy_.node(); }
     145       18032 :     const BgpIfmapInstanceConfig *instance() { return instance_; }
     146             : 
     147      471334 :     const BgpProtocolConfig *protocol_config() const { return &data_; }
     148             : 
     149             : private:
     150             :     BgpIfmapInstanceConfig *instance_;
     151             :     IFMapNodeProxy node_proxy_;
     152             :     BgpProtocolConfig data_;
     153             :     boost::intrusive_ptr<const autogen::BgpRouter> bgp_router_;
     154             : 
     155             :     DISALLOW_COPY_AND_ASSIGN(BgpIfmapProtocolConfig);
     156             : };
     157             : 
     158             : //
     159             : // Internal representation of routing-instance.
     160             : //
     161             : // A BgpInstanceConfig causes creation of a RoutingInstance. RoutingInstance
     162             : // has a pointer to the BgpInstanceConfig. This pointer gets invalidated and
     163             : // cleared when the RoutingInstance is undergoing deletion.
     164             : //
     165             : // The IFMapNodeProxy maintains a reference to the IFMapNode object for the
     166             : // routing-instance in the ifmap routing-instance table.
     167             : //
     168             : // The BgpInstanceConfig for the master instance is manually created when the
     169             : // BgpConfigManager is initialized. It gets deleted when the BgpConfigManager
     170             : // is terminated.
     171             : //
     172             : // For other routing-instances, a BgpInstanceConfig is created when we first
     173             : // see the IFMapNode for the routing-instance or when we see the IFMapNode for
     174             : // the local bgp-router in the routing-instance.
     175             : //
     176             : // BgpInstanceConfig is deleted only when all references to it are
     177             : // gone. The IFMapNode for the routing-instance must be deleted, any
     178             : // BgpProtcolConfig for the local bgp-router in the routing-instance
     179             : // must be deleted and all the BgpNeighborConfigs and
     180             : // BgpIfmapPeeringConfigs in the routing-instance must be deleted.
     181             : //
     182             : // The protocol_ field is a pointer to the BgpProtocolConfig object
     183             : // for the local bgp-router object, if any, in the routing-instance.
     184             : // The NeighborMap keeps pointers to all the BgpNeighborConfig objects
     185             : // in a BgpInstanceConfig.  The PeeringMap keeps pointers to all the
     186             : // BgpIfmapPeeringConfig objects in the BgpInstanceConfig.
     187             : //
     188             : class BgpIfmapInstanceConfig {
     189             : public:
     190             :     typedef BgpInstanceConfig::RouteTargetList RouteTargetList;
     191             :     typedef std::map<std::string,
     192             :         BgpNeighborConfig *> NeighborMap;
     193             :     typedef std::map<std::string,
     194             :         BgpIfmapPeeringConfig *> PeeringMap;
     195             :     typedef std::map<std::string,
     196             :         BgpIfmapRoutingPolicyConfig *> RouitngPolicyMap;
     197             : 
     198             :     explicit BgpIfmapInstanceConfig(const std::string &name);
     199             :     ~BgpIfmapInstanceConfig();
     200             : 
     201             :     void SetNodeProxy(IFMapNodeProxy *proxy);
     202             : 
     203             :     void Update(BgpIfmapConfigManager *manager,
     204             :                 const autogen::RoutingInstance *config);
     205             : 
     206             :     // The corresponding if-map node has been deleted.
     207             :     void ResetConfig();
     208             :     bool DeleteIfEmpty(BgpConfigManager *manager);
     209             : 
     210      247992 :     const BgpIfmapProtocolConfig *protocol_config() const {
     211      247992 :         return protocol_.get();
     212             :     }
     213        9181 :     BgpIfmapProtocolConfig *protocol_config_mutable() {
     214        9181 :         return protocol_.get();
     215             :     }
     216             :     BgpIfmapProtocolConfig *LocateProtocol();
     217             :     void ResetProtocol();
     218             : 
     219             :     void AddNeighbor(BgpConfigManager *manager, BgpNeighborConfig *neighbor);
     220             :     void ChangeNeighbor(BgpConfigManager *manager, BgpNeighborConfig *neighbor);
     221             :     void DeleteNeighbor(BgpConfigManager *manager, BgpNeighborConfig *neighbor);
     222             :     const BgpNeighborConfig *FindNeighbor(const std::string &name) const;
     223             : 
     224             :     BgpConfigManager::NeighborMapRange NeighborMapItems() const;
     225             : 
     226          12 :     const NeighborMap &neighbors() const { return neighbors_; }
     227           7 :     const PeeringMap &peerings() const { return peerings_; }
     228             : 
     229             :     void AddPeering(BgpIfmapPeeringConfig *peering);
     230             :     void DeletePeering(BgpIfmapPeeringConfig *peering);
     231             : 
     232      103940 :     IFMapNode *node() { return node_proxy_.node(); }
     233      251502 :     const std::string &name() const { return name_; }
     234             : 
     235      394570 :     BgpInstanceConfig *instance_config() { return &data_; }
     236             :     const BgpInstanceConfig *instance_config() const { return &data_; }
     237             : 
     238      285462 :     const RouteTargetList &import_list() const {
     239      285462 :         return data_.import_list();
     240             :     }
     241      285462 :     const RouteTargetList &export_list() const {
     242      285462 :         return data_.export_list();
     243             :     }
     244      152360 :     const std::string &virtual_network() const {
     245      152360 :         return data_.virtual_network();
     246             :     }
     247      152360 :     int virtual_network_index() const { return data_.virtual_network_index(); }
     248             :     void AddRoutingPolicy(BgpIfmapRoutingPolicyConfig *rtp);
     249             :     void DeleteRoutingPolicy(BgpIfmapRoutingPolicyConfig *rtp);
     250       50601 :     void set_index(int index) { index_ = index; };
     251      356273 :     int index() const { return index_; }
     252             :     std::string GetVitFromId(uint32_t identifier) const;
     253             :     std::string GetESRouteTarget(uint32_t as) const;
     254             :     void InsertVitAndESRTargetInImportList(BgpIfmapConfigManager *manager,
     255             :             BgpInstanceConfig::RouteTargetList& import_list);
     256             :     void ProcessIdentifierUpdate(uint32_t new_id, uint32_t old_id);
     257             :     void ProcessASUpdate(uint32_t new_as, uint32_t old_as);
     258             : 
     259             : private:
     260             :     friend class BgpConfigManagerTest;
     261             : 
     262             :     std::string name_;
     263             :     IFMapNodeProxy node_proxy_;
     264             :     BgpInstanceConfig data_;
     265             :     int index_;
     266             :     boost::scoped_ptr<BgpIfmapProtocolConfig> protocol_;
     267             :     NeighborMap neighbors_;
     268             :     PeeringMap peerings_;
     269             :     RouitngPolicyMap routing_policies_;
     270             : 
     271             :     DISALLOW_COPY_AND_ASSIGN(BgpIfmapInstanceConfig);
     272             : };
     273             : 
     274             : class BgpIfmapRoutingPolicyLinkConfig {
     275             : public:
     276             :     explicit BgpIfmapRoutingPolicyLinkConfig(BgpIfmapInstanceConfig *rti,
     277             :         BgpIfmapRoutingPolicyConfig *rtp);
     278             :     ~BgpIfmapRoutingPolicyLinkConfig();
     279             : 
     280             :     void SetNodeProxy(IFMapNodeProxy *proxy);
     281             : 
     282         282 :     const IFMapNode *node() const { return node_proxy_.node(); }
     283             :     std::string name() const { return name_; }
     284             :     const autogen::RoutingPolicyRoutingInstance *routing_policy_link() const {
     285             :         return ri_rp_link_.get();
     286             :     }
     287             :     static bool GetInstancePolicyPair(DBGraph *graph, IFMapNode *node,
     288             :         std::pair<IFMapNode *, IFMapNode *> *pair);
     289         303 :     BgpIfmapInstanceConfig *instance() { return instance_; }
     290         303 :     BgpIfmapRoutingPolicyConfig *policy() { return policy_; }
     291             : 
     292             :     void Update(BgpIfmapConfigManager *manager,
     293             :                 const autogen::RoutingPolicyRoutingInstance *ri_rp);
     294             :     void Delete(BgpIfmapConfigManager *manager);
     295             : 
     296             : private:
     297             :     BgpIfmapInstanceConfig *instance_;
     298             :     BgpIfmapRoutingPolicyConfig *policy_;
     299             :     std::string name_;
     300             :     IFMapNodeProxy node_proxy_;
     301             :     boost::intrusive_ptr<
     302             :         const autogen::RoutingPolicyRoutingInstance> ri_rp_link_;
     303             : 
     304             :     DISALLOW_COPY_AND_ASSIGN(BgpIfmapRoutingPolicyLinkConfig);
     305             : };
     306             : 
     307             : class BgpIfmapRoutingPolicyConfig {
     308             : public:
     309             :     typedef std::map<std::string, BgpIfmapInstanceConfig *> InstanceMap;
     310             :     explicit BgpIfmapRoutingPolicyConfig(const std::string &name);
     311             :     ~BgpIfmapRoutingPolicyConfig();
     312             : 
     313             :     void SetNodeProxy(IFMapNodeProxy *proxy);
     314             : 
     315             :     // The corresponding if-map node has been deleted.
     316             :     void ResetConfig();
     317             :     void Delete(BgpConfigManager *manager);
     318             :     bool DeleteIfEmpty(BgpConfigManager *manager);
     319             : 
     320             :     void Update(BgpIfmapConfigManager *manager,
     321             :                 const autogen::RoutingPolicy *policy);
     322             : 
     323         367 :     IFMapNode *node() { return node_proxy_.node(); }
     324         297 :     const std::string &name() const { return name_; }
     325             : 
     326         571 :     BgpRoutingPolicyConfig *routing_policy_config() { return &data_; }
     327             :     const BgpRoutingPolicyConfig *routing_policy_config() const {
     328             :         return &data_;
     329             :     }
     330             : 
     331             :     void AddInstance(BgpIfmapInstanceConfig *rti);
     332             :     void RemoveInstance(BgpIfmapInstanceConfig *rti);
     333             : 
     334             : private:
     335             :     friend class BgpConfigManagerTest;
     336             : 
     337             :     std::string name_;
     338             :     IFMapNodeProxy node_proxy_;
     339             :     BgpRoutingPolicyConfig data_;
     340             :     boost::intrusive_ptr<const autogen::RoutingPolicy> routing_policy_;
     341             :     InstanceMap instances_;
     342             : 
     343             :     DISALLOW_COPY_AND_ASSIGN(BgpIfmapRoutingPolicyConfig);
     344             : };
     345             : 
     346             : class BgpIfmapGlobalSystemConfig {
     347             : public:
     348         840 :     const BgpGlobalSystemConfig *config() const { return &data_; }
     349             :     bool Update(BgpIfmapConfigManager *manager,
     350             :                 const autogen::GlobalSystemConfig *system);
     351             : 
     352             : private:
     353             :     BgpGlobalSystemConfig data_;
     354             : };
     355             : 
     356             : class BgpIfmapGlobalQosConfig {
     357             : public:
     358           9 :     const BgpGlobalQosConfig *config() const { return &data_; }
     359             :     bool Update(BgpIfmapConfigManager *manager,
     360             :                 const autogen::GlobalQosConfig *qos);
     361             : 
     362             : private:
     363             :     BgpGlobalQosConfig data_;
     364             : };
     365             : 
     366             : //
     367             : // BgpConfigData contains all the configuration data that's relevant to a
     368             : // node. The BgpConfigManager has a pointer to BgpConfigData.
     369             : //
     370             : // The IfmapInstanceMap stores pointers to the BgpIfmapInstanceConfigs
     371             : // that have been created for all the routing-instances.
     372             : // The IfmapPeeringMap stores pointers to the BgpIfmapPeeringConfigs
     373             : // that have been created for all the bgp-peerings.
     374             : // The IfmapRoutingPolicyMap stores pointers to the BgpIfmapRoutingPolicyConfig
     375             : // that have been created for all the routing-policy.
     376             : //
     377             : class BgpIfmapConfigData {
     378             : public:
     379             :     typedef BgpConfigManager::InstanceMap BgpInstanceMap;
     380             :     typedef BgpConfigManager::RoutingPolicyMap BgpRoutingPolicyMap;
     381             :     typedef IndexMap<std::string,
     382             :         BgpIfmapInstanceConfig, BitSet> IfmapInstanceMap;
     383             :     typedef std::map<std::string,
     384             :         BgpIfmapRoutingPolicyConfig *> IfmapRoutingPolicyMap;
     385             :     typedef std::map<std::string,
     386             :         BgpIfmapPeeringConfig *> IfmapPeeringMap;
     387             :     typedef std::map<std::string,
     388             :         BgpIfmapRoutingPolicyLinkConfig *> IfmapRoutingPolicyLinkMap;
     389             : 
     390             :     BgpIfmapConfigData();
     391             :     ~BgpIfmapConfigData();
     392             : 
     393             :     BgpIfmapInstanceConfig *LocateInstance(const std::string &name);
     394             :     void DeleteInstance(BgpIfmapInstanceConfig *rti);
     395             :     BgpIfmapInstanceConfig *FindInstance(const std::string &name);
     396             :     const BgpIfmapInstanceConfig *FindInstance(const std::string &name) const;
     397             : 
     398             :     // Routing Policy
     399             :     BgpIfmapRoutingPolicyConfig *LocateRoutingPolicy(const std::string &name);
     400             :     void DeleteRoutingPolicy(BgpIfmapRoutingPolicyConfig *rtp);
     401             :     BgpIfmapRoutingPolicyConfig *FindRoutingPolicy(const std::string &name);
     402             :     const BgpIfmapRoutingPolicyConfig *FindRoutingPolicy(
     403             :         const std::string &name) const;
     404             : 
     405             :     BgpIfmapPeeringConfig *CreatePeering(BgpIfmapInstanceConfig *rti,
     406             :         IFMapNodeProxy *proxy);
     407             :     void DeletePeering(BgpIfmapPeeringConfig *peer);
     408             :     BgpIfmapPeeringConfig *FindPeering(const std::string &name);
     409             :     const BgpIfmapPeeringConfig *FindPeering(const std::string &name) const;
     410           7 :     int PeeringCount() const { return peerings_.size(); }
     411             : 
     412             :     BgpIfmapRoutingPolicyLinkConfig *CreateRoutingPolicyLink(
     413             :         BgpIfmapInstanceConfig *rti, BgpIfmapRoutingPolicyConfig *rtp,
     414             :         IFMapNodeProxy *proxy);
     415             :     void DeleteRoutingPolicyLink(BgpIfmapRoutingPolicyLinkConfig *ri_rp_link);
     416             :     BgpIfmapRoutingPolicyLinkConfig *FindRoutingPolicyLink(
     417             :         const std::string &name);
     418             :     const BgpIfmapRoutingPolicyLinkConfig *FindRoutingPolicyLink(
     419             :         const std::string &name) const;
     420             : 
     421             :     BgpConfigManager::InstanceMapRange InstanceMapItems(
     422             :         const std::string &start_name = std::string()) const;
     423             :     BgpConfigManager::RoutingPolicyMapRange RoutingPolicyMapItems(
     424             :         const std::string &start_name = std::string()) const;
     425             : 
     426       51028 :     IfmapInstanceMap &instances() { return instances_; }
     427        9181 :     const IfmapPeeringMap &peerings() const { return peerings_; }
     428        1976 :     BgpIfmapGlobalSystemConfig *global_config() { return &global_config_; }
     429             :     const BgpIfmapGlobalSystemConfig *global_config() const {
     430             :         return &global_config_;
     431             :     }
     432          20 :     BgpIfmapGlobalQosConfig *global_qos() { return &global_qos_; }
     433             :     const BgpIfmapGlobalQosConfig *global_qos() const {
     434             :         return &global_qos_;
     435             :     }
     436             :     void ProcessIdentifierAndASUpdate(BgpIfmapConfigManager* manager,
     437             :         uint32_t new_id, uint32_t old_id, uint32_t new_as, uint32_t old_as);
     438             : 
     439             : private:
     440             :     IfmapInstanceMap instances_;
     441             :     BgpInstanceMap instance_config_map_;
     442             :     IfmapRoutingPolicyMap routing_policies_;
     443             :     BgpRoutingPolicyMap routing_policy_config_map_;
     444             :     IfmapPeeringMap peerings_;
     445             :     IfmapRoutingPolicyLinkMap ri_rp_links_;
     446             :     BgpIfmapGlobalSystemConfig global_config_;
     447             :     BgpIfmapGlobalQosConfig global_qos_;
     448             : 
     449             :     DISALLOW_COPY_AND_ASSIGN(BgpIfmapConfigData);
     450             : };
     451             : 
     452             : //
     453             : // This class is responsible for managing all bgp related configuration for
     454             : // a BgpServer. A BgpServer allocates an instance of a BgpConfigManager.
     455             : //
     456             : // BgpConfigManager listens to updates for IFMap objects which are relevant
     457             : // to BGP.  This is accomplished using an instance of the BgpConfigListener.
     458             : // The BgpConfigListener is used to build a ChangeList of BgpConfigDeltas
     459             : // that are then processed by the BgpConfigManager.
     460             : //
     461             : // Internal representations of interesting IFMap objects are generated and
     462             : // updated as BgpConfigDeltas are processed.  An instance of BgpConfigData
     463             : // is used to store the internal representations (the BgpXyzConfig classes).
     464             : //
     465             : // Notifications of changes to the internal representations are sent to the
     466             : // registered Observers. The BgpServer::ConfigUpdater is the only client that
     467             : // registers observers.
     468             : //
     469             : class BgpIfmapConfigManager : public BgpConfigManager,
     470             :     public IFMapConfigListener::ConfigManager {
     471             : public:
     472             :     explicit BgpIfmapConfigManager(BgpServer *server);
     473             :     virtual ~BgpIfmapConfigManager();
     474             : 
     475             :     void Initialize(DB *db, DBGraph *db_graph, const std::string &localname);
     476             : 
     477             :     /*
     478             :      * begin: BgpConfigManager Interface
     479             :      */
     480             :     virtual void Terminate();
     481      698481 :     virtual const std::string &localname() const { return localname_; }
     482             : 
     483             :     virtual InstanceMapRange InstanceMapItems(
     484             :         const std::string &start_name = std::string()) const;
     485             :     virtual RoutingPolicyMapRange RoutingPolicyMapItems(
     486             :         const std::string &start_name = std::string()) const;
     487             :     virtual NeighborMapRange NeighborMapItems(
     488             :         const std::string &instance_name) const;
     489             : 
     490             :     virtual int NeighborCount(const std::string &instance_name) const;
     491             :     virtual void ResetRoutingInstanceIndexBit(int index);
     492             : 
     493             :     virtual const BgpInstanceConfig *FindInstance(
     494             :         const std::string &name) const;
     495             :     virtual const BgpRoutingPolicyConfig *FindRoutingPolicy(
     496             :         const std::string &name) const;
     497             :     virtual const BgpProtocolConfig *GetProtocolConfig(
     498             :         const std::string &instance_name) const;
     499             :     virtual const BgpNeighborConfig *FindNeighbor(
     500             :         const std::string &instance_name, const std::string &name) const;
     501             :     // end: BgpConfigManager
     502             : 
     503             :     void DefaultBgpRouterParams(autogen::BgpRouterParams *param);
     504             :     void OnChange();
     505             : 
     506      396336 :     DB *database() { return db_; }
     507      153849 :     DBGraph *graph() { return db_graph_; }
     508           7 :     const BgpIfmapConfigData *config() const { return config_.get(); }
     509      192259 :     BgpIfmapConfigData *config() { return config_.get(); }
     510             :     void UpdateInstanceConfig(BgpIfmapInstanceConfig *rti,
     511             :             BgpConfigManager::EventType event);
     512             : 
     513             : private:
     514             :     friend class BgpConfigListenerTest;
     515             : 
     516             :     typedef std::vector<BgpConfigDelta> ChangeList;
     517             :     typedef std::map<std::string,
     518             :         boost::function<void(const BgpConfigDelta &)> >IdentifierMap;
     519             : 
     520             :     void IdentifierMapInit();
     521             :     void DefaultConfig();
     522             : 
     523             :     void ProcessChanges(const ChangeList &change_list);
     524             :     void ProcessRoutingInstance(const BgpConfigDelta &change);
     525             :     void ProcessRoutingPolicyLink(const BgpConfigDelta &change);
     526             :     void ProcessRoutingPolicy(const BgpConfigDelta &change);
     527             :     void ProcessBgpRouter(const BgpConfigDelta &change);
     528             :     void ProcessBgpProtocol(const BgpConfigDelta &change);
     529             :     void ProcessBgpPeering(const BgpConfigDelta &change);
     530             :     void ProcessGlobalSystemConfig(const BgpConfigDelta &delta);
     531             :     void ProcessGlobalQosConfig(const BgpConfigDelta &delta);
     532             : 
     533             :     bool ConfigHandler();
     534             : 
     535             :     static const int kConfigTaskInstanceId;
     536             : 
     537             :     DB *db_;
     538             :     DBGraph *db_graph_;
     539             :     std::string localname_;
     540             :     IdentifierMap id_map_;
     541             : 
     542             :     TaskTrigger trigger_;
     543             :     boost::scoped_ptr<BgpConfigListener> listener_;
     544             :     boost::scoped_ptr<BgpIfmapConfigData> config_;
     545             : 
     546             :     DISALLOW_COPY_AND_ASSIGN(BgpIfmapConfigManager);
     547             : };
     548             : 
     549             : #endif  // SRC_BGP_BGP_CONFIG_IFMAP_H_

Generated by: LCOV version 1.14