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