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

Generated by: LCOV version 1.14