LCOV - code coverage report
Current view: top level - vnsw/agent/oper - config_manager.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 2 3 66.7 %
Date: 2026-06-04 02:06:09 Functions: 3 4 75.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2015 Juniper Networks, Inc. All rights reserved.
       3             :  */
       4             : #ifndef SRC_VNSW_AGENT_OPER_CONFIG_MANAGER_H_
       5             : #define SRC_VNSW_AGENT_OPER_CONFIG_MANAGER_H_
       6             : 
       7             : /*****************************************************************************
       8             :  * Implements change list for the oper table. Normally, the oper objects
       9             :  * process configuration thru IFNodeToReq or IFLinkToReq callback methods.
      10             :  *
      11             :  * In scaled environments there can be large number of invocations to
      12             :  * IFNodeToReq and IFLinkToReq APIs. The config processing routines are
      13             :  * written to act on the latest version of configuration. So, an invocation
      14             :  * of config routine will override all previous invocations. Ideally, we wnat
      15             :  * to invoke the config callbacks only once after all configuraiton is
      16             :  * received. However, we dont have any marker to identify end of configuration.
      17             :  *
      18             :  * The next best design we follow is to add the objects changed into a
      19             :  * change list. The change-list is run from a task-trigger. The list can
      20             :  * potentially compress multiple changes to a node
      21             :  *
      22             :  * The changelist should also take care of dependency between objects. For
      23             :  * example, VMInterface has reference to VirtualNetwork. So, the change list
      24             :  * for virtual-network should be invoked before VMInterface. The changelist
      25             :  * should take of all dependencies.
      26             :  *
      27             :  * The changelist is implemented to objects
      28             :  * security-group
      29             :  * virtual-machine-interface
      30             :  * logical-interfaces
      31             :  * physical-device-vn
      32             :  * physical-router
      33             :  *****************************************************************************/
      34             : 
      35             : #include <cmn/agent_cmn.h>
      36             : #include <cmn/agent_db.h>
      37             : #include <operdb_init.h>
      38             : #include <ifmap_dependency_manager.h>
      39             : 
      40             : class ConfigManagerNodeList;
      41             : class ConfigManagerDeviceVnList;
      42             : class IFMapAgentLinkTable;
      43             : 
      44             : class ConfigHelper {
      45             : public:
      46             :     ConfigHelper(const ConfigManager *mgr, const Agent *agent);
      47           4 :     virtual ~ConfigHelper() { }
      48             : 
      49             :     IFMapNode *GetOtherAdjacentNode(IFMapLink *link,
      50             :                                     IFMapNode *node);
      51             :     IFMapNode *FindLink(const char *type, IFMapNode *node);
      52             : 
      53             : private:
      54             :     const ConfigManager *mgr_;
      55             :     IFMapAgentLinkTable *link_table_;
      56             :     const Agent *agent_;
      57             :     DISALLOW_COPY_AND_ASSIGN(ConfigHelper);
      58             : };
      59             : 
      60             : class ConfigManager {
      61             : public:
      62             :     // Number of changelist entries to pick in one run
      63             :     const static uint32_t kIterationCount = 64;
      64             :     const static uint32_t kMinTimeout = 1;
      65             :     const static uint32_t kMaxTimeout = 10;
      66             : 
      67             :     ConfigManager(Agent *agent);
      68             :     virtual ~ConfigManager();
      69             : 
      70             :     void Init();
      71             :     int Run();
      72             :     bool TriggerRun();
      73             :     bool TimerRun();
      74             :     void Start();
      75             : 
      76             :     uint32_t Size() const;
      77             :     uint32_t ProcessCount() const;
      78           0 :     uint32_t timeout() const { return timeout_; }
      79             :     std::string ProfileInfo() const;
      80             : 
      81             :     void AddVmiNode(IFMapNode *node);
      82             :     uint32_t VmiNodeCount() const;
      83             : 
      84             :     void AddLogicalInterfaceNode(IFMapNode *node);
      85             :     void AddPhysicalInterfaceNode(IFMapNode *node);
      86             :     void AddSgNode(IFMapNode *node);
      87             :     void AddTagNode(IFMapNode *node);
      88             :     void AddVnNode(IFMapNode *node);
      89             :     void AddVrfNode(IFMapNode *node);
      90             :     void AddVmNode(IFMapNode *node);
      91             :     void AddQosConfigNode(IFMapNode *node);
      92             :     void AddQosQueueNode(IFMapNode *node);
      93             :     void AddForwardingClassNode(IFMapNode *node);
      94             :     void AddGlobalQosConfigNode(IFMapNode *node);
      95             :     void AddGlobalSystemConfigNode(IFMapNode *node);
      96             :     void AddNetworkIpamNode(IFMapNode *node);
      97             :     void AddVirtualDnsNode(IFMapNode *node);
      98             :     void AddGlobalVrouterNode(IFMapNode *node);
      99             :     void AddBgpRouterConfigNode(IFMapNode *node);
     100             :     void AddVirtualRouterNode(IFMapNode *node);
     101             :     uint32_t LogicalInterfaceNodeCount() const;
     102             :     void AddSecurityLoggingObjectNode(IFMapNode *node);
     103             :     void AddMulticastPolicyNode(IFMapNode *node);
     104             : 
     105             :     void AddPhysicalDeviceNode(IFMapNode *node);
     106             :     void AddPhysicalDeviceVn(const boost::uuids::uuid &dev,
     107             :                              const boost::uuids::uuid &vn);
     108             :     void DelPhysicalDeviceVn(const boost::uuids::uuid &dev,
     109             :                              const boost::uuids::uuid &vn);
     110             :     void AddHealthCheckServiceNode(IFMapNode *node);
     111             :     void AddBridgeDomainNode(IFMapNode *node);
     112             :     void AddPolicySetNode(IFMapNode *node);
     113             :     void AddProjectNode(IFMapNode *node);
     114             :     uint32_t PhysicalDeviceVnCount() const;
     115             :     bool CanUseNode(IFMapNode *node);
     116             :     bool CanUseNode(IFMapNode *node, IFMapAgentTable *table);
     117             :     bool SkipNode(IFMapNode *node);
     118             :     bool SkipNode(IFMapNode *node, IFMapAgentTable *table);
     119             :     IFMapNode * FindAdjacentIFMapNode(IFMapNode *node,
     120             :             const char *type);
     121             :     void NodeResync(IFMapNode *node);
     122             :     ConfigHelper *helper() const {return helper_.get();}
     123             : 
     124         943 :     Agent *agent() { return agent_; }
     125             : 
     126             : private:
     127             :     Agent *agent_;
     128             :     std::unique_ptr<TaskTrigger> trigger_;
     129             :     Timer *timer_;
     130             :     uint32_t timeout_;
     131             : 
     132             :     std::unique_ptr<ConfigManagerNodeList> vmi_list_;
     133             :     std::unique_ptr<ConfigManagerNodeList> physical_interface_list_;
     134             :     std::unique_ptr<ConfigManagerNodeList> logical_interface_list_;
     135             :     std::unique_ptr<ConfigManagerNodeList> device_list_;
     136             :     std::unique_ptr<ConfigManagerNodeList> sg_list_;
     137             :     std::unique_ptr<ConfigManagerNodeList> tag_list_;
     138             :     std::unique_ptr<ConfigManagerNodeList> vn_list_;
     139             :     std::unique_ptr<ConfigManagerNodeList> vrf_list_;
     140             :     std::unique_ptr<ConfigManagerNodeList> vm_list_;
     141             :     std::unique_ptr<ConfigManagerNodeList> hc_list_;
     142             :     std::unique_ptr<ConfigManagerNodeList> qos_config_list_;
     143             :     std::unique_ptr<ConfigManagerNodeList> qos_queue_list_;
     144             :     std::unique_ptr<ConfigManagerNodeList> forwarding_class_list_;
     145             :     std::unique_ptr<ConfigManagerDeviceVnList> device_vn_list_;
     146             :     std::unique_ptr<ConfigManagerNodeList> bridge_domain_list_;
     147             :     std::unique_ptr<ConfigManagerNodeList> slo_list_;
     148             :     std::unique_ptr<ConfigManagerNodeList> policy_set_list_;
     149             :     std::unique_ptr<ConfigManagerNodeList> mp_list_;
     150             : 
     151             :     // Lists of IFMapNodes without corresponding oper db-tables
     152             :     std::unique_ptr<ConfigManagerNodeList> global_vrouter_list_;
     153             :     std::unique_ptr<ConfigManagerNodeList> bgp_router_config_list_;
     154             :     std::unique_ptr<ConfigManagerNodeList> virtual_router_list_;
     155             :     std::unique_ptr<ConfigManagerNodeList> global_qos_config_list_;
     156             :     std::unique_ptr<ConfigManagerNodeList> network_ipam_list_;
     157             :     std::unique_ptr<ConfigManagerNodeList> virtual_dns_list_;
     158             :     std::unique_ptr<ConfigManagerNodeList> global_system_config_list_;
     159             :     std::unique_ptr<ConfigManagerNodeList> project_list_;
     160             : 
     161             :     uint64_t process_config_count_[kMaxTimeout + 1];
     162             :     boost::scoped_ptr<ConfigHelper> helper_;
     163             :     DISALLOW_COPY_AND_ASSIGN(ConfigManager);
     164             : };
     165             : 
     166             : #endif  // SRC_VNSW_AGENT_OPER_CONFIG_MANAGER_H_

Generated by: LCOV version 1.14