LCOV - code coverage report
Current view: top level - vnsw/agent/init - agent_init.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 0 376 0.0 %
Date: 2026-11-23 02:04:52 Functions: 0 57 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2014 Juniper Networks, Inc. All rights reserved.
       3             :  * Copyright Contributors to the OpenSDN project
       4             :  */
       5             : 
       6             : #include <cmn/agent_cmn.h>
       7             : 
       8             : #include <cmn/agent_factory.h>
       9             : #include <cmn/agent_stats.h>
      10             : #include <cmn/event_notifier.h>
      11             : #include <init/agent_param.h>
      12             : 
      13             : #include <cfg/cfg_init.h>
      14             : #include <vgw/cfg_vgw.h>
      15             : 
      16             : #include <oper/operdb_init.h>
      17             : #include <oper/sg.h>
      18             : #include <oper/vrf.h>
      19             : #include <oper/nexthop.h>
      20             : #include <oper/vn.h>
      21             : #include <oper/vm.h>
      22             : #include <oper/interface.h>
      23             : #include <oper/route_common.h>
      24             : #include <oper/agent_profile.h>
      25             : #include <oper/crypt_tunnel.h>
      26             : #include <filter/acl.h>
      27             : #include <oper/multicast_policy.h>
      28             : #include <controller/controller_init.h>
      29             : #include <resource_manager/resource_manager.h>
      30             : 
      31             : #include "agent_init.h"
      32             : 
      33           0 : AgentInit::AgentInit() :
      34           0 :     agent_(new Agent()), agent_param_(NULL), trigger_(),
      35           0 :     enable_controller_(true) {
      36           0 : }
      37             : 
      38           0 : AgentInit::~AgentInit() {
      39           0 :     stats_.reset();
      40           0 :     trigger_.reset();
      41           0 :     controller_.reset();
      42           0 :     cfg_.reset();
      43           0 :     oper_.reset();
      44           0 :     resource_manager_.reset();
      45           0 :     agent_->db()->ClearFactoryRegistry();
      46           0 :     agent_.reset();
      47           0 : }
      48             : 
      49             : /****************************************************************************
      50             :  * Initialization routines
      51             : ****************************************************************************/
      52           0 : void AgentInit::ProcessOptions
      53             :     (const std::string &config_file, const std::string &program_name) {
      54           0 :     agent_param_->Init(config_file, program_name);
      55           0 : }
      56             : 
      57           0 : int AgentInit::ModuleType() {
      58           0 :     return Module::VROUTER_AGENT;
      59             : }
      60             : 
      61           0 : string AgentInit::ModuleName() {
      62           0 :     Module::type module = static_cast<Module::type>(ModuleType());
      63           0 :     return g_vns_constants.ModuleNames.find(module)->second;
      64             : }
      65             : 
      66           0 : string AgentInit::AgentName() {
      67           0 :     return agent_param_->agent_name();
      68             : }
      69             : 
      70           0 : string AgentInit::InstanceId() {
      71           0 :     return g_vns_constants.INSTANCE_ID_DEFAULT;
      72             : }
      73             : 
      74           0 : void AgentInit::InitPlatform() {
      75           0 :     boost::system::error_code ec;
      76           0 :     Ip4Address ip = Ip4Address::from_string("127.0.0.1", ec);
      77           0 :     if (ec.value() != 0) {
      78           0 :         assert(0);
      79             :     }
      80             : 
      81           0 :     if (agent_param_->platform() == AgentParam::VROUTER_ON_NIC) {
      82           0 :         agent_->set_vrouter_server_ip(ip);
      83           0 :         agent_->set_vrouter_server_port(VROUTER_SERVER_PORT);
      84           0 :         agent_->set_pkt_interface_name("pkt0");
      85           0 :     } else if (agent_param_->platform() == AgentParam::VROUTER_ON_HOST_DPDK) {
      86           0 :         agent_->set_vrouter_server_ip(ip);
      87           0 :         agent_->set_vrouter_server_port(VROUTER_SERVER_PORT);
      88           0 :         agent_->set_pkt_interface_name("unix");
      89             :     }
      90           0 : }
      91             : 
      92             : // Start of Agent init.
      93             : // Trigger init in DBTable task context
      94           0 : int AgentInit::Start(Logging &logging) {
      95           0 :     agent_->set_task_scheduler(TaskScheduler::GetInstance());
      96           0 :     agent_->set_agent_init(this);
      97             : 
      98             :     // Init platform specific information
      99           0 :     InitPlatform();
     100             : 
     101             :     // Copy tunable parameters into agent_
     102           0 :     agent_->CopyConfig(agent_param_);
     103             : 
     104           0 :     string module_name = ModuleName();
     105           0 :     agent_->set_agent_name(AgentName());
     106           0 :     agent_->set_instance_id(InstanceId());
     107           0 :     agent_->set_module_type(ModuleType());
     108           0 :     agent_->set_module_name(module_name);
     109           0 :     std::vector<std::string> v_slo_destinations = agent_param_->
     110           0 :                                                    get_slo_destination();
     111           0 :     std::string log_property_file = agent_param_->log_property_file();
     112           0 :     if (log_property_file.size()) {
     113           0 :         logging.Init(log_property_file);
     114             :     }
     115             :     else {
     116           0 :         logging.Init(agent_param_->log_file(), agent_param_->log_file_size(),
     117           0 :                     agent_param_->log_files_count(), false,
     118           0 :                     agent_param_->syslog_facility(), module_name,
     119             :                     SandeshLevelTolog4Level(
     120           0 :                         Sandesh::StringToLevel(agent_param_->log_level())));
     121             :     }
     122           0 :     agent_param_->LogConfig();
     123             : 
     124             :     // Set the sample logger params
     125           0 :     Sandesh::set_logger_appender(agent_param_->log_file(),
     126           0 :                                  agent_param_->log_file_size(),
     127           0 :                                  agent_param_->log_files_count(),
     128           0 :                                  agent_param_->syslog_facility(),
     129           0 :                                  agent_param_->get_sample_destination(),
     130             :                                  module_name, true);
     131             :     // Set the SLO logger params
     132           0 :     Sandesh::set_logger_appender(agent_param_->log_file(),
     133           0 :                                  agent_param_->log_file_size(),
     134           0 :                                  agent_param_->log_files_count(),
     135           0 :                                  agent_param_->syslog_facility(),
     136           0 :                                  agent_param_->get_slo_destination(),
     137             :                                  module_name, false);
     138             : 
     139           0 :     Sandesh::set_send_to_collector_flags(agent_param_->get_sample_destination(),
     140           0 :                                          agent_param_->get_slo_destination());
     141             : 
     142           0 :     int ret = agent_param_->Validate();
     143           0 :     if (ret != 0) {
     144           0 :         return ret;
     145             :     }
     146             : 
     147           0 :     agent_param_->PostValidateLogConfig();
     148             : 
     149           0 :     int task_id = agent_->task_scheduler()->GetTaskId(AGENT_INIT_TASKNAME);
     150           0 :     trigger_.reset(new TaskTrigger(boost::bind(&AgentInit::InitBase, this),
     151           0 :                                    task_id, 0));
     152           0 :     trigger_->Set();
     153           0 :     return 0;
     154           0 : }
     155             : 
     156             : // Start init sequence
     157           0 : bool AgentInit::InitBase() {
     158           0 :     FactoryInit();
     159           0 :     InitLoggingBase();
     160           0 :     CreatePeersBase();
     161           0 :     CreateModulesBase();
     162           0 :     CreateResourceManager();
     163           0 :     return true;
     164             : }
     165             : 
     166           0 : void AgentInit::SetResourceManagerReady() {
     167           0 :     agent_->SetResourceManagerReady();
     168           0 :     CreateDBTablesBase();
     169           0 :     RegisterDBClientsBase();
     170           0 :     InitModulesBase();
     171           0 :     InitCollectorBase();
     172           0 :     CreateVrfBase();
     173           0 :     CreateNextHopsBase();
     174           0 :     CreateInterfacesBase();
     175           0 :     InitDoneBase();
     176             : 
     177           0 :     Init();
     178           0 :     agent_->set_init_done(true);
     179           0 :     ConnectToControllerBase();
     180           0 : }
     181             : 
     182           0 : void AgentInit::InitLoggingBase() {
     183           0 :     Sandesh::SetLoggingParams(agent_param_->log_local(),
     184           0 :                               agent_param_->log_category(),
     185           0 :                               agent_param_->log_level(),
     186             :                               false,
     187           0 :                               agent_param_->log_flow());
     188           0 :     InitLogging();
     189           0 : }
     190             : 
     191             : // Connect to collector specified in config
     192           0 : void AgentInit::InitCollectorBase() {
     193           0 :     agent_->InitCollector();
     194           0 :     InitCollector();
     195           0 : }
     196             : 
     197             : // Create peers
     198           0 : void AgentInit::CreatePeersBase() {
     199           0 :     agent_->InitPeers();
     200           0 :     CreatePeers();
     201           0 : }
     202             : 
     203             : // Create the basic modules for agent operation.
     204             : // Optional modules or modules that have different implementation are created
     205             : // by init module
     206           0 : void AgentInit::CreateModulesBase() {
     207             :     //Event notify manager
     208           0 :     event_notifier_.reset(new EventNotifier(agent()));
     209           0 :     agent()->set_event_notifier(event_notifier_.get());
     210             : 
     211           0 :     cfg_.reset(new AgentConfig(agent()));
     212           0 :     agent_->set_cfg(cfg_.get());
     213             : 
     214           0 :     oper_.reset(new OperDB(agent()));
     215           0 :     agent_->set_oper_db(oper_.get());
     216             : 
     217           0 :     if (enable_controller_) {
     218           0 :         controller_.reset(new VNController(agent()));
     219           0 :         agent_->set_controller(controller_.get());
     220             :     }
     221             : 
     222           0 :     stats_.reset(new AgentStats(agent()));
     223           0 :     agent()->set_stats(stats_.get());
     224             : 
     225           0 :     CreateModules();
     226           0 : }
     227             : 
     228           0 : void AgentInit::CreateResourceManager() {
     229           0 :     resource_manager_.reset(new ResourceManager(agent()));
     230           0 :     resource_manager_->Init();
     231           0 : }
     232             : 
     233           0 : void AgentInit::CreateDBTablesBase() {
     234           0 :     if (cfg_.get()) {
     235           0 :         cfg_->CreateDBTables(agent_->db());
     236             :     }
     237             : 
     238           0 :     if (oper_.get()) {
     239           0 :         oper_->CreateDBTables(agent_->db());
     240             :     }
     241             : 
     242           0 :     CreateDBTables();
     243           0 : }
     244             : 
     245           0 : void AgentInit::RegisterDBClientsBase() {
     246           0 :     if (cfg_.get()) {
     247           0 :         cfg_->RegisterDBClients(agent_->db());
     248             :     }
     249             : 
     250           0 :     if (oper_.get()) {
     251           0 :         oper_->RegisterDBClients();
     252             :     }
     253             : 
     254           0 :     RegisterDBClients();
     255           0 : }
     256             : 
     257           0 : void AgentInit::InitModulesBase() {
     258           0 :     if (cfg_.get()) {
     259           0 :         cfg_->Init();
     260             :     }
     261             : 
     262           0 :     if (oper_.get()) {
     263           0 :         oper_->Init();
     264             :     }
     265             : 
     266           0 :     InitModules();
     267           0 : }
     268             : 
     269           0 : static void CreateVrfIndependentNextHop(Agent *agent) {
     270             : 
     271           0 :     DiscardNH::Create();
     272           0 :     DiscardNHKey key1;
     273           0 :     NextHop *nh = static_cast<NextHop *>
     274           0 :         (agent->nexthop_table()->FindActiveEntry(&key1));
     275           0 :     agent->nexthop_table()->set_discard_nh(nh);
     276             : 
     277             :     //Reserve index 2, this would be used to
     278             :     //set as RPF NH when packet has to be discarded
     279             :     //due to source route mismatch
     280           0 :     assert(agent->nexthop_table()->ReserveIndex() ==
     281             :                NextHopTable::kRpfDiscardIndex);
     282           0 :     L2ReceiveNH::Create();
     283           0 :     L2ReceiveNHKey key2;
     284           0 :     nh = static_cast<NextHop *>
     285           0 :                 (agent->nexthop_table()->FindActiveEntry(&key2));
     286           0 :     agent->nexthop_table()->set_l2_receive_nh(nh);
     287           0 : }
     288             : 
     289           0 : void AgentInit::CreateVrfBase() {
     290             :     // Bridge Receive routes are added on VRF creation. Ensure that Bridge
     291             :     // Receive-NH which is independent of VRF is created first
     292           0 :     CreateVrfIndependentNextHop(agent_.get());
     293             : 
     294             :     // Create the default VRF
     295           0 :     VrfTable *vrf_table = agent_->vrf_table();
     296             : 
     297           0 :     vrf_table->CreateStaticVrf(agent_->fabric_vrf_name());
     298           0 :     vrf_table->CreateFabricPolicyVrf(agent_->fabric_policy_vrf_name());
     299           0 :     VrfEntry *vrf = vrf_table->FindVrfFromName(agent_->fabric_vrf_name());
     300           0 :     assert(vrf);
     301           0 :     VrfEntry *policy_vrf = vrf_table->FindVrfFromName(agent_->
     302             :                                                       fabric_policy_vrf_name());
     303           0 :     assert(policy_vrf);
     304             : 
     305           0 :     agent_->set_fabric_vrf(vrf);
     306           0 :     agent_->set_fabric_policy_vrf(policy_vrf);
     307           0 :     agent_->set_fabric_inet4_unicast_table(vrf->GetInet4UnicastRouteTable());
     308           0 :     agent_->set_fabric_inet4_mpls_table(vrf->GetInet4MplsUnicastRouteTable());
     309             :     agent_->set_fabric_inet4_multicast_table
     310           0 :         (vrf->GetInet4MulticastRouteTable());
     311           0 :     agent_->set_fabric_l2_unicast_table(vrf->GetBridgeRouteTable());
     312           0 :     agent_->set_fabric_evpn_table(vrf->GetEvpnRouteTable());
     313             : 
     314           0 :     CreateVrf();
     315           0 : }
     316             : 
     317           0 : void AgentInit::CreateNextHopsBase() {
     318           0 :     CreateNextHops();
     319           0 : }
     320             : 
     321           0 : void AgentInit::CreateInterfacesBase() {
     322           0 :     CreateInterfaces();
     323           0 : }
     324             : 
     325           0 : void AgentInit::ConnectToControllerBase() {
     326           0 :     if (agent_->router_id_configured() == false) {
     327           0 :         LOG(DEBUG,
     328             :             "Router ID not configured. Connection to controller postponed");
     329             :     } else {
     330           0 :         LOG(DEBUG, "Router ID configured. Connection to controller initiated");
     331             :         // Connect to controller and DNS servers
     332           0 :         agent_->controller()->Connect();
     333             :     }
     334             : 
     335           0 :     ConnectToController();
     336           0 :     if (agent_->controller()) {
     337           0 :         agent_->controller()->EnableWorkQueue();
     338             :     }
     339           0 : }
     340             : 
     341           0 : void AgentInit::InitDoneBase() {
     342           0 :     TaskScheduler *scheduler = agent_->task_scheduler();
     343             :     // Enable task latency measurements once init is done
     344           0 :     scheduler->EnableLatencyThresholds(agent_param_->tbb_exec_delay(),
     345           0 :                                        agent_param_->tbb_schedule_delay());
     346           0 :     agent_param_->vgw_config_table()->InitDone(agent_.get());
     347           0 :     if (cfg_.get()) {
     348           0 :         cfg_->InitDone();
     349             :     }
     350             :     // Enable task latency measurements once init is done
     351             :     scheduler->EnableLatencyThresholds
     352           0 :         (agent_param_->tbb_exec_delay() * 1000,
     353           0 :          agent_param_->tbb_schedule_delay() * 1000);
     354             : 
     355             :     // Flow related tasks are known have greater latency. Add exception
     356             :     // for them
     357           0 :     uint32_t execute_delay = (20 * 1000);
     358           0 :     uint32_t schedule_delay = (20 * 1000);
     359           0 :     scheduler->SetLatencyThreshold(kTaskFlowEvent, execute_delay,
     360             :                                    schedule_delay);
     361           0 :     scheduler->SetLatencyThreshold(kTaskFlowKSync, execute_delay,
     362             :                                    schedule_delay);
     363           0 :     scheduler->SetLatencyThreshold(kTaskFlowUpdate, execute_delay,
     364             :                                    schedule_delay);
     365           0 :     scheduler->SetLatencyThreshold(kTaskFlowStatsCollector, (execute_delay * 2),
     366             :                                    (schedule_delay * 2));
     367           0 :     scheduler->SetLatencyThreshold(kTaskSessionStatsCollector, (execute_delay * 2),
     368             :                                    (schedule_delay * 2));
     369           0 :     scheduler->SetLatencyThreshold(kTaskSessionStatsCollectorEvent, (execute_delay * 2),
     370             :                                    (schedule_delay * 2));
     371           0 :     agent_->InitDone();
     372           0 :     InitDone();
     373           0 : }
     374             : 
     375             : /****************************************************************************
     376             :  * Shutdown routines
     377             :  ***************************************************************************/
     378             : typedef boost::function<bool(void)> TaskFnPtr;
     379           0 : static void RunInTaskContext(AgentInit *init, uint32_t task_id, TaskFnPtr fn) {
     380           0 :     TaskTrigger trigger(fn, task_id, 0);
     381           0 :     trigger.Set();
     382           0 :     init->WaitForIdle();
     383           0 :     return;
     384           0 : }
     385             : 
     386             : // Shutdown IO channel to controller+DNS
     387           0 : void AgentInit::IoShutdownBase() {
     388           0 :     agent_->controller()->Cleanup();
     389           0 :     agent_->controller()->DisConnect();
     390           0 :     IoShutdown();
     391           0 : }
     392             : 
     393           0 : static bool IoShutdownInternal(AgentInit *init) {
     394           0 :     init->IoShutdownBase();
     395           0 :     return true;
     396             : }
     397             : 
     398           0 : void AgentInit::FlushFlowsBase() {
     399           0 :     FlushFlows();
     400           0 :     return;
     401             : }
     402             : 
     403           0 : static bool FlushFlowsInternal(AgentInit *init) {
     404           0 :     init->FlushFlowsBase();
     405           0 :     return true;
     406             : }
     407             : 
     408           0 : void AgentInit::VgwShutdownBase() {
     409           0 :     VgwShutdown();
     410           0 :     return;
     411             : }
     412             : 
     413           0 : static bool VgwShutdownInternal(AgentInit *init) {
     414           0 :     init->VgwShutdownBase();
     415           0 :     return true;
     416             : }
     417             : 
     418           0 : void AgentInit::DeleteRoutesBase() {
     419           0 :     DeleteRoutes();
     420           0 :     if (agent_->oper_db())
     421           0 :         agent_->oper_db()->DeleteRoutes();
     422           0 : }
     423             : 
     424           0 : static bool DeleteRoutesInternal(AgentInit *init) {
     425           0 :     init->DeleteRoutesBase();
     426           0 :     return true;
     427             : }
     428             : 
     429           0 : static bool FlushTable(AgentDBTable *table) {
     430           0 :     table->Flush();
     431           0 :     return true;
     432             : }
     433             : 
     434           0 : void AgentInit::DeleteVhost() {
     435           0 :     DBRequest req(DBRequest::DB_ENTRY_DELETE);
     436           0 :     req.key.reset(new VmInterfaceKey(AgentKey::ADD_DEL_CHANGE,
     437           0 :                                      boost::uuids::nil_uuid(),
     438           0 :                                      agent_->vhost_interface_name()));
     439           0 :     VmInterfaceConfigData *data = new VmInterfaceConfigData(agent_.get(), NULL);
     440           0 :     req.data.reset(data);
     441           0 :     agent_->interface_table()->Enqueue(&req);
     442           0 : }
     443             : 
     444           0 : void AgentInit::DeleteDBEntriesBase() {
     445           0 :     int task_id = agent_->task_scheduler()->GetTaskId(AGENT_SHUTDOWN_TASKNAME);
     446             : 
     447           0 :     RunInTaskContext(this, task_id, boost::bind(&DeleteRoutesInternal, this));
     448           0 :     agent_->vrf_table()->DeleteStaticVrf(agent_->fabric_policy_vrf_name());
     449             : 
     450           0 :     agent_->vrf_table()->DeleteStaticVrf(agent_->fabric_policy_vrf_name());
     451             : 
     452           0 :     DeleteVhost();
     453             : 
     454           0 :     RunInTaskContext(this, task_id,
     455             :                      boost::bind(&FlushTable, agent_->interface_table()));
     456           0 :     agent_->set_vhost_interface(NULL);
     457             : 
     458           0 :     RunInTaskContext(this, task_id,
     459             :                      boost::bind(&FlushTable, agent_->vm_table()));
     460             : 
     461           0 :     RunInTaskContext(this, task_id,
     462             :                      boost::bind(&FlushTable, agent_->vn_table()));
     463             : 
     464             : 
     465           0 :     agent_->vrf_table()->DeleteStaticVrf(agent_->fabric_vrf_name());
     466           0 :     RunInTaskContext(this, task_id,
     467             :                      boost::bind(&FlushTable, agent_->vrf_table()));
     468             : 
     469           0 :     RunInTaskContext(this, task_id,
     470             :                      boost::bind(&FlushTable, agent_->nexthop_table()));
     471           0 :     agent_->nexthop_table()->set_discard_nh(NULL);
     472             : 
     473             : 
     474           0 :     RunInTaskContext(this, task_id,
     475             :                      boost::bind(&FlushTable, agent_->sg_table()));
     476             : 
     477           0 :     RunInTaskContext(this, task_id,
     478             :                      boost::bind(&FlushTable, agent_->acl_table()));
     479             : 
     480           0 :     RunInTaskContext(this, task_id,
     481             :                  boost::bind(&FlushTable, agent_->mp_table()));
     482           0 : }
     483             : 
     484           0 : static bool WaitForDbCount(DBTableBase *table, AgentInit *init,
     485             :                            uint32_t count, int msec) {
     486           0 :     while ((table->Size() > count)  && (msec > 0)) {
     487           0 :         init->WaitForIdle();
     488           0 :         usleep(1000);
     489           0 :         msec -= 1;
     490             :     }
     491             : 
     492           0 :     return (table->Size() == count);
     493             : }
     494             : 
     495           0 : void AgentInit::WaitForDBEmpty() {
     496           0 :     WaitForDbCount(agent_->interface_table(), this, 0, 10000);
     497           0 :     WaitForDbCount(agent_->vrf_table(), this, 0, 10000);
     498           0 :     WaitForDbCount(agent_->nexthop_table(), this, 0, 10000);
     499           0 :     WaitForDbCount(agent_->vm_table(), this, 0, 10000);
     500           0 :     WaitForDbCount(agent_->vn_table(), this, 0, 10000);
     501           0 :     WaitForDbCount(agent_->mpls_table(), this, 2, 10000);
     502           0 :     WaitForDbCount(agent_->acl_table(), this, 0, 10000);
     503           0 :     WaitForDbCount(agent_->mp_table(), this, 0, 10000);
     504           0 : }
     505             : 
     506           0 : void AgentInit::ServicesShutdownBase() {
     507           0 :     ServicesShutdown();
     508           0 :     return;
     509             : }
     510             : 
     511           0 : static bool ServicesShutdownInternal(AgentInit *init) {
     512           0 :     init->ServicesShutdownBase();
     513           0 :     return true;
     514             : }
     515             : 
     516           0 : void AgentInit::PktShutdownBase() {
     517           0 :     PktShutdown();
     518           0 :     return;
     519             : }
     520             : 
     521           0 : static bool PktShutdownInternal(AgentInit *init) {
     522           0 :     init->PktShutdownBase();
     523           0 :     return true;
     524             : }
     525             : 
     526           0 : void AgentInit::ProfileShutdownBase() {
     527           0 :     if (agent_->oper_db() && agent_->oper_db()->agent_profile()) {
     528           0 :         agent_->oper_db()->agent_profile()->Shutdown();
     529             :     }
     530           0 : }
     531             : 
     532           0 : static bool ProfileShutdownInternal(AgentInit *init) {
     533           0 :     init->ProfileShutdownBase();
     534           0 :     return true;
     535             : }
     536             : 
     537           0 : void AgentInit::ModulesShutdownBase() {
     538           0 :     ModulesShutdown();
     539           0 :     if (agent_->oper_db()) {
     540           0 :         agent_->oper_db()->Shutdown();
     541             :     }
     542             : 
     543           0 :     if (agent_->cfg()) {
     544           0 :         agent_->cfg()->Shutdown();
     545             :     }
     546           0 :     return;
     547             : }
     548             : 
     549           0 : static bool ModulesShutdownInternal(AgentInit *init) {
     550           0 :     init->ModulesShutdownBase();
     551           0 :     return true;
     552             : }
     553             : 
     554           0 : void AgentInit::UveShutdownBase() {
     555           0 :     UveShutdown();
     556           0 :     return;
     557             : }
     558             : 
     559           0 : void AgentInit::StatsCollectorShutdownBase() {
     560           0 :     StatsCollectorShutdown();
     561           0 :     return;
     562             : }
     563             : 
     564           0 : void AgentInit::FlowStatsCollectorShutdownBase() {
     565           0 :     FlowStatsCollectorShutdown();
     566           0 :     return;
     567             : }
     568             : 
     569           0 : static bool UveShutdownInternal(AgentInit *init) {
     570           0 :     init->UveShutdownBase();
     571           0 :     return true;
     572             : }
     573             : 
     574           0 : static bool StatsCollectorShutdownInternal(AgentInit *init) {
     575           0 :     init->StatsCollectorShutdownBase();
     576           0 :     return true;
     577             : }
     578             : 
     579           0 : static bool FlowStatsCollectorShutdownInternal(AgentInit *init) {
     580           0 :     init->FlowStatsCollectorShutdownBase();
     581           0 :     return true;
     582             : }
     583             : 
     584           0 : void AgentInit::KSyncShutdownBase() {
     585           0 :     KSyncShutdown();
     586           0 :     return;
     587             : }
     588             : 
     589           0 : static bool KSyncShutdownInternal(AgentInit *init) {
     590           0 :     init->KSyncShutdownBase();
     591           0 :     return true;
     592             : }
     593             : 
     594           0 : void AgentInit::Shutdown() {
     595           0 :     int task_id = agent_->task_scheduler()->GetTaskId(AGENT_SHUTDOWN_TASKNAME);
     596             : 
     597           0 :     DeleteDBEntriesBase();
     598           0 :     RunInTaskContext(this, task_id, boost::bind(&IoShutdownInternal, this));
     599           0 :     RunInTaskContext(this, task_id, boost::bind(&ProfileShutdownInternal, this));
     600           0 :     RunInTaskContext(this, task_id, boost::bind(&FlushFlowsInternal, this));
     601           0 :     RunInTaskContext(this, task_id, boost::bind(&VgwShutdownInternal, this));
     602           0 :     WaitForDBEmpty();
     603           0 :     RunInTaskContext(this, task_id, boost::bind(&ServicesShutdownInternal,
     604             :                                                 this));
     605           0 :     RunInTaskContext(this, task_id, boost::bind
     606             :                      (&FlowStatsCollectorShutdownInternal, this));
     607           0 :     RunInTaskContext(this, task_id, boost::bind(&StatsCollectorShutdownInternal,
     608             :                                                 this));
     609           0 :     RunInTaskContext(this, task_id, boost::bind(&UveShutdownInternal, this));
     610           0 :     RunInTaskContext(this, task_id, boost::bind(&PktShutdownInternal, this));
     611           0 :     RunInTaskContext(this, task_id, boost::bind(&ModulesShutdownInternal,
     612             :                                                 this));
     613           0 :     RunInTaskContext(this, task_id, boost::bind(&KSyncShutdownInternal, this));
     614             : 
     615           0 :     Sandesh::Uninit();
     616           0 :     WaitForIdle();
     617             : 
     618           0 :     agent_->event_manager()->Shutdown();
     619           0 :     WaitForIdle();
     620           0 : }

Generated by: LCOV version 1.14