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

Generated by: LCOV version 1.14