OpenSDN source code
agent.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #include <algorithm>
6 #include <fstream>
7 #include <iostream>
8 #include <string>
9 #include <vector>
10 
11 #include <base/logging.h>
12 #include <base/lifetime.h>
13 #include <base/misc_utils.h>
14 #include <io/event_manager.h>
15 #include <ifmap/ifmap_link.h>
16 #include <cmn/agent_cmn.h>
17 #include <vnc_cfg_types.h>
18 #include <agent_types.h>
19 
20 #include <base/sandesh/task_types.h>
21 
22 #include <init/agent_param.h>
23 #include <cmn/agent_signal.h>
24 #include <cfg/cfg_init.h>
25 #include <cfg/cfg_mirror.h>
26 #include <cmn/agent.h>
27 #include <cmn/event_notifier.h>
31 
32 #include <oper/operdb_init.h>
33 #include <oper/config_manager.h>
34 #include <oper/interface_common.h>
35 #include <oper/health_check.h>
36 #include <oper/metadata_ip.h>
37 #include <oper/multicast.h>
38 #include <oper/nexthop.h>
39 #include <oper/mirror_table.h>
40 #include <oper/mpls.h>
41 #include <oper/peer.h>
42 #include <xmpp/xmpp_client.h>
43 
44 #include <filter/acl.h>
45 
46 #include <cmn/agent_factory.h>
47 #include <net/if.h>
48 
49 const std::string Agent::null_string_ = "";
50 const std::set<std::string> Agent::null_string_list_;
51 const std::string Agent::fabric_vn_name_ =
52  "default-domain:default-project:ip-fabric";
53 std::string Agent::fabric_vrf_name_ =
54  "default-domain:default-project:ip-fabric:__default__";
56  "default-domain:default-project:ip-fabric:ip-fabric";
57 const std::string Agent::link_local_vn_name_ =
58  "default-domain:default-project:__link_local__";
59 const std::string Agent::link_local_vrf_name_ =
60  "default-domain:default-project:__link_local__:__link_local__";
61 const MacAddress Agent::vrrp_mac_(0x00, 0x00, 0x5E, 0x00, 0x01, 0x00);
62 // use the following MAC when sending data to left or right SI interfaces
63 const MacAddress Agent::left_si_mac_(0x02, 0x00, 0x00, 0x00, 0x00, 0x01);
64 const MacAddress Agent::right_si_mac_(0x02, 0x00, 0x00, 0x00, 0x00, 0x02);
65 const MacAddress Agent::pkt_interface_mac_(0x00, 0x00, 0x00, 0x00, 0x00, 0x01);
66 const std::string Agent::bcast_mac_ = "FF:FF:FF:FF:FF:FF";
67 const std::string Agent::xmpp_dns_server_connection_name_prefix_ = "dns-server:";
68 const std::string Agent::xmpp_control_node_connection_name_prefix_ = "control-node:";
69 const uint16_t Agent::kDefaultVmiVmVnUveInterval = 30; //in seconds
70 const std::string Agent::v4_link_local_subnet_ = "169.254.0.0";
71 const std::string Agent::v6_link_local_subnet_ = "FE80::";
72 
75 
77  IpAddress sip;
78  if (dest.is_v4()) {
79  if (router_id() == dest) {
80  // If source IP and dest IP are same,
81  // linux kernel will drop the packet.
82  // Hence we will use link local IP address as sip.
84  } else {
85  sip = router_id();
86  }
87  } else if (dest.is_v6()) {
88  sip = Ip6Address::v4_mapped(router_id());
89  }
90  return sip;
91 }
92 
93 const string &Agent::GetHostInterfaceName() const {
94  // There is single host interface. Its addressed by type and not name
95  return Agent::null_string_;
96 };
97 
98 std::string Agent::GetUuidStr(boost::uuids::uuid uuid_val) const {
99  std::ostringstream str;
100  str << uuid_val;
101  return str.str();
102 }
103 
104 const string &Agent::vhost_interface_name() const {
105  return vhost_interface_name_;
106 };
107 
109  if (tor_agent_enabled() || test_mode()|| isMockMode()) {
110  return true;
111  }
112 
113  static const int log_rate_limit = 15;
114  struct ifreq ifr;
115  static int err_count = 0;
116  int sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
117  memset(&ifr, 0, sizeof(ifr));
118  strcpy(ifr.ifr_name, vhost_interface_name().c_str());
119  int err = ioctl(sock, SIOCGIFFLAGS, &ifr);
120  if (err < 0 || !(ifr.ifr_flags & IFF_UP)) {
121  close(sock);
122  if ((err_count % log_rate_limit) == 0) {
123  LOG(DEBUG, "vhost is down");
124  }
125  err_count++;
126  return false;
127  }
128  err = ioctl(sock, SIOCGIFADDR, &ifr);
129  if (false == is_l3mh() && err < 0) {
130  close(sock);
131  if ((err_count % log_rate_limit) == 0) {
132  LOG(DEBUG, "vhost is up. but ip is not set");
133  }
134  err_count++;
135  return false;
136  }
137  close(sock);
138  return true;
139 }
140 
142  return params_->isXenMode();
143 }
144 
146  return params_->isKvmMode();
147 }
148 
150  return params_->isDockerMode();
151 }
152 
153 bool Agent::isMockMode() const {
154  return params_->cat_is_agent_mocked();
155 }
156 
157 std::string Agent::AgentGUID() const {
158  char *envval = NULL;
159  assert(params_);
160  return std::string(((envval = getenv("LOGNAME"))== NULL)? "" : envval)
161  + "_" + agent_name() + "_" + integerToString(getpid());
162 }
163 
164 static void SetTaskPolicyOne(const char *task, const char *exclude_list[],
165  int count) {
167  TaskPolicy policy;
168  for (int i = 0; i < count; ++i) {
169  int task_id = scheduler->GetTaskId(exclude_list[i]);
170  policy.push_back(TaskExclusion(task_id));
171  }
172  scheduler->SetPolicy(scheduler->GetTaskId(task), policy);
173 }
174 
176  /*
177  * TODO(roque): this method should not be called by the agent constructor.
178  */
179  static bool initialized = false;
180  if (initialized) {
181  return;
182  }
183  initialized = true;
184 
185  const char *db_exclude_list[] = {
192  "Agent::Services",
193  "Agent::StatsCollector",
197  "sandesh::RecvQueue",
198  "Agent::Uve",
199  "Agent::KSync",
200  "Agent::PktFlowResponder",
201  "Agent::Profile",
202  "Agent::PktHandler",
203  "Agent::Diag",
204  "http::RequestHandlerTask",
216  };
217  SetTaskPolicyOne("db::DBTable", db_exclude_list,
218  sizeof(db_exclude_list) / sizeof(char *));
219 
220  // ConfigManager task
221  const char *config_manager_exclude_list[] = {
224  };
225  SetTaskPolicyOne(kTaskConfigManager, config_manager_exclude_list,
226  sizeof(config_manager_exclude_list) / sizeof(char *));
227 
228  const char *flow_table_exclude_list[] = {
229  "Agent::PktFlowResponder",
232  };
233  SetTaskPolicyOne(kTaskFlowEvent, flow_table_exclude_list,
234  sizeof(flow_table_exclude_list) / sizeof(char *));
235 
236  SetTaskPolicyOne(kTaskFlowKSync, flow_table_exclude_list,
237  sizeof(flow_table_exclude_list) / sizeof(char *));
238 
239  SetTaskPolicyOne(kTaskFlowUpdate, flow_table_exclude_list,
240  sizeof(flow_table_exclude_list) / sizeof(char *));
241 
242  SetTaskPolicyOne(kTaskFlowDelete, flow_table_exclude_list,
243  sizeof(flow_table_exclude_list) / sizeof(char *));
244 
245  const char *sandesh_exclude_list[] = {
246  "db::DBTable",
247  "Agent::Services",
248  "Agent::StatsCollector",
249  "io::ReaderTask",
250  "Agent::PktFlowResponder",
251  "Agent::Profile",
252  "BFD",
256  };
257  SetTaskPolicyOne("sandesh::RecvQueue", sandesh_exclude_list,
258  sizeof(sandesh_exclude_list) / sizeof(char *));
259 
260  const char *xmpp_config_exclude_list[] = {
261  "Agent::Services",
262  "Agent::StatsCollector",
263  "sandesh::RecvQueue",
264  "io::ReaderTask",
265  "Agent::ControllerXmpp",
266  "db::Walker",
267  "db::DBTable",
268  "xmpp::StateMachine",
269  "bgp::ShowCommand",
272  };
273  SetTaskPolicyOne("bgp::Config", xmpp_config_exclude_list,
274  sizeof(xmpp_config_exclude_list) / sizeof(char *));
275 
276  const char *controller_xmpp_exclude_list[] = {
277  "Agent::Services",
278  "io::ReaderTask",
279  "db::DBTable",
282  };
283  SetTaskPolicyOne("Agent::ControllerXmpp", controller_xmpp_exclude_list,
284  sizeof(controller_xmpp_exclude_list) / sizeof(char *));
285 
286  const char *walker_exclude_list[] = {
287  "Agent::ControllerXmpp",
288  "db::DBTable",
289  // For ToR Agent Agent::KSync and db::Walker both task tries
290  // to modify route path list inline (out of DB table context) to
291  // manage route exports from dynamic peer before release the peer
292  // which is resulting in parallel access, for now we will avoid this
293  // race by adding task exclusion policy.
294  // TODO(prabhjot): need to remove this task exclusion one dynamic peer
295  // handling is done.
296  "Agent::KSync",
299  };
300  SetTaskPolicyOne("db::Walker", walker_exclude_list,
301  sizeof(walker_exclude_list) / sizeof(char *));
302 
303  const char *ksync_exclude_list[] = {
304  "db::DBTable",
307  };
308  SetTaskPolicyOne("Agent::KSync", ksync_exclude_list,
309  sizeof(ksync_exclude_list) / sizeof(char *));
310 
311  const char *stats_collector_exclude_list[] = {
312  "Agent::PktFlowResponder",
315  };
316  SetTaskPolicyOne("Agent::StatsCollector", stats_collector_exclude_list,
317  sizeof(stats_collector_exclude_list) / sizeof(char *));
318 
319  const char *flow_stats_exclude_list[] = {
322  };
323  SetTaskPolicyOne(kTaskFlowStatsCollector, flow_stats_exclude_list,
324  sizeof(flow_stats_exclude_list) / sizeof(char *));
325 
326  const char *session_stats_exclude_list[] = {
330  };
331  SetTaskPolicyOne(kTaskSessionStatsCollector, session_stats_exclude_list,
332  sizeof(session_stats_exclude_list) / sizeof(char *));
333 
334  const char *session_stats_event_exclude_list[] = {
337  };
338  SetTaskPolicyOne(kTaskSessionStatsCollectorEvent, session_stats_exclude_list,
339  sizeof(session_stats_event_exclude_list) / sizeof(char *));
340  const char *metadata_exclude_list[] = {
341  "xmpp::StateMachine",
342  "http::RequestHandlerTask"
343  };
344  SetTaskPolicyOne("http client", metadata_exclude_list,
345  sizeof(metadata_exclude_list) / sizeof(char *));
346 
347  const char *xmpp_state_machine_exclude_list[] = {
348  "io::ReaderTask"
349  };
350  SetTaskPolicyOne("xmpp::StateMachine", xmpp_state_machine_exclude_list,
351  sizeof(xmpp_state_machine_exclude_list) / sizeof(char *));
352 
353  const char *agent_init_exclude_list[] = {
354  "xmpp::StateMachine",
355  "http client",
356  "db::DBTable",
361  };
362  SetTaskPolicyOne(AGENT_INIT_TASKNAME, agent_init_exclude_list,
363  sizeof(agent_init_exclude_list) / sizeof(char *));
364 
365  const char *flow_stats_manager_exclude_list[] = {
366  "Agent::StatsCollector",
371  };
373  flow_stats_manager_exclude_list,
374  sizeof(flow_stats_manager_exclude_list) / sizeof(char *));
375 
377  scheduler->RegisterLog(boost::bind(&Agent::TaskTrace, this,
378  _1, _2, _3, _4, _5));
379 
380  const char *db_exclude_task_exclude_list[] = {
381  "Agent::Uve",
382  "sandesh::RecvQueue",
383  "Agent::ControllerXmpp",
384  "bgp::Config",
387  };
388  SetTaskPolicyOne(kTaskDBExclude, db_exclude_task_exclude_list,
389  sizeof(db_exclude_task_exclude_list) / sizeof(char *));
390 
391  const char *flow_stats_update_exclude_list[] = {
392  "Agent::Uve"
393  };
394  SetTaskPolicyOne(kTaskFlowStatsUpdate, flow_stats_update_exclude_list,
395  sizeof(flow_stats_update_exclude_list) / sizeof(char *));
396 
397  const char *profile_task_exclude_list[] = {
401  };
402  SetTaskPolicyOne("Agent::Profile", profile_task_exclude_list,
403  sizeof(profile_task_exclude_list) / sizeof(char *));
404 
405  //event notify exclude list
406  const char *event_notify_exclude_list[] = {
407  "Agent::ControllerXmpp",
408  "db::DBTable",
412  };
413  SetTaskPolicyOne(kEventNotifierTask, event_notify_exclude_list,
414  sizeof(event_notify_exclude_list) / sizeof(char *));
415 
416  // Health Check task
417  const char *health_check_exclude_list[] = {
419  };
420  SetTaskPolicyOne(kTaskHealthCheck, health_check_exclude_list,
421  sizeof(health_check_exclude_list) / sizeof(char *));
422 
423  const char *rest_api_exclude_list[] = {
424  "db::DBTable",
425  };
426  SetTaskPolicyOne("Agent::RestApi", rest_api_exclude_list,
427  sizeof(rest_api_exclude_list) / sizeof(char *));
428 
429 }
430 
433  TaskScheduler::GetInstance()->GetTaskId("db::DBTable"));
434 }
435 
437  delete lifetime_manager_;
438  lifetime_manager_ = NULL;
439 }
440 
441 uint32_t Agent::GenerateHash(std::vector<std::string> &list) {
442 
443  std::string concat_servers;
444  std::vector<std::string>::iterator iter;
445  for (iter = list.begin();
446  iter != list.end(); iter++) {
447  concat_servers += *iter;
448  }
449 
450  boost::hash<std::string> string_hash;
451  return(string_hash(concat_servers));
452 }
453 
457 }
458 
462 }
463 
466  InitDnsList();
467 }
468 
470 
471  // Controller
472  // 1. Save checksum of the Configured List
473  // 2. Randomize the Configured List
474  std::vector<string> list = params_->controller_server_list();
475  uint32_t new_chksum = GenerateHash(list);
476  if (new_chksum != controller_chksum_) {
477  controller_chksum_ = new_chksum;
479  std::random_shuffle(controller_list_.begin(), controller_list_.end());
480  }
481 
482  // Dns
483  // 1. Save checksum of the Configured List
484  // 2. Pick first two DNS Servers to connect
485  list.clear();
486  list = params_->dns_server_list();
487  new_chksum = GenerateHash(list);
488  if (new_chksum != dns_chksum_) {
489  dns_chksum_ = new_chksum;
491  }
492 
493  // Collector
494  // 1. Save checksum of the Configured List
495  // 2. Randomize the Configured List
496  list.clear();
497  list = params_->collector_server_list();
498  new_chksum = GenerateHash(list);
499  if (new_chksum != collector_chksum_) {
500  collector_chksum_ = new_chksum;
502  std::random_shuffle(collector_list_.begin(), collector_list_.end());
503  }
504 }
505 
506 // Get configuration from AgentParam into Agent
508  params_ = params;
509 
516 
519 
521 
522  // Don't fetch the VHOST conf for tor agent. For tor agent, vhost conf will
523  // not be populated into eth_port_list_ from conf file.
524  if (params_->eth_port_list().size() != 0) {
525  ip_fabric_intf_name_ = params_->eth_port_list()[0].c_str(); /* PKC: Using first element for now */
526  }
538  if (params_->loopback_ip() != Ip4Address(0)) {
540  is_l3mh_ = true;
541  }
542  if (router_id_.to_ulong()) {
543  router_id_configured_ = false;
544  }
545 
546  router_id6_ = Ip6Address::v4_mapped(router_id_);
548  if (params_->tunnel_type() == "MPLSoUDP")
550  else if (params_->tunnel_type() == "VXLAN")
552  else
554 
575  vr_limits_exceeded_map_.insert(VrLimitData("vr_nexthops", "Normal"));
576  vr_limits_exceeded_map_.insert(VrLimitData("vr_mpls_labels", "Normal"));
577 }
578 
580  cn_mcast_builder_ = peer;
581 }
582 
584  /* We need to do sandesh initialization here */
585 
586  /* If collector configuration is specified, use that for connection to
587  * collector. If not we still need to invoke InitGenerator to initialize
588  * introspect.
589  */
590  Module::type module = static_cast<Module::type>(module_type_);
591  NodeType::type node_type =
592  g_vns_constants.Module2NodeType.find(module)->second;
593  if (GetCollectorlist().size() != 0) {
595  host_name(),
596  g_vns_constants.NodeTypeNames.find(node_type)->second,
597  instance_id_,
598  event_manager(),
601  NULL, params_->derived_stats_map(),
603  } else {
605  host_name(),
606  g_vns_constants.NodeTypeNames.find(node_type)->second,
607  instance_id_,
608  event_manager(),
610  NULL, params_->derived_stats_map(),
612  }
613 
614  if (params_->cat_is_agent_mocked()) {
615  std::cout << "Agent Name: " << params_->agent_name()
616  << " Introspect Port: " << Sandesh::http_port() << std::endl;
617  std::string sub("{\"HTTPPort\":");
618  std::string pidstring = integerToString(getpid());
619 
620  pidstring += ".json";
621  sub += integerToString(Sandesh::http_port()) + "}";
622 
623  std::ofstream outfile(pidstring.c_str(), std::ofstream::out);
624  outfile << sub;
625  outfile.close();
626  }
627 }
628 
630  // ReConnect Collectors
633 }
634 
637  // Its observed that sometimes TBB scheduler misses spawn events
638  // and doesnt schedule a task till its triggered again. As a work around
639  // dummy timer is created at scheduler with default timeout of 1 sec
640  // that fires and awake TBB periodically. Modify the timeout if required.
643  }
644 
645  // Its observed that sometimes TBB stops scheduling tasks altogether.
646  // Initiate a monitor which asserts if no task is spawned for a given time.
650  }
651 }
652 
653 static bool interface_exist(string &name) {
654  struct if_nameindex *ifs = NULL;
655  struct if_nameindex *head = NULL;
656  bool ret = false;
657  string tname = "";
658 
659  ifs = if_nameindex();
660  if (ifs == NULL) {
661  LOG(INFO, "No interface exists!");
662  return ret;
663  }
664  head = ifs;
665  while (ifs->if_name && ifs->if_index) {
666  tname = ifs->if_name;
667  if (string::npos != tname.find(name)) {
668  ret = true;
669  name = tname;
670  break;
671  }
672  ifs++;
673  }
674  if_freenameindex(head);
675  return ret;
676 }
677 
679  if (!params_->isXenMode() || params_->xen_ll_name() == "")
680  return;
681 
682  string dev_name = params_->xen_ll_name();
683  if(!interface_exist(dev_name)) {
684  LOG(INFO, "Interface " << dev_name << " not found");
685  return;
686  }
687  params_->set_xen_ll_name(dev_name);
688 
689  //We create a kernel visible interface to support xapi
690  //Once we support dpdk on xen, we should change
691  //the transport type to KNI
697 }
698 
700  // Create peer entries
701  local_peer_.reset(new Peer(Peer::LOCAL_PEER, LOCAL_PEER_NAME, false));
703  false));
705  false));
706  ecmp_peer_.reset(new Peer(Peer::ECMP_PEER, ECMP_PEER_NAME, true));
707  vgw_peer_.reset(new Peer(Peer::VGW_PEER, VGW_PEER_NAME, true));
708  evpn_routing_peer_.reset(new EvpnRoutingPeer());
709  vxlan_bgp_peer_.reset(new VxlanBgpPeer());
710  evpn_peer_.reset(new EvpnPeer());
711  inet_evpn_peer_.reset(new InetEvpnPeer());
713  false));
715  MULTICAST_TOR_PEER_NAME, false));
719  false));
721  MAC_VM_BINDING_PEER_NAME, false));
724  false));
727  true));
730  true));
731 }
732 
733 void Agent::ReconfigSignalHandler(boost::system::error_code ec, int signum) {
734  LOG(DEBUG, "Received SIGHUP to apply updated configuration");
735  // Read the configuration
736  params_->ReInit();
737  // Generates checksum, randomizes and saves the list
739  // ReConnnect only ones whose checksums are different
740  controller()->ReConnect();
741  // ReConnect Collectors
743 }
744 
745 void Agent::DebugSignalHandler(boost::system::error_code ec, int signum) {
746  LOG(INFO, "Received SIGUSR1 to update debug configuration");
747  //Read the debug configuration
748  params_->DebugInit();
749 }
750 
752  params_(NULL), cfg_(NULL), stats_(NULL), ksync_(NULL), uve_(NULL),
753  stats_collector_(NULL), flow_stats_manager_(NULL), pkt_(NULL),
754  services_(NULL), vgw_(NULL), rest_server_(NULL), port_ipc_handler_(NULL),
755  oper_db_(NULL), diag_table_(NULL), controller_(NULL), resource_manager_(),
756  event_notifier_(), event_mgr_(NULL),
757  agent_xmpp_channel_(), ifmap_channel_(),
758  xmpp_client_(), xmpp_init_(), dns_xmpp_channel_(), dns_xmpp_client_(),
759  dns_xmpp_init_(), agent_stale_cleaner_(NULL), cn_mcast_builder_(NULL),
760  metadata_server_port_(0), host_name_(""), agent_name_(""),
761  prog_name_(""), introspect_port_(0),
762  instance_id_(g_vns_constants.INSTANCE_ID_DEFAULT),
763  module_type_(Module::VROUTER_AGENT), module_name_(),
764  db_(NULL), task_scheduler_(NULL), agent_init_(NULL), fabric_vrf_(NULL),
765  fabric_policy_vrf_(NULL),
766  intf_table_(NULL), health_check_table_(), metadata_ip_allocator_(),
767  metadata_ip6_allocator_(nullptr), nh_table_(NULL), uc_rt_table_(NULL), mc_rt_table_(NULL),
768  evpn_rt_table_(NULL), l2_rt_table_(NULL), vrf_table_(NULL),
769  vm_table_(NULL), vn_table_(NULL), sg_table_(NULL), mpls_table_(NULL),
770  acl_table_(NULL), mirror_table_(NULL), vrf_assign_table_(NULL),
771  vxlan_table_(NULL), service_instance_table_(NULL),
772  physical_device_table_(NULL), physical_device_vn_table_(NULL),
773  config_manager_(), mirror_cfg_table_(NULL),
774  intf_mirror_cfg_table_(NULL), router_id6_(Ip4Address(0)), router_id_(0), prefix_len_(0),
775  gateway_list_(0), compute_node_ip_(0), xs_cfg_addr_(""), xs_idx_(0),
776  xs_addr_(), xs_port_(),
777  xs_stime_(), xs_auth_enable_(false), xs_dns_idx_(0), dns_addr_(),
778  dns_port_(), dns_auth_enable_(false),
779  controller_chksum_(0), dns_chksum_(0), collector_chksum_(0),
780  ip_fabric_intf_name_(""), crypt_intf_name_(""),
781  vhost_interface_name_(""),
782  pkt_interface_name_("pkt0"), arp_proto_(NULL),
783  dhcp_proto_(NULL), dns_proto_(NULL), icmp_proto_(NULL),
784  dhcpv6_proto_(NULL), icmpv6_proto_(NULL), flow_proto_(NULL),
785  mac_learning_proto_(NULL), mac_learning_module_(NULL),
786  local_peer_(), local_vm_peer_(), linklocal_peer_(),
787  ecmp_peer_(), vgw_peer_(), evpn_routing_peer_(),
788  vxlan_bgp_peer_(), evpn_peer_(), multicast_peer_(),
789  multicast_tor_peer_(), multicast_tree_builder_peer_(),mac_vm_binding_peer_(),
790  inet_evpn_peer_(), mac_learning_peer_(), fabric_rt_export_peer_(),
791  local_vm_export_peer_(), agent_signal_(), ifmap_parser_(NULL),
792  router_id_configured_(false), mirror_src_udp_port_(0),
793  lifetime_manager_(NULL), ksync_sync_mode_(false), mgmt_ip_(""),
794  vxlan_network_identifier_mode_(AUTOMATIC), vhost_interface_(NULL),
795  crypt_interface_(NULL), connection_state_(NULL), test_mode_(false),
796  xmpp_dns_test_mode_(false),
797  init_done_(false), resource_manager_ready_(false),
798  simulate_evpn_tor_(false), tsn_no_forwarding_enabled_(false),
799  tsn_enabled_(false),
800  tor_agent_enabled_(false), forwarding_enabled_(true),
801  server_gateway_mode_(false), pbb_gateway_mode_(false),
802  inet_labeled_enabled_(false),
803  flow_table_size_(0), flow_thread_count_(0), flow_trace_enable_(true),
804  max_vm_flows_perc_(FLOWS_LIMIT_UNLIMITED),
805  max_vm_flows_(FLOWS_LIMIT_UNLIMITED),
806  global_max_vmi_flows_(FLOWS_LIMIT_UNLIMITED),
807  ovsdb_client_(NULL), vrouter_server_ip_(0),
808  vrouter_server_port_(0), vrouter_max_labels_(0), vrouter_max_nexthops_(0),
809  vrouter_max_interfaces_(0), vrouter_max_vrfs_(0),
810  vrouter_max_mirror_entries_(0), vrouter_max_bridge_entries_(0),
811  vrouter_max_oflow_bridge_entries_(0), vrouter_priority_tagging_(true),
812  flow_stats_req_handler_(NULL),
813  tbb_keepawake_timeout_(kDefaultTbbKeepawakeTimeout),
814  task_monitor_timeout_msec_(kDefaultTaskMonitorTimeout),
815  vr_limit_high_watermark_(kDefaultHighWatermark),
816  vr_limit_low_watermark_(kDefaultLowWatermark),
817  loopback_ip_(), is_l3mh_(false), ip_fabric_intf_name_list_() {
818 
819  assert(singleton_ == NULL);
820  singleton_ = this;
821  db_ = new DB();
822  assert(db_);
823 
824  event_mgr_ = new EventManager();
825  assert(event_mgr_);
826 
829 
830  Module::type module = static_cast<Module::type>(module_type_);
831  module_name_ = g_vns_constants.ModuleNames.find(module)->second;
832 
833  agent_signal_.reset(
834  AgentStaticObjectFactory::Create<AgentSignal>(event_mgr_));
835  agent_signal_.get()->RegisterSigHupHandler(
836  boost::bind(&Agent::ReconfigSignalHandler, this, _1, _2));
837  agent_signal_.get()->RegisterDebugSigHandler(
838  boost::bind(&Agent::DebugSignalHandler, this, _1, _2));
839 
840  config_manager_.reset(new ConfigManager(this));
841  for (uint8_t count = 0; count < MAX_XMPP_SERVERS; count++) {
842  (agent_xmpp_channel_[count]).reset();
843  }
844 }
845 
847  uve_ = NULL;
848  flow_stats_manager_ = NULL;
849 
850  agent_signal_->Terminate();
851  agent_signal_.reset();
852 
854 
855  delete db_;
856  db_ = NULL;
857  singleton_ = NULL;
858 
859  if (task_scheduler_) {
861  task_scheduler_ = NULL;
862  }
863 
864  delete event_mgr_;
865  event_mgr_ = NULL;
866 }
867 
869  return cfg_;
870 }
871 
873  cfg_ = cfg;
874 }
875 
877  return diag_table_;
878 }
879 
881  diag_table_ = table;
882 }
883 
885  return stats_;
886 }
887 
889  stats_ = stats;
890 }
891 
893  return config_manager_.get();
894 }
895 
897  return event_notifier_;
898 }
899 
901  event_notifier_ = val;
902 }
903 
904 KSync *Agent::ksync() const {
905  return ksync_;
906 }
907 
908 void Agent::set_ksync(KSync *ksync) {
909  ksync_ = ksync;
910 }
911 
913  return uve_;
914 }
915 
917  uve_ = uve;
918 }
919 
921  return stats_collector_;
922 }
923 
925  stats_collector_ = asc;
926 }
927 
929  return flow_stats_manager_;
930 }
931 
933  flow_stats_manager_ = aging_module;
934 }
935 
937  return health_check_table_;
938 }
939 
941  health_check_table_ = table;
942 }
943 
945  return bridge_domain_table_;
946 }
947 
949  bridge_domain_table_ = table;
950 }
951 
953  return metadata_ip_allocator_.get();
954 }
955 
957  metadata_ip_allocator_.reset(allocator);
958 }
959 
961  return metadata_ip6_allocator_.get();
962 }
963 
965  metadata_ip6_allocator_.reset(allocator);
966 }
967 
969  return pkt_;
970 }
971 
973  pkt_ = pkt;
974 }
975 
977  return services_;
978 }
979 
982 }
983 
985  return controller_;
986 }
987 
989  controller_ = val;
990 }
991 
993  return vgw_;
994 }
995 
997  vgw_ = vgw;
998 }
999 
1001  return rest_server_;
1002 }
1003 
1005  rest_server_ = r;
1006 }
1007 
1009  return port_ipc_handler_;
1010 }
1011 
1013  port_ipc_handler_ = r;
1014 }
1015 
1017  return oper_db_;
1018 }
1019 
1020 void Agent::set_oper_db(OperDB *oper_db) {
1021  oper_db_ = oper_db;
1022 }
1023 
1025  return resource_manager_;
1026 }
1027 
1029  resource_manager_ = val;
1030 }
1031 
1033  return oper_db_->domain_config_table();
1034 }
1035 
1036 bool Agent::isVmwareMode() const {
1037  return params_->isVmwareMode();
1038 }
1039 
1041  if (isVmwareMode() == false)
1042  return false;
1043 
1044  return params_->isVmwareVcenterMode();
1045 }
1046 
1048  if (test_mode_) {
1049  CHECK_CONCURRENCY("db::DBTable", "Agent::KSync", AGENT_INIT_TASKNAME,
1053  }
1054 }
1055 
1057  return params_->vrouter_on_nic_mode();
1058 }
1059 
1061  return params_->vrouter_on_host_dpdk();
1062 }
1063 
1065  return params_->vrouter_on_host();
1066 }
1067 
1068 uint16_t
1069 Agent::ProtocolStringToInt(const std::string &proto_arg) {
1070  std::string proto = proto_arg;
1071 
1072  std::transform(proto.begin(), proto.end(), proto.begin(), ::tolower);
1073 
1074  if (proto == "tcp") {
1075  return IPPROTO_TCP;
1076  }
1077 
1078  if (proto == "udp") {
1079  return IPPROTO_UDP;
1080  }
1081 
1082  if (proto == "sctp") {
1083  return IPPROTO_SCTP;
1084  }
1085 
1086  if (proto =="icmp") {
1087  return IPPROTO_ICMP;
1088  }
1089 
1090  if (proto == "icmp6") {
1091  return IPPROTO_ICMPV6;
1092  }
1093 
1094  return atoi(proto.c_str());
1095 }
1096 
1098 (const std::string &mode) const {
1099  if (mode == "l2")
1100  return Agent::L2;
1101  else if (mode == "l3")
1102  return Agent::L3;
1103  else if (mode == "l2_l3")
1104  return Agent::L2_L3;
1105 
1106  return Agent::NONE;
1107 }
1108 
1109 void Agent::update_max_vm_flows(uint32_t flow_table_size) {
1110  if (flow_table_size == 0) {
1111  return;
1112  }
1113  if (max_vm_flows_perc_ >= 100) {
1115  } else if (max_vm_flows_perc_ == FLOWS_LIMIT_UNLIMITED) {
1117  } else {
1119  }
1120 }
1121 
1122 void Agent::set_flow_table_size(uint32_t count) {
1123  flow_table_size_ = count;
1125 }
1126 
1128  assert(channel != NULL);
1129  (agent_xmpp_channel_[idx]).reset(channel);
1130 }
1131 
1133  (agent_xmpp_channel_[idx]).reset();
1134 }
1135 
1136 boost::shared_ptr<AgentXmppChannel> Agent::controller_xmpp_channel_ref(uint8_t idx) {
1137  return agent_xmpp_channel_[idx];
1138 }
1139 
1140 void Agent::TaskTrace(const char *file_name, uint32_t line_no,
1141  const Task *task, const char *description,
1142  uint64_t delay) {
1143  TaskTrace::TraceMsg(TaskTraceBuf, file_name, line_no,
1144  task->GetTaskId(), task->GetTaskInstance(),
1145  description, delay, task->Description());
1146 }
1147 
1149  return params_->measure_queue_delay();
1150 }
1151 
1153  return params_->set_measure_queue_delay(val);
1154 }
1155 
1156 void Agent::SetXmppDscp(uint8_t val) {
1157  for (uint8_t count = 0; count < MAX_XMPP_SERVERS; count++) {
1158  XmppClient *client = xmpp_client_[count];
1159  if (client) {
1161  }
1162  client = dns_xmpp_client_[count];
1163  if (client) {
1164  client->SetDscpValue(val, XmppInit::kDnsNodeJID);
1165  }
1166  }
1167 }
1168 
1169 VrouterObjectLimits Agent::GetVrouterObjectLimits() {
1170  VrouterObjectLimits vr_limits;
1171  vr_limits.set_max_labels(vrouter_max_labels());
1172  vr_limits.set_max_nexthops(vrouter_max_nexthops());
1173  vr_limits.set_max_interfaces(vrouter_max_interfaces());
1174  vr_limits.set_max_vrfs(vrouter_max_vrfs());
1175  vr_limits.set_max_mirror_entries(vrouter_max_mirror_entries());
1176  vr_limits.set_vrouter_max_bridge_entries(vrouter_max_bridge_entries());
1177  vr_limits.set_vrouter_max_oflow_bridge_entries(
1179  vr_limits.set_vrouter_build_info(vrouter_build_info());
1180  vr_limits.set_vrouter_max_flow_entries(vrouter_max_flow_entries());
1181  vr_limits.set_vrouter_max_oflow_entries(vrouter_max_oflow_entries());
1182  vr_limits.set_vrouter_priority_tagging(vrouter_priority_tagging());
1183  return vr_limits;
1184 }
1185 
1187  resource_manager_ready_ = true;
1188  config_manager_->Start();
1189 }
1190 
1192  if (params()->vrouter_on_host_dpdk()) {
1193  return Interface::TRANSPORT_PMD;
1194  }
1196 }
1197 
1198 
1199 std::string AgentBackTrace(int skip = 1)
1200 {
1201  std::ostringstream sbuffer;
1202  void *callstack[128];
1203  char buffer[1024];
1204  const int nMaxFrames = sizeof(callstack) / sizeof(callstack[0]);
1205  int nFrames = backtrace(callstack, nMaxFrames);
1206 
1207  for (int i = skip; i < nFrames; i++) {
1208  Dl_info info;
1209  if (dladdr(callstack[i], &info)) {
1210  char *demangled = NULL;
1211  int status;
1212  demangled = abi::__cxa_demangle(info.dli_sname, NULL, 0, &status);
1213  snprintf(buffer, sizeof(buffer), "%-3d %p %s + %zd\n",
1214  i, callstack[i],
1215  status == 0 ? demangled : info.dli_sname,
1216  (char *)callstack[i] - (char *)info.dli_saddr);
1217  free(demangled);
1218  } else {
1219  snprintf(buffer, sizeof(buffer), "%-3d %p\n",
1220  i, callstack[i]);
1221  }
1222  sbuffer << buffer;
1223  }
1224  if (nFrames == nMaxFrames)
1225  sbuffer << " [truncated]\n";
1226 
1227  return sbuffer.str();
1228 }
static AclTable * acl_table_
Definition: acl.cc:36
boost::asio::ip::address IpAddress
Definition: address.h:13
boost::asio::ip::address_v4 Ip4Address
Definition: address.h:14
static void SetTaskPolicyOne(const char *task, const char *exclude_list[], int count)
Definition: agent.cc:164
std::string AgentBackTrace(int skip=1)
Definition: agent.cc:1199
static bool interface_exist(string &name)
Definition: agent.cc:653
SandeshTraceBufferPtr TaskTraceBuf(SandeshTraceBufferCreate("TaskTrace", 5000))
std::pair< std::string, std::string > VrLimitData
Definition: agent.h:215
#define AGENT_SHUTDOWN_TASKNAME
Definition: agent.h:299
#define kTaskFlowStatsUpdate
Definition: agent.h:333
#define kAgentResourceBackUpTask
Definition: agent.h:342
#define FLOWS_LIMIT_UNLIMITED
Definition: agent.h:306
#define kTaskFlowDelete
Definition: agent.h:326
#define kTaskFlowMgmt
Definition: agent.h:327
#define XMPP_SERVER_PORT
Definition: agent.h:292
#define AGENT_SANDESH_TASKNAME
Definition: agent.h:301
#define kTaskDBExclude
Definition: agent.h:338
#define AGENT_INIT_TASKNAME
Definition: agent.h:297
#define MAX_XMPP_SERVERS
Definition: agent.h:291
#define INSTANCE_MANAGER_TASK_NAME
Definition: agent.h:298
#define kEventNotifierTask
Definition: agent.h:358
#define kTaskSessionStatsCollector
Definition: agent.h:331
#define kTaskFlowEvent
Definition: agent.h:323
#define kTaskCryptTunnel
Definition: agent.h:336
#define kTaskConfigManager
Definition: agent.h:339
#define kAgentResourceRestoreTask
Definition: agent.h:341
#define kTaskFlowAudit
Definition: agent.h:328
#define kTaskFlowKSync
Definition: agent.h:324
#define METADATA_IP_ADDR
Definition: agent.h:294
#define kTaskMacLearning
Definition: agent.h:343
#define kTaskFlowUpdate
Definition: agent.h:325
#define AGENT_FLOW_STATS_MANAGER_TASK
Definition: agent.h:300
#define kTaskFlowStatsCollector
Definition: agent.h:330
#define kTaskHealthCheck
Definition: agent.h:335
#define XMPP_DNS_SERVER_PORT
Definition: agent.h:293
#define kTaskSessionStatsCollectorEvent
Definition: agent.h:332
bool simulate_evpn_tor() const
Definition: agent_param.h:271
std::string xmpp_server_cert() const
Definition: agent_param.h:267
std::string xmpp_ca_cert() const
Definition: agent_param.h:269
bool vrouter_on_host() const
Definition: agent_param.h:349
const std::string & tunnel_type() const
Definition: agent_param.h:240
bool isTsnAgent() const
Definition: agent_param.h:380
void set_measure_queue_delay(bool val)
Definition: agent_param.h:508
bool flow_trace_enable() const
Definition: agent_param.h:430
const int vhost_plen() const
Definition: agent_param.h:189
uint32_t flow_del_tokens() const
Definition: agent_param.h:260
bool isXenMode() const
Definition: agent_param.h:336
bool cat_is_agent_mocked() const
Definition: agent_param.h:568
const void set_xen_ll_name(const std::string &name)
Definition: agent_param.h:196
const std::string & host_name() const
Definition: agent_param.h:313
const std::string & agent_name() const
Definition: agent_param.h:204
uint32_t flow_ksync_tokens() const
Definition: agent_param.h:259
const std::vector< std::string > collector_server_list() const
Definition: agent_param.h:305
void DebugInit()
bool IsForwardingEnabled() const
Definition: agent_param.h:385
bool isTorAgent() const
Definition: agent_param.h:384
const std::string & vhost_name() const
Definition: agent_param.h:183
uint16_t flow_thread_count() const
Definition: agent_param.h:427
bool vrouter_on_nic_mode() const
Definition: agent_param.h:343
bool isDockerMode() const
Definition: agent_param.h:338
const Ip4Address & vhost_addr() const
Definition: agent_param.h:184
const SandeshConfig & sandesh_config() const
Definition: agent_param.h:425
bool vrouter_on_host_dpdk() const
Definition: agent_param.h:346
bool xmpp_dns_auth_enabled() const
Definition: agent_param.h:270
bool isVcpeGatewayMode() const
Definition: agent_param.h:389
const Ip4Address & xen_ll_gw() const
Definition: agent_param.h:202
const std::string & crypt_port() const
Definition: agent_param.h:213
bool test_mode() const
Definition: agent_param.h:367
bool isPbbGatewayMode() const
Definition: agent_param.h:390
const AddressList & gateway_list() const
Definition: agent_param.h:191
const std::string & program_name() const
Definition: agent_param.h:288
const std::string & xen_ll_name() const
Definition: agent_param.h:195
const std::string & subcluster_name() const
Definition: agent_param.h:220
uint32_t flow_update_tokens() const
Definition: agent_param.h:261
const Ip4Address & xen_ll_addr() const
Definition: agent_param.h:199
bool measure_queue_delay() const
Definition: agent_param.h:507
uint16_t http_server_port() const
Definition: agent_param.h:311
uint32_t flow_add_tokens() const
Definition: agent_param.h:258
uint32_t task_monitor_timeout_msec() const
Definition: agent_param.h:456
const Ip4Address & loopback_ip() const
Definition: agent_param.h:576
std::string xmpp_server_key() const
Definition: agent_param.h:268
const std::vector< std::string > controller_server_list() const
Definition: agent_param.h:217
bool isVmwareVcenterMode() const
Definition: agent_param.h:340
const std::vector< std::string > & eth_port_list() const
Definition: agent_param.h:205
bool isKvmMode() const
Definition: agent_param.h:337
float vr_object_high_watermark() const
Definition: agent_param.h:574
const int xen_ll_plen() const
Definition: agent_param.h:201
uint32_t tbb_keepawake_timeout() const
Definition: agent_param.h:455
void ReInit()
bool isVmwareMode() const
Definition: agent_param.h:339
bool isServerGatewayMode() const
Definition: agent_param.h:388
const std::vector< std::string > dns_server_list() const
Definition: agent_param.h:221
const AddressList & eth_port_addr_list() const
Definition: agent_param.h:208
const std::map< std::string, std::map< std::string, std::string > > derived_stats_map() const
Definition: agent_param.h:308
bool xmpp_auth_enabled() const
Definition: agent_param.h:266
Definition: agent.h:360
uint32_t prefix_len_
Definition: agent.h:1504
void SetMeasureQueueDelay(bool val)
Definition: agent.cc:1152
ConfigManager * config_manager() const
Definition: agent.cc:892
static std::string fabric_vrf_name_
Definition: agent.h:1660
bool vrouter_on_nic_mode() const
Definition: agent.cc:1056
bool vcpe_gateway_mode_
Definition: agent.h:1593
MetaDataIpAllocator * metadata_ip6_allocator() const
Definition: agent.cc:960
PortIpcHandler * port_ipc_handler_
Definition: agent.h:1429
std::string GetUuidStr(boost::uuids::uuid uuid_val) const
Definition: agent.cc:98
ResourceManager * resource_manager() const
Definition: agent.cc:1024
ResourceManager * resource_manager_
Definition: agent.h:1433
void TaskTrace(const char *file_name, uint32_t line_no, const Task *task, const char *description, uint64_t delay)
Definition: agent.cc:1140
XmppClient * xmpp_client_[MAX_XMPP_SERVERS]
Definition: agent.h:1439
uint8_t GetInterfaceTransport() const
Definition: agent.cc:1191
std::unique_ptr< Peer > multicast_tor_peer_
Definition: agent.h:1560
float vr_limit_low_watermark_
Definition: agent.h:1650
Agent::ForwardingMode TranslateForwardingMode(const std::string &mode) const
Definition: agent.cc:1098
std::vector< std::string > collector_list_
Definition: agent.h:1532
std::string xs_ca_cert_
Definition: agent.h:1521
std::vector< std::string > controller_list_
Definition: agent.h:1528
void ReConnectCollectors()
Definition: agent.cc:629
ServicesModule * services() const
Definition: agent.cc:976
bool MeasureQueueDelay()
Definition: agent.cc:1148
static const MacAddress pkt_interface_mac_
Definition: agent.h:1666
void InitCollector()
Definition: agent.cc:583
VNController * controller() const
Definition: agent.cc:984
std::unique_ptr< Peer > multicast_tree_builder_peer_
Definition: agent.h:1561
std::unique_ptr< Peer > evpn_routing_peer_
Definition: agent.h:1556
void set_flow_table_size(uint32_t count)
Definition: agent.cc:1122
Ip4Address loopback_ip_
Definition: agent.h:1652
uint32_t controller_chksum_
Definition: agent.h:1529
VirtualGateway * vgw() const
Definition: agent.cc:992
void set_uve(AgentUveBase *uve)
Definition: agent.cc:916
OperDB * oper_db() const
Definition: agent.cc:1016
BridgeDomainTable * bridge_domain_table_
Definition: agent.h:1465
std::unique_ptr< Peer > linklocal_peer_
Definition: agent.h:1553
Agent()
Definition: agent.cc:751
static const std::string link_local_vrf_name_
Definition: agent.h:1663
void set_ksync(KSync *ksync)
Definition: agent.cc:908
uint16_t dns_port_[MAX_XMPP_SERVERS]
Definition: agent.h:1525
AgentStats * stats_
Definition: agent.h:1420
uint32_t vrouter_max_oflow_entries() const
Definition: agent.h:1318
VNController * controller_
Definition: agent.h:1432
DomainConfig * domain_config_table() const
Definition: agent.cc:1032
bool vrouter_priority_tagging() const
Definition: agent.h:1335
bool test_mode_
Definition: agent.h:1583
uint16_t flow_thread_count_
Definition: agent.h:1599
void InitPeers()
Definition: agent.cc:699
void set_resource_manager(ResourceManager *resource_manager)
Definition: agent.cc:1028
PortIpcHandler * port_ipc_handler() const
Definition: agent.cc:1008
bool resource_manager_ready_
Definition: agent.h:1586
AgentStatsCollector * stats_collector_
Definition: agent.h:1423
FlowStatsManager * flow_stats_manager() const
Definition: agent.cc:928
static const std::string bcast_mac_
Definition: agent.h:1667
static const std::string xmpp_control_node_connection_name_prefix_
Definition: agent.h:1671
uint32_t flow_update_tokens_
Definition: agent.h:1607
void set_bridge_domain_table(BridgeDomainTable *table)
Definition: agent.cc:948
std::string host_name_
Definition: agent.h:1448
bool vrouter_on_host() const
Definition: agent.cc:1064
VrLimitExceeded vr_limits_exceeded_map_
Definition: agent.h:1647
uint32_t vrouter_max_interfaces() const
Definition: agent.h:1274
AgentParam * params() const
Definition: agent.h:1226
void InitXenLinkLocalIntf()
Definition: agent.cc:678
uint32_t flow_ksync_tokens_
Definition: agent.h:1605
void set_metadata_ip6_allocator(MetaDataIpAllocator *allocator)
Definition: agent.cc:964
const std::string & agent_name() const
Definition: agent.h:880
bool isXenMode()
Definition: agent.cc:141
std::string prog_name_
Definition: agent.h:1452
FlowStatsManager * flow_stats_manager_
Definition: agent.h:1424
uint32_t vrouter_max_flow_entries() const
Definition: agent.h:1311
const std::string & GetHostInterfaceName() const
Definition: agent.cc:93
std::string vhost_interface_name_
Definition: agent.h:1536
std::string crypt_intf_name_
Definition: agent.h:1535
void InitDone()
Definition: agent.cc:635
AgentUveBase * uve() const
Definition: agent.cc:912
std::unique_ptr< Peer > local_vm_export_peer_
Definition: agent.h:1566
VirtualGateway * vgw_
Definition: agent.h:1427
static const MacAddress right_si_mac_
Definition: agent.h:1669
static const std::string fabric_vn_name_
Definition: agent.h:1661
EventManager * event_manager() const
Definition: agent.h:1105
static const std::set< std::string > null_string_list_
Definition: agent.h:1659
void SetXmppDscp(uint8_t val)
Definition: agent.cc:1156
void set_port_ipc_handler(PortIpcHandler *r)
Definition: agent.cc:1012
bool isDockerMode()
Definition: agent.cc:149
uint32_t flow_del_tokens_
Definition: agent.h:1606
bool tor_agent_enabled_
Definition: agent.h:1590
RestServer * rest_server_
Definition: agent.h:1428
uint32_t task_monitor_timeout_msec_
Definition: agent.h:1641
std::unique_ptr< Peer > ecmp_peer_
Definition: agent.h:1554
void set_stats(AgentStats *stats)
Definition: agent.cc:888
uint32_t vrouter_max_labels() const
Definition: agent.h:1260
uint32_t vrouter_max_vrfs() const
Definition: agent.h:1281
uint32_t flow_add_tokens_
Definition: agent.h:1604
AgentConfig * cfg() const
Definition: agent.cc:868
static const std::string xmpp_dns_server_connection_name_prefix_
Definition: agent.h:1670
AgentStatsCollector * stats_collector() const
Definition: agent.cc:920
void ConcurrencyCheck()
Definition: agent.cc:1047
std::unique_ptr< Peer > fabric_rt_export_peer_
Definition: agent.h:1565
void CopyConfig(AgentParam *params)
Definition: agent.cc:507
uint32_t collector_chksum_
Definition: agent.h:1533
void InitDnsList()
Definition: agent.cc:459
Ip4Address compute_node_ip_
Definition: agent.h:1512
void set_health_check_table(HealthCheckTable *table)
Definition: agent.cc:940
std::unique_ptr< Peer > evpn_peer_
Definition: agent.h:1558
AgentUveBase * uve_
Definition: agent.h:1422
bool xs_auth_enable_
Definition: agent.h:1518
void set_pkt(PktModule *pkt)
Definition: agent.cc:972
void set_cfg(AgentConfig *cfg)
Definition: agent.cc:872
const std::string & vhost_interface_name() const
Definition: agent.cc:104
uint32_t vrouter_max_oflow_bridge_entries() const
Definition: agent.h:1303
void set_oper_db(OperDB *oper_db)
Definition: agent.cc:1020
uint32_t max_vm_flows_perc_
Definition: agent.h:1601
bool is_l3mh() const
Definition: agent.h:727
static const uint16_t kDefaultVmiVmVnUveInterval
Definition: agent.h:384
DiagTable * diag_table_
Definition: agent.h:1431
void SetResourceManagerReady()
Definition: agent.cc:1186
void set_event_notifier(EventNotifier *mgr)
Definition: agent.cc:900
IpAddress GetMirrorSourceIp(const IpAddress &dest)
Definition: agent.cc:76
uint16_t xs_port_[MAX_XMPP_SERVERS]
Definition: agent.h:1516
void set_metadata_ip_allocator(MetaDataIpAllocator *allocator)
Definition: agent.cc:956
bool simulate_evpn_tor_
Definition: agent.h:1587
uint32_t flow_table_size() const
Definition: agent.h:1201
void set_controller(VNController *val)
Definition: agent.cc:988
void ReconfigSignalHandler(boost::system::error_code, int)
Definition: agent.cc:733
void set_diag_table(DiagTable *table)
Definition: agent.cc:880
void DebugSignalHandler(boost::system::error_code, int)
Definition: agent.cc:745
static const MacAddress left_si_mac_
Definition: agent.h:1668
KSync * ksync() const
Definition: agent.cc:904
const std::string & host_name() const
Definition: agent.h:877
const std::string & module_name() const
Definition: agent.h:894
std::string ip_fabric_intf_name_
Definition: agent.h:1534
static const std::string link_local_vn_name_
Definition: agent.h:1664
bool isVmwareVcenterMode() const
Definition: agent.cc:1040
bool vrouter_on_host_dpdk() const
Definition: agent.cc:1060
static const std::string null_string_
Definition: agent.h:1658
static const std::string & NullString()
Definition: agent.h:439
static const MacAddress vrrp_mac_
Definition: agent.h:1665
std::unique_ptr< Peer > multicast_peer_
Definition: agent.h:1559
std::string AgentGUID() const
Definition: agent.cc:157
bool is_vhost_interface_up() const
Definition: agent.cc:108
bool flow_trace_enable_
Definition: agent.h:1600
void set_vgw(VirtualGateway *vgw)
Definition: agent.cc:996
boost::shared_ptr< AgentXmppChannel > agent_xmpp_channel_[MAX_XMPP_SERVERS]
Definition: agent.h:1437
uint32_t vrouter_max_bridge_entries() const
Definition: agent.h:1296
BridgeDomainTable * bridge_domain_table() const
Definition: agent.cc:944
static uint16_t ProtocolStringToInt(const std::string &str)
Definition: agent.cc:1069
uint32_t flow_table_size_
Definition: agent.h:1598
uint32_t GenerateHash(std::vector< std::string > &)
Definition: agent.cc:441
uint32_t vrouter_max_nexthops() const
Definition: agent.h:1267
std::string instance_id_
Definition: agent.h:1454
void set_cn_mcast_builder(AgentXmppChannel *peer)
Definition: agent.cc:579
std::string subcluster_name_
Definition: agent.h:1522
AgentXmppChannel * cn_mcast_builder_
Definition: agent.h:1445
bool isKvmMode()
Definition: agent.cc:145
IpAddress router_id6_
Definition: agent.h:1501
std::string vrouter_build_info() const
Definition: agent.h:1327
XmppClient * dns_xmpp_client_[MAX_XMPP_SERVERS]
Definition: agent.h:1442
bool test_mode() const
Definition: agent.h:1193
HealthCheckTable * health_check_table_
Definition: agent.h:1464
void set_flow_stats_manager(FlowStatsManager *fsc)
Definition: agent.cc:932
std::string agent_name_
Definition: agent.h:1451
bool router_id_configured_
Definition: agent.h:1571
int introspect_port_
Definition: agent.h:1453
void ShutdownLifetimeManager()
Definition: agent.cc:436
RestServer * rest_server() const
Definition: agent.cc:1000
KSync * ksync_
Definition: agent.h:1421
bool pbb_gateway_mode_
Definition: agent.h:1594
LifetimeManager * lifetime_manager_
Definition: agent.h:1574
std::unique_ptr< Peer > mac_learning_peer_
Definition: agent.h:1564
static Agent * GetInstance()
Definition: agent.h:438
virtual ~Agent()
Definition: agent.cc:846
DB * db_
Definition: agent.h:1458
static std::string fabric_policy_vrf_name_
Definition: agent.h:1662
void set_services(ServicesModule *services)
Definition: agent.cc:980
std::vector< std::string > ip_fabric_intf_name_list_
Definition: agent.h:1654
PktModule * pkt_
Definition: agent.h:1425
std::string module_name_
Definition: agent.h:1456
void set_stats_collector(AgentStatsCollector *asc)
Definition: agent.cc:924
ForwardingMode
Definition: agent.h:405
@ L2_L3
Definition: agent.h:407
@ L3
Definition: agent.h:409
@ NONE
Definition: agent.h:406
@ L2
Definition: agent.h:408
AgentParam * params_
Definition: agent.h:1418
std::string xs_server_key_
Definition: agent.h:1520
float vr_limit_high_watermark_
Definition: agent.h:1649
std::unique_ptr< MetaDataIpAllocator > metadata_ip_allocator_
Definition: agent.h:1466
std::string xs_server_cert_
Definition: agent.h:1519
std::string xs_addr_[MAX_XMPP_SERVERS]
Definition: agent.h:1515
AgentConfig * cfg_
Definition: agent.h:1419
void set_rest_server(RestServer *r)
Definition: agent.cc:1004
Ip4Address router_id_
Definition: agent.h:1502
static const std::string v4_link_local_subnet_
Definition: agent.h:1674
std::unique_ptr< Peer > vxlan_bgp_peer_
Definition: agent.h:1557
bool tor_agent_enabled() const
Definition: agent.h:1166
std::unique_ptr< MetaDataIpAllocator > metadata_ip6_allocator_
Definition: agent.h:1467
uint32_t dns_chksum_
Definition: agent.h:1531
AgentStats * stats() const
Definition: agent.cc:884
void SetAgentTaskPolicy()
Definition: agent.cc:175
DiagTable * diag_table() const
Definition: agent.cc:876
void InitializeFilteredParams()
Definition: agent.cc:464
bool dns_auth_enable_
Definition: agent.h:1526
bool tsn_no_forwarding_enabled_
Definition: agent.h:1588
HealthCheckTable * health_check_table() const
Definition: agent.cc:936
void set_controller_xmpp_channel(AgentXmppChannel *channel, uint8_t idx)
Definition: agent.cc:1127
void CreateLifetimeManager()
Definition: agent.cc:431
std::vector< string > & GetCollectorlist()
Definition: agent.h:710
TaskScheduler * task_scheduler_
Definition: agent.h:1459
EventNotifier * event_notifier() const
Definition: agent.cc:896
EventNotifier * event_notifier_
Definition: agent.h:1434
std::unique_ptr< Peer > vgw_peer_
Definition: agent.h:1555
std::unique_ptr< Peer > mac_vm_binding_peer_
Definition: agent.h:1562
ServicesModule * services_
Definition: agent.h:1426
std::unique_ptr< Peer > local_peer_
Definition: agent.h:1551
std::unique_ptr< ConfigManager > config_manager_
Definition: agent.h:1493
uint32_t vrouter_max_mirror_entries() const
Definition: agent.h:1288
void reset_controller_xmpp_channel(uint8_t idx)
Definition: agent.cc:1132
OperDB * oper_db_
Definition: agent.h:1430
std::unique_ptr< AgentSignal > agent_signal_
Definition: agent.h:1568
bool isVmwareMode() const
Definition: agent.cc:1036
static Agent * singleton_
Definition: agent.h:1577
bool server_gateway_mode_
Definition: agent.h:1592
Ip4Address router_id() const
Definition: agent.h:668
void update_max_vm_flows(uint32_t flow_table_size)
Definition: agent.cc:1109
int module_type_
Definition: agent.h:1455
uint32_t tbb_keepawake_timeout_
Definition: agent.h:1639
void InitControllerList()
Definition: agent.cc:454
bool is_l3mh_
Definition: agent.h:1653
std::vector< std::string > dns_list_
Definition: agent.h:1530
bool isMockMode() const
Definition: agent.cc:153
EventManager * event_mgr_
Definition: agent.h:1436
static const std::string v6_link_local_subnet_
Definition: agent.h:1675
bool forwarding_enabled_
Definition: agent.h:1591
std::string dns_addr_[MAX_XMPP_SERVERS]
Definition: agent.h:1524
AddressList ip_fabric_intf_addr_list_
Definition: agent.h:1506
MetaDataIpAllocator * metadata_ip_allocator() const
Definition: agent.cc:952
bool tsn_enabled_
Definition: agent.h:1589
PktModule * pkt() const
Definition: agent.cc:968
InterfaceTable * intf_table_
Definition: agent.h:1463
std::unique_ptr< Peer > local_vm_peer_
Definition: agent.h:1552
std::unique_ptr< Peer > inet_evpn_peer_
Definition: agent.h:1563
uint32_t max_vm_flows_
Definition: agent.h:1602
VrouterObjectLimits GetVrouterObjectLimits()
Definition: agent.cc:1169
AddressList gateway_list_
Definition: agent.h:1505
void CopyFilteredParams()
Definition: agent.cc:469
boost::shared_ptr< AgentXmppChannel > controller_xmpp_channel_ref(uint8_t idx)
Definition: agent.cc:1136
Definition: db.h:24
Definition: peer.h:257
static void Create(InterfaceTable *table, const std::string &ifname, SubType sub_type, const std::string &vrf_name, const Ip4Address &addr, int plen, const Ip4Address &gw, const std::string &xconnect, const std::string &vn_name, Interface::Transport transport)
@ TRANSPORT_PMD
Definition: interface.h:67
@ TRANSPORT_ETHERNET
Definition: interface.h:65
DomainConfig * domain_config_table()
Definition: operdb_init.h:67
Definition: peer.h:44
@ LOCAL_PEER
Definition: peer.h:58
@ MULTICAST_PEER
Definition: peer.h:49
@ LINKLOCAL_PEER
Definition: peer.h:53
@ MAC_LEARNING_PEER
Definition: peer.h:66
@ VGW_PEER
Definition: peer.h:60
@ LOCAL_VM_PEER
Definition: peer.h:57
@ ECMP_PEER
Definition: peer.h:54
@ MAC_VM_BINDING_PEER
Definition: peer.h:64
@ MULTICAST_FABRIC_TREE_BUILDER
Definition: peer.h:61
@ MULTICAST_TOR_PEER
Definition: peer.h:63
static int http_port()
Definition: cpp/sandesh.h:297
static void ReConfigCollectors(const std::vector< std::string > &collector_list)
Definition: sandesh.cc:230
static bool InitGenerator(const std::string &module, const std::string &source, const std::string &node_type, const std::string &instance_id, EventManager *evm, unsigned short http_port, const std::vector< std::string > &collectors, SandeshContext *client_context=NULL, DerivedStats ds=DerivedStats(), const SandeshConfig &config=SandeshConfig())
Definition: sandesh.cc:271
The TaskScheduler keeps track of what tasks are currently schedulable. When a task is enqueued it is ...
Definition: task.h:178
void Terminate()
Definition: task.cc:978
int GetTaskId(const std::string &name)
Definition: task.cc:856
void ModifyTbbKeepAwakeTimeout(uint32_t timeout)
Definition: task.cc:505
void EnableMonitor(EventManager *evm, uint64_t tbb_keepawake_time_msec, uint64_t inactivity_time_msec, uint64_t poll_interval_msec)
Enable Task monitoring.
Definition: task.cc:511
void SetPolicy(int task_id, TaskPolicy &policy)
Sets the task exclusion policy. Adds policy entries for the task Examples:
Definition: task.cc:610
static TaskScheduler * GetInstance()
Definition: task.cc:547
void RegisterLog(LogFn fn)
Definition: task.cc:531
Task is a wrapper over tbb::task to support policies.
Definition: task.h:86
@ MPLS_UDP
Definition: nexthop.h:242
@ MPLS_GRE
Definition: nexthop.h:241
static void SetDefaultType(Type type)
Definition: nexthop.h:306
int SetDscpValue(uint8_t value, const char *conn_id)
Definition: xmpp_client.cc:274
static const char * kControlNodeJID
Definition: xmpp_init.h:17
static const char * kDnsNodeJID
Definition: xmpp_init.h:19
void ParseAddresses(const std::vector< std::string > &addresses, std::string out_ips[], uint16_t out_ports[]) const
uint8_t type
Definition: load_balance.h:2
#define LOG(_Level, _Msg)
Definition: logging.h:33
int32_t skip(Protocol_ &prot, TType type)
Definition: TProtocol.h:187
#define LOCAL_VM_EXPORT_PEER
Definition: peer.h:31
#define MULTICAST_FABRIC_TREE_BUILDER_NAME
Definition: peer.h:27
#define MAC_LEARNING_PEER_NAME
Definition: peer.h:29
#define LINKLOCAL_PEER_NAME
Definition: peer.h:20
#define ECMP_PEER_NAME
Definition: peer.h:21
#define VGW_PEER_NAME
Definition: peer.h:22
#define LOCAL_VM_PEER_NAME
Definition: peer.h:17
#define MULTICAST_PEER_NAME
Definition: peer.h:25
#define LOCAL_PEER_NAME
Definition: peer.h:16
#define MAC_VM_BINDING_PEER_NAME
Definition: peer.h:28
#define MULTICAST_TOR_PEER_NAME
Definition: peer.h:26
#define FABRIC_RT_EXPORT
Definition: peer.h:30
boost::shared_ptr< TraceBuffer< SandeshTrace > > SandeshTraceBufferPtr
Definition: sandesh_trace.h:18
SandeshTraceBufferPtr SandeshTraceBufferCreate(const std::string &buf_name, size_t buf_size, bool trace_enable=true)
Definition: sandesh_trace.h:46
static const std::string integerToString(const NumberType &num)
Definition: string_util.h:19
Definition: task_int.h:10
std::vector< TaskExclusion > TaskPolicy
Definition: task.h:59
#define CHECK_CONCURRENCY(...)
boost::uuids::uuid uuid