LCOV - code coverage report
Current view: top level - vnsw/agent/init - agent_param.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 902 1390 64.9 %
Date: 2026-11-09 02:10:49 Functions: 45 69 65.2 %
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             : /*
       7             :  * Agent parameters are derived from 3 entities in increasing priority,
       8             :  * - System information
       9             :  * - Configuration file
      10             :  * - Parameters
      11             :  */
      12             : 
      13             : #include "base/os.h"
      14             : #include <sys/types.h>
      15             : #include <sys/stat.h>
      16             : #include <sys/resource.h>
      17             : #include <net/if_arp.h>
      18             : #include <unistd.h>
      19             : #include <iostream>
      20             : #include <string>
      21             : 
      22             : #include <boost/property_tree/ini_parser.hpp>
      23             : #include <boost/algorithm/string.hpp>
      24             : #include <boost/foreach.hpp>
      25             : #include <boost/program_options.hpp>
      26             : #include <boost/thread/thread.hpp>
      27             : 
      28             : #include <base/bgp_as_service_utils.h>
      29             : #include <base/logging.h>
      30             : #include <base/misc_utils.h>
      31             : #include <base/options_util.h>
      32             : 
      33             : #include <contrail/pkt0_interface.h>
      34             : 
      35             : #include <sandesh/sandesh_trace.h>
      36             : 
      37             : #include <cmn/agent_cmn.h>
      38             : #include <init/agent_param.h>
      39             : #include <vgw/cfg_vgw.h>
      40             : 
      41             : using namespace std;
      42             : using namespace boost::property_tree;
      43             : using boost::optional;
      44             : namespace opt = boost::program_options;
      45             : using namespace options::util;
      46             : 
      47           2 : bool AgentParam::GetIpAddress(const string &str, Ip4Address *addr) {
      48           2 :     boost::system::error_code ec;
      49           2 :     Ip4Address tmp = Ip4Address::from_string(str, ec);
      50           2 :     if (ec.value() != 0) {
      51           0 :         return false;
      52             :     }
      53           2 :     *addr = tmp;
      54           2 :     return true;
      55             : }
      56             : 
      57           0 : bool AgentParam::ParseIp(const string &key, Ip4Address *server) {
      58           0 :     boost::optional<string> opt_str;
      59           0 :     if (opt_str = tree_.get_optional<string>(key)) {
      60           0 :         Ip4Address addr;
      61           0 :         if (GetIpAddress(opt_str.get(), &addr) == false) {
      62           0 :             LOG(ERROR, "Error in config file <" << config_file_
      63             :                     << ">. Error parsing IP address from <"
      64             :                     << opt_str.get() << ">");
      65           0 :             return false;
      66             : 
      67             :         } else {
      68           0 :             *server = addr;
      69             :         }
      70             :     }
      71           0 :     return true;
      72           0 : }
      73             : 
      74           0 : bool AgentParam::ParseServerList(const string &key, Ip4Address *server1,
      75             :                                  Ip4Address *server2) {
      76           0 :     boost::optional<string> opt_str;
      77           0 :     Ip4Address addr;
      78           0 :     vector<string> tokens;
      79           0 :     if (opt_str = tree_.get_optional<string>(key)) {
      80           0 :         boost::split(tokens, opt_str.get(), boost::is_any_of(" \t"));
      81           0 :         if (tokens.size() > 2) {
      82           0 :             LOG(ERROR, "Error in config file <" << config_file_
      83             :                     << ">. Cannot have more than 2 servers <"
      84             :                     << opt_str.get() << ">");
      85           0 :             return false;
      86             :         }
      87           0 :         vector<string>::iterator it = tokens.begin();
      88           0 :         if (it != tokens.end()) {
      89           0 :             if (!GetIpAddress(*it, server1)) {
      90           0 :                 return false;
      91             :             }
      92           0 :             ++it;
      93           0 :             if (it != tokens.end()) {
      94           0 :                 if (!GetIpAddress(*it, server2)) {
      95           0 :                     return false;
      96             :                 }
      97             :             }
      98             :         }
      99             :     }
     100           0 :     return true;
     101           0 : }
     102             : 
     103             : // Parse address string in the form <ip>:<port>
     104           0 : bool AgentParam::ParseAddress(const std::string &addr_string,
     105             :                               Ip4Address *server, uint16_t *port) {
     106           0 :     vector<string> tokens;
     107           0 :     boost::split(tokens, addr_string, boost::is_any_of(":"));
     108           0 :     if (tokens.size() > 2) {
     109           0 :         cout << "Error in config file <" << config_file_
     110           0 :              << ">. Improper server address <" << addr_string << ">\n";
     111           0 :         return false;
     112             :     }
     113           0 :     vector<string>::iterator it = tokens.begin();
     114           0 :     if (!GetIpAddress(*it, server)) {
     115           0 :         cout << "Error in config file <" << config_file_
     116           0 :              << ">. Improper server address <" << addr_string << ">\n";
     117           0 :         return false;
     118             :     }
     119           0 :     ++it;
     120           0 :     if (it != tokens.end()) {
     121           0 :         stringToInteger(*it, *port);
     122             :     }
     123             : 
     124           0 :     return true;
     125           0 : }
     126             : 
     127             : // Parse list of servers in the <ip1>:<port1> <ip2>:<port2> format
     128           0 : bool AgentParam::ParseServerList(const std::string &key,
     129             :                                  Ip4Address *server1, uint16_t *port1,
     130             :                                  Ip4Address *server2, uint16_t *port2) {
     131           0 :     boost::optional<string> opt_str;
     132           0 :     if (opt_str = tree_.get_optional<string>(key)) {
     133           0 :         vector<string> tokens;
     134           0 :         boost::split(tokens, opt_str.get(), boost::is_any_of(" \t"));
     135           0 :         if (tokens.size() > 2) {
     136           0 :             cout << "Error in config file <" << config_file_
     137             :                  << ">. Cannot have more than 2 DNS servers <"
     138           0 :                  << opt_str.get() << ">\n";
     139           0 :             return false;
     140             :         }
     141           0 :         vector<string>::iterator it = tokens.begin();
     142           0 :         if (it != tokens.end()) {
     143           0 :             if (!ParseAddress(*it, server1, port1))
     144           0 :                 return false;
     145           0 :             ++it;
     146           0 :             if (it != tokens.end()) {
     147           0 :                 return ParseAddress(*it, server2, port2);
     148             :             }
     149             :         }
     150           0 :     }
     151           0 :     return true;
     152           0 : }
     153             : 
     154           4 : void AgentParam::ParseIpArgument
     155             :     (const boost::program_options::variables_map &var_map, Ip4Address &server,
     156             :      const string &key) {
     157             : 
     158           4 :     if (var_map.count(key)) {
     159           0 :         Ip4Address addr;
     160           0 :         if (GetIpAddress(var_map[key].as<string>(), &addr)) {
     161           0 :             server = addr;
     162             :         }
     163             :     }
     164           4 : }
     165             : 
     166           0 : bool AgentParam::ParseServerListArguments
     167             :     (const boost::program_options::variables_map &var_map, Ip4Address &server1,
     168             :      Ip4Address &server2, const string &key) {
     169             : 
     170           0 :     if (var_map.count(key)) {
     171           0 :         vector<string> value = var_map[key].as<vector<string> >();
     172           0 :         if (value.size() == 1) {
     173           0 :             boost::split(value, value[0], boost::is_any_of(" \t"));
     174             :         }
     175           0 :         if (value.size() > 2) {
     176             :             cout << "Error in Arguments. Cannot have more than 2 servers for "
     177           0 :                  << key << "\n";
     178           0 :             return false;
     179             :         }
     180           0 :         vector<string>::iterator it = value.begin();
     181           0 :         Ip4Address addr;
     182           0 :         if (it !=  value.end()) {
     183           0 :             if (GetIpAddress(*it, &addr)) {
     184           0 :                 server1 = addr;
     185             :             }
     186           0 :             ++it;
     187           0 :             if (it != value.end()) {
     188           0 :                 if (GetIpAddress(*it, &addr)) {
     189           0 :                     server2 = addr;
     190             :                 }
     191             :             }
     192             :         }
     193           0 :     }
     194           0 :     return true;
     195             : }
     196             : 
     197           0 : bool AgentParam::ParseServerListArguments
     198             :     (const boost::program_options::variables_map &var_map, Ip4Address *server1,
     199             :      uint16_t *port1, Ip4Address *server2, uint16_t *port2,
     200             :      const std::string &key) {
     201             : 
     202           0 :     if (var_map.count(key)) {
     203           0 :         vector<string> value = var_map[key].as<vector<string> >();
     204           0 :         if (value.size() == 1) {
     205           0 :             boost::split(value, value[0], boost::is_any_of(" \t"));
     206             :         }
     207           0 :         if (value.size() > 2) {
     208           0 :             LOG(ERROR, "Error in Arguments. Cannot have more than 2 servers "
     209             :                     "for " << key );
     210           0 :             return false;
     211             :         }
     212           0 :         vector<string>::iterator it = value.begin();
     213           0 :         if (it != value.end()) {
     214           0 :             if (!ParseAddress(*it, server1, port1))
     215           0 :                 return false;
     216           0 :             ++it;
     217           0 :             if (it != value.end()) {
     218           0 :                 return ParseAddress(*it, server2, port2);
     219             :             }
     220             :         }
     221           0 :     }
     222           0 :     return true;
     223             : }
     224             : 
     225             : std::map<string, std::map<string, string> >
     226           0 : AgentParam::ParseDerivedStats(const std::vector<std::string> &dsvec) {
     227           0 :     std::map<string, std::map<string, string> > dsmap;
     228           0 :     std::map<string, std::map<string, string> >::iterator dsiter;
     229             : 
     230           0 :     for (size_t idx=0; idx!=dsvec.size(); idx++) {
     231           0 :         size_t pos = dsvec[idx].find(':');
     232           0 :         if(pos == string::npos) {
     233           0 :             LOG(ERROR,
     234             :                 "Error config-file, DerivedStats parsing: dsvec size "
     235             :                 << dsvec.size() << " at index " << idx << ": " <<dsvec[idx]
     236             :                 << ". BackTrace: " << AgentBackTrace(1));
     237           0 :             _Exit(0);
     238             :         }
     239           0 :         string dsfull = dsvec[idx].substr(0,pos);
     240           0 :         string dsarg = dsvec[idx].substr(pos+1, string::npos);
     241             : 
     242           0 :         size_t dpos = dsfull.find('.');
     243           0 :         if(dpos == string::npos) {
     244           0 :             LOG(ERROR,
     245             :                 "Error config-file, DerivedStats parsing: dsvec size "
     246             :                 << dsvec.size() << " at index " << idx << ": " <<dsvec[idx]
     247             :                 << ". substr: " << dsfull << ". BackTrace: " << AgentBackTrace(1));
     248           0 :             _Exit(0);
     249             :         }
     250           0 :         string dsstruct = dsfull.substr(0,dpos);
     251           0 :         string dsattr = dsfull.substr(dpos+1, string::npos);
     252             : 
     253           0 :         dsiter = dsmap.find(dsstruct);
     254           0 :         std::map<string, string> dselem;
     255           0 :         if (dsiter!=dsmap.end()) dselem = dsiter->second;
     256           0 :         dselem[dsattr] = dsarg;
     257             : 
     258           0 :         dsmap[dsstruct] = dselem;
     259           0 :     }
     260           0 :     return dsmap;
     261           0 : }
     262             : 
     263           0 : void AgentParam::BuildAddressList(const string &val) {
     264           0 :     compute_node_address_list_.clear();
     265           0 :     if (val.empty()) {
     266           0 :         return;
     267             :     }
     268             : 
     269           0 :     vector<string> tokens;
     270           0 :     boost::split(tokens, val, boost::is_any_of(" "));
     271           0 :     vector<string>::iterator it = tokens.begin();
     272           0 :     while (it != tokens.end()) {
     273           0 :         std::string str = *it;
     274           0 :         ++it;
     275             : 
     276           0 :         boost::algorithm::trim(str);
     277           0 :         Ip4Address addr;
     278           0 :         if (GetIpAddress(str, &addr)) {
     279           0 :             compute_node_address_list_.push_back(addr);
     280             :         } else {
     281           0 :             LOG(ERROR, "Error in parsing address " << *it);
     282             :         }
     283           0 :     }
     284           0 : }
     285             : 
     286           0 : void AgentParam::set_agent_mode(const std::string &mode) {
     287           0 :     std::string agent_mode = boost::to_lower_copy(mode);
     288           0 :     if (agent_mode == "tsn")
     289           0 :         agent_mode_ = TSN_AGENT;
     290           0 :     else if (agent_mode == "tsn-no-forwarding")
     291           0 :         agent_mode_ = TSN_NO_FORWARDING_AGENT;
     292           0 :     else if (agent_mode == "tor")
     293           0 :         agent_mode_ = TOR_AGENT;
     294             :     else
     295           0 :         agent_mode_ = VROUTER_AGENT;
     296           0 : }
     297             : 
     298           0 : void AgentParam::set_gateway_mode(const std::string &mode) {
     299           0 :     std::string gateway_mode = boost::to_lower_copy(mode);
     300           0 :     if (gateway_mode == "server")
     301           0 :         gateway_mode_ = SERVER;
     302           0 :     else if (gateway_mode == "vcpe")
     303           0 :         gateway_mode_ = VCPE;
     304           0 :     else if (gateway_mode == "pbb")
     305           0 :         gateway_mode_ = PBB;
     306             :     else
     307           0 :         gateway_mode_ = NONE;
     308           0 : }
     309             : 
     310           2 : void AgentParam::ParseQueue() {
     311             : 
     312           2 :     const std::string qos_str = "QUEUE";
     313           2 :     std::string input;
     314           2 :     std::vector<std::string> tokens;
     315           2 :     std::string sep = "[],";
     316           6 :     BOOST_FOREACH(const ptree::value_type &section, tree_) {
     317           2 :         if (section.first.compare(0, qos_str.size(), qos_str) != 0) {
     318           2 :             continue;
     319             :         }
     320             :         uint16_t queue;
     321           0 :         std::string hw_queue = section.first;
     322           0 :         if (sscanf(hw_queue.c_str(), "QUEUE-%hu", &queue) != 1) {
     323           0 :                 continue;
     324             :         }
     325           0 :         BOOST_FOREACH(const ptree::value_type &key, section.second) {
     326           0 :             if (key.first.compare("logical_queue") == 0) {
     327           0 :                 input = key.second.get_value<string>();
     328           0 :                 boost::split(tokens, input, boost::is_any_of(sep),
     329             :                          boost::token_compress_on);
     330             : 
     331           0 :                 for (std::vector<string>::const_iterator it = tokens.begin();
     332           0 :                     it != tokens.end(); it++) {
     333             : 
     334           0 :                     if (*it == Agent::NullString()) {
     335           0 :                         continue;
     336             :                     }
     337             : 
     338           0 :                     string range = *it;
     339           0 :                     nic_queue_list_.insert(queue);
     340           0 :                     std::vector<uint16_t> range_value;
     341           0 :                     if (stringToIntegerList(range, "-", range_value)) {
     342           0 :                         if (range_value.size() == 1) {
     343           0 :                             qos_queue_map_[range_value[0]] = queue;
     344           0 :                             continue;
     345             :                         }
     346             : 
     347           0 :                         if (range_value[0] > range_value[1]) {
     348           0 :                             continue;
     349             :                         }
     350             : 
     351           0 :                         for (uint16_t i = range_value[0]; i <= range_value[1]; i++) {
     352           0 :                             qos_queue_map_[i] = queue;
     353             :                         }
     354             :                     }
     355           0 :                 }
     356             :             }
     357           0 :             if (key.first.compare("default_hw_queue") == 0) {
     358           0 :                 bool is_default = key.second.get_value<bool>();
     359           0 :                 if (is_default) {
     360           0 :                     default_nic_queue_ = queue;
     361             :                 }
     362             :             }
     363             :         }
     364           0 :     }
     365           2 :     GetValueFromTree<uint32_t>(task_monitor_timeout_msec_,
     366             :                                "TASK.task_monitor_timeout");
     367           2 : }
     368             : 
     369           2 : void AgentParam::ParseSessionDestinationArguments
     370             :     (const boost::program_options::variables_map &var_map) {
     371           2 :     slo_destination_.clear();
     372           2 :     sample_destination_.clear();
     373           2 :     GetOptValue< vector<string> >(var_map, slo_destination_,
     374             :                                   "SESSION.slo_destination");
     375           2 :     GetOptValue< vector<string> >(var_map, sample_destination_,
     376             :                                   "SESSION.sample_destination");
     377             :     //validate the string
     378           2 :     std::set<string> valid_dest_values;
     379           2 :     valid_dest_values.insert("collector");
     380           2 :     valid_dest_values.insert("file");
     381           2 :     valid_dest_values.insert("syslog");
     382           2 :     valid_dest_values.insert("");
     383           4 :     for (uint32_t i=0; i<slo_destination_.size(); i++) {
     384             : 
     385           2 :         if(valid_dest_values.find(slo_destination_[i]) ==
     386           4 :             valid_dest_values.end()) {
     387           0 :             LOG(ERROR,
     388             :                 "Error in config file <" << config_file_
     389             :                 << ">. Error parsing slo_destination, size "
     390             :                 << slo_destination_.size() << " at index " << i << ":" 
     391             :                 << slo_destination_[i]
     392             :                 << ". BackTrace: " << AgentBackTrace(1));
     393           0 :             _Exit(0);
     394             :         }
     395             : 
     396             :     }
     397           4 :     for (uint32_t i=0; i<sample_destination_.size(); i++) {
     398             :     
     399           2 :         if(valid_dest_values.find(sample_destination_[i]) ==
     400           4 :             valid_dest_values.end()) {
     401           0 :             LOG(ERROR,
     402             :                 "Error in config file <" << config_file_
     403             :                 << ">. Error parsing sample_destination, size "
     404             :                 << sample_destination_.size() << " at index " << i << ":" 
     405             :                 << sample_destination_[i]
     406             :                 << ". BackTrace: " << AgentBackTrace(1));
     407           0 :             _Exit(0);
     408             :         }
     409             : 
     410             :     }
     411           2 : }
     412             : 
     413           0 : void AgentParam::ParseCollectorArguments
     414             :     (const boost::program_options::variables_map &var_map) {
     415           0 :     collector_server_list_.clear();
     416           0 :     GetOptValueIfNotDefaulted< vector<string> >(var_map, collector_server_list_,
     417             :                                   "DEFAULT.collectors");
     418           0 :     if (collector_server_list_.size() == 1) {
     419           0 :         boost::split(collector_server_list_, collector_server_list_[0],
     420           0 :                      boost::is_any_of(" "));
     421             :     }
     422           0 : }
     423             : 
     424           2 : void AgentParam::ParseControllerServersArguments
     425             :     (const boost::program_options::variables_map &var_map) {
     426           2 :     controller_server_list_.clear();
     427           2 :     GetOptValueIfNotDefaulted< vector<string> >(var_map, controller_server_list_,
     428             :                                   "CONTROL-NODE.servers");
     429           2 :     if (controller_server_list_.size() == 1) {
     430           2 :         boost::split(controller_server_list_, controller_server_list_[0],
     431           4 :                      boost::is_any_of(" "));
     432             :     }
     433           2 :     GetOptValue<string>(var_map, subcluster_name_, "CONTROL-NODE.subcluster_name");
     434           2 : }
     435             : 
     436           2 : void AgentParam::ParseDnsServersArguments
     437             :     (const boost::program_options::variables_map &var_map) {
     438           2 :     dns_server_list_.clear();
     439           2 :     GetOptValueIfNotDefaulted< vector<string> >(var_map, dns_server_list_,
     440             :                                   "DNS.servers");
     441           2 :     if (dns_server_list_.size() == 1) {
     442           2 :         boost::split(dns_server_list_, dns_server_list_[0],
     443           4 :                      boost::is_any_of(" "));
     444             :     }
     445           2 : }
     446             : 
     447           2 : void AgentParam::ParseTsnServersArguments
     448             :     (const boost::program_options::variables_map &var_map) {
     449           2 :     tsn_server_list_.clear();
     450           2 :     GetOptValueIfNotDefaulted< vector<string> >(var_map, tsn_server_list_,
     451             :                                   "DEFAULT.tsn_servers");
     452           2 :     if (tsn_server_list_.size() == 1) {
     453           0 :         boost::split(tsn_server_list_, tsn_server_list_[0],
     454           0 :                      boost::is_any_of(" "));
     455             :     }
     456           2 :     std::sort(tsn_server_list_.begin(), tsn_server_list_.end());
     457           2 : }
     458             : 
     459           2 : void AgentParam::ParseCollectorDSArguments
     460             :     (const boost::program_options::variables_map &var_map) {
     461           2 :     GetOptValueIfNotDefaulted< vector<string> >(var_map, collector_server_list_,
     462             :                                       "DEFAULT.collectors");
     463           2 :     vector<string> dsvec;
     464           2 :     if (GetOptValueIfNotDefaulted< vector<string> >(var_map, dsvec,
     465             :                                       "DEFAULT.derived_stats")) {
     466           0 :         derived_stats_map_ = ParseDerivedStats(dsvec);
     467             :     }
     468           2 : }
     469             : 
     470           2 : void AgentParam::BuildAddrList(const string &val, AddressList& addr_list) {
     471           2 :     addr_list.clear();
     472           2 :     if (val.empty()) {
     473           0 :         return;
     474             :     }
     475             : 
     476           2 :     vector<string> tokens;
     477           2 :     boost::split(tokens, val, boost::is_any_of(" "));
     478           2 :     vector<string>::iterator it = tokens.begin();
     479           4 :     while (it != tokens.end()) {
     480           2 :         std::string str = *it;
     481           2 :         ++it;
     482             : 
     483           2 :         boost::algorithm::trim(str);
     484           2 :         Ip4Address addr;
     485             :         int plen;
     486           2 :         if (str.find('/') != std::string::npos) {
     487             :             boost::system::error_code ec =
     488           0 :                 Ip4PrefixParse(str, &addr, &plen);
     489           0 :             if (ec.failed() || vhost_.plen_ >= 32) {
     490           0 :                 LOG(ERROR, "Error in parsing address " << *it);
     491             :             } else {
     492           0 :                 addr_list.push_back(addr);
     493           0 :                 eth_port_plen_list_.push_back(plen);
     494             :             }
     495             :         } else {
     496           2 :             if (GetIpAddress(str, &addr)) {
     497           2 :                 addr_list.push_back(addr);
     498             :             } else {
     499           0 :                 LOG(ERROR, "Error in parsing address " << *it);
     500             :             }
     501             :         }
     502           2 :     }
     503           2 : }
     504             : 
     505           2 : void AgentParam::ParseVirtualHostArguments
     506             :     (const boost::program_options::variables_map &var_map) {
     507           2 :     boost::system::error_code ec;
     508             : 
     509           2 :     GetOptValue<string>(var_map, vhost_.name_, "VIRTUAL-HOST-INTERFACE.name");
     510           2 :     string ip;
     511           2 :     if (GetOptValue<string>(var_map, ip, "VIRTUAL-HOST-INTERFACE.ip")) {
     512           2 :         ec = Ip4PrefixParse(ip, &vhost_.addr_, &vhost_.plen_);
     513           2 :         if (ec.failed() || vhost_.plen_ >= 32) {
     514           0 :             cout << "Error parsing vhost ip argument from <" << ip << ">\n";
     515             :         }
     516             :     }
     517             :     //ParseIpArgument(var_map, vhost_.gw_, "VIRTUAL-HOST-INTERFACE.gateway");
     518             : 
     519           2 :     eth_port_list_.clear();
     520           2 :     GetOptValueIfNotDefaulted< vector<string> >(var_map, eth_port_list_,
     521             :                         "VIRTUAL-HOST-INTERFACE.physical_interface");
     522           2 :     if (eth_port_list_.size() == 1) {
     523           2 :         boost::split(eth_port_list_, eth_port_list_[0],
     524           4 :                      boost::is_any_of(" "));
     525             :     }
     526             : 
     527           2 :     string eth_port_addr_list;
     528           2 :     if (GetOptValue<string>(var_map, eth_port_addr_list,
     529             :                 "VIRTUAL-HOST-INTERFACE.physical_interface_addr")) {
     530           0 :         BuildAddrList(eth_port_addr_list, eth_port_addr_list_);
     531             :     }
     532             : 
     533           2 :     string gateway_list;
     534           2 :     if (GetOptValue<string>(var_map, gateway_list,
     535             :                 "VIRTUAL-HOST-INTERFACE.gateway")) {
     536           2 :         BuildAddrList(gateway_list, gateway_list_);
     537             :     }
     538             : 
     539           2 :     ParseIpArgument(var_map, loopback_ip_, "VIRTUAL-HOST-INTERFACE.loopback_ip");
     540           2 : }
     541             : 
     542           2 : void AgentParam::ParseDnsArguments
     543             :     (const boost::program_options::variables_map &var_map) {
     544           2 :     GetOptValue<uint16_t>(var_map, dns_client_port_, "DNS.dns_client_port");
     545           2 :     GetOptValue<uint32_t>(var_map, dns_timeout_, "DNS.dns_timeout");
     546           2 :     GetOptValue<uint32_t>(var_map, dns_max_retries_, "DNS.dns_max_retries");
     547           2 : }
     548             : 
     549           2 : void AgentParam::ParseNetworksArguments
     550             :     (const boost::program_options::variables_map &var_map) {
     551           2 :     ParseIpArgument(var_map, mgmt_ip_, "NETWORKS.control_network_ip");
     552           2 : }
     553             : 
     554           2 : void AgentParam::ParseHypervisorArguments
     555             :     (const boost::program_options::variables_map &var_map) {
     556           2 :     boost::system::error_code ec;
     557           6 :     if (var_map.count("HYPERVISOR.type") &&
     558           4 :         !var_map["HYPERVISOR.type"].defaulted()) {
     559           0 :         if (var_map["HYPERVISOR.type"].as<string>() == "xen") {
     560           0 :             hypervisor_mode_ = AgentParam::MODE_XEN;
     561           0 :             GetOptValue<string>(var_map, xen_ll_.name_,
     562             :                                 "HYPERVISOR.xen_ll_interface");
     563             : 
     564           0 :             if (var_map.count("HYPERVISOR.xen_ll_ip")) {
     565           0 :                 string ip = var_map["HYPERVISOR.xen_ll_ip"].as<string>();
     566           0 :                 ec = Ip4PrefixParse(ip, &xen_ll_.addr_, &xen_ll_.plen_);
     567           0 :                 if (ec.failed() || xen_ll_.plen_ >= 32) {
     568           0 :                     cout << "Error in argument <" << config_file_
     569             :                             << ">. Error parsing Xen Link-local ip-address from <"
     570           0 :                             << ip << ">\n";
     571           0 :                     exit(EINVAL);
     572             :                 }
     573           0 :             }
     574           0 :         } else if (var_map["HYPERVISOR.type"].as<string>() == "vmware") {
     575           0 :             hypervisor_mode_ = AgentParam::MODE_VMWARE;
     576           0 :             GetOptValue<string>(var_map, vmware_physical_port_,
     577             :                                 "HYPERVISOR.vmware_physical_interface");
     578             :         } else {
     579           0 :             hypervisor_mode_ = AgentParam::MODE_KVM;
     580             :         }
     581             :     }
     582             : 
     583           6 :     if (var_map.count("HYPERVISOR.vmware_mode") &&
     584           4 :         !var_map["HYPERVISOR.vmware_mode"].defaulted()) {
     585           0 :         cout << " vmware_mode is " << var_map["HYPERVISOR.vmware_mode"].as<string>() << endl;
     586           0 :         if (var_map["HYPERVISOR.vmware_mode"].as<string>() == "vcenter") {
     587           0 :             vmware_mode_ = VCENTER;
     588           0 :         } else if (var_map["HYPERVISOR.vmware_mode"].as<string>() ==
     589             :                    "esxi_neutron") {
     590           0 :             vmware_mode_ = ESXI_NEUTRON;
     591             :         } else {
     592             :             cout << "Error in parsing arguement for HYPERVISOR.vmware_mode <"
     593           0 :                 << var_map["HYPERVISOR.vmware_mode"].as<string>() << endl;
     594           0 :             return;
     595             :         }
     596             :     }
     597           2 :     if (!GetValueFromTree<uint16_t>(vmi_vm_vn_uve_interval_,
     598             :                                     "DEFAULT.vmi_vm_vn_uve_interval")) {
     599           2 :         vmi_vm_vn_uve_interval_ = Agent::kDefaultVmiVmVnUveInterval;
     600             :     }
     601             : }
     602             : 
     603           2 : void AgentParam::ParseDefaultSectionArguments
     604             :     (const boost::program_options::variables_map &var_map) {
     605             : 
     606           2 :     GetOptValue<uint16_t>(var_map, flow_cache_timeout_,
     607             :                           "DEFAULT.flow_cache_timeout");
     608           2 :     GetOptValue<uint32_t>(var_map, stale_interface_cleanup_timeout_,
     609             :                           "DEFAULT.stale_interface_cleanup_timeout");
     610           2 :     GetOptValue<string>(var_map, host_name_, "DEFAULT.hostname");
     611           2 :     GetOptValue<string>(var_map, agent_name_, "DEFAULT.agent_name");
     612           2 :     GetOptValue<uint16_t>(var_map, http_server_port_,
     613             :                           "DEFAULT.http_server_port");
     614           2 :     GetOptValue<uint16_t>(var_map, rest_port_,
     615             :                           "DEFAULT.rest_port");
     616           2 :     GetOptValue<string>(var_map, log_category_, "DEFAULT.log_category");
     617           2 :     GetOptValue<string>(var_map, log_file_, "DEFAULT.log_file");
     618           2 :     GetOptValue<int>(var_map, log_files_count_, "DEFAULT.log_files_count");
     619           2 :     GetOptValue<long>(var_map, log_file_size_, "DEFAULT.log_file_size");
     620           2 :     GetOptValue<string>(var_map, log_level_, "DEFAULT.log_level");
     621           2 :     GetOptValue<string>(var_map, syslog_facility_, "DEFAULT.syslog_facility");
     622             : 
     623           2 :     GetOptValue<bool>(var_map, xmpp_auth_enable_, "DEFAULT.xmpp_auth_enable");
     624           2 :     GetOptValue<bool>(var_map, xmpp_dns_auth_enable_,
     625             :                       "DEFAULT.xmpp_dns_auth_enable");
     626           2 :     GetOptValue<string>(var_map, xmpp_server_cert_, "DEFAULT.xmpp_server_cert");
     627           2 :     GetOptValue<string>(var_map, xmpp_server_key_,
     628             :                         "DEFAULT.xmpp_server_key");
     629           2 :     GetOptValue<string>(var_map, xmpp_ca_cert_, "DEFAULT.xmpp_ca_cert");
     630             : 
     631           2 :     GetOptValue<bool>(var_map, subnet_hosts_resolvable_,
     632             :                       "DEFAULT.subnet_hosts_resolvable");
     633           2 :     GetOptValue<uint16_t>(var_map, mirror_client_port_,
     634             :                           "DEFAULT.mirror_client_port");
     635           2 :     GetOptValue<uint32_t>(var_map, pkt0_tx_buffer_count_,
     636             :                           "DEFAULT.pkt0_tx_buffers");
     637           2 :     GetOptValue<bool>(var_map, measure_queue_delay_,
     638             :                       "DEFAULT.measure_queue_delay");
     639           2 :     GetOptValue<string>(var_map, tunnel_type_,
     640             :                         "DEFAULT.tunnel_type");
     641           2 :     GetOptValue<uint16_t>(var_map, min_aap_prefix_len_,
     642             :                          "DEFAULT.min_aap_prefix_len");
     643           2 :     GetOptValue<uint16_t>(var_map, vmi_vm_vn_uve_interval_,
     644             :                           "DEFAULT.vmi_vm_vn_uve_interval");
     645           2 :     GetOptValue<bool>(var_map, mvpn_ipv4_enable_,
     646             :                           "DEFAULT.mvpn_ipv4_enable");
     647           2 :     float high_watermark = 0;
     648           2 :     if (GetOptValue<float>(var_map, high_watermark, "DEFAULT.vr_object_high_watermark")) {
     649           2 :         vr_object_high_watermark_ = high_watermark;
     650             :     }
     651           2 : }
     652             : 
     653           2 : void AgentParam::ParseTaskSectionArguments
     654             :     (const boost::program_options::variables_map &var_map) {
     655           2 :     GetOptValue<uint32_t>(var_map, tbb_thread_count_,
     656             :                           "TASK.thread_count");
     657           2 :     GetOptValue<uint32_t>(var_map, tbb_exec_delay_,
     658             :                           "TASK.log_exec_threshold");
     659           2 :     GetOptValue<uint32_t>(var_map, tbb_schedule_delay_,
     660             :                           "TASK.log_schedule_threshold");
     661           2 :     GetOptValue<uint32_t>(var_map, tbb_keepawake_timeout_,
     662             :                           "TASK.tbb_keepawake_timeout");
     663           2 :     GetOptValue<uint32_t>(var_map, task_monitor_timeout_msec_,
     664             :                           "TASK.task_monitor_timeout");
     665           2 :     GetOptValue<string>(var_map, ksync_thread_cpu_pin_policy_,
     666             :                         "TASK.ksync_thread_cpu_pin_policy");
     667           2 :     GetOptValue<uint32_t>(var_map, flow_netlink_pin_cpuid_,
     668             :                         "TASK.flow_netlink_pin_cpuid");
     669           2 : }
     670             : 
     671           2 : void AgentParam::ParseMetadataProxyArguments
     672             :     (const boost::program_options::variables_map &var_map) {
     673           2 :     GetOptValue<string>(var_map, metadata_shared_secret_,
     674             :                         "METADATA.metadata_proxy_secret");
     675           2 :     GetOptValue<uint16_t>(var_map, metadata_proxy_port_,
     676             :                         "METADATA.metadata_proxy_port");
     677           2 :     GetOptValue<bool>(var_map, metadata_use_ssl_,
     678             :                         "METADATA.metadata_use_ssl");
     679           2 :     GetOptValue<string>(var_map, metadata_client_cert_,
     680             :                         "METADATA.metadata_client_cert");
     681           2 :     GetOptValue<string>(var_map, metadata_client_cert_type_,
     682             :                         "METADATA.metadata_client_cert_type");
     683           2 :     GetOptValue<string>(var_map, metadata_client_key_,
     684             :                         "METADATA.metadata_client_key");
     685           2 :     GetOptValue<string>(var_map, metadata_ca_cert_,
     686             :                         "METADATA.metadata_ca_cert");
     687           2 : }
     688             : 
     689           2 : void AgentParam::ParseFlowArguments
     690             :     (const boost::program_options::variables_map &var_map) {
     691           2 :     GetOptValue<uint16_t>(var_map, flow_thread_count_,
     692             :                           "FLOWS.thread_count");
     693           2 :     GetOptValue<uint16_t>(var_map, flow_latency_limit_,
     694             :                           "FLOWS.latency_limit");
     695           2 :     GetOptValue<bool>(var_map, flow_trace_enable_, "FLOWS.trace_enable");
     696           2 :     GetOptValue<uint16_t>(var_map, linklocal_system_flows_,
     697             :                           "FLOWS.max_system_linklocal_flows");
     698           2 :     GetOptValue<uint16_t>(var_map, linklocal_vm_flows_,
     699             :                           "FLOWS.max_vm_linklocal_flows");
     700           2 :     GetOptValue<uint16_t>(var_map, flow_index_sm_log_count_,
     701             :                           "FLOWS.index_sm_log_count");
     702           2 :     GetOptValue<uint32_t>(var_map, flow_add_tokens_,
     703             :                           "FLOWS.add_tokens");
     704           2 :     GetOptValue<uint32_t>(var_map, flow_ksync_tokens_,
     705             :                           "FLOWS.ksync_tokens");
     706           2 :     GetOptValue<uint32_t>(var_map, flow_del_tokens_,
     707             :                           "FLOWS.del_tokens");
     708           2 :     GetOptValue<uint32_t>(var_map, flow_update_tokens_,
     709             :                           "FLOWS.update_tokens");
     710           2 :     GetOptValue<bool>(var_map, flow_hash_excl_rid_,
     711             :                       "FLOWS.hash_exclude_router_id");
     712           2 :     GetOptValue<uint16_t>(var_map, max_sessions_per_aggregate_,
     713             :                           "FLOWS.max_sessions_per_aggregate");
     714           2 :     GetOptValue<uint16_t>(var_map, max_aggregates_per_session_endpoint_,
     715             :                           "FLOWS.max_aggregates_per_session_endpoint");
     716           2 :     GetOptValue<uint16_t>(var_map, max_endpoints_per_session_msg_,
     717             :                           "FLOWS.max_endpoints_per_session_msg");
     718           2 :     GetOptValue<uint16_t>(var_map, fabric_snat_hash_table_size_,
     719             :                           "FLOWS.fabric_snat_hash_table_size");
     720           2 : }
     721             : 
     722           2 : void AgentParam::ParseDhcpRelayModeArguments
     723             :     (const boost::program_options::variables_map &var_map) {
     724           2 :     GetOptValue<bool>(var_map, dhcp_relay_mode_, "DEFAULT.dhcp_relay_mode");
     725           2 : }
     726             : 
     727           2 : void AgentParam::ParseSimulateEvpnTorArguments
     728             :     (const boost::program_options::variables_map &var_map) {
     729           2 :     GetOptValue<bool>(var_map, simulate_evpn_tor_, "DEFAULT.simulate_evpn_tor");
     730           2 : }
     731             : 
     732           2 : void AgentParam::ParseAgentInfoArguments
     733             :     (const boost::program_options::variables_map &var_map) {
     734           2 :     std::string mode;
     735           2 :     if (GetOptValue<string>(var_map, mode, "DEFAULT.agent_mode")) {
     736           0 :         set_agent_mode(mode);
     737             :     }
     738           2 :     if (GetOptValue<string>(var_map, mode, "DEFAULT.gateway_mode")) {
     739           0 :         set_gateway_mode(mode);
     740             :     }
     741           2 :     GetOptValue<string>(var_map, agent_base_dir_,
     742             :                         "DEFAULT.agent_base_directory");
     743           2 : }
     744             : 
     745           2 : void AgentParam::ParseServiceInstanceArguments
     746             :     (const boost::program_options::variables_map &var_map) {
     747           2 :     GetOptValue<string>(var_map, si_netns_command_, "SERVICE-INSTANCE.netns_command");
     748           2 :     GetOptValue<string>(var_map, si_docker_command_, "SERVICE-INSTANCE.docker_command");
     749           2 :     GetOptValue<int>(var_map, si_netns_workers_, "SERVICE-INSTANCE.netns_workers");
     750           2 :     GetOptValue<int>(var_map, si_netns_timeout_, "SERVICE-INSTANCE.netns_timeout");
     751           2 :     GetOptValue<string>(var_map, si_lb_ssl_cert_path_,
     752             :                         "SERVICE-INSTANCE.lb_ssl_cert_path");
     753           2 :     GetOptValue<string>(var_map, si_lbaas_auth_conf_,
     754             :                         "SERVICE-INSTANCE.lbaas_auth_conf");
     755             : 
     756           2 : }
     757             : 
     758           2 : void AgentParam::ParseNexthopServerArguments
     759             :     (const boost::program_options::variables_map &var_map) {
     760           2 :     GetOptValue<string>(var_map, nexthop_server_endpoint_,
     761             :                         "NEXTHOP-SERVER.endpoint");
     762           2 :     GetOptValue<bool>(var_map, nexthop_server_add_pid_,
     763             :                              "NEXTHOP-SERVER.add_pid");
     764           2 :     if (nexthop_server_add_pid_) {
     765           0 :         std::stringstream ss;
     766           0 :         ss << nexthop_server_endpoint_ << "." << getpid();
     767           0 :         nexthop_server_endpoint_ = ss.str();
     768           0 :     }
     769           2 : }
     770             : 
     771           0 : void AgentParam::SplitByDelimiter (const std::string &txt,
     772             :                                    std::vector<std::string> &strs, char ch) {
     773           0 :     size_t pos = txt.find(ch);
     774           0 :     size_t initialPos = 0;
     775           0 :     strs.clear();
     776             : 
     777           0 :     while(pos != std::string::npos) {
     778           0 :         strs.push_back(txt.substr(initialPos, pos - initialPos));
     779           0 :         initialPos = pos + 1;
     780           0 :         pos = txt.find(ch, initialPos);
     781             :     }
     782           0 :     strs.push_back(txt.substr(initialPos, std::min(pos, txt.size()) -
     783             :                                                    initialPos + 1));
     784           0 : }
     785             : 
     786           2 : void AgentParam::ParsePlatformArguments
     787             :     (const boost::program_options::variables_map &var_map) {
     788           4 :     if (var_map.count("DEFAULT.platform") &&
     789           2 :         !var_map["DEFAULT.platform"].defaulted()) {
     790           0 :         if (var_map["DEFAULT.platform"].as<string>() == "nic") {
     791           0 :             platform_ = AgentParam::VROUTER_ON_NIC;
     792           0 :         } else if (var_map["DEFAULT.platform"].as<string>() == "dpdk") {
     793           0 :             platform_ = AgentParam::VROUTER_ON_HOST_DPDK;
     794           0 :             if (var_map.count("DEFAULT.physical_interface_address")) {
     795           0 :                 string physical_interface_pci_addr_list;
     796           0 :                 physical_interface_pci_addr_list_.clear();
     797           0 :                 if (GetOptValue<string>(var_map, physical_interface_pci_addr_list,
     798             :                             "DEFAULT.physical_interface_address")) {
     799           0 :                     SplitByDelimiter(physical_interface_pci_addr_list,
     800           0 :                                      physical_interface_pci_addr_list_, ' ');
     801             :                 }
     802           0 :                 string physical_interface_mac_addr_list;
     803           0 :                 physical_interface_mac_addr_list_.clear();
     804           0 :                 if (GetOptValue<string>(var_map, physical_interface_mac_addr_list,
     805             :                             "DEFAULT.physical_interface_mac")) {
     806           0 :                     SplitByDelimiter(physical_interface_mac_addr_list,
     807           0 :                                      physical_interface_mac_addr_list_, ' ');
     808             :                 }
     809           0 :             }
     810             :         } else {
     811           0 :             platform_ = AgentParam::VROUTER_ON_HOST;
     812             :         }
     813             :     }
     814           2 : }
     815             : 
     816             : //this has been intentionally seperated from platform to provide an easier mix and match in the future if necessary
     817           2 : void AgentParam::ParseTestFrameworkArguments(
     818             :     const boost::program_options::variables_map &var_map) {
     819           2 :     GetOptValue<bool>(var_map, AgentMock_, "DEFAULT.agent_mock");
     820             : 
     821           2 :     if (AgentMock_) {
     822           0 :        GetOptValue<bool>(var_map, cat_MockDPDK_,
     823             :           "AGENT-TEST-FRAMEWORK.mock_dpdk");
     824           0 :        GetOptValue<string>(var_map, cat_kSocketDir_,
     825             :           "AGENT-TEST-FRAMEWORK.ksocketdir");
     826             :     }
     827             : 
     828           2 :    if (!AgentMock_ && cat_MockDPDK_) {
     829             :       std::cout <<"Please fix conf file parameters."
     830             :           <<" The DPDK cannot be mocked unless the Agent"
     831           0 :           <<"  is also executed in the Mock mode" << std::endl;
     832           0 :       exit(1);
     833             :    }
     834             : 
     835           2 : }
     836             : 
     837             : 
     838           2 : void AgentParam::ParseServicesArguments
     839             :     (const boost::program_options::variables_map &v) {
     840           2 :     GetOptValue<string>(v, bgp_as_a_service_port_range_,
     841             :                         "SERVICES.bgp_as_a_service_port_range");
     842           2 :     GetOptValue<uint32_t>(v, services_queue_limit_, "SERVICES.queue_limit");
     843           2 :     GetOptValue<uint32_t>(v, bgpaas_max_shared_sessions_,
     844             :                           "SERVICES.bgpaas_max_shared_sessions");
     845           2 : }
     846             : 
     847           2 : void AgentParam::ParseSandeshArguments
     848             :     (const boost::program_options::variables_map &v) {
     849           2 :     sandesh::options::ProcessOptions(v, &sandesh_config_);
     850           2 : }
     851             : 
     852           2 : void AgentParam::ParseRestartArguments
     853             :     (const boost::program_options::variables_map &v) {
     854           2 :     GetOptValue<bool>(v, restart_backup_enable_, "RESTART.backup_enable");
     855           2 :     GetOptValue<uint64_t>(v, restart_backup_idle_timeout_,
     856             :                           "RESTART.backup_idle_timeout");
     857           2 :     GetOptValue<string>(v, restart_backup_dir_, "RESTART.backup_dir");
     858           2 :     GetOptValue<uint16_t>(v, restart_backup_count_, "RESTART.backup_count");
     859             : 
     860           2 :     GetOptValue<bool>(v, restart_restore_enable_, "RESTART.restore_enable");
     861           2 :     GetOptValue<uint64_t>(v, restart_restore_audit_timeout_,
     862             :                           "RESTART.restore_audit_timeout");
     863           2 :     huge_page_file_1G_.clear();
     864           2 :     GetOptValueIfNotDefaulted< vector<string> >(v, huge_page_file_1G_,
     865             :                                                 "RESTART.huge_page_1G");
     866           2 :     if (huge_page_file_1G_.size() == 1) {
     867           0 :         boost::split(huge_page_file_1G_, huge_page_file_1G_[0],
     868           0 :                      boost::is_any_of(" "));
     869             :     }
     870           2 :     huge_page_file_2M_.clear();
     871           2 :     GetOptValueIfNotDefaulted< vector<string> >(v, huge_page_file_2M_,
     872             :                                                 "RESTART.huge_page_2M");
     873           2 :     if (huge_page_file_2M_.size() == 1) {
     874           0 :         boost::split(huge_page_file_2M_, huge_page_file_2M_[0],
     875           0 :                      boost::is_any_of(" "));
     876             :     }
     877           2 : }
     878             : 
     879           0 : void AgentParam::ParseLlgrArguments
     880             :     (const boost::program_options::variables_map &var_map) {
     881           0 :     GetOptValue<uint16_t>(var_map, llgr_params_.stale_config_cleanup_time_,
     882             :                           "LLGR.stale_config_cleanup_time_");
     883           0 :     GetOptValue<uint16_t>(var_map, llgr_params_.config_inactivity_time_,
     884             :                           "LLGR.config_inactivity_time");
     885           0 :     GetOptValue<uint16_t>(var_map, llgr_params_.config_fallback_time_,
     886             :                           "LLGR.config_fallback_time");
     887           0 :     GetOptValue<uint16_t>(var_map, llgr_params_.end_of_rib_rx_fallback_time_,
     888             :                           "LLGR.end_of_rib_rx_fallback_time");
     889           0 :     GetOptValue<uint16_t>(var_map, llgr_params_.end_of_rib_tx_fallback_time_,
     890             :                           "LLGR.end_of_rib_tx_fallback_time");
     891           0 :     GetOptValue<uint16_t>(var_map, llgr_params_.end_of_rib_tx_inactivity_time_,
     892             :                           "LLGR.end_of_rib_tx_inactivity_time_");
     893           0 :     GetOptValue<uint32_t>(var_map, llgr_params_.llgr_stale_time_,
     894             :                           "LLGR.llgr_stale_time");
     895           0 : }
     896             : 
     897           2 : void AgentParam::ParseMacLearning
     898             :     (const boost::program_options::variables_map &var_map) {
     899           2 :     GetOptValue<uint32_t>(var_map, mac_learning_thread_count_,
     900             :                           "MAC-LEARNING.thread_count");
     901           2 :     GetOptValue<uint32_t>(var_map, mac_learning_add_tokens_,
     902             :                           "MAC-LEARNING.add_tokens");
     903           2 :     GetOptValue<uint32_t>(var_map, mac_learning_delete_tokens_,
     904             :                           "MAC-LEARNING.del_tokens");
     905           2 :     GetOptValue<uint32_t>(var_map, mac_learning_update_tokens_,
     906             :                           "MAC-LEARNING.update_tokens");
     907           2 : }
     908             : 
     909           2 : void AgentParam::ParseCryptArguments
     910             :     (const boost::program_options::variables_map &var_map) {
     911           2 :     GetOptValue<string>(var_map, crypt_port_,
     912             :                         "CRYPT.crypt_interface");
     913           2 : }
     914             : 
     915             : // Initialize hypervisor mode based on system information
     916             : // If "/proc/xen" exists it means we are running in Xen dom0
     917           2 : void AgentParam::InitFromSystem() {
     918           2 :     boost::system::error_code error;
     919           2 :     host_name_ = boost::asio::ip::host_name(error);
     920           2 :     agent_name_ = host_name_;
     921             : 
     922             :     struct stat fstat;
     923           2 :     if (stat("/proc/xen", &fstat) == 0) {
     924           0 :         hypervisor_mode_ = MODE_XEN;
     925           0 :         cout << "Found file /proc/xen. Initializing mode to XEN\n";
     926             :     }
     927           2 :     xen_ll_.addr_ = Ip4Address::from_string("169.254.0.1");
     928           2 :     xen_ll_.plen_ = 16;
     929             : 
     930           4 :     return;
     931             : }
     932             : 
     933             : // Update agent parameters from config file
     934           2 : void AgentParam::InitFromConfig() {
     935             :     // Read and parse INI
     936           2 :     ifstream config_file_in;
     937           2 :     config_file_in.open(config_file_.c_str());
     938           2 :     if (config_file_in.good()) {
     939           2 :         opt::basic_parsed_options<char> ParsedOptions = opt::parse_config_file(config_file_in, config_file_options_, true);
     940           2 :         boost::program_options::store(ParsedOptions,
     941           2 :                    var_map_);
     942           2 :         boost::program_options::notify(var_map_);
     943           2 :         std::vector<boost::program_options::basic_option<char> >::iterator it;
     944          34 :         for (it=ParsedOptions.options.begin() ; it < ParsedOptions.options.end(); ++it) {
     945          32 :             if (it->unregistered) {
     946           2 :                 tree_.put(it->string_key,it->value.at(0));
     947             :             }
     948             :         }
     949           2 :     }
     950           2 :     config_file_in.close();
     951           2 :     cout << "Config file <" << config_file_ << "> parsing completed.\n";
     952           4 :     return;
     953           2 : }
     954             : 
     955           2 : void AgentParam::ProcessArguments() {
     956           2 :     ParseCollectorDSArguments(var_map_);
     957           2 :     ParseVirtualHostArguments(var_map_);
     958           2 :     ParseControllerServersArguments(var_map_);
     959           2 :     ParseDnsServersArguments(var_map_);
     960           2 :     ParseDnsArguments(var_map_);
     961           2 :     ParseNetworksArguments(var_map_);
     962           2 :     ParseHypervisorArguments(var_map_);
     963           2 :     ParseDefaultSectionArguments(var_map_);
     964           2 :     ParseTaskSectionArguments(var_map_);
     965           2 :     ParseFlowArguments(var_map_);
     966           2 :     ParseMetadataProxyArguments(var_map_);
     967           2 :     ParseDhcpRelayModeArguments(var_map_);
     968           2 :     ParseServiceInstanceArguments(var_map_);
     969           2 :     ParseSimulateEvpnTorArguments(var_map_);
     970           2 :     ParseAgentInfoArguments(var_map_);
     971           2 :     ParseNexthopServerArguments(var_map_);
     972           2 :     ParsePlatformArguments(var_map_);
     973           2 :     ParseServicesArguments(var_map_);
     974           2 :     ParseTestFrameworkArguments(var_map_);//sagarc
     975           2 :     ParseSandeshArguments(var_map_);
     976           2 :     ParseQueue();
     977           2 :     ParseRestartArguments(var_map_);
     978           2 :     ParseMacLearning(var_map_);
     979           2 :     ParseTsnServersArguments(var_map_);
     980           2 :     ParseCryptArguments(var_map_);
     981           2 :     ParseSessionDestinationArguments(var_map_);
     982           2 : }
     983             : 
     984           0 : void AgentParam::DebugInitFromConfig() {
     985             :     // Read and parse INI
     986           0 :     opt::variables_map var_map;
     987           0 :     ifstream config_file_in;
     988           0 :     config_file_in.open(config_file_.c_str());
     989           0 :     if (config_file_in.good()) {
     990             :         opt::basic_parsed_options<char> ParsedOptions =
     991           0 :             opt::parse_config_file(config_file_in, config_file_options_, true);
     992           0 :         boost::program_options::store(ParsedOptions, var_map);
     993           0 :     }
     994           0 :     config_file_in.close();
     995           0 :     LOG(INFO, "Config file parsing for debug params completed. \n");
     996           0 :     return;
     997           0 : }
     998             : 
     999           0 : void AgentParam::ReInitFromConfig() {
    1000             : 
    1001             :     // Read and parse INI
    1002           0 :     opt::variables_map var_map;
    1003           0 :     ifstream config_file_in;
    1004           0 :     config_file_in.open(config_file_.c_str());
    1005           0 :     if (config_file_in.good()) {
    1006             :         opt::basic_parsed_options<char> ParsedOptions =
    1007           0 :             opt::parse_config_file(config_file_in, config_file_options_, true);
    1008           0 :         boost::program_options::store(ParsedOptions, var_map);
    1009             : 
    1010           0 :         ParseControllerServersArguments(var_map);
    1011           0 :         ParseDnsServersArguments(var_map);
    1012           0 :         ParseCollectorArguments(var_map);
    1013           0 :         ParseTsnServersArguments(var_map);
    1014           0 :         ParseSessionDestinationArguments(var_map);
    1015             : 
    1016           0 :         LogFilteredConfig();
    1017           0 :     }
    1018           0 :     config_file_in.close();
    1019           0 :     LOG(DEBUG, "Config file re-parsing completed. \n");
    1020             : 
    1021           0 :     return;
    1022           0 : }
    1023             : 
    1024           2 : void AgentParam::UpdateBgpAsaServicePortRangeValue() {
    1025           2 :     if (!stringToIntegerList(bgp_as_a_service_port_range_, "-",
    1026           2 :                              bgp_as_a_service_port_range_value_)) {
    1027           0 :         bgp_as_a_service_port_range_value_.clear();
    1028           0 :         return;
    1029             :     }
    1030             : }
    1031             : 
    1032           0 : void AgentParam::UpdateBgpAsaServicePortRange() {
    1033           0 :     if (!stringToIntegerList(bgp_as_a_service_port_range_, "-",
    1034           0 :                              bgp_as_a_service_port_range_value_)) {
    1035           0 :         bgp_as_a_service_port_range_value_.clear();
    1036           0 :         return;
    1037             :     }
    1038           0 :     uint16_t start = bgp_as_a_service_port_range_value_[0];
    1039           0 :     uint16_t end = bgp_as_a_service_port_range_value_[1];
    1040             : 
    1041           0 :     uint16_t count = end - start + 1;
    1042           0 :     if (count > Agent::kMaxBgpAsAServerSessions) {
    1043           0 :         bgp_as_a_service_port_range_value_[1] =
    1044           0 :             start + Agent::kMaxBgpAsAServerSessions - 1;
    1045           0 :         count = Agent::kMaxBgpAsAServerSessions;
    1046             :     }
    1047             : 
    1048             :     struct rlimit rl;
    1049           0 :     int result = getrlimit(RLIMIT_NOFILE, &rl);
    1050           0 :     if (result == 0) {
    1051           0 :         if (rl.rlim_max <= Agent::kMaxOtherOpenFds) {
    1052             :             cout << "Clearing BGP as a Service port range," <<
    1053           0 :                     "as Max fd system limit is inadequate\n";
    1054           0 :             bgp_as_a_service_port_range_value_.clear();
    1055           0 :             return;
    1056             :         }
    1057           0 :         if (count > rl.rlim_max - Agent::kMaxOtherOpenFds) {
    1058           0 :             bgp_as_a_service_port_range_value_[1] =
    1059           0 :                 start + rl.rlim_max - Agent::kMaxOtherOpenFds - 1;
    1060           0 :             cout << "Updating BGP as a Service port range to " <<
    1061           0 :                 bgp_as_a_service_port_range_value_[0] << " - " <<
    1062           0 :                 bgp_as_a_service_port_range_value_[1] << "\n";
    1063             :         }
    1064             :     } else {
    1065           0 :         cout << "Unable to validate BGP as a server port range configuration\n";
    1066             :     }
    1067             : }
    1068             : 
    1069           2 : void AgentParam::ComputeVrWatermark() {
    1070           2 :     if (vr_object_high_watermark_ > 95) {
    1071           0 :         cout << "Max is 95 updating vrouter objects high watermark to max : 95%\n";
    1072           0 :         vr_object_high_watermark_ = 95;
    1073             :     }
    1074           2 :     if (vr_object_high_watermark_ < 50) {
    1075           0 :         cout << "Wrong config updating vrouter objects high watermark to lowest : 50%\n";
    1076           0 :         vr_object_high_watermark_ = 50;
    1077             :     }
    1078           2 : }
    1079             : 
    1080           2 : void AgentParam::ComputeFlowAndFileLimits() {
    1081             :     struct rlimit rl;
    1082           2 :     int result = getrlimit(RLIMIT_NOFILE, &rl);
    1083           2 :     if (result == 0) {
    1084           2 :         if (rl.rlim_max <= Agent::kMaxOtherOpenFds + 1) {
    1085           0 :             cout << "Updating linklocal flows configuration to 0\n";
    1086           0 :             linklocal_system_flows_ = linklocal_vm_flows_ = 0;
    1087           0 :             return;
    1088             :         }
    1089           2 :         if (linklocal_system_flows_ > rl.rlim_max -
    1090           2 :                                       Agent::kMaxOtherOpenFds - 1) {
    1091           0 :             linklocal_system_flows_ = rl.rlim_max -
    1092           0 :                                       Agent::kMaxOtherOpenFds - 1;
    1093           0 :             cout << "Updating linklocal-system-flows configuration to : " <<
    1094           0 :                 linklocal_system_flows_ << "\n";
    1095             :         }
    1096             : 
    1097             :         /* Set the rlimit here for max open files to the required value of
    1098             :          * linklocal_system_flows_ + Agent::kMaxOtherOpenFds + 1. Note that
    1099             :          * soft limit is set to the required value even if the existing soft
    1100             :          * limit is higher than the required value. This is done to avoid long
    1101             :          * close() FD loops following any fork or vfork() agent may do in case
    1102             :          * the soft value is set to max allowed value of 1M */
    1103             :         struct rlimit new_rl;
    1104           2 :         new_rl.rlim_max = rl.rlim_max;
    1105           2 :         new_rl.rlim_cur = linklocal_system_flows_ +
    1106           2 :                           Agent::kMaxOtherOpenFds + 1;
    1107           2 :         result = setrlimit(RLIMIT_NOFILE, &new_rl);
    1108           2 :         if (result != 0) {
    1109           0 :             if (rl.rlim_cur <= Agent::kMaxOtherOpenFds + 1) {
    1110           0 :                 linklocal_system_flows_ = 0;
    1111             :             } else {
    1112           0 :                 linklocal_system_flows_ = rl.rlim_cur -
    1113           0 :                                           Agent::kMaxOtherOpenFds - 1;
    1114             :             }
    1115           0 :             cout << "Unable to set Max open files limit to : " <<
    1116           0 :                 new_rl.rlim_cur <<
    1117           0 :                 " Updating linklocal-system-flows configuration to : " <<
    1118           0 :                 linklocal_system_flows_ << "\n";
    1119             :         }
    1120             : 
    1121           2 :         if (linklocal_vm_flows_ > linklocal_system_flows_) {
    1122           0 :             linklocal_vm_flows_ = linklocal_system_flows_;
    1123           0 :             cout << "Updating linklocal-vm-flows configuration to : " <<
    1124           0 :                 linklocal_vm_flows_ << "\n";
    1125             :         }
    1126             :     } else {
    1127           0 :         cout << "Unable to validate linklocal flow configuration\n";
    1128             :     }
    1129             : }
    1130             : 
    1131           4 : static bool ValidateInterface(bool test_mode, const std::string &ifname,
    1132             :                               bool *no_arp, string *eth_encap) {
    1133           4 :     *no_arp = false;
    1134           4 :     *eth_encap = "";
    1135             : 
    1136           4 :     if (test_mode) {
    1137           4 :         return true;
    1138             :     }
    1139             : 
    1140           0 :     int fd = socket(AF_LOCAL, SOCK_STREAM, 0);
    1141           0 :     assert(fd >= 0);
    1142             : 
    1143             :     struct ifreq ifr;
    1144           0 :     memset(&ifr, 0, sizeof(ifr));
    1145           0 :     strncpy(ifr.ifr_name, ifname.c_str(), IF_NAMESIZE-1);
    1146           0 :     int err = ioctl(fd, SIOCGIFFLAGS, (void *)&ifr);
    1147           0 :     close (fd);
    1148             : 
    1149           0 :     if (err < 0) {
    1150           0 :         LOG(ERROR, "Error reading interface <" << ifname << ">. Error number "
    1151             :             << errno << " : " << strerror(errno));
    1152           0 :         return false;
    1153             :     }
    1154             : 
    1155           0 :     if ((ifr.ifr_flags & IFF_NOARP)) {
    1156           0 :         *no_arp = true;
    1157             :     }
    1158             : 
    1159             :     char fname[128];
    1160           0 :     snprintf(fname, 128, "/sys/class/net/%s/type", ifname.c_str());
    1161           0 :     FILE *f = fopen(fname, "r");
    1162           0 :     if (f) {
    1163             :         int type;
    1164           0 :         if (fscanf(f, "%d", &type) >= 0) {
    1165           0 :             if (type == ARPHRD_NONE) {
    1166           0 :                 *eth_encap = "none";
    1167             :             }
    1168             :         }
    1169           0 :         fclose(f);
    1170             :     }
    1171             : 
    1172           0 :     return true;
    1173             : }
    1174             : 
    1175           2 : int AgentParam::Validate() {
    1176             :     // TODO: fix the validation for the DPDK platform
    1177           2 :     if (platform_ == AgentParam::VROUTER_ON_HOST_DPDK)
    1178           0 :         return 0;
    1179             : 
    1180             :     // Validate vhost interface name
    1181           2 :     if (vhost_.name_ == "") {
    1182           0 :         LOG(ERROR, "Configuration error. vhost interface name not specified");
    1183           0 :         return (EINVAL);
    1184             :     }
    1185             : 
    1186             :     bool no_arp;
    1187           2 :     string encap;
    1188             :     // Check if interface is already present
    1189           2 :     if (ValidateInterface(test_mode_, vhost_.name_, &no_arp, &encap) == false) {
    1190           0 :         return (ENODEV);
    1191             :     }
    1192             : 
    1193             :     // Validate ethernet port
    1194           2 :     if (eth_port_list_.empty()) {
    1195           0 :         LOG(ERROR, "Configuration error. eth_port not specified");
    1196           0 :         return (EINVAL);
    1197             :     }
    1198             : 
    1199             :     // Check if interface is already present
    1200           2 :     std::vector<std::string>::iterator iter;
    1201           4 :     for (iter = eth_port_list_.begin(); iter != eth_port_list_.end(); iter++) {
    1202           2 :         if (ValidateInterface(test_mode_, *iter, &eth_port_no_arp_,
    1203           2 :                     &eth_port_encap_type_) == false) {
    1204           0 :             return (ENODEV);
    1205             :         }
    1206             :     }
    1207             : 
    1208           2 :     if (crypt_port_ != "") {
    1209             :        // Check if interface is already present
    1210           0 :        if (ValidateInterface(test_mode_, crypt_port_, &crypt_port_no_arp_,
    1211           0 :                              &crypt_port_encap_type_) == false) {
    1212           0 :            return (ENODEV);
    1213             :        }
    1214             :     }
    1215             : 
    1216             :     // Validate physical port used in vmware
    1217           2 :     if (hypervisor_mode_ == MODE_VMWARE) {
    1218           0 :         if (vmware_physical_port_ == "") {
    1219           0 :             LOG(ERROR, "Configuration error. Physical port connecting to "
    1220             :                 "virtual-machines not specified");
    1221           0 :             return (EINVAL);
    1222             :         }
    1223             : 
    1224           0 :         if (ValidateInterface(test_mode_, vmware_physical_port_, &no_arp,
    1225           0 :                               &encap) == false) {
    1226           0 :             return (ENODEV);
    1227             :         }
    1228             :     }
    1229             : 
    1230           2 :     return 0;
    1231           2 : }
    1232             : 
    1233           2 : void AgentParam::InitVhostAndXenLLPrefix() {
    1234             :     // Set the prefix address for VHOST and XENLL interfaces
    1235           2 :     uint32_t mask = vhost_.plen_ ? (0xFFFFFFFF << (32 - vhost_.plen_)) : 0;
    1236           2 :     vhost_.prefix_ = Ip4Address(vhost_.addr_.to_ulong() & mask);
    1237             : 
    1238           2 :     mask = xen_ll_.plen_ ? (0xFFFFFFFF << (32 - xen_ll_.plen_)) : 0;
    1239           2 :     xen_ll_.prefix_ = Ip4Address(xen_ll_.addr_.to_ulong() & mask);
    1240           2 : }
    1241             : 
    1242           0 : bool AgentParam::IsConfiguredTsnHostRoute(std::string addr) const {
    1243           0 :     return (std::find(tsn_server_list_.begin(), tsn_server_list_.end(), addr) !=
    1244           0 :             tsn_server_list_.end());
    1245             : }
    1246             : 
    1247           2 : void AgentParam::Init(const string &config_file, const string &program_name) {
    1248             : 
    1249           2 :     config_file_ = config_file;
    1250           2 :     program_name_ = program_name;
    1251           2 :     InitFromSystem();
    1252           2 :     InitFromConfig();
    1253           2 :     ProcessArguments();
    1254           2 :     InitVhostAndXenLLPrefix();
    1255           2 :     UpdateBgpAsaServicePortRangeValue();
    1256           2 :     ComputeFlowAndFileLimits();
    1257           2 :     ComputeVrWatermark();
    1258           2 :     vgw_config_table_->InitFromConfig(tree_);
    1259           2 : }
    1260             : 
    1261           0 : void AgentParam::ReInit() {
    1262           0 :     ReInitFromConfig();
    1263           0 : }
    1264             : 
    1265           0 : void AgentParam::DebugInit() {
    1266           0 :     DebugInitFromConfig();
    1267           0 : }
    1268             : 
    1269           0 : void AgentParam::LogFilteredConfig() const {
    1270           0 :     std::string concat_servers;
    1271           0 :     std::vector<string> list = controller_server_list();
    1272           0 :     std::vector<string>::iterator iter;
    1273           0 :     for (iter = list.begin();
    1274           0 :          iter != list.end(); iter++) {
    1275           0 :          concat_servers += *iter + " ";
    1276             :     }
    1277           0 :     LOG(DEBUG, "Xmpp Servers                : " << concat_servers);
    1278             : 
    1279           0 :     concat_servers.clear();
    1280           0 :     list = dns_server_list();
    1281           0 :     for (iter = list.begin();
    1282           0 :          iter != list.end(); iter++) {
    1283           0 :          concat_servers += *iter + " ";
    1284             :     }
    1285           0 :     LOG(DEBUG, "DNS Servers                 : " << concat_servers);
    1286             : 
    1287           0 :     list = tsn_server_list();
    1288           0 :     concat_servers.clear();
    1289           0 :     for (iter = list.begin();
    1290           0 :          iter != list.end(); iter++) {
    1291           0 :          concat_servers += *iter + " ";
    1292             :     }
    1293           0 :     LOG(DEBUG, "TSN Servers                 : " << concat_servers);
    1294             : 
    1295           0 :     concat_servers.clear();
    1296           0 :     list = collector_server_list();
    1297           0 :     for (iter = list.begin();
    1298           0 :          iter != list.end(); iter++) {
    1299           0 :          concat_servers += *iter + " ";
    1300             :     }
    1301           0 :     LOG(DEBUG, "COLLECTOR Servers                 : " << concat_servers);
    1302           0 : }
    1303             : 
    1304           2 : void AgentParam::LogConfig() const {
    1305           2 :     LOG(DEBUG, "vhost interface name        : " << vhost_.name_);
    1306           2 :     LOG(DEBUG, "vhost IP Address            : " << vhost_.addr_.to_string()
    1307             :         << "/" << vhost_.plen_);
    1308           2 :     LOG(DEBUG, "vhost gateway               : " << vhost_.gw_.to_string());
    1309           2 :     std::string eth_port_list;
    1310           2 :     std::vector<std::string>::const_iterator iter;
    1311           4 :     for (iter = eth_port_list_.begin(); iter != eth_port_list_.end(); iter++) {
    1312           2 :         eth_port_list += *iter + " ";
    1313             :     }
    1314           2 :     LOG(DEBUG, "Ethernet ports              : " << eth_port_list);
    1315           2 :     LOG(DEBUG, "Loopback IP                 : " << loopback_ip_.to_string());
    1316             : 
    1317           2 :     std::string concat_servers;
    1318           2 :     std::vector<string> list = controller_server_list();
    1319           2 :     for (iter = list.begin();
    1320           4 :          iter != list.end(); iter++) {
    1321           2 :          concat_servers += *iter + " ";
    1322             :     }
    1323           2 :     LOG(DEBUG, "Xmpp Servers                : " << concat_servers);
    1324           2 :     LOG(DEBUG, "Xmpp Authentication         : " << xmpp_auth_enable_);
    1325           2 :     if (xmpp_auth_enable_) {
    1326           0 :         LOG(DEBUG, "Xmpp Server Certificate : " << xmpp_server_cert_);
    1327           0 :         LOG(DEBUG, "Xmpp Server Key         : " << xmpp_server_key_);
    1328           0 :         LOG(DEBUG, "Xmpp CA Certificate     : " << xmpp_ca_cert_);
    1329             :     }
    1330           2 :     LOG(DEBUG, "Cluster-Name : " << subcluster_name_);
    1331             : 
    1332           2 :     concat_servers.clear();
    1333           2 :     list = dns_server_list();
    1334           2 :     for (iter = list.begin();
    1335           4 :          iter != list.end(); iter++) {
    1336           2 :          concat_servers += *iter + " ";
    1337             :     }
    1338           2 :     LOG(DEBUG, "DNS Servers                 : " << concat_servers);
    1339           2 :     LOG(DEBUG, "DNS client port             : " << dns_client_port_);
    1340           2 :     LOG(DEBUG, "DNS timeout                 : " << dns_timeout_);
    1341           2 :     LOG(DEBUG, "DNS max retries             : " << dns_max_retries_);
    1342           2 :     LOG(DEBUG, "Xmpp Dns Authentication     : " << xmpp_dns_auth_enable_);
    1343           2 :     if (xmpp_dns_auth_enable_) {
    1344           0 :         LOG(DEBUG, "Xmpp Server Certificate : " << xmpp_server_cert_);
    1345           0 :         LOG(DEBUG, "Xmpp Server Key         : " << xmpp_server_key_);
    1346           0 :         LOG(DEBUG, "Xmpp CA Certificate     : " << xmpp_ca_cert_);
    1347             :     }
    1348             : 
    1349           2 :     concat_servers.clear();
    1350           2 :     list = tsn_server_list();
    1351           2 :     for (iter = list.begin();
    1352           2 :          iter != list.end(); iter++) {
    1353           0 :          concat_servers += *iter + " ";
    1354             :     }
    1355           2 :     LOG(DEBUG, "TSN Servers                 : " << concat_servers);
    1356           2 :     concat_servers.clear();
    1357             : 
    1358           2 :     list = collector_server_list();
    1359           2 :     for (iter = list.begin();
    1360           4 :          iter != list.end(); iter++) {
    1361           2 :          concat_servers += *iter + " ";
    1362             :     }
    1363           2 :     LOG(DEBUG, "COLLECTOR Servers                 : " << concat_servers);
    1364             : 
    1365           2 :     LOG(DEBUG, "Tunnel-Type                 : " << tunnel_type_);
    1366           2 :     LOG(DEBUG, "Metadata-Proxy Shared Secret: " << metadata_shared_secret_);
    1367           2 :     LOG(DEBUG, "Metadata-Proxy Port         : " << metadata_proxy_port_);
    1368           2 :     LOG(DEBUG, "Metadata-Proxy SSL Flag     : " << metadata_use_ssl_);
    1369           2 :     if (metadata_use_ssl_) {
    1370           0 :         LOG(DEBUG, "Metadata Client Certificate     : " << metadata_client_cert_);
    1371           0 :         LOG(DEBUG, "Metadata Client Certificate Type: "
    1372             :             << metadata_client_cert_type_);
    1373           0 :         LOG(DEBUG, "Metadata Client Key             : " << metadata_client_key_);
    1374           0 :         LOG(DEBUG, "Metadata CA Certificate         : " << metadata_ca_cert_);
    1375             :     }
    1376             : 
    1377           2 :     LOG(DEBUG, "Linklocal Max System Flows  : " << linklocal_system_flows_);
    1378           2 :     LOG(DEBUG, "Linklocal Max Vm Flows      : " << linklocal_vm_flows_);
    1379           2 :     LOG(DEBUG, "Flow cache timeout          : " << flow_cache_timeout_);
    1380           2 :     LOG(DEBUG, "Stale Interface cleanup timeout  : "
    1381             :         << stale_interface_cleanup_timeout_);
    1382           2 :     LOG(DEBUG, "Flow thread count           : " << flow_thread_count_);
    1383           2 :     LOG(DEBUG, "Flow latency limit          : " << flow_latency_limit_);
    1384           2 :     LOG(DEBUG, "Flow index-mgr sm log count : " << flow_index_sm_log_count_);
    1385           2 :     LOG(DEBUG, "Flow add-tokens             : " << flow_add_tokens_);
    1386           2 :     LOG(DEBUG, "Flow ksync-tokens           : " << flow_ksync_tokens_);
    1387           2 :     LOG(DEBUG, "Flow del-tokens             : " << flow_del_tokens_);
    1388           2 :     LOG(DEBUG, "Flow update-tokens          : " << flow_update_tokens_);
    1389           2 :     LOG(DEBUG, "Pin flow netlink task to CPU: "
    1390             :         << ksync_thread_cpu_pin_policy_);
    1391           2 :     LOG(DEBUG, "Maximum sessions            : " << max_sessions_per_aggregate_);
    1392           2 :     LOG(DEBUG, "Maximum session aggregates  : " << max_aggregates_per_session_endpoint_);
    1393           2 :     LOG(DEBUG, "Maximum session endpoints   : " << max_endpoints_per_session_msg_);
    1394           2 :     LOG(DEBUG, "Fabric SNAT hash table size : " << fabric_snat_hash_table_size_);
    1395           2 :     LOG(DEBUG, "Flow excluding Router ID in hash    :" << flow_hash_excl_rid_);
    1396             : 
    1397           2 :     if (agent_mode_ == VROUTER_AGENT)
    1398           2 :         LOG(DEBUG, "Agent Mode                  : Vrouter");
    1399           0 :     else if (agent_mode_ == TSN_AGENT)
    1400           0 :         LOG(DEBUG, "Agent Mode                  : TSN");
    1401           0 :     else if (agent_mode_ == TOR_AGENT)
    1402           0 :         LOG(DEBUG, "Agent Mode                  : TOR");
    1403             : 
    1404           2 :     if (gateway_mode_ == SERVER)
    1405           0 :         LOG(DEBUG, "Gateway Mode                : Server");
    1406           2 :     else if (gateway_mode_ == VCPE)
    1407           0 :         LOG(DEBUG, "Gateway Mode                : vCPE");
    1408           2 :     else if (gateway_mode_ == PBB)
    1409           0 :         LOG(DEBUG, "Gateway Mode                : PBB node");
    1410           2 :     else if (gateway_mode_ == NONE)
    1411           2 :         LOG(DEBUG, "Gateway Mode                : None");
    1412             : 
    1413           2 :     LOG(DEBUG, "DHCP Relay Mode             : " << dhcp_relay_mode_);
    1414           2 :     if (simulate_evpn_tor_) {
    1415           0 :         LOG(DEBUG, "Simulate EVPN TOR           : " << simulate_evpn_tor_);
    1416             :     }
    1417           2 :     LOG(DEBUG, "Service instance netns cmd  : " << si_netns_command_);
    1418           2 :     LOG(DEBUG, "Service instance docker cmd  : " << si_docker_command_);
    1419           2 :     LOG(DEBUG, "Service instance workers    : " << si_netns_workers_);
    1420           2 :     LOG(DEBUG, "Service instance timeout    : " << si_netns_timeout_);
    1421           2 :     LOG(DEBUG, "Service instance lb ssl     : " << si_lb_ssl_cert_path_);
    1422           2 :     LOG(DEBUG, "Service instance lbaas auth : " << si_lbaas_auth_conf_);
    1423           2 :     LOG(DEBUG, "Bgp as a service port range : " << bgp_as_a_service_port_range_);
    1424           2 :     LOG(DEBUG, "Services queue limit        : " << services_queue_limit_);
    1425           2 :     LOG(DEBUG, "BGPAAS max shared sessions for service port  : " << bgpaas_max_shared_sessions_);
    1426             : 
    1427           2 :     LOG(DEBUG, "Sandesh Key file            : " << sandesh_config_.keyfile);
    1428           2 :     LOG(DEBUG, "Sandesh Cert file           : " << sandesh_config_.certfile);
    1429           2 :     LOG(DEBUG, "Sandesh CA Cert             : " << sandesh_config_.ca_cert);
    1430           2 :     LOG(DEBUG, "Sandesh SSL Enable          : "
    1431             :         << sandesh_config_.sandesh_ssl_enable);
    1432           2 :     LOG(DEBUG, "Introspect SSL Enable       : "
    1433             :         << sandesh_config_.introspect_ssl_enable);
    1434             : 
    1435           2 :     if (hypervisor_mode_ == MODE_KVM) {
    1436           2 :     LOG(DEBUG, "Hypervisor mode             : kvm");
    1437           2 :         return;
    1438             :     }
    1439             : 
    1440           0 :     if (hypervisor_mode_ == MODE_XEN) {
    1441           0 :     LOG(DEBUG, "Hypervisor mode             : xen");
    1442           0 :     LOG(DEBUG, "XEN Link Local port         : " << xen_ll_.name_);
    1443           0 :     LOG(DEBUG, "XEN Link Local IP Address   : " << xen_ll_.addr_.to_string()
    1444             :         << "/" << xen_ll_.plen_);
    1445             :     }
    1446             : 
    1447           0 :     if (hypervisor_mode_ == MODE_VMWARE) {
    1448           0 :     LOG(DEBUG, "Hypervisor mode             : vmware");
    1449           0 :     LOG(DEBUG, "Vmware port                 : " << vmware_physical_port_);
    1450           0 :     if (vmware_mode_ == VCENTER) {
    1451           0 :     LOG(DEBUG, "Vmware mode                 : Vcenter");
    1452             :     } else {
    1453           0 :     LOG(DEBUG, "Vmware mode                 : Esxi_Neutron");
    1454             :     }
    1455             :     }
    1456           0 :     LOG(DEBUG, "Nexthop server endpoint  : " << nexthop_server_endpoint_);
    1457           0 :     LOG(DEBUG, "Agent base directory     : " << agent_base_dir_);
    1458           0 :     LOG(DEBUG, "Vrouter objects high watermark     : " << vr_object_high_watermark_);
    1459           6 : }
    1460             : 
    1461           2 : void AgentParam::PostValidateLogConfig() const {
    1462           2 :     LOG(DEBUG, "Ethernet Port Encap Type    : " << eth_port_encap_type_);
    1463           2 :     if (eth_port_no_arp_) {
    1464           0 :     LOG(DEBUG, "Ethernet Port No-ARP        : " << "TRUE");
    1465             :     }
    1466             : 
    1467           2 :     if (platform_ == VROUTER_ON_NIC) {
    1468           0 :         LOG(DEBUG, "Platform mode           : Vrouter on NIC");
    1469           2 :     } else if (platform_ == VROUTER_ON_HOST_DPDK) {
    1470           0 :         LOG(DEBUG, "Platform mode           : Vrouter on DPDK");
    1471             :     }
    1472             :     else {
    1473           2 :         LOG(DEBUG, "Platform mode           : Vrouter on host linux kernel ");
    1474             :     }
    1475           2 : }
    1476             : 
    1477           2 : void AgentParam::set_test_mode(bool mode) {
    1478           2 :     test_mode_ = mode;
    1479           2 : }
    1480             : 
    1481           0 : void AgentParam::AddOptions
    1482             : (const boost::program_options::options_description &opt) {
    1483           0 :     options_.add(opt);
    1484           0 : }
    1485             : 
    1486           0 : void AgentParam::ConfigAddOptions
    1487             : (const boost::program_options::options_description &opt) {
    1488           0 :     config_file_options_.add(opt);
    1489           0 : }
    1490             : 
    1491           0 : void AgentParam::ParseArguments(int argc, char *argv[]) {
    1492           0 :     boost::program_options::store(opt::parse_command_line(argc, argv, options_),
    1493           0 :                                   var_map_);
    1494           0 :     boost::program_options::notify(var_map_);
    1495           0 : }
    1496             : 
    1497           2 : AgentParam::AgentParam(bool enable_flow_options,
    1498             :                        bool enable_vhost_options,
    1499             :                        bool enable_hypervisor_options,
    1500             :                        bool enable_service_options,
    1501           2 :                        AgentMode agent_mode) :
    1502           2 :         enable_flow_options_(enable_flow_options),
    1503           2 :         enable_vhost_options_(enable_vhost_options),
    1504           2 :         enable_hypervisor_options_(enable_hypervisor_options),
    1505           2 :         enable_service_options_(enable_service_options),
    1506           2 :         agent_mode_(agent_mode), gateway_mode_(NONE), vhost_(),
    1507           2 :         pkt0_tx_buffer_count_(Agent::kPkt0TxBufferCount),
    1508           2 :         measure_queue_delay_(false),
    1509           2 :         agent_name_(),
    1510           2 :         eth_port_no_arp_(false), eth_port_encap_type_(),
    1511           2 :         crypt_port_(), crypt_port_no_arp_(true), crypt_port_encap_type_(),
    1512           2 :         subcluster_name_(),
    1513           2 :         dns_client_port_(0), dns_timeout_(3000),
    1514           2 :         dns_max_retries_(2), mirror_client_port_(0),
    1515           2 :         mgmt_ip_(), hypervisor_mode_(MODE_KVM),
    1516           2 :         xen_ll_(), tunnel_type_(), metadata_shared_secret_(),
    1517           2 :         metadata_proxy_port_(0), metadata_use_ssl_(false),
    1518           2 :         metadata_client_cert_(""), metadata_client_cert_type_("PEM"),
    1519           2 :         metadata_client_key_(""), metadata_ca_cert_(""),
    1520           2 :         linklocal_system_flows_(), linklocal_vm_flows_(),
    1521           2 :         flow_cache_timeout_(), flow_index_sm_log_count_(),
    1522           2 :         flow_add_tokens_(Agent::kFlowAddTokens),
    1523           2 :         flow_ksync_tokens_(Agent::kFlowKSyncTokens),
    1524           2 :         flow_del_tokens_(Agent::kFlowDelTokens),
    1525           2 :         flow_update_tokens_(Agent::kFlowUpdateTokens),
    1526           2 :         flow_netlink_pin_cpuid_(0),
    1527           2 :         stale_interface_cleanup_timeout_
    1528             :         (Agent::kDefaultStaleInterfaceCleanupTimeout),
    1529           2 :         config_file_(), program_name_(),
    1530           2 :         log_file_(), log_files_count_(kLogFilesCount),
    1531           2 :         log_file_size_(kLogFileSize),
    1532           2 :         log_local_(false), log_flow_(false), log_level_(),
    1533           2 :         log_category_(), use_syslog_(false),
    1534           2 :         http_server_port_(), rest_port_(), host_name_(),
    1535           2 :         agent_stats_interval_(kAgentStatsInterval),
    1536           2 :         flow_stats_interval_(kFlowStatsInterval),
    1537           2 :         vrouter_stats_interval_(kVrouterStatsInterval),
    1538           2 :         vmware_physical_port_(""), test_mode_(false), tree_(),
    1539           2 :         vgw_config_table_(new VirtualGatewayConfigTable() ),
    1540           2 :         dhcp_relay_mode_(false), xmpp_auth_enable_(false),
    1541           2 :         xmpp_server_cert_(""), xmpp_server_key_(""), xmpp_ca_cert_(""),
    1542           2 :         xmpp_dns_auth_enable_(false),
    1543           2 :         simulate_evpn_tor_(false), si_netns_command_(),
    1544           2 :         si_docker_command_(), si_netns_workers_(0),
    1545           2 :         si_netns_timeout_(0), si_lb_ssl_cert_path_(), si_lbaas_auth_conf_(),
    1546           2 :         vmware_mode_(ESXI_NEUTRON), nexthop_server_endpoint_(),
    1547           2 :         nexthop_server_add_pid_(0),
    1548           2 :         vrouter_on_nic_mode_(false),
    1549           2 :         exception_packet_interface_(""),
    1550           2 :         platform_(VROUTER_ON_HOST),
    1551           2 :         agent_base_dir_(),
    1552           2 :         flow_thread_count_(Agent::kDefaultFlowThreadCount),
    1553           2 :         flow_trace_enable_(true),
    1554           2 :         flow_hash_excl_rid_(false),
    1555           2 :         flow_latency_limit_(Agent::kDefaultFlowLatencyLimit),
    1556           2 :         max_sessions_per_aggregate_(Agent::kMaxSessions),
    1557           2 :         max_aggregates_per_session_endpoint_(Agent::kMaxSessionAggs),
    1558           2 :         max_endpoints_per_session_msg_(Agent::kMaxSessionEndpoints),
    1559           2 :         subnet_hosts_resolvable_(true),
    1560           2 :         bgp_as_a_service_port_range_("50000-50512"),
    1561           2 :         services_queue_limit_(1024),
    1562           2 :         bgpaas_max_shared_sessions_(4),
    1563           2 :         sandesh_config_(),
    1564           2 :         restart_backup_enable_(false),
    1565           2 :         restart_backup_idle_timeout_(CFG_BACKUP_IDLE_TIMEOUT),
    1566           2 :         restart_backup_dir_(CFG_BACKUP_DIR),
    1567           2 :         restart_backup_count_(CFG_BACKUP_COUNT),
    1568           2 :         restart_restore_enable_(true),
    1569           2 :         restart_restore_audit_timeout_(CFG_RESTORE_AUDIT_TIMEOUT),
    1570           2 :         huge_page_file_1G_(),
    1571           2 :         huge_page_file_2M_(),
    1572           2 :         ksync_thread_cpu_pin_policy_(),
    1573           2 :         tbb_thread_count_(Agent::kMaxTbbThreads),
    1574           2 :         tbb_exec_delay_(0),
    1575           2 :         tbb_schedule_delay_(0),
    1576           2 :         tbb_keepawake_timeout_(Agent::kDefaultTbbKeepawakeTimeout),
    1577           2 :         task_monitor_timeout_msec_(Agent::kDefaultTaskMonitorTimeout),
    1578           2 :         qos_priority_tagging_(true),
    1579           2 :         default_nic_queue_(Agent::kInvalidQueueId),
    1580           2 :         llgr_params_(),
    1581           2 :         mac_learning_thread_count_(Agent::kDefaultFlowThreadCount),
    1582           2 :         mac_learning_add_tokens_(Agent::kMacLearningDefaultTokens),
    1583           2 :         mac_learning_update_tokens_(Agent::kMacLearningDefaultTokens),
    1584           2 :         mac_learning_delete_tokens_(Agent::kMacLearningDefaultTokens),
    1585           2 :         min_aap_prefix_len_(Agent::kMinAapPrefixLen),
    1586           2 :         vmi_vm_vn_uve_interval_(Agent::kDefaultVmiVmVnUveInterval),
    1587           2 :         fabric_snat_hash_table_size_(Agent::kFabricSnatTableSize),
    1588           2 :         mvpn_ipv4_enable_(false),AgentMock_(false), cat_MockDPDK_(false),
    1589           2 :         cat_kSocketDir_("/tmp/"),
    1590           2 :         vr_object_high_watermark_(Agent::kDefaultHighWatermark),
    1591          22 :         loopback_ip_(), gateway_list_(AddressList(1, Ip4Address(0))) {
    1592             : 
    1593           2 :     uint32_t default_pkt0_tx_buffers = Agent::kPkt0TxBufferCount;
    1594           2 :     uint32_t default_stale_interface_cleanup_timeout = Agent::kDefaultStaleInterfaceCleanupTimeout;
    1595           2 :     uint32_t default_flow_update_tokens = Agent::kFlowUpdateTokens;
    1596           2 :     uint32_t default_flow_del_tokens = Agent::kFlowDelTokens;
    1597           2 :     uint32_t default_flow_ksync_tokens = Agent::kFlowKSyncTokens;
    1598           2 :     uint32_t default_flow_add_tokens = Agent::kFlowAddTokens;
    1599           2 :     uint32_t default_tbb_keepawake_timeout = Agent::kDefaultTbbKeepawakeTimeout;
    1600           2 :     uint32_t default_tbb_thread_count = Agent::kMaxTbbThreads;
    1601           2 :     uint32_t default_mac_learning_thread_count = Agent::kDefaultFlowThreadCount;
    1602           2 :     uint32_t default_mac_learning_add_tokens = Agent::kMacLearningDefaultTokens;
    1603           2 :     uint32_t default_mac_learning_update_tokens = Agent::kMacLearningDefaultTokens;
    1604           2 :     uint32_t default_mac_learning_delete_tokens = Agent::kMacLearningDefaultTokens;
    1605           2 :     uint16_t default_fabric_snat_table_size = Agent::kFabricSnatTableSize;
    1606             : 
    1607             :     // Set common command line arguments supported
    1608           4 :     boost::program_options::options_description generic("Generic options");
    1609           2 :     generic.add_options()
    1610           2 :         ("help", "help message")
    1611           4 :         ("config_file",
    1612           2 :          opt::value<string>()->default_value(Agent::config_file_),
    1613             :          "Configuration file")
    1614           2 :         ("version", "Display version information")
    1615             :         ;
    1616           4 :     opt::options_description debug("Debug options");
    1617           2 :     debug.add_options()
    1618           2 :         ("TRACEBUFFSIZE.AgentDBwalkTrace",opt::value<uint32_t>(),
    1619             :           "AgentDBwalkTrace trace buffer size")
    1620           2 :         ("TRACEBUFFSIZE.BgpAsAService",opt::value<uint32_t>(),
    1621             :           "BgpAsAService trace buffer size")
    1622           2 :         ("TRACEBUFFSIZE.CryptTunnel",opt::value<uint32_t>(),
    1623             :           "CryptTunnel trace buffer size")
    1624           2 :         ("TRACEBUFFSIZE.HealthCheck",opt::value<uint32_t>(),
    1625             :           "HealthCheck trace buffer size")
    1626           2 :         ("TRACEBUFFSIZE.MplsTrace",opt::value<uint32_t>(),
    1627             :           "MplsTrace trace buffer size")
    1628           2 :         ("TRACEBUFFSIZE.Multicast",opt::value<uint32_t>(),
    1629             :           "Multicast trace buffer size")
    1630           2 :         ("TRACEBUFFSIZE.InstanceManager",opt::value<uint32_t>(),
    1631             :           "InstanceManager trace buffer size")
    1632           2 :         ("TRACEBUFFSIZE.OperIfmap",opt::value<uint32_t>(),
    1633             :           "OperIfmap trace buffer size")
    1634           2 :         ("TRACEBUFFSIZE.PathPreference",opt::value<uint32_t>(),
    1635             :           "PathPreference trace buffer size")
    1636           2 :         ("TRACEBUFFSIZE.MulticastPolicy",opt::value<uint32_t>(),
    1637             :           "MulticastPolicy trace buffer size")
    1638           2 :         ("TRACEBUFFSIZE.TaskTrace",opt::value<uint32_t>(),
    1639             :           "TaskTrace trace buffer size")
    1640           2 :         ("TRACEBUFFSIZE.InterfaceMplsData",opt::value<uint32_t>(),
    1641             :           "InterfaceMplsData trace buffer size")
    1642           2 :         ("TRACEBUFFSIZE.VrfMplsData",opt::value<uint32_t>(),
    1643             :           "VrfMplsData trace buffer size")
    1644           2 :         ("TRACEBUFFSIZE.VlanMplsData",opt::value<uint32_t>(),
    1645             :           "VlanMplsData trace buffer size")
    1646           2 :         ("TRACEBUFFSIZE.RouteMplsData",opt::value<uint32_t>(),
    1647             :           "RouteMplsData trace buffer size")
    1648           2 :         ("TRACEBUFFSIZE.VersionTrace",opt::value<uint32_t>(),
    1649             :           "VersionTrace trace buffer size")
    1650           2 :         ("TRACEBUFFSIZE.DnsBind",opt::value<uint32_t>(),
    1651             :           "DnsBind trace buffer size")
    1652           2 :         ("TRACEBUFFSIZE.IFMapAgentTrace",opt::value<uint32_t>(),
    1653             :           "IFMapAgentTrace trace buffer size")
    1654           2 :         ("TRACEBUFFSIZE.IOTraceBuf",opt::value<uint32_t>(),
    1655             :           "IOTraceBuf trace buffer size")
    1656           2 :         ("TRACEBUFFSIZE.XmppMessageTrace",opt::value<uint32_t>(),
    1657             :           "XmppMessageTrace trace buffer size")
    1658           2 :         ("TRACEBUFFSIZE.XmppTrace",opt::value<uint32_t>(),
    1659             :           "XmppTrace trace buffer size")
    1660           2 :         ("TRACEBUFFSIZE.Config",opt::value<uint32_t>(),
    1661             :           "Config trace buffer size")
    1662           2 :         ("TRACEBUFFSIZE.ControllerConnections",opt::value<uint32_t>(),
    1663             :           "ControllerConnections trace buffer size")
    1664           2 :         ("TRACEBUFFSIZE.ControllerInfo",opt::value<uint32_t>(),
    1665             :           "ControllerInfo trace buffer size")
    1666           2 :         ("TRACEBUFFSIZE.ControllerTxConfig_1",opt::value<uint32_t>(),
    1667             :           "ControllerTxConfig_1 trace buffer size")
    1668           2 :         ("TRACEBUFFSIZE.ControllerTxConfig_2",opt::value<uint32_t>(),
    1669             :           "ControllerTxConfig_2 trace buffer size")
    1670           2 :         ("TRACEBUFFSIZE.ControllerRouteWalker",opt::value<uint32_t>(),
    1671             :           "ControllerRouteWalker trace buffer size")
    1672           2 :         ("TRACEBUFFSIZE.Controller",opt::value<uint32_t>(),
    1673             :           "Controller trace buffer size")
    1674           2 :         ("TRACEBUFFSIZE.ControllerRxRouteXmppMessage1",opt::value<uint32_t>(),
    1675             :           "ControllerRxRouteXmppMessage1 trace buffer size")
    1676           2 :         ("TRACEBUFFSIZE.ControllerRxConfigXmppMessage1",opt::value<uint32_t>(),
    1677             :           "ControllerRxConfigXmppMessage1 trace buffer size")
    1678           2 :         ("TRACEBUFFSIZE.ControllerRxRouteXmppMessage2",opt::value<uint32_t>(),
    1679             :           "ControllerRxRouteXmppMessage2 trace buffer size")
    1680           2 :         ("TRACEBUFFSIZE.ControllerRxConfigXmppMessage2",opt::value<uint32_t>(),
    1681             :           "ControllerRxConfigXmppMessage2 trace buffer size")
    1682           2 :         ("TRACEBUFFSIZE.ControllerTxXmppMessage_1",opt::value<uint32_t>(),
    1683             :           "ControllerTxXmppMessage_1 trace buffer size")
    1684           2 :         ("TRACEBUFFSIZE.ControllerTxXmppMessage_2",opt::value<uint32_t>(),
    1685             :           "ControllerTxXmppMessage_2 trace buffer size")
    1686           2 :         ("TRACEBUFFSIZE.Acl",opt::value<uint32_t>(),
    1687             :           "Acl trace buffer size")
    1688           2 :         ("TRACEBUFFSIZE.VnswIfTrace",opt::value<uint32_t>(),
    1689             :           "VnswIfTrace trace buffer size")
    1690           2 :         ("TRACEBUFFSIZE.Flow",opt::value<uint32_t>(),
    1691             :           "Flow trace buffer size")
    1692           2 :         ("TRACEBUFFSIZE.Packet",opt::value<uint32_t>(),
    1693             :           "Packet trace buffer size")
    1694           2 :         ("TRACEBUFFSIZE.FlowHandler",opt::value<uint32_t>(),
    1695             :           "FlowHandler trace buffer size")
    1696           2 :         ("TRACEBUFFSIZE.ProuterUve",opt::value<uint32_t>(),
    1697             :           "ProuterUve trace buffer size")
    1698           2 :         ("TRACEBUFFSIZE.SessionStats",opt::value<uint32_t>(),
    1699             :           "SessionStats trace buffer size")
    1700           2 :         ("TRACEBUFFSIZE.FlowExportStats",opt::value<uint32_t>(),
    1701             :           "FlowExportStats trace buffer size")
    1702           2 :         ("TRACEBUFFSIZE.Dhcp",opt::value<uint32_t>(),
    1703             :           "Dhcp trace buffer size")
    1704           2 :         ("TRACEBUFFSIZE.Dhcpv6",opt::value<uint32_t>(),
    1705             :           "Dhcpv6 trace buffer size")
    1706           2 :         ("TRACEBUFFSIZE.Icmpv6",opt::value<uint32_t>(),
    1707             :           "Icmpv6 trace buffer size")
    1708           2 :         ("TRACEBUFFSIZE.Arp",opt::value<uint32_t>(),
    1709             :           "Arp trace buffer size")
    1710           2 :         ("TRACEBUFFSIZE.Metadata",opt::value<uint32_t>(),
    1711             :           "Metadata trace buffer size")
    1712           2 :         ("TRACEBUFFSIZE.Bfd",opt::value<uint32_t>(),
    1713             :           "Bfd trace buffer size")
    1714           2 :         ("TRACEBUFFSIZE.Igmp",opt::value<uint32_t>(),
    1715             :           "Igmp trace buffer size")
    1716           2 :         ("TRACEBUFFSIZE.KSync Error",opt::value<uint32_t>(),
    1717             :           "KSync Error trace buffer size")
    1718           2 :         ("TRACEBUFFSIZE.MacLearning",opt::value<uint32_t>(),
    1719             :           "MacLearning trace buffer size")
    1720           2 :         ("TRACEBUFFSIZE.Xmpp",opt::value<uint32_t>(),
    1721             :           "Xmpp trace buffer size")
    1722           2 :         ("TRACEBUFFSIZE.KSync Interface",opt::value<uint32_t>(),
    1723             :           "KSync Interface trace buffer size")
    1724           2 :         ("TRACEBUFFSIZE.KSync Mpls",opt::value<uint32_t>(),
    1725             :           "KSync Mpls trace buffer size")
    1726           2 :         ("TRACEBUFFSIZE.KSync Nexthop",opt::value<uint32_t>(),
    1727             :           "KSync Nexthop trace buffer size")
    1728           2 :         ("TRACEBUFFSIZE.KSync Mirror",opt::value<uint32_t>(),
    1729             :           "KSync Mirror trace buffer size")
    1730           2 :         ("TRACEBUFFSIZE.KSync VxLan",opt::value<uint32_t>(),
    1731             :           "KSync VxLan trace buffer size")
    1732           2 :         ("TRACEBUFFSIZE.KSync VrfAssign",opt::value<uint32_t>(),
    1733             :           "KSync VrfAssign trace buffer size")
    1734           2 :         ("TRACEBUFFSIZE.KSync Qos Queue Object",opt::value<uint32_t>(),
    1735             :           "KSync Qos Queue Object trace buffer size")
    1736           2 :         ("TRACEBUFFSIZE.KSync Forwarding class object",opt::value<uint32_t>(),
    1737             :           "KSync Forwarding class object trace buffer size")
    1738           2 :         ("TRACEBUFFSIZE.KSync Qos Config class object",opt::value<uint32_t>(),
    1739             :           "KSync Qos Config class object trace buffer size")
    1740           2 :         ("TRACEBUFFSIZE.KSync BridgeRouteTable",opt::value<uint32_t>(),
    1741             :           "KSync BridgeRouteTable trace buffer size")
    1742           2 :         ("TRACEBUFFSIZE.KSync FlowTable",opt::value<uint32_t>(),
    1743             :           "KSync FlowTable trace buffer size")
    1744           2 :         ("TRACEBUFFSIZE.Oper db.interface.0",opt::value<uint32_t>(),
    1745             :           "Oper db.interface.0 trace buffer size")
    1746           2 :         ("TRACEBUFFSIZE.Oper db.healthcheck.0",opt::value<uint32_t>(),
    1747             :           "Oper db.healthcheck.0 trace buffer size")
    1748           2 :         ("TRACEBUFFSIZE.Oper db.crypttunnel.0",opt::value<uint32_t>(),
    1749             :           "Oper db.crypttunnel.0 trace buffer size")
    1750           2 :         ("TRACEBUFFSIZE.Oper db.nexthop.0",opt::value<uint32_t>(),
    1751             :           "Oper db.nexthop.0 trace buffer size")
    1752           2 :         ("TRACEBUFFSIZE.Oper db.vrf.0",opt::value<uint32_t>(),
    1753             :           "Oper db.vrf.0 trace buffer size")
    1754           2 :         ("TRACEBUFFSIZE.Oper db.vm.0",opt::value<uint32_t>(),
    1755             :           "Oper db.vm.0 trace buffer size")
    1756           2 :         ("TRACEBUFFSIZE.Oper db.sg.0",opt::value<uint32_t>(),
    1757             :           "Oper db.sg.0 trace buffer size")
    1758           2 :         ("TRACEBUFFSIZE.Oper db.tag.0",opt::value<uint32_t>(),
    1759             :           "Oper db.tag.0 trace buffer size")
    1760           2 :         ("TRACEBUFFSIZE.Oper db.vn.0",opt::value<uint32_t>(),
    1761             :           "Oper db.vn.0 trace buffer size")
    1762           2 :         ("TRACEBUFFSIZE.Oper db.mpls.0",opt::value<uint32_t>(),
    1763             :           "Oper db.mpls.0 trace buffer size")
    1764           2 :         ("TRACEBUFFSIZE.Oper db.acl.0",opt::value<uint32_t>(),
    1765             :           "Oper db.acl.0 trace buffer size")
    1766           2 :         ("TRACEBUFFSIZE.Oper db.mirror_table.0",opt::value<uint32_t>(),
    1767             :           "Oper db.mirror_table.0 trace buffer size")
    1768           2 :         ("TRACEBUFFSIZE.Oper db.vrf_assign.0",opt::value<uint32_t>(),
    1769             :           "Oper db.vrf_assign.0 trace buffer size")
    1770           2 :         ("TRACEBUFFSIZE.Oper db.policy_set.0",opt::value<uint32_t>(),
    1771             :           "Oper db.policy_set.0 trace buffer size")
    1772           2 :         ("TRACEBUFFSIZE.Oper db.vxlan.0",opt::value<uint32_t>(),
    1773             :           "Oper db.vxlan.0 trace buffer size")
    1774           2 :         ("TRACEBUFFSIZE.Oper db.qos_queue.0",opt::value<uint32_t>(),
    1775             :           "Oper db.qos_queue.0 trace buffer size")
    1776           2 :         ("TRACEBUFFSIZE.Oper db.forwardingclass.0",opt::value<uint32_t>(),
    1777             :           "Oper db.forwardingclass.0 trace buffer size")
    1778           2 :         ("TRACEBUFFSIZE.Oper db.security_logging_object.0",opt::value<uint32_t>(),
    1779             :           "Oper db.security_logging_object.0 trace buffer size")
    1780           2 :         ("TRACEBUFFSIZE.Oper db.qos_config.0",opt::value<uint32_t>(),
    1781             :           "Oper db.qos_config.0 trace buffer size")
    1782           2 :         ("TRACEBUFFSIZE.Oper db.bridge_domain.0",opt::value<uint32_t>(),
    1783             :           "Oper db.bridge_domain.0 trace buffer size")
    1784           2 :         ("TRACEBUFFSIZE.Oper db.multicast_policy.0",opt::value<uint32_t>(),
    1785             :           "Oper db.multicast_policy.0 trace buffer size")
    1786           2 :         ("TRACEBUFFSIZE.Oper db.service-instance.0",opt::value<uint32_t>(),
    1787             :           "Oper db.service-instance.0 trace buffer size")
    1788           2 :         ("TRACEBUFFSIZE.Oper db.physical_devices.0",opt::value<uint32_t>(),
    1789             :           "Oper db.physical_devices.0 trace buffer size")
    1790           2 :         ("TRACEBUFFSIZE.Oper db.physical_device_vn.0",opt::value<uint32_t>(),
    1791             :           "Oper db.physical_device_vn.0 trace buffer size")
    1792           2 :         ("TRACEBUFFSIZE.httpbuf",opt::value<uint32_t>(),
    1793             :           "httpbuf trace buffer size")
    1794           2 :         ("TRACEBUFFSIZE.OperRoute",opt::value<uint32_t>(),
    1795             :           "OperRoute trace buffer size")
    1796           2 :         ("TRACEBUFFSIZE.KSync Route",opt::value<uint32_t>(),
    1797             :           "KSync Route trace buffer size");
    1798           2 :     options_.add(debug);
    1799           2 :     config_file_options_.add(debug);
    1800             : 
    1801             : 
    1802           4 :     boost::program_options::options_description config("Configuration options");
    1803           2 :     config.add_options()
    1804           2 :         ("CONTROL-NODE.servers",
    1805           2 :          opt::value<std::vector<std::string> >()->multitoken(),
    1806             :          "List of IPAddress:Port of Control node Servers")
    1807           2 :         ("CONTROL-NODE.subcluster_name", opt::value<string>(), "Cluster identifier")
    1808           2 :         ("DEFAULT.collectors",
    1809           2 :          opt::value<std::vector<std::string> >()->multitoken(),
    1810             :          "Collector server list")
    1811           2 :         ("DEFAULT.derived_stats",
    1812           2 :          opt::value<std::vector<std::string> >()->multitoken(),
    1813             :          "Derived Stats Parameters")
    1814           4 :         ("DEFAULT.flow_cache_timeout",
    1815           2 :          opt::value<uint16_t>()->default_value(Agent::kDefaultFlowCacheTimeout),
    1816             :          "Flow aging time in seconds")
    1817           4 :         ("DEFAULT.stale_interface_cleanup_timeout",
    1818           2 :          opt::value<uint32_t>()->default_value(default_stale_interface_cleanup_timeout),
    1819             :          "Stale Interface cleanup timeout")
    1820           2 :         ("DEFAULT.hostname", opt::value<string>(),
    1821             :          "Hostname of compute-node")
    1822           2 :         ("DEFAULT.dhcp_relay_mode", opt::bool_switch(&dhcp_relay_mode_),
    1823             :          "Enable / Disable DHCP relay of DHCP packets from virtual instance")
    1824           2 :         ("DEFAULT.agent_name", opt::value<string>(),
    1825             :          "Agent Name")
    1826           4 :         ("DEFAULT.http_server_port",
    1827           2 :          opt::value<uint16_t>()->default_value(ContrailPorts::HttpPortAgent()),
    1828             :          "Sandesh HTTP listener port")
    1829           4 :         ("DEFAULT.rest_port",
    1830           2 :          opt::value<uint16_t>()->default_value(ContrailPorts::PortIpcVrouterAgentPort()),
    1831             :          "REST Server port")
    1832           4 :         ("DEFAULT.tunnel_type", opt::value<string>()->default_value("MPLSoGRE"),
    1833             :          "Tunnel Encapsulation type <MPLSoGRE|MPLSoUDP|VXLAN>")
    1834           2 :         ("DEFAULT.agent_mode", opt::value<string>(),
    1835             :          "Run agent in vrouter / tsn / tor mode")
    1836           2 :         ("DEFAULT.gateway_mode", opt::value<string>(),
    1837             :           "Set gateway mode to server/ vcpe")
    1838           4 :         ("DEFAULT.agent_base_directory", opt::value<string>()->default_value("/var/lib/contrail"),
    1839             :          "Base directory used by the agent")
    1840           2 :         ("DNS.servers",
    1841           2 :          opt::value<vector<string> >()->multitoken(),
    1842             :          "List of IPAddress:Port of DNS node Servers")
    1843           2 :         ("DEFAULT.xmpp_auth_enable", opt::bool_switch(&xmpp_auth_enable_),
    1844             :          "Enable Xmpp over TLS")
    1845           2 :         ("DEFAULT.tsn_servers",
    1846           2 :          opt::value<std::vector<std::string> >()->multitoken(),
    1847             :          "List of IPAddress of TSN Servers")
    1848           2 :         ("DEFAULT.min_aap_prefix_len", opt::value<uint16_t>(),
    1849             :          "Minimum prefix-len for Allowed-address-pair entries")
    1850           4 :         ("DEFAULT.vmi_vm_vn_uve_interval",
    1851           2 :          opt::value<uint16_t>()->default_value(Agent::kDefaultVmiVmVnUveInterval),
    1852             :          "UVE send interval in seconds")
    1853           2 :         ("DNS.dns_timeout", opt::value<uint32_t>()->default_value(3000),
    1854             :          "DNS Timeout")
    1855           2 :         ("DNS.dns_max_retries", opt::value<uint32_t>()->default_value(2),
    1856             :          "Dns Max Retries")
    1857           4 :         ("DNS.dns_client_port",
    1858           2 :          opt::value<uint16_t>()->default_value(ContrailPorts::VrouterAgentDnsClientUdpPort()),
    1859             :          "Dns client port")
    1860           4 :         ("DEFAULT.xmpp_server_cert",
    1861           4 :           opt::value<string>()->default_value(
    1862             :           "/etc/contrail/ssl/certs/server.pem"),
    1863             :           "XMPP Server ssl certificate")
    1864           4 :         ("DEFAULT.xmpp_server_key",
    1865           4 :           opt::value<string>()->default_value(
    1866             :           "/etc/contrail/ssl/private/server-privkey.pem"),
    1867             :           "XMPP Server ssl private key")
    1868           4 :         ("DEFAULT.xmpp_ca_cert",
    1869           4 :           opt::value<string>()->default_value(
    1870             :           "/etc/contrail/ssl/certs/ca-cert.pem"),
    1871             :           "XMPP CA ssl certificate")
    1872           2 :         ("DEFAULT.xmpp_dns_auth_enable", opt::bool_switch(&xmpp_dns_auth_enable_),
    1873             :          "Enable Xmpp over TLS for DNS")
    1874           2 :         ("METADATA.metadata_proxy_secret", opt::value<string>(),
    1875             :          "Shared secret for metadata proxy service")
    1876           4 :         ("METADATA.metadata_proxy_port",
    1877           2 :          opt::value<uint16_t>()->default_value(ContrailPorts::MetadataProxyVrouterAgentPort()),
    1878             :         "Metadata proxy port ")
    1879           2 :         ("METADATA.metadata_use_ssl", opt::bool_switch(&metadata_use_ssl_),
    1880             :          "Enable SSL for Metadata proxy service")
    1881           4 :         ("METADATA.metadata_client_cert", opt::value<string>()->default_value(""),
    1882             :           "METADATA Client ssl certificate")
    1883           4 :         ("METADATA.metadata_client_cert_type", opt::value<string>()->default_value("PEM"),
    1884             :           "METADATA Client ssl certificate type")
    1885           4 :         ("METADATA.metadata_client_key", opt::value<string>()->default_value(""),
    1886             :           "METADATA Client ssl private key")
    1887           4 :         ("METADATA.metadata_ca_cert", opt::value<string>()->default_value(""),
    1888             :           "METADATA CA ssl certificate")
    1889           2 :         ("NETWORKS.control_network_ip", opt::value<string>(),
    1890             :          "control-channel IP address used by WEB-UI to connect to vnswad")
    1891           2 :         ("DEFAULT.platform", opt::value<string>(),
    1892             :          "Mode in which vrouter is running, option are dpdk or vnic")
    1893           2 :         ("DEFAULT.agent_mock",opt::value<bool>()->default_value(false),
    1894             :              "Agent Mocking Mode")
    1895           4 :         ("AGENT-TEST-FRAMEWORK.mock_dpdk",
    1896           2 :              opt::value<bool>()->default_value(false),
    1897             :              "mock dpdk")
    1898           4 :         ("AGENT-TEST-FRAMEWORK.ksocketdir",
    1899           4 :               opt::value<string>()->default_value("/tmp/"),
    1900             :              "ksocket directory")
    1901           4 :         ("DEFAULT.subnet_hosts_resolvable",
    1902           2 :          opt::bool_switch(&subnet_hosts_resolvable_)->default_value(true))
    1903           2 :         ("DEFAULT.pkt0_tx_buffers", opt::value<uint32_t>()->default_value(default_pkt0_tx_buffers),
    1904             :          "Number of tx-buffers for pkt0 interface")
    1905           4 :         ("DEFAULT.physical_interface_address",
    1906           4 :           opt::value<string>()->default_value(""))
    1907           4 :         ("DEFAULT.physical_interface_mac",
    1908           4 :           opt::value<string>()->default_value(""))
    1909           4 :         ("HYPERVISOR.vmware_physical_interface",
    1910           4 :           opt::value<string>()->default_value(""))
    1911           4 :         ("DEFAULT.mirror_client_port",
    1912           2 :          opt::value<uint16_t>()->default_value(ContrailPorts::VrouterAgentMirrorClientUdpPort()),
    1913             :          "Mirror client Port")
    1914           2 :         ("DEFAULT.simulate_evpn_tor", opt::bool_switch(&simulate_evpn_tor_),
    1915             :          "Simulate Evpn Tor")
    1916           2 :         ("DEFAULT.measure_queue_delay", opt::bool_switch(&measure_queue_delay_),
    1917             :           "Measure flow queue delay")
    1918           2 :         ("NEXTHOP-SERVER.endpoint", opt::value<string>(),
    1919             :          "Nexthop Server Endpoint")
    1920           2 :         ("NEXTHOP-SERVER.add_pid", opt::bool_switch(&nexthop_server_add_pid_),
    1921             :          "Enable Nh Sever Pid")
    1922           2 :         ("DEFAULT.mvpn_ipv4_enable", opt::bool_switch(&mvpn_ipv4_enable_),
    1923             :           "Enable MVPN IPv4 in Agent")
    1924           2 :         ("DEFAULT.vr_object_high_watermark", opt::value<float>()->default_value(80),
    1925             :          "Max allowed vr object usage till alarm is raised - given as % (in integer) of object limit in vrouter")
    1926             :         ;
    1927           2 :     options_.add(generic).add(config);
    1928           2 :     config_file_options_.add(config);
    1929             : 
    1930           4 :     opt::options_description restart("Restart options");
    1931           2 :     restart.add_options()
    1932           4 :         ("RESTART.backup_enable",
    1933           2 :          opt::bool_switch(&restart_backup_enable_)->default_value(false),
    1934             :          "Enable backup of config and resources into a file")
    1935           2 :         ("RESTART.backup_idle_timeout", opt::value<uint64_t>()->default_value(CFG_BACKUP_IDLE_TIMEOUT),
    1936             :          "Generate backup if no change detected in configured time (in msec)")
    1937           4 :         ("RESTART.backup_dir", opt::value<string>()->default_value(CFG_BACKUP_DIR),
    1938             :          "Directory storing backup files for configuraion or resource")
    1939           2 :         ("RESTART.backup_count", opt::value<uint16_t>()->default_value(CFG_BACKUP_COUNT),
    1940             :          "Number of backup files")
    1941           2 :         ("RESTART.restore_enable", opt::bool_switch(&restart_restore_enable_)->default_value(true),
    1942             :          "Enable restore of config and resources from backup files")
    1943           4 :         ("RESTART.restore_audit_timeout", opt::value<uint64_t>()->default_value(CFG_RESTORE_AUDIT_TIMEOUT),
    1944             :          "Audit time for config/resource read from file (in milli-sec)")
    1945           2 :         ("RESTART.huge_page_1G",
    1946           2 :          opt::value<std::vector<std::string> >()->multitoken(),
    1947             :          "List of 1G Huge pages to be used by vrouter for flow and bridge entries")
    1948           2 :         ("RESTART.huge_page_2M",
    1949           2 :          opt::value<std::vector<std::string> >()->multitoken(),
    1950             :          "List of 2M Huge pages to be used by vrouter");
    1951           2 :     options_.add(restart);
    1952           2 :     config_file_options_.add(restart);
    1953           4 :     opt::options_description log("Logging options");
    1954           2 :     std::vector<std::string> default_session_destination;
    1955           2 :     std::vector<std::string> implicit_session_destination;
    1956           2 :     default_session_destination.push_back("collector");
    1957           2 :     log.add_options()
    1958           4 :         ("DEFAULT.log_category", opt::value<string>()->default_value(""),
    1959             :          "Category filter for local logging of sandesh messages")
    1960           4 :         ("DEFAULT.log_file",
    1961           2 :          opt::value<string>()->default_value(Agent::GetInstance()->log_file()),
    1962             :          "Filename for the logs to be written to")
    1963           2 :         ("DEFAULT.log_files_count", opt::value<int>(),
    1964             :          "Maximum log file roll over index")
    1965           2 :         ("DEFAULT.log_file_size", opt::value<long>(),
    1966             :          "Maximum size of the log file")
    1967           4 :         ("DEFAULT.log_level", opt::value<string>()->default_value("SYS_NOTICE"),
    1968             :          "Severity level for local logging of sandesh messages")
    1969           2 :         ("DEFAULT.log_local", opt::bool_switch(&log_local_),
    1970             :          "Enable local logging of sandesh messages")
    1971           2 :         ("DEFAULT.use_syslog", opt::bool_switch(&use_syslog_),
    1972             :          "Enable logging to syslog")
    1973           4 :         ("DEFAULT.syslog_facility", opt::value<string>()->default_value("LOG_LOCAL0"),
    1974             :          "Syslog facility to receive log lines")
    1975           2 :         ("DEFAULT.log_flow", opt::bool_switch(&log_flow_),
    1976             :          "Enable local logging of flow sandesh messages")
    1977           4 :         ("DEFAULT.log_property_file", opt::value<string>()->default_value(""),
    1978             :          "Log Property File")
    1979           4 :         ("SESSION.slo_destination",
    1980             :          opt::value<vector<string> >()
    1981           4 :              ->default_value(default_session_destination, std::string("collector"))
    1982           6 :              ->implicit_value(implicit_session_destination, std::string("")),
    1983             :         "List of destinations. valid values are collector, file, syslog. Space delimited")
    1984           2 :         ("SESSION.sample_destination",
    1985             :          opt::value<std::vector<std::string> >()
    1986           4 :              ->default_value(default_session_destination, std::string("collector"))
    1987           4 :              ->implicit_value(implicit_session_destination, std::string("")),
    1988             :         "List of destinations. valid values are collector, file, syslog. Space delimited");
    1989           2 :     options_.add(log);
    1990           2 :     config_file_options_.add(log);
    1991             : 
    1992           2 :     if (enable_flow_options_) {
    1993           4 :         opt::options_description flow("Flow options");
    1994           2 :         flow.add_options()
    1995           2 :             ("FLOWS.thread_count", opt::value<uint16_t>()->default_value(Agent::kDefaultFlowThreadCount),
    1996             :              "Number of threads for flow setup")
    1997           2 :             ("FLOWS.max_system_linklocal_flows", opt::value<uint16_t>()->default_value(Agent::kDefaultMaxLinkLocalOpenFds),
    1998             :              "Maximum number of link-local flows allowed across all VMs")
    1999           2 :             ("FLOWS.max_vm_linklocal_flows", opt::value<uint16_t>()->default_value(Agent::kDefaultMaxLinkLocalOpenFds),
    2000             :              "Maximum number of link-local flows allowed per VM")
    2001           2 :             ("FLOWS.trace_enable", opt::bool_switch(&flow_trace_enable_)->default_value(true),
    2002             :              "Enable flow tracing")
    2003           2 :             ("FLOWS.add_tokens", opt::value<uint32_t>()->default_value(default_flow_add_tokens),
    2004             :              "Number of add-tokens")
    2005           2 :             ("FLOWS.ksync_tokens", opt::value<uint32_t>()->default_value(default_flow_ksync_tokens),
    2006             :              "Number of ksync-tokens")
    2007           2 :             ("FLOWS.del_tokens", opt::value<uint32_t>()->default_value(default_flow_del_tokens),
    2008             :              "Number of delete-tokens")
    2009           2 :             ("FLOWS.update_tokens", opt::value<uint32_t>()->default_value(default_flow_update_tokens),
    2010             :              "Number of update-tokens")
    2011           2 :             ("FLOWS.hash_exclude_router_id", opt::value<bool>(),
    2012             :              "Exclude router-id in hash calculation")
    2013           2 :             ("FLOWS.index_sm_log_count", opt::value<uint16_t>()->default_value(Agent::kDefaultFlowIndexSmLogCount),
    2014             :              "Index Sm Log Count")
    2015           2 :             ("FLOWS.latency_limit", opt::value<uint16_t>()->default_value(Agent::kDefaultFlowLatencyLimit),
    2016             :              "Latency Limit")
    2017           2 :             ("FLOWS.max_sessions_per_aggregate", opt::value<uint16_t>()->default_value(Agent::kMaxSessions),
    2018             :              "Maximum number of sessions per Session Aggregate entry")
    2019           2 :             ("FLOWS.max_aggregates_per_session_endpoint", opt::value<uint16_t>()->default_value(Agent::kMaxSessionAggs),
    2020             :              "Maximum number of Session Aggregates per SessionEndpoint Entry")
    2021           2 :             ("FLOWS.max_endpoints_per_session_msg", opt::value<uint16_t>()->default_value(Agent::kMaxSessionEndpoints),
    2022             :              "Maximum number of SessionEnpoint entries per SessionEndpointObject")
    2023           2 :             ("FLOWS.fabric_snat_hash_table_size", opt::value<uint16_t>()->default_value(default_fabric_snat_table_size),
    2024             :              "Size of Port NAT hash table")
    2025             :             ;
    2026           2 :         options_.add(flow);
    2027           2 :         config_file_options_.add(flow);
    2028           2 :     }
    2029             : 
    2030           2 :     if (enable_hypervisor_options_) {
    2031           4 :         opt::options_description hypervisor("Hypervisor specific options");
    2032           2 :         hypervisor.add_options()
    2033           4 :             ("HYPERVISOR.type", opt::value<string>()->default_value("kvm"),
    2034             :              "Type of hypervisor <kvm|xen|vmware>")
    2035           2 :             ("HYPERVISOR.xen_ll_interface", opt::value<string>(),
    2036             :              "Port name on host for link-local network")
    2037           2 :             ("HYPERVISOR.xen_ll_ip", opt::value<string>(),
    2038             :              "IP Address and prefix or the link local port in ip/prefix format")
    2039           2 :             ("HYPERVISOR.vmware_physical_port", opt::value<string>(),
    2040             :              "Physical port used to connect to VMs in VMWare environment")
    2041           2 :             ("HYPERVISOR.vmware_mode",
    2042           2 :              opt::value<string>()->default_value("esxi_neutron"),
    2043             :              "VMWare mode <esxi_neutron|vcenter>")
    2044             :             ;
    2045           2 :         options_.add(hypervisor);
    2046           2 :         config_file_options_.add(hypervisor);
    2047           2 :     }
    2048             : 
    2049           2 :     if (enable_vhost_options_) {
    2050           4 :         opt::options_description vhost("VHOST interface specific options");
    2051           2 :         vhost.add_options()
    2052           2 :             ("VIRTUAL-HOST-INTERFACE.name", opt::value<string>(),
    2053             :              "Name of virtual host interface")
    2054           2 :             ("VIRTUAL-HOST-INTERFACE.ip", opt::value<string>(),
    2055             :              "IP address and prefix in ip/prefix_len format")
    2056           4 :             ("VIRTUAL-HOST-INTERFACE.gateway",
    2057           2 :              opt::value<string>(),
    2058             :              "Lisg of gateway IP address for virtual host")
    2059           2 :             ("VIRTUAL-HOST-INTERFACE.physical_interface",
    2060           2 :              opt::value<std::vector<std::string> >()->multitoken(),
    2061             :              "Physical interface name to which virtual host interface maps to")
    2062           4 :             ("VIRTUAL-HOST-INTERFACE.physical_interface_addr",
    2063           2 :              opt::value<string>(),
    2064             :              "List of Physical interface ip address")
    2065           2 :             ("VIRTUAL-HOST-INTERFACE.compute_node_address",
    2066           2 :              opt::value<std::vector<std::string> >()->multitoken(),
    2067             :              "List of addresses on compute node")
    2068           2 :             ("VIRTUAL-HOST-INTERFACE.physical_port_routes",
    2069           2 :              opt::value<std::vector<std::string> >()->multitoken(),
    2070             :              "Static routes to be added on physical interface")
    2071           2 :             ("VIRTUAL-HOST-INTERFACE.eth_port_no_arp", opt::bool_switch(&eth_port_no_arp_),
    2072             :              "Ethernet Port No-ARP")
    2073           2 :             ("VIRTUAL-HOST-INTERFACE.eth_port_encap_type", opt::value<string>(),
    2074             :              "Ethernet Port Encap Type")
    2075           2 :             ("VIRTUAL-HOST-INTERFACE.loopback_ip", opt::value<string>(),
    2076             :              "Compute Loopback IP")
    2077             :             ;
    2078           2 :         options_.add(vhost);
    2079           2 :         config_file_options_.add(vhost);
    2080           2 :     }
    2081             : 
    2082           2 :     if (enable_service_options_) {
    2083           4 :         opt::options_description service("Service instance specific options");
    2084           2 :         service.add_options()
    2085           2 :             ("SERVICE-INSTANCE.netns_command", opt::value<string>(),
    2086             :              "Script path used when a service instance is spawned with network namespace")
    2087           2 :             ("SERVICE-INSTANCE.netns_timeout", opt::value<int>()->default_value(0),
    2088             :              "Timeout used to set a netns command as failing and to destroy it")
    2089           2 :             ("SERVICE-INSTANCE.netns_workers", opt::value<int>()->default_value(0),
    2090             :              "Number of workers used to spawn netns command")
    2091           2 :             ("SERVICE-INSTANCE.docker_command", opt::value<string>(),
    2092             :              "Service instance docker command")
    2093           2 :             ("SERVICE-INSTANCE.lb_ssl_cert_path", opt::value<string>(),
    2094             :              "Loadbalancer ssl certificate path")
    2095           2 :             ("SERVICES.bgp_as_a_service_port_range", opt::value<string>(),
    2096             :              "Port range for BgPass ")
    2097           2 :             ("SERVICES.queue_limit", opt::value<uint32_t>()->default_value(1024),
    2098             :              "Work queue for different services")
    2099           2 :             ("SERVICES.bgpaas_max_shared_sessions", opt::value<uint32_t>(),
    2100             :              "BGPAAS max shared sessions for service port")
    2101           2 :             ("SERVICE-INSTANCE.lbaas_auth_conf", opt::value<string>(),
    2102             :              "Credentials fo ssl certificates and private-keys")
    2103             :             ;
    2104           2 :         options_.add(service);
    2105           2 :         config_file_options_.add(service);
    2106           2 :     }
    2107             : 
    2108             : 
    2109           4 :     opt::options_description tbb("TBB specific options");
    2110           2 :     tbb.add_options()
    2111           2 :         ("TASK.thread_count", opt::value<uint32_t>()->default_value(default_tbb_thread_count),
    2112             :          "Max number of threads used by TBB")
    2113           2 :         ("TASK.log_exec_threshold", opt::value<uint32_t>()->default_value(0),
    2114             :          "Log message if task takes more than threshold (msec) to execute")
    2115           2 :         ("TASK.log_schedule_threshold", opt::value<uint32_t>()->default_value(0),
    2116             :          "Log message if task takes more than threshold (msec) to schedule")
    2117           2 :         ("TASK.tbb_keepawake_timeout", opt::value<uint32_t>()->default_value(default_tbb_keepawake_timeout),
    2118             :          "Timeout for the TBB keepawake timer")
    2119           2 :         ("TASK.task_monitor_timeout", opt::value<uint32_t>(),
    2120             :          "Timeout for the Task monitoring")
    2121           2 :         ("TASK.ksync_thread_cpu_pin_policy", opt::value<string>(),
    2122             :          "Pin ksync io task to CPU")
    2123           2 :         ("TASK.flow_netlink_pin_cpuid", opt::value<uint32_t>(),
    2124             :          "CPU-ID to pin")
    2125             :         ;
    2126           2 :     options_.add(tbb);
    2127           2 :     config_file_options_.add(tbb);
    2128             : 
    2129           4 :     opt::options_description sandesh("Sandesh specific options");
    2130           2 :     sandesh::options::AddOptions(&sandesh, &sandesh_config_);
    2131           2 :     options_.add(sandesh);
    2132           2 :     config_file_options_.add(sandesh);
    2133             : 
    2134           4 :     opt::options_description llgr("LLGR");
    2135           2 :     llgr.add_options()
    2136           2 :         ("LLGR.disable", opt::value<bool>()->default_value(false),
    2137             :          "Disable LLGR")
    2138           2 :         ("LLGR.stale_config_cleanup_time", opt::value<uint16_t>()->default_value(100),
    2139             :          "LLGR Stale Config Cleanup Time")
    2140           2 :         ("LLGR.config_poll_time", opt::value<uint16_t>()->default_value(5),
    2141             :          "LLGR Config Poll Time")
    2142           2 :         ("LLGR.config_inactivity_time", opt::value<uint16_t>()->default_value(15),
    2143             :          "LLGR Config Inactive Time")
    2144           2 :         ("LLGR.config_fallback_time", opt::value<uint16_t>()->default_value(900),
    2145             :          "LLGR Config Fallback Time")
    2146           2 :         ("LLGR.end_of_rib_tx_poll_time", opt::value<uint16_t>()->default_value(5),
    2147             :          "LLGR End Of Rib Poll Time")
    2148           2 :         ("LLGR.end_of_rib_tx_fallback_time", opt::value<uint16_t>()->default_value(60),
    2149             :          "LLGR End Of Rib Tx Fallback Time")
    2150           2 :         ("LLGR.end_of_rib_tx_inactivity_time", opt::value<uint16_t>()->default_value(15),
    2151             :          "LLGR End Of Rib Tx Inactivity Time")
    2152           2 :         ("LLGR.end_of_rib_rx_fallback_time", opt::value<uint16_t>()->default_value(60),
    2153             :          "LLGR End Of Rib Rx Fallback Time")
    2154             :         ;
    2155           2 :     options_.add(llgr);
    2156           2 :     config_file_options_.add(llgr);
    2157             : 
    2158           4 :     opt::options_description mac_learn("MAC-LEARNING");
    2159           2 :     mac_learn.add_options()
    2160           2 :         ("MAC-LEARNING.thread_count", opt::value<uint32_t>()->default_value(default_mac_learning_thread_count),
    2161             :          "Thread Count")
    2162           2 :         ("MAC-LEARNING.add_tokens", opt::value<uint32_t>()->default_value(default_mac_learning_add_tokens),
    2163             :          "Add Tokens")
    2164           2 :         ("MAC-LEARNING.del_tokens", opt::value<uint32_t>()->default_value(default_mac_learning_update_tokens),
    2165             :          "Del Tokens")
    2166           2 :         ("MAC-LEARNING.update_tokens", opt::value<uint32_t>()->default_value(default_mac_learning_delete_tokens),
    2167             :          "Update Tokens")
    2168             :         ;
    2169           2 :     options_.add(mac_learn);
    2170           2 :     config_file_options_.add(mac_learn);
    2171             : 
    2172           4 :     opt::options_description qos("Quality of Service options");
    2173           2 :     qos.add_options()
    2174           2 :         ("QOS.priority_tagging",
    2175           2 :          opt::bool_switch(&qos_priority_tagging_)->default_value(true),
    2176             :          "Enable Priority tagging")
    2177             :         ;
    2178           2 :     options_.add(qos);
    2179           2 :     config_file_options_.add(qos);
    2180             : 
    2181           4 :     opt::options_description crypt("CRYPT");
    2182           2 :     crypt.add_options()
    2183           2 :         ("CRYPT.crypt_interface", opt::value<string>(),
    2184             :           "Interface name to send data for encrypt")
    2185             :         ;
    2186           2 :     options_.add(crypt);
    2187           2 :     config_file_options_.add(crypt);
    2188             : 
    2189           2 : }
    2190             : 
    2191           2 : AgentParam::~AgentParam() {
    2192           2 : }
    2193             : 
    2194           2 : LlgrParams::LlgrParams() {
    2195           2 :     stale_config_cleanup_time_ = kStaleConfigCleanupTime;
    2196           2 :     config_poll_time_ = kConfigPollTime;
    2197           2 :     config_inactivity_time_ = kConfigInactivityTime;
    2198           2 :     config_fallback_time_ = kConfigFallbackTimeOut;
    2199           2 :     end_of_rib_tx_poll_time_ = kEorTxPollTime;
    2200           2 :     end_of_rib_tx_fallback_time_ = kEorTxFallbackTimeOut;
    2201           2 :     end_of_rib_tx_inactivity_time_ = kEorTxInactivityTime;
    2202           2 :     end_of_rib_rx_fallback_time_ = kEorRxFallbackTime;
    2203           2 :     llgr_stale_time_ = kLlgrStaleTime;
    2204           2 : }

Generated by: LCOV version 1.14