OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
vn.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 <boost/uuid/uuid_io.hpp>
7 #include <cmn/agent_cmn.h>
8 
9 #include <base/os.h>
10 #include <base/parse_object.h>
11 #include <base/util.h>
12 #include <base/address_util.h>
13 #include <ifmap/ifmap_link.h>
14 #include <ifmap/ifmap_table.h>
15 #include <vnc_cfg_types.h>
16 #include <agent_types.h>
17 
18 #include <cfg/cfg_init.h>
19 #include <cfg/cfg_mirror.h>
20 
21 #include <oper/route_common.h>
22 #include <oper/interface_common.h>
23 #include <oper/vn.h>
24 #include <oper/nexthop.h>
25 #include <oper/mpls.h>
26 #include <oper/mirror_table.h>
27 #include <oper/agent_sandesh.h>
28 #include <oper/oper_dhcp_options.h>
30 #include <oper/config_manager.h>
31 #include <oper/global_vrouter.h>
33 #include <oper/qos_config.h>
34 #include <filter/acl.h>
36 
37 using namespace autogen;
38 using namespace std;
39 using namespace boost;
40 using boost::assign::map_list_of;
41 using boost::assign::list_of;
42 
44 
46 // VnIpam routines
48 VnIpam::VnIpam(const std::string& ip, uint32_t len, const std::string& gw,
49  const std::string& dns, bool dhcp, const std::string &name,
50  const std::vector<autogen::DhcpOptionType> &dhcp_options,
51  const std::vector<autogen::RouteType> &host_routes,
52  uint32_t alloc)
53  : plen(len), installed(false), dhcp_enable(dhcp), dhcp_enable_v6(dhcp), ipam_name(name),
54  alloc_unit(alloc) {
55  boost::system::error_code ec;
56  ip_prefix = IpAddress::from_string(ip, ec);
57  default_gw = IpAddress::from_string(gw, ec);
58  dns_server = IpAddress::from_string(dns, ec);
59  oper_dhcp_options.set_options(dhcp_options);
61 }
62 
64  if (ip_prefix.is_v4()) {
66  }
67  if (ip_prefix.is_v6()) {
69  }
70  return IpAddress();
71 }
72 
73 bool VnIpam::IsSubnetMember(const IpAddress &ip) const {
74  if (ip_prefix.is_v4() && ip.is_v4()) {
75  return ((ip_prefix.to_v4().to_ulong() |
76  ~(0xFFFFFFFF << (32 - plen))) ==
77  (ip.to_v4().to_ulong() | ~(0xFFFFFFFF << (32 - plen))));
78  } else if (ip_prefix.is_v6() && ip.is_v6()) {
79  return IsIp6SubnetMember(ip.to_v6(), ip_prefix.to_v6(), plen);
80  }
81  return false;
82 }
83 
85 // VnEntry routines
88  AgentOperDBEntry(), agent_(agent), uuid_(id), vrf_(NULL, this),
89  vxlan_id_(0), vnid_(0), active_vxlan_id_(0), bridging_(true),
90  layer3_forwarding_(true), admin_state_(true), table_label_(0),
91  enable_rpf_(true), flood_unknown_unicast_(false),
92  forwarding_mode_(Agent::L2_L3), mirror_destination_(false),
93  underlay_forwarding_(false), vxlan_routing_vn_(false),
94  logical_router_uuid_(), cfg_igmp_enable_(false), vn_max_flows_(0),
95  lr_vrf_(NULL, this) {
96 }
97 
99 }
100 
101 bool VnEntry::IsLess(const DBEntry &rhs) const {
102  const VnEntry &a = static_cast<const VnEntry &>(rhs);
103  return (uuid_ < a.uuid_);
104 }
105 
106 string VnEntry::ToString() const {
107  std::stringstream uuidstring;
108  uuidstring << uuid_;
109  return uuidstring.str();
110 }
111 
113  return DBEntryBase::KeyPtr(new VnKey(uuid_));
114 }
115 
116 void VnEntry::SetKey(const DBRequestKey *key) {
117  const VnKey *k = static_cast<const VnKey *>(key);
118  uuid_ = k->uuid_;
119 }
120 
121 // Resync operation for VN. Invoked on change of forwarding-mode or global
122 // vxlan-config mode
123 bool VnEntry::Resync(Agent *agent) {
124  // Evaluate rebake of vxlan
125  bool ret = UpdateVxlan(agent, false);
126  // Evaluate forwarding mode change
127  ret |= UpdateForwardingMode(agent);
128  // Update routes from Ipam
129  ret |= ApplyAllIpam(agent, vrf_.get(), false);
130  return ret;
131 }
132 
133 bool VnEntry::ChangeHandler(Agent *agent, const DBRequest *req) {
134  bool ret = false;
135  VnData *data = static_cast<VnData *>(req->data.get());
136 
137  AclKey key(data->acl_id_);
138  AclDBEntry *acl = static_cast<AclDBEntry *>
139  (agent->acl_table()->FindActiveEntry(&key));
140  if (acl_.get() != acl) {
141  acl_ = acl;
142  ret = true;
143  }
144 
145  AclKey mirror_key(data->mirror_acl_id_);
146  AclDBEntry *mirror_acl = static_cast<AclDBEntry *>
147  (agent->acl_table()->FindActiveEntry(&mirror_key));
148  if (mirror_acl_.get() != mirror_acl) {
149  mirror_acl_ = mirror_acl;
150  ret = true;
151  }
152 
153  AclKey mirror_cfg_acl_key(data->mirror_cfg_acl_id_);
154  AclDBEntry *mirror_cfg_acl = static_cast<AclDBEntry *>
155  (agent->acl_table()->FindActiveEntry(&mirror_cfg_acl_key));
156  if (mirror_cfg_acl_.get() != mirror_cfg_acl) {
157  mirror_cfg_acl_ = mirror_cfg_acl;
158  ret = true;
159  }
160 
161  AgentQosConfigKey qos_config_key(data->qos_config_uuid_);
162  AgentQosConfig *qos_config = static_cast<AgentQosConfig *>
163  (agent->qos_config_table()->FindActiveEntry(&qos_config_key));
164  if (qos_config_.get() != qos_config) {
166  ret = true;
167  }
168 
169  VrfKey vrf_key(data->vrf_name_);
170  VrfEntry *vrf = static_cast<VrfEntry *>
171  (agent->vrf_table()->FindActiveEntry(&vrf_key));
172  VrfEntryRef old_vrf = vrf_;
173  bool rebake_vxlan = false;
174  if (vrf != old_vrf.get()) {
175  if (!vrf) {
176  ApplyAllIpam(agent, old_vrf.get(), true);
177  }
178  vrf_ = vrf;
179  rebake_vxlan = true;
180  ret = true;
181  }
182 
183  if (admin_state_ != data->admin_state_) {
184  admin_state_ = data->admin_state_;
185  ret = true;
186  }
187 
188  if (forwarding_mode_ != data->forwarding_mode_) {
190  ret = true;
191  }
192 
193  // Recompute the forwarding modes in VN
194  // Must rebake the routes if any change in forwarding modes
195  bool resync_routes = false;
196  resync_routes = UpdateForwardingMode(agent);
197  ret |= resync_routes;
198 
199  // Update the routes derived from IPAM
200  ret |= UpdateIpam(agent, data->ipam_);
201 
202  if (vn_ipam_data_ != data->vn_ipam_data_) {
204  ret = true;
205  }
206 
207  if (enable_rpf_ != data->enable_rpf_) {
208  enable_rpf_ = data->enable_rpf_;
209  ret = true;
210  }
211 
212  if (vxlan_id_ != data->vxlan_id_) {
213  vxlan_id_ = data->vxlan_id_;
214  ret = true;
216  rebake_vxlan = true;
217  }
218  }
219 
220  if (vnid_ != data->vnid_) {
221  vnid_ = data->vnid_;
222  ret = true;
224  rebake_vxlan = true;
225  }
226  }
227 
230  rebake_vxlan = true;
231  ret = true;
232  }
233 
236  rebake_vxlan = true;
237  ret = true;
238  }
239 
240  if (rebake_vxlan) {
241  ret |= UpdateVxlan(agent, false);
242  }
243 
244  if (resync_routes) {
245  if (vrf_.get() != NULL) {
246  AgentRouteResync *resync =
247  (static_cast<AgentRouteResync *>(route_resync_walker_.get()));
248  resync->UpdateRoutesInVrf(vrf_.get());
249  }
250  }
251 
252  if (pbb_evpn_enable_ != data->pbb_evpn_enable_) {
254  ret = true;
255  }
256 
257  if (pbb_etree_enable_ != data->pbb_etree_enable_) {
259  ret = true;
260  }
261 
264  ret = true;
265  }
266 
269  ret = true;
270  }
271 
272  if (slo_list_ != data->slo_list_) {
273  slo_list_ = data->slo_list_;
274  }
275 
276  if (vxlan_routing_vn_ != data->vxlan_routing_vn_) {
278  ret = true;
279  }
280 
283  ret = true;
284  }
285 
286  if (mp_list_ != data->mp_list_) {
287  mp_list_ = data->mp_list_;
288  }
289 
290  if (cfg_igmp_enable_ != data->cfg_igmp_enable_) {
292  }
293 
294  if (vn_max_flows_ != data->vn_max_flows_) {
296  ret = true;
297  }
298 
301  ret = true;
302  }
303 
304  if (health_check_uuid_ != data->health_check_uuid_) {
306  ret = true;
307  }
308 
309  return ret;
310 }
311 
312 // Rebake handles
313 // - vxlan-id change :
314 // Deletes the config-entry for old-vxlan and adds config-entry for new-vxlan
315 // Might result in change of vxlan_id_ref_ for the VN
316 //
317 // If vxlan_id is 0, or vrf is NULL, its treated as delete of config-entry
318 // - Delete
319 // Deletes the vxlan-config entry. Will reset the vxlan-id-ref to NULL
320 bool VnEntry::UpdateVxlan(Agent *agent, bool op_del) {
321  int old_vxlan = active_vxlan_id_;
322  int new_vxlan = GetVxLanId();
323 
324  if (op_del || old_vxlan != new_vxlan || vrf_.get() == NULL) {
325  if (old_vxlan != 0) {
326  agent->vxlan_table()->Delete(old_vxlan, uuid_);
327  vxlan_id_ref_ = NULL;
328  active_vxlan_id_ = 0;
329  }
330  }
331 
332  if (op_del == false && vrf_.get() != NULL && new_vxlan != 0) {
333  vxlan_id_ref_ = agent->vxlan_table()->Locate
334  (new_vxlan, uuid_, vrf_->GetName(), flood_unknown_unicast_,
335  mirror_destination_, false, true);
336  active_vxlan_id_ = new_vxlan;
337  }
338 
339  return (old_vxlan != new_vxlan);
340 }
341 
342 // Compute the layer3_forwarding_ and bridging mode for the VN.
343 // Forwarding mode is picked from VN if its defined. Else, picks forwarding
344 // mode from global-vrouter-config
347  if (forwarding_mode == Agent::NONE) {
348  forwarding_mode =
349  agent->oper_db()->global_vrouter()->forwarding_mode();
350  }
351 
352  bool ret = false;
353  bool routing = (forwarding_mode == Agent::L2) ? false : true;
354  if (routing != layer3_forwarding_) {
355  layer3_forwarding_ = routing;
356  ret = true;
357  }
358 
359  bool bridging = (forwarding_mode == Agent::L3) ? false : true;
360  if (bridging != bridging_) {
362  ret = true;
363  }
364 
365  return ret;
366 }
367 
368 // Update all IPAM configurations. Typically invoked when forwarding-mode
369 // changes or VRF is set for the VN
370 bool VnEntry::ApplyAllIpam(Agent *agent, VrfEntry *old_vrf, bool del) {
371  bool ret = false;
372  for (unsigned int i = 0; i < ipam_.size(); ++i) {
373  ret |= ApplyIpam(agent, &ipam_[i], old_vrf, del);
374  }
375 
376  return ret;
377 }
378 
379 // Add/Delete routes dervied from a single IPAM
380 bool VnEntry::ApplyIpam(Agent *agent, VnIpam *ipam, VrfEntry *old_vrf,
381  bool del) {
382  if (CanInstallIpam(ipam) == false)
383  del = true;
384 
385  bool old_installed = ipam->installed;
386  if (del == false) {
387  ipam->installed = AddIpamRoutes(agent, ipam);
388  } else {
389  DelIpamRoutes(agent, ipam, old_vrf);
390  ipam->installed = false;
391  }
392 
393  return old_installed != ipam->installed;
394 }
395 
396 bool VnEntry::CanInstallIpam(const VnIpam *ipam) {
397  if (vrf_.get() == NULL || layer3_forwarding_ == false)
398  return false;
399  return true;
400 }
401 
402 // Check the old and new Ipam data and update receive routes for GW addresses
403 bool VnEntry::UpdateIpam(Agent *agent, std::vector<VnIpam> &new_ipam) {
404  std::sort(new_ipam.begin(), new_ipam.end());
405 
406  std::vector<VnIpam>::iterator it_old = ipam_.begin();
407  std::vector<VnIpam>::iterator it_new = new_ipam.begin();
408  bool change = false;
409  while (it_old != ipam_.end() && it_new != new_ipam.end()) {
410  if (*it_old < *it_new) {
411  // old entry is deleted
412  ApplyIpam(agent, &(*it_old), vrf_.get(), true);
413  change = true;
414  it_old++;
415  } else if (*it_new < *it_old) {
416  // new entry
417  ApplyIpam(agent, &(*it_new), vrf_.get(), false);
418  change = true;
419  it_new++;
420  } else {
421  change |= HandleIpamChange(agent, &(*it_old), &(*it_new));
422  it_old++;
423  it_new++;
424  }
425  }
426 
427  // delete remaining old entries
428  for (; it_old != ipam_.end(); ++it_old) {
429  ApplyIpam(agent, &(*it_old), vrf_.get(), true);
430  change = true;
431  }
432 
433  // add remaining new entries
434  for (; it_new != new_ipam.end(); ++it_new) {
435  ApplyIpam(agent, &(*it_new), vrf_.get(), false);
436  change = true;
437  }
438 
439  ipam_ = new_ipam;
440  return change;
441 }
442 
443 static bool IsGwHostRouteRequired(const Agent *agent) {
444  return (!agent->tsn_enabled());
445 }
446 
447 // Evaluate non key members of IPAM for changes. Key fields are not changed
448 // Handles changes to gateway-ip and service-ip in the IPAM
449 bool VnEntry::HandleIpamChange(Agent *agent, VnIpam *old_ipam,
450  VnIpam *new_ipam) {
451  bool install = CanInstallIpam(new_ipam);
452 
453  if (install == false && old_ipam->installed == false)
454  return false;
455 
456  if (install == false && old_ipam->installed == true) {
457  ApplyIpam(agent, old_ipam, vrf_.get(), true);
458  return true;
459  }
460 
461  if (install == true && old_ipam->installed == false) {
462  ApplyIpam(agent, new_ipam, vrf_.get(), false);
463  return true;
464  }
465 
466  new_ipam->installed = install;
467  bool changed = false;
468  bool policy = (agent->tsn_enabled()) ? false : true;
469  // CEM-4646:don't delete route if is used by DNS/GW
470  // Update: GW changed?NO, DNS changed?YES
471  // action: check if old DNS address is same as GW address
472  // Update: GW changed?YES, DNS changed?NO
473  // action: check if old GW address is same as DNS address
474  // Update: GW changed?YES, DNS changed?YES
475  // action: check if new DNS server address is same as old GW address
476 
477  if (vrf_.get() && (vrf_->GetName() != agent->linklocal_vrf_name())) {
478  if (old_ipam->default_gw != new_ipam->default_gw) {
479  changed = true;
480  if (IsGwHostRouteRequired(agent)) {
481  if (old_ipam->default_gw != new_ipam->dns_server) {
482  UpdateHostRoute(agent, old_ipam->default_gw,
483  new_ipam->default_gw, policy);
484  } else {
485  AddHostRoute(new_ipam->default_gw, policy);
486  }
487  }
488  }
489  }
490 
491  if (old_ipam->dns_server != new_ipam->dns_server) {
492  if (old_ipam->dns_server != new_ipam->default_gw) {
493  UpdateHostRoute(agent, old_ipam->dns_server,
494  new_ipam->dns_server, policy);
495  } else {
496  AddHostRoute(new_ipam->dns_server, policy);
497  }
498  changed = true;
499  }
500 
501  // update DHCP options
502  old_ipam->oper_dhcp_options = new_ipam->oper_dhcp_options;
503 
504  if (old_ipam->dhcp_enable != new_ipam->dhcp_enable) {
505  changed = true;
506  }
507 
508  if (old_ipam->dhcp_enable_v6 != new_ipam->dhcp_enable_v6) {
509  changed = true;
510  }
511 
512  return changed;
513 }
514 
515 void VnEntry::UpdateHostRoute(Agent *agent, const IpAddress &old_address,
516  const IpAddress &new_address,
517  bool policy) {
518  AddHostRoute(new_address, policy);
519  DelHostRoute(old_address);
520 }
521 
522 // Add all routes derived from IPAM. IPAM generates following routes,
523 // - Subnet route
524 // - Gateway route
525 // - Service-IP route
526 bool VnEntry::AddIpamRoutes(Agent *agent, VnIpam *ipam) {
527  if (vrf_ == NULL)
528  return false;
529 
530  // Do not let the gateway configuration overwrite the receive nh.
531  if (vrf_->GetName() == agent->linklocal_vrf_name()) {
532  return false;
533  }
534 
535  // Allways policy will be enabled for default Gateway and
536  // Dns server to create flows for BGP as service even
537  // though explicit disable policy config form user.
538  bool policy = (agent->tsn_enabled()) ? false : true;
539  if (IsGwHostRouteRequired(agent))
540  AddHostRoute(ipam->default_gw, policy);
541  AddHostRoute(ipam->dns_server, policy);
542  AddSubnetRoute(ipam);
543  return true;
544 }
545 
546 // Delete routes generated from an IPAM
547 void VnEntry::DelIpamRoutes(Agent *agent, VnIpam *ipam, VrfEntry *vrf) {
548  if (ipam->installed == false)
549  return;
550 
551  assert(vrf);
552  if (IsGwHostRouteRequired(agent))
553  DelHostRoute(ipam->default_gw);
554  DelHostRoute(ipam->dns_server);
555  DelSubnetRoute(ipam);
556 }
557 
558 // Add host route for gateway-ip or service-ip
559 void VnEntry::AddHostRoute(const IpAddress &address, bool policy) {
560  if (address.is_v4()) {
561  static_cast<InetUnicastAgentRouteTable *>(vrf_->
562  GetInet4UnicastRouteTable())->AddHostRoute(vrf_->GetName(),
563  address.to_v4(), 32, GetName(), policy);
564  } else if (address.is_v6()) {
565  static_cast<InetUnicastAgentRouteTable *>(vrf_->
566  GetInet6UnicastRouteTable())->AddHostRoute(vrf_->GetName(),
567  address.to_v6(), 128, GetName(), policy);
568  }
569 }
570 
571 // Del host route for gateway-ip or service-ip
572 void VnEntry::DelHostRoute(const IpAddress &address) {
573  Agent *agent = static_cast<VnTable *>(get_table())->agent();
574  if (address.is_v4()) {
575  static_cast<InetUnicastAgentRouteTable *>
576  (vrf_->GetInet4UnicastRouteTable())->DeleteReq
577  (agent->local_peer(), vrf_->GetName(), address.to_v4(), 32, NULL);
578  } else if (address.is_v6()) {
579  static_cast<InetUnicastAgentRouteTable *>
580  (vrf_->GetInet6UnicastRouteTable())->DeleteReq
581  (agent->local_peer(), vrf_->GetName(), address.to_v6(), 128,
582  NULL);
583  }
584 }
585 
586 // Add subnet route for the IPAM
588  static_cast<InetUnicastAgentRouteTable *>(vrf_->
589  GetInetUnicastRouteTable(ipam->ip_prefix))->AddIpamSubnetRoute
590  (vrf_->GetName(), ipam->GetSubnetAddress(), ipam->plen,
591  GetName());
592 }
593 
594 // Del subnet route for the IPAM
596  Agent *agent = static_cast<VnTable *>(get_table())->agent();
597  static_cast<InetUnicastAgentRouteTable *>(vrf_->
598  GetInetUnicastRouteTable(ipam->ip_prefix))->DeleteReq
599  (agent->local_peer(), vrf_->GetName(),
600  ipam->GetSubnetAddress(), ipam->plen, NULL);
601 }
602 
604  assert(route_resync_walker_.get() == NULL);
605  route_resync_walker_ = new AgentRouteResync("VnRouteResyncWalker",
606  agent_);
608  RegisterWalker(static_cast<AgentRouteWalker *>
609  (route_resync_walker_.get()));
610 }
611 
613  if (route_resync_walker_.get() == NULL)
614  return;
617  route_resync_walker_.reset(NULL);
618 }
619 
620 bool VnEntry::GetVnHostRoutes(const std::string &ipam,
621  std::vector<OperDhcpOptions::HostRoute> *routes) const {
622  VnData::VnIpamDataMap::const_iterator it = vn_ipam_data_.find(ipam);
623  if (it != vn_ipam_data_.end()) {
624  *routes = it->second.oper_dhcp_options_.host_routes();
625  return true;
626  }
627  return false;
628 }
629 
630 bool VnEntry::GetIpamName(const IpAddress &vm_addr,
631  std::string *ipam_name) const {
632  for (unsigned int i = 0; i < ipam_.size(); i++) {
633  if (ipam_[i].IsSubnetMember(vm_addr)) {
634  *ipam_name = ipam_[i].ipam_name;
635  return true;
636  }
637  }
638  return false;
639 }
640 
641 bool VnEntry::GetIpamData(const IpAddress &vm_addr,
642  std::string *ipam_name,
643  autogen::IpamType *ipam) const {
644  if (!GetIpamName(vm_addr, ipam_name) ||
645  !agent_->domain_config_table()->GetIpam(*ipam_name, ipam))
646  return false;
647 
648  return true;
649 }
650 
651 const VnIpam *VnEntry::GetIpam(const IpAddress &ip) const {
652  for (unsigned int i = 0; i < ipam_.size(); i++) {
653  if (ipam_[i].IsSubnetMember(ip)) {
654  return &ipam_[i];
655  }
656  }
657  return NULL;
658 }
659 
661  const VnIpam *ipam = GetIpam(ip);
662  if (ipam) {
663  return ipam->default_gw;
664  }
665  return IpAddress();
666 }
667 
669  const VnIpam *ipam = GetIpam(ip);
670  if (ipam) {
671  return ipam->dns_server;
672  }
673  return IpAddress();
674 }
675 
676 uint32_t VnEntry::GetAllocUnitFromIpam(const IpAddress &ip) const {
677  const VnIpam *ipam = GetIpam(ip);
678  if (ipam) {
679  return ipam->alloc_unit;
680  }
681  return 1;//Default value
682 }
683 
685  autogen::IpamType *ipam_type,
686  autogen::VirtualDnsType *vdns_type) const {
687  std::string ipam_name;
688  if (!GetIpamName(vm_addr, &ipam_name) ||
689  !agent_->domain_config_table()->GetIpam(ipam_name, ipam_type) ||
690  ipam_type->ipam_dns_method != "virtual-dns-server")
691  return false;
692 
694  ipam_type->ipam_dns_server.virtual_dns_server_name, vdns_type))
695  return false;
696 
697  return true;
698 }
699 
700 bool VnEntry::GetPrefix(const Ip6Address &ip, Ip6Address *prefix,
701  uint8_t *plen) const {
702  for (uint32_t i = 0; i < ipam_.size(); ++i) {
703  if (!ipam_[i].IsV6()) {
704  continue;
705  }
706  if (IsIp6SubnetMember(ip, ipam_[i].ip_prefix.to_v6(),
707  ipam_[i].plen)) {
708  *prefix = ipam_[i].ip_prefix.to_v6();
709  *plen = (uint8_t)ipam_[i].plen;
710  return true;
711  }
712  }
713  return false;
714 }
715 
716 std::string VnEntry::GetProject() const {
717  // TODO: update to get the project name from project-vn link.
718  // Currently, this info doesnt come to the agent
719  std::string name(name_.c_str());
720  char *saveptr;
721  if (strtok_r(const_cast<char *>(name.c_str()), ":", &saveptr) == NULL)
722  return "";
723  char *project = strtok_r(NULL, ":", &saveptr);
724  return (project == NULL) ? "" : std::string(project);
725 }
726 
727 int VnEntry::GetVxLanId() const {
729  return vxlan_id_;
730  }
731  if (vxlan_routing_vn_ && vxlan_id_) {
732  return vxlan_id_;
733  }
734  return vnid_;
735 }
736 
738 // VnTable routines
740 VnTable::VnTable(DB *db, const std::string &name) : AgentOperDBTable(db, name) {
741  walk_ref_ = AllocWalker(boost::bind(&VnTable::VnEntryWalk, this, _1, _2),
742  boost::bind(&VnTable::VnEntryWalkDone, this, _1,
743  _2));
744 }
745 
747 }
748 
751 }
752 
753 DBTableBase *VnTable::CreateTable(DB *db, const std::string &name) {
754  vn_table_ = new VnTable(db, name);
755  vn_table_->Init();
756  return vn_table_;
757 };
758 
760  VnKey key(u);
761  return static_cast<VnEntry *>(FindActiveEntry(&key));
762 }
763 
764 std::unique_ptr<DBEntry> VnTable::AllocEntry(const DBRequestKey *k) const {
765  const VnKey *key = static_cast<const VnKey *>(k);
766  VnEntry *vn = new VnEntry(agent(), key->uuid_);
767  return std::unique_ptr<DBEntry>(static_cast<DBEntry *>(vn));
768 }
769 
771  VnKey *key = static_cast<VnKey *>(req->key.get());
772  VnData *data = static_cast<VnData *>(req->data.get());
773  VnEntry *vn = new VnEntry(agent(), key->uuid_);
774  vn->name_ = data->name_;
775  vn->AllocWalker();
776 
777  vn->ChangeHandler(agent(), req);
778  vn->SendObjectLog(AgentLogEvent::ADD);
779 
780  if (vn->name_ == agent()->fabric_vn_name()) {
781  //In case of distributes SNAT we want all
782  //interfaces to revaluated upon receiving
783  //the config
784  agent()->set_fabric_vn_uuid(key->uuid_);
786  }
787  return vn;
788 }
789 
790 bool VnTable::OperDBDelete(DBEntry *entry, const DBRequest *req) {
791  VnEntry *vn = static_cast<VnEntry *>(entry);
792  vn->ApplyAllIpam(agent(), vn->vrf_.get(), true);
793  vn->UpdateVxlan(agent(), true);
794  vn->ReleaseWalker();
795  vn->SendObjectLog(AgentLogEvent::DEL);
796 
797  if (vn->name_ == agent()->fabric_vn_name()) {
798  agent()->set_fabric_vn_uuid(boost::uuids::nil_uuid());
800  }
801  return true;
802 }
803 
804 bool VnTable::OperDBOnChange(DBEntry *entry, const DBRequest *req) {
805  VnEntry *vn = static_cast<VnEntry *>(entry);
806  bool ret = vn->ChangeHandler(agent(), req);
807  vn->SendObjectLog(AgentLogEvent::CHANGE);
808  if (ret) {
809  VnData *data = static_cast<VnData *>(req->data.get());
810  if (data && data->ifmap_node()) {
812  (data->ifmap_node());
813  }
814  }
815  return ret;
816 }
817 
818 bool VnTable::OperDBResync(DBEntry *entry, const DBRequest *req) {
819  VnEntry *vn = static_cast<VnEntry *>(entry);
820  return vn->Resync(agent());
821 }
822 
824  VnEntry *vn_entry = static_cast<VnEntry *>(entry);
825  if (vn_entry->GetVrf()) {
826  ResyncReq(vn_entry->GetUuid());
827  }
828  return true;
829 }
830 
832  DBTableBase *partition) {
835  UpdateVxLanNetworkIdentifierMode();
836 }
837 
840 }
841 
842 /*
843  * IsVRFServiceChainingInstance
844  * Helper function to identify the service chain vrf.
845  * In VN-VRF mapping config can send multiple VRF for same VN.
846  * Since assumption had been made that VN to VRF is always 1:1 this
847  * situation needs to be handled.
848  * This is a temporary solution in which all VRF other than primary VRF
849  * is ignored.
850  * Example:
851  * VN name: domain:vn1
852  * VRF 1: domain:vn1:vn1 ----> Primary
853  * VRF 2: domain:vn1:service-vn1_vn2 ----> Second vrf linked to vn1
854  * Break the VN and VRF name into tokens based on ':'
855  * So in primary vrf last and second-last token will be same and will be
856  * equal to last token of VN name. Keep this VRF.
857  * The second VRF last and second-last token are not same so it will be ignored.
858  *
859  */
860 bool IsVRFServiceChainingInstance(const string &vn_name, const string &vrf_name)
861 {
862  vector<string> vn_token_result;
863  vector<string> vrf_token_result;
864  uint32_t vrf_token_result_size = 0;
865 
866  split(vn_token_result, vn_name, is_any_of(":"), token_compress_on);
867  split(vrf_token_result, vrf_name, is_any_of(":"), token_compress_on);
868  vrf_token_result_size = vrf_token_result.size();
869 
870  /*
871  * This check is to handle test cases where vrf and vn name
872  * are single word without discriminator ':'
873  * e.g. vrf1 or vn1. In these cases we dont ignore and use
874  * the VRF
875  */
876  if (vrf_token_result_size == 1) {
877  return false;
878  }
879  if ((vrf_token_result.at(vrf_token_result_size - 1) ==
880  vrf_token_result.at(vrf_token_result_size - 2)) &&
881  (vn_token_result.at(vn_token_result.size() - 1) ==
882  vrf_token_result.at(vrf_token_result_size - 1))) {
883  return false;
884  }
885  return true;
886 }
887 
889  std::string node_type) {
890  for (DBGraphVertex::adjacency_iterator it = node->begin(table->GetGraph());
891  it != node->end(table->GetGraph()); ++it) {
892  IFMapNode *adj_node = static_cast<IFMapNode *>(it.operator->());
893  if (adj_node->table()->Typename() == node_type)
894  return adj_node;
895  }
896  return NULL;
897 }
898 
899 int VnTable::GetCfgVnId(VirtualNetwork *cfg_vn) {
900  if (cfg_vn->IsPropertySet(autogen::VirtualNetwork::NETWORK_ID))
901  return cfg_vn->network_id();
902  else
903  return cfg_vn->properties().network_id;
904 }
905 
907  bool *rpf, bool *flood_unknown_unicast,
908  Agent::ForwardingMode *forwarding_mode,
909  bool *mirror_destination) {
910  *rpf = true;
911 
912  VirtualNetwork *cfg = static_cast <VirtualNetwork *> (node->GetObject());
913  autogen::VirtualNetworkType properties = cfg->properties();
914 
915  if (properties.rpf == "disable") {
916  *rpf = false;
917  }
918 
919  *flood_unknown_unicast = cfg->flood_unknown_unicast();
920  *mirror_destination = properties.mirror_destination;
921  *forwarding_mode =
922  agent()->TranslateForwardingMode(properties.forwarding_mode);
923  }
924 
925 void
926 VnTable::BuildVnIpamData(const std::vector<autogen::IpamSubnetType> &subnets,
927  const std::string &ipam_name,
928  std::vector<VnIpam> *vn_ipam) {
929  for (unsigned int i = 0; i < subnets.size(); ++i) {
930  // if the DNS server address is not specified, set this
931  // to be the same as the GW address
932  std::string dns_server_address = subnets[i].dns_server_address;
933  boost::system::error_code ec;
934  IpAddress dns_server =
935  IpAddress::from_string(dns_server_address, ec);
936  if (ec.value() || dns_server.is_unspecified()) {
937  dns_server_address = subnets[i].default_gateway;
938  }
939 
940  vn_ipam->push_back
941  (VnIpam(subnets[i].subnet.ip_prefix,
942  subnets[i].subnet.ip_prefix_len,
943  subnets[i].default_gateway,
944  dns_server_address,
945  subnets[i].enable_dhcp, ipam_name,
946  subnets[i].dhcp_option_list.dhcp_option,
947  subnets[i].host_routes.route,
948  subnets[i].alloc_unit));
949  }
950 }
951 
953  using boost::uuids::uuid;
954  using boost::uuids::nil_uuid;
955  boost::uuids::uuid mp_uuid = nil_uuid();
956  UuidList mp_list;
957 
958  VirtualNetwork *cfg = static_cast <VirtualNetwork *> (node->GetObject());
959  assert(cfg);
960 
961  uuid acl_uuid = nil_uuid();
962  uuid mirror_cfg_acl_uuid = nil_uuid();
963  uuid qos_config_uuid = nil_uuid();
964  string vrf_name = "";
965  std::vector<VnIpam> vn_ipam;
966  VnData::VnIpamDataMap vn_ipam_data;
967  std::string ipam_name;
968  UuidList slo_list;
969  bool underlay_forwarding = false;
970  bool vxlan_routing_vn = false;
971  uuid logical_router_uuid = nil_uuid();
972  uuid health_check_uuid = nil_uuid();
973 
974  // Find link with ACL / VRF adjacency
975  IFMapAgentTable *table = static_cast<IFMapAgentTable *>(node->table());
976  DBGraph *graph = table->GetGraph();
977  for (DBGraphVertex::adjacency_iterator iter = node->begin(graph);
978  iter != node->end(table->GetGraph()); ++iter) {
979 
980  IFMapNode *adj_node = static_cast<IFMapNode *>(iter.operator->());
981  if (agent()->config_manager()->SkipNode(adj_node)) {
982  continue;
983  }
984 
985  if (adj_node->table() == agent()->cfg()->cfg_acl_table()) {
986  AccessControlList *acl_cfg = static_cast<AccessControlList *>
987  (adj_node->GetObject());
988  assert(acl_cfg);
989  autogen::IdPermsType id_perms = acl_cfg->id_perms();
990  if (acl_cfg->entries().dynamic) {
991  CfgUuidSet(id_perms.uuid.uuid_mslong, id_perms.uuid.uuid_lslong,
992  mirror_cfg_acl_uuid);
993  } else {
994  CfgUuidSet(id_perms.uuid.uuid_mslong, id_perms.uuid.uuid_lslong,
995  acl_uuid);
996  }
997  }
998 
999  if ((adj_node->table() == agent()->cfg()->cfg_vrf_table()) &&
1000  (!IsVRFServiceChainingInstance(node->name(), adj_node->name()))) {
1001  vrf_name = adj_node->name();
1002  }
1003 
1004  if (adj_node->table() == agent()->cfg()->cfg_qos_table()) {
1005  autogen::QosConfig *qc =
1006  static_cast<autogen::QosConfig *>(adj_node->GetObject());
1007  autogen::IdPermsType id_perms = qc->id_perms();
1008  CfgUuidSet(id_perms.uuid.uuid_mslong, id_perms.uuid.uuid_lslong,
1009  qos_config_uuid);
1010  }
1011 
1012  if (adj_node->table() == agent()->cfg()->cfg_slo_table()) {
1013  uuid slo_uuid = nil_uuid();
1014  autogen::SecurityLoggingObject *slo =
1015  static_cast<autogen::SecurityLoggingObject *>(adj_node->
1016  GetObject());
1017  autogen::IdPermsType id_perms = slo->id_perms();
1018  CfgUuidSet(id_perms.uuid.uuid_mslong, id_perms.uuid.uuid_lslong,
1019  slo_uuid);
1020  slo_list.push_back(slo_uuid);
1021  }
1022 
1023  if (adj_node->table() == agent()->cfg()->cfg_vn_network_ipam_table()) {
1024  if (IFMapNode *ipam_node = FindTarget(table, adj_node,
1025  "network-ipam")) {
1026  ipam_name = ipam_node->name();
1027  VirtualNetworkNetworkIpam *vnni =
1028  static_cast<VirtualNetworkNetworkIpam *>
1029  (adj_node->GetObject());
1030  VnSubnetsType subnets;
1031  if (vnni)
1032  subnets = vnni->data();
1033 
1034  autogen::NetworkIpam *network_ipam =
1035  static_cast<autogen::NetworkIpam *>(ipam_node->GetObject());
1036  const std::string subnet_method =
1037  boost::to_lower_copy(network_ipam->ipam_subnet_method());
1038 
1039  if (subnet_method == "flat-subnet") {
1040  BuildVnIpamData(network_ipam->ipam_subnets(),
1041  ipam_name, &vn_ipam);
1042  } else {
1043  BuildVnIpamData(subnets.ipam_subnets, ipam_name, &vn_ipam);
1044  }
1045 
1046  VnIpamLinkData ipam_data;
1047  ipam_data.oper_dhcp_options_.set_host_routes(subnets.host_routes.route);
1048  vn_ipam_data.insert(VnData::VnIpamDataPair(ipam_name, ipam_data));
1049  }
1050  }
1051 
1052  if (adj_node->table() == agent()->cfg()->cfg_vn_table()) {
1053  if (agent()->fabric_vn_name() == adj_node->name()) {
1054  underlay_forwarding = true;
1055  }
1056  }
1057 
1058  if (strcmp(adj_node->table()->Typename(),
1059  "logical-router-virtual-network") == 0) {
1060  autogen::LogicalRouterVirtualNetwork *lr_vn_node =
1061  dynamic_cast<autogen::LogicalRouterVirtualNetwork *>
1062  (adj_node->GetObject());
1063  autogen::LogicalRouter *lr = NULL;
1064  IFMapNode *lr_adj_node =
1066  "logical-router");
1067  if (lr_adj_node) {
1068  lr = dynamic_cast<autogen::LogicalRouter *>(lr_adj_node->
1069  GetObject());
1070  }
1071 
1072  if (lr_vn_node && lr) {
1073  autogen::IdPermsType id_perms = lr->id_perms();
1074  CfgUuidSet(id_perms.uuid.uuid_mslong,
1075  id_perms.uuid.uuid_lslong,
1076  logical_router_uuid);
1077  autogen::LogicalRouterVirtualNetworkType data =
1078  lr_vn_node->data();
1079  if (data.logical_router_virtual_network_type ==
1080  "InternalVirtualNetwork")
1081  {
1082  vxlan_routing_vn = true;
1083  }
1084  }
1085  }
1086 
1087  if (adj_node->table() ==
1089  MulticastPolicy *mcast_group = static_cast<MulticastPolicy *>
1090  (adj_node->GetObject());
1091  assert(mcast_group);
1092  autogen::IdPermsType id_perms = mcast_group->id_perms();
1093  CfgUuidSet(id_perms.uuid.uuid_mslong, id_perms.uuid.uuid_lslong,
1094  mp_uuid);
1095  mp_list.push_back(mp_uuid);
1096  }
1097 
1098  if (adj_node->table() ==
1099  agent()->cfg()->cfg_health_check_table()) {
1100  autogen::ServiceHealthCheck *hc =
1101  static_cast<autogen::ServiceHealthCheck *> (adj_node->GetObject());
1102  assert(hc);
1103  if (hc->properties().health_check_type.find("vn-ip-list") == std::string::npos)
1104  continue;
1105  autogen::IdPermsType id_perms = hc->id_perms();
1106  CfgUuidSet(id_perms.uuid.uuid_mslong, id_perms.uuid.uuid_lslong,
1107  health_check_uuid);
1108  }
1109  }
1110 
1111  uuid mirror_acl_uuid = agent()->mirror_cfg_table()->GetMirrorUuid(node->name());
1112  std::sort(vn_ipam.begin(), vn_ipam.end());
1113 
1114  // Fetch VN forwarding Properties
1115  bool enable_rpf;
1116  bool flood_unknown_unicast;
1117  bool mirror_destination;
1118  bool pbb_evpn_enable = cfg->pbb_evpn_enable();
1119  bool pbb_etree_enable = cfg->pbb_etree_enable();
1120  bool layer2_control_word = cfg->layer2_control_word();
1121  bool cfg_igmp_enable = cfg->igmp_enable();
1122  uint32_t vn_max_flows = cfg->properties().max_flows;
1123  bool mac_ip_learning_enable = cfg->mac_ip_learning_enable();
1124  Agent::ForwardingMode forwarding_mode;
1125  CfgForwardingFlags(node, &enable_rpf, &flood_unknown_unicast,
1126  &forwarding_mode, &mirror_destination);
1127  return new VnData(agent(), node, node->name(), acl_uuid, vrf_name,
1128  mirror_acl_uuid, mirror_cfg_acl_uuid, vn_ipam,
1129  vn_ipam_data, cfg->properties().vxlan_network_identifier,
1130  GetCfgVnId(cfg), cfg->id_perms().enable, enable_rpf,
1131  flood_unknown_unicast, forwarding_mode,
1132  qos_config_uuid, mirror_destination, pbb_etree_enable,
1133  pbb_evpn_enable, layer2_control_word, slo_list,
1134  underlay_forwarding, vxlan_routing_vn,
1135  logical_router_uuid, mp_list, cfg_igmp_enable,
1136  vn_max_flows, mac_ip_learning_enable,
1137  health_check_uuid);
1138 }
1139 
1141  VirtualNetwork *cfg = static_cast <VirtualNetwork *> (node->GetObject());
1142  assert(cfg);
1143  autogen::IdPermsType id_perms = cfg->id_perms();
1144  CfgUuidSet(id_perms.uuid.uuid_mslong, id_perms.uuid.uuid_lslong, u);
1145  return true;
1146 }
1147 
1149  const boost::uuids::uuid &u) {
1150 
1151  assert(!u.is_nil());
1152 
1153  if ((req.oper == DBRequest::DB_ENTRY_DELETE) || node->IsDeleted()) {
1154  req.key.reset(new VnKey(u));
1156  Enqueue(&req);
1157  return false;
1158  }
1159 
1160  agent()->config_manager()->AddVnNode(node);
1161  return false;
1162 }
1163 
1165  const boost::uuids::uuid &u) {
1166 
1167  if (node->IsDeleted()) {
1168  return false;
1169  }
1170 
1172  req.key.reset(new VnKey(u));
1173  req.data.reset(BuildData(node));
1174  Enqueue(&req);
1175  return false;
1176 }
1177 
1178 void VnTable::AddVn(const boost::uuids::uuid &vn_uuid, const string &name,
1179  const boost::uuids::uuid &acl_id, const string &vrf_name,
1180  const std::vector<VnIpam> &ipam,
1181  const VnData::VnIpamDataMap &vn_ipam_data, int vn_id,
1182  int vxlan_id, bool admin_state, bool enable_rpf,
1183  bool flood_unknown_unicast, bool pbb_etree_enable,
1184  bool pbb_evpn_enable, bool layer2_control_word) {
1185  using boost::uuids::nil_uuid;
1186 
1188  UuidList empty_list;
1189  req.key.reset(new VnKey(vn_uuid));
1190  bool mirror_destination = false;
1191  VnData *data = new VnData(agent(), NULL, name, acl_id, vrf_name, nil_uuid(),
1192  nil_uuid(), ipam, vn_ipam_data,
1193  vxlan_id, vn_id, admin_state, enable_rpf,
1194  flood_unknown_unicast, Agent::NONE, nil_uuid(),
1195  mirror_destination, pbb_etree_enable,
1196  pbb_evpn_enable, layer2_control_word, empty_list,
1197  false, false, nil_uuid(), empty_list, false, 0,
1198  false, nil_uuid());
1199 
1200  req.data.reset(data);
1201  Enqueue(&req);
1202 }
1203 
1204 void VnTable::DelVn(const boost::uuids::uuid &vn_uuid) {
1206  req.key.reset(new VnKey(vn_uuid));
1207  req.data.reset(NULL);
1208  Enqueue(&req);
1209 }
1210 
1213  VnKey *key = new VnKey(vn);
1214  key->sub_op_ = AgentKey::RESYNC;
1215  req.key.reset(key);
1216  req.data.reset(NULL);
1217  Enqueue(&req);
1218 }
1219 
1221 // Introspect routines
1223 bool VnEntry::DBEntrySandesh(Sandesh *sresp, std::string &name) const {
1224  VnListResp *resp = static_cast<VnListResp *>(sresp);
1225 
1226  VnSandeshData data;
1227  data.set_name(GetName());
1228  data.set_uuid(UuidToString(GetUuid()));
1229  data.set_vxlan_id(GetVxLanId());
1230  data.set_config_vxlan_id(vxlan_id_);
1231  data.set_vn_id(vnid_);
1232  if (GetAcl()) {
1233  data.set_acl_uuid(UuidToString(GetAcl()->GetUuid()));
1234  } else {
1235  data.set_acl_uuid("");
1236  }
1237 
1238  if (GetVrf()) {
1239  data.set_vrf_name(GetVrf()->GetName());
1240  } else {
1241  data.set_vrf_name("");
1242  }
1243 
1244  if (GetMirrorAcl()) {
1245  data.set_mirror_acl_uuid(UuidToString(GetMirrorAcl()->GetUuid()));
1246  } else {
1247  data.set_mirror_acl_uuid("");
1248  }
1249 
1250  if (GetMirrorCfgAcl()) {
1251  data.set_mirror_cfg_acl_uuid(UuidToString(GetMirrorCfgAcl()->GetUuid()));
1252  } else {
1253  data.set_mirror_cfg_acl_uuid("");
1254  }
1255 
1256  std::vector<VnIpamData> vn_subnet_sandesh_list;
1257  const std::vector<VnIpam> &vn_ipam = GetVnIpam();
1258  for (unsigned int i = 0; i < vn_ipam.size(); ++i) {
1259  VnIpamData entry;
1260  entry.set_ip_prefix(vn_ipam[i].ip_prefix.to_string());
1261  entry.set_prefix_len(vn_ipam[i].plen);
1262  entry.set_gateway(vn_ipam[i].default_gw.to_string());
1263  entry.set_ipam_name(vn_ipam[i].ipam_name);
1264  entry.set_dhcp_enable(vn_ipam[i].dhcp_enable ? "true" : "false");
1265  entry.set_dhcp_enable_v6(vn_ipam[i].dhcp_enable_v6 ? "true" : "false");
1266  entry.set_dns_server(vn_ipam[i].dns_server.to_string());
1267  vn_subnet_sandesh_list.push_back(entry);
1268  }
1269  data.set_ipam_data(vn_subnet_sandesh_list);
1270 
1271  std::vector<VnIpamHostRoutes> vn_ipam_host_routes_list;
1272  for (VnData::VnIpamDataMap::const_iterator it = vn_ipam_data_.begin();
1273  it != vn_ipam_data_.end(); ++it) {
1274  VnIpamHostRoutes vn_ipam_host_routes;
1275  vn_ipam_host_routes.ipam_name = it->first;
1276  const std::vector<OperDhcpOptions::HostRoute> &host_routes =
1277  it->second.oper_dhcp_options_.host_routes();
1278  for (uint32_t i = 0; i < host_routes.size(); ++i) {
1279  vn_ipam_host_routes.host_routes.push_back(
1280  host_routes[i].ToString());
1281  }
1282  vn_ipam_host_routes_list.push_back(vn_ipam_host_routes);
1283  }
1284  data.set_ipam_host_routes(vn_ipam_host_routes_list);
1285  data.set_ipv4_forwarding(layer3_forwarding());
1286  data.set_layer2_forwarding(bridging());
1287  data.set_bridging(bridging());
1288  data.set_admin_state(admin_state());
1289  data.set_enable_rpf(enable_rpf());
1290  data.set_flood_unknown_unicast(flood_unknown_unicast());
1291  data.set_pbb_etree_enabled(pbb_etree_enable());
1292  data.set_layer2_control_word(layer2_control_word());
1293  std::vector<SecurityLoggingObjectLink> slo_list;
1294  UuidList::const_iterator sit = slo_list_.begin();
1295  while (sit != slo_list_.end()) {
1296  SecurityLoggingObjectLink slo_entry;
1297  slo_entry.set_slo_uuid(to_string(*sit));
1298  slo_list.push_back(slo_entry);
1299  ++sit;
1300  }
1301  data.set_slo_list(slo_list);
1302  std::vector<VnSandeshData> &list =
1303  const_cast<std::vector<VnSandeshData>&>(resp->get_vn_list());
1304  std::vector<MulticastPolicyLink> mp_list;
1305  UuidList::const_iterator mpit = mp_list_.begin();
1306  while (mpit != mp_list_.end()) {
1307  MulticastPolicyLink mp_entry;
1308  mp_entry.set_mp_uuid(to_string(*mpit));
1309  mp_list.push_back(mp_entry);
1310  ++mpit;
1311  }
1312  data.set_mp_list(mp_list);
1313  data.set_cfg_igmp_enable(cfg_igmp_enable());
1314  data.set_max_flows(vn_max_flows());
1315  data.set_mac_ip_learning_enable(mac_ip_learning_enable());
1316  data.set_health_check_uuid(to_string(health_check_uuid()));
1317 
1318  list.push_back(data);
1319  return true;
1320 }
1321 
1323  VnObjectLogInfo info;
1324  string str;
1325  string vn_uuid = UuidToString(GetUuid());
1326  const AclDBEntry *acl = GetAcl();
1327  const AclDBEntry *mirror_acl = GetMirrorAcl();
1328  const AclDBEntry *mirror_cfg_acl = GetMirrorCfgAcl();
1329  string acl_uuid;
1330  string mirror_acl_uuid;
1331  string mirror_cfg_acl_uuid;
1332 
1333  info.set_uuid(vn_uuid);
1334  info.set_name(GetName());
1335  switch (event) {
1336  case AgentLogEvent::ADD:
1337  str.assign("Addition ");
1338  break;
1339  case AgentLogEvent::DEL:
1340  str.assign("Deletion ");
1341  info.set_event(str);
1342  VN_OBJECT_LOG_LOG("AgentVn", SandeshLevel::SYS_INFO, info);
1343  return;
1344  case AgentLogEvent::CHANGE:
1345  str.assign("Modification ");
1346  break;
1347  default:
1348  str.assign("");
1349  break;
1350  }
1351 
1352  info.set_event(str);
1353  if (acl) {
1354  acl_uuid.assign(UuidToString(acl->GetUuid()));
1355  info.set_acl_uuid(acl_uuid);
1356  }
1357  if (mirror_acl) {
1358  mirror_acl_uuid.assign(UuidToString(mirror_acl->GetUuid()));
1359  info.set_mirror_acl_uuid(mirror_acl_uuid);
1360  }
1361  if (mirror_cfg_acl) {
1362  mirror_cfg_acl_uuid.assign(UuidToString(mirror_cfg_acl->GetUuid()));
1363  info.set_mirror_cfg_acl_uuid(mirror_cfg_acl_uuid);
1364  }
1365  VrfEntry *vrf = GetVrf();
1366  if (vrf) {
1367  info.set_vrf(vrf->GetName());
1368  }
1369  vector<VnObjectLogIpam> ipam_list;
1370  VnObjectLogIpam sandesh_ipam;
1371  vector<VnIpam>::const_iterator it = ipam_.begin();
1372  while (it != ipam_.end()) {
1373  VnIpam ipam = *it;
1374  sandesh_ipam.set_ip_prefix(ipam.ip_prefix.to_string());
1375  sandesh_ipam.set_prefix_len(ipam.plen);
1376  sandesh_ipam.set_gateway_ip(ipam.default_gw.to_string());
1377  sandesh_ipam.set_ipam_name(ipam.ipam_name);
1378  sandesh_ipam.set_dhcp_enable(ipam.dhcp_enable ? "true" : "false");
1379  sandesh_ipam.set_dhcp_enable_v6(ipam.dhcp_enable_v6 ? "true" : "false");
1380  sandesh_ipam.set_dns_server(ipam.dns_server.to_string());
1381  ipam_list.push_back(sandesh_ipam);
1382  ++it;
1383  }
1384 
1385  if (ipam_list.size()) {
1386  info.set_ipam_list(ipam_list);
1387  }
1388  info.set_bridging(bridging());
1389  info.set_ipv4_forwarding(layer3_forwarding());
1390  info.set_admin_state(admin_state());
1391  VN_OBJECT_LOG_LOG("AgentVn", SandeshLevel::SYS_INFO, info);
1392 }
1393 
1394 void VnListReq::HandleRequest() const {
1395  AgentSandeshPtr sand(new AgentVnSandesh(context(), get_name(), get_uuid(),
1396  get_vxlan_id(), get_ipam_name()));
1397  sand->DoSandesh(sand);
1398 }
1399 
1401  const std::string &context) {
1402  return AgentSandeshPtr
1403  (new AgentVnSandesh(context, args->GetString("name"),
1404  args->GetString("uuid"),
1405  args->GetString("vxlan_id"),
1406  args->GetString("ipam_name")));
1407 }
1408 
1410 // DomainConfig routines
1413 }
1414 
1416 }
1417 
1419 }
1420 
1422 }
1423 
1425  ipam_callback_.push_back(cb);
1426 }
1427 
1429  vdns_callback_.push_back(cb);
1430 }
1431 
1432 // Callback is invoked only if there is change in IPAM properties.
1433 // In case of change in a link with IPAM, callback is not invoked.
1435  CallIpamCb(node);
1436  ipam_config_.erase(node->name());
1437  return;
1438 }
1439 
1441  autogen::NetworkIpam *network_ipam =
1442  static_cast <autogen::NetworkIpam *> (node->GetObject());
1443  assert(network_ipam);
1444 
1445  bool change = false;
1446  IpamDomainConfigMap::iterator it = ipam_config_.find(node->name());
1447  if (it != ipam_config_.end()) {
1448  if (IpamChanged(it->second, network_ipam->mgmt())) {
1449  it->second = network_ipam->mgmt();
1450  change = true;
1451  }
1452  } else {
1453  ipam_config_.insert(IpamDomainConfigPair(node->name(),
1454  network_ipam->mgmt()));
1455  change = true;
1456  }
1457  if (change)
1458  CallIpamCb(node);
1459 }
1460 
1462  CallVdnsCb(node);
1463  vdns_config_.erase(node->name());
1464  return;
1465 }
1466 
1468  autogen::VirtualDns *virtual_dns =
1469  static_cast <autogen::VirtualDns *> (node->GetObject());
1470  assert(virtual_dns);
1471 
1472  VdnsDomainConfigMap::iterator it = vdns_config_.find(node->name());
1473  if (it != vdns_config_.end()) {
1474  it->second = virtual_dns->data();
1475  } else {
1476  vdns_config_.insert(VdnsDomainConfigPair(node->name(),
1477  virtual_dns->data()));
1478  }
1479  CallVdnsCb(node);
1480 }
1481 
1483  for (unsigned int i = 0; i < ipam_callback_.size(); ++i) {
1484  ipam_callback_[i](node);
1485  }
1486 }
1487 
1489  for (unsigned int i = 0; i < vdns_callback_.size(); ++i) {
1490  vdns_callback_[i](node);
1491  }
1492 }
1493 
1494 bool DomainConfig::IpamChanged(const autogen::IpamType &old,
1495  const autogen::IpamType &cur) const {
1496  if (old.ipam_method != cur.ipam_method ||
1497  old.ipam_dns_method != cur.ipam_dns_method)
1498  return true;
1499 
1500  if ((old.ipam_dns_server.virtual_dns_server_name !=
1501  cur.ipam_dns_server.virtual_dns_server_name) ||
1502  (old.ipam_dns_server.tenant_dns_server_address.ip_address !=
1503  cur.ipam_dns_server.tenant_dns_server_address.ip_address))
1504  return true;
1505 
1506  if (old.cidr_block.ip_prefix != cur.cidr_block.ip_prefix ||
1507  old.cidr_block.ip_prefix_len != cur.cidr_block.ip_prefix_len)
1508  return true;
1509 
1510  if (old.dhcp_option_list.dhcp_option.size() !=
1511  cur.dhcp_option_list.dhcp_option.size())
1512  return true;
1513 
1514  for (uint32_t i = 0; i < old.dhcp_option_list.dhcp_option.size(); i++) {
1515  if ((old.dhcp_option_list.dhcp_option[i].dhcp_option_name !=
1516  cur.dhcp_option_list.dhcp_option[i].dhcp_option_name) ||
1517  (old.dhcp_option_list.dhcp_option[i].dhcp_option_value !=
1518  cur.dhcp_option_list.dhcp_option[i].dhcp_option_value) ||
1519  (old.dhcp_option_list.dhcp_option[i].dhcp_option_value_bytes !=
1520  cur.dhcp_option_list.dhcp_option[i].dhcp_option_value_bytes))
1521  return true;
1522  }
1523 
1524  if (old.host_routes.route.size() != cur.host_routes.route.size())
1525  return true;
1526 
1527  for (uint32_t i = 0; i < old.host_routes.route.size(); i++) {
1528  if ((old.host_routes.route[i].prefix !=
1529  cur.host_routes.route[i].prefix) ||
1530  (old.host_routes.route[i].next_hop !=
1531  cur.host_routes.route[i].next_hop) ||
1532  (old.host_routes.route[i].next_hop_type !=
1533  cur.host_routes.route[i].next_hop_type) ||
1534  (old.host_routes.route[i].community_attributes.community_attribute !=
1535  cur.host_routes.route[i].community_attributes.community_attribute))
1536  return true;
1537  }
1538 
1539  return false;
1540 }
1541 
1542 bool DomainConfig::GetIpam(const std::string &name, autogen::IpamType *ipam) {
1543  IpamDomainConfigMap::iterator it = ipam_config_.find(name);
1544  if (it == ipam_config_.end())
1545  return false;
1546  *ipam = it->second;
1547  return true;
1548 }
1549 
1550 bool DomainConfig::GetVDns(const std::string &vdns,
1551  autogen::VirtualDnsType *vdns_type) {
1552  VdnsDomainConfigMap::iterator it = vdns_config_.find(vdns);
1553  if (it == vdns_config_.end())
1554  return false;
1555  *vdns_type = it->second;
1556  return true;
1557 }
1558 
1560 // OperNetworkIpam routines
1563  OperIFMapTable(agent), domain_config_(domain_config) {
1564 }
1565 
1567 }
1568 
1570  domain_config_->IpamDelete(node);
1571 }
1572 
1575 }
1576 
1579 }
1580 
1582  OperIFMapTable(agent), domain_config_(domain_config) {
1583 }
1584 
1586 }
1587 
1589  domain_config_->VDnsDelete(node);
1590 }
1591 
1594 }
1595 
1598 }
int GetVxLanId() const
Definition: vn.cc:727
Agent * agent_
Definition: vn.h:290
const UuidList & slo_list() const
Definition: vn.h:222
bool mac_ip_learning_enable_
Definition: vn.h:147
uint32_t alloc_unit
Definition: vn.h:39
UuidList slo_list_
Definition: vn.h:318
bool layer3_forwarding_
Definition: vn.h:305
IpAddress GetDnsFromIpam(const IpAddress &ip) const
Definition: vn.cc:668
string name_
Definition: vn.h:122
void SendObjectLog(AgentLogEvent::type event) const
Definition: vn.cc:1322
void ResyncReq(const boost::uuids::uuid &vn)
Definition: vn.cc:1211
void AddNetworkIpamNode(IFMapNode *node)
void ConfigDelete(IFMapNode *node)
Definition: vn.cc:1588
bool tsn_enabled() const
Definition: agent.h:1162
bool enable_rpf() const
Definition: vn.h:198
bool enable_rpf_
Definition: vn.h:132
bool IsVRFServiceChainingInstance(const string &vn_name, const string &vrf_name)
Definition: vn.cc:860
bool pbb_evpn_enable_
Definition: vn.h:138
bool mac_ip_learning_enable() const
Definition: vn.h:238
ForwardingMode
Definition: agent.h:403
static void CfgUuidSet(uint64_t ms_long, uint64_t ls_long, boost::uuids::uuid &u)
Definition: agent_cmn.h:67
Definition: vrf.h:86
void PropogateNodeChange(IFMapNode *node)
virtual bool IFNodeToUuid(IFMapNode *node, boost::uuids::uuid &u)
Definition: vn.cc:1140
void AddVirtualDnsNode(IFMapNode *node)
Agent * agent() const
Definition: oper_db.h:245
bool mirror_destination_
Definition: vn.h:314
const AclDBEntry * GetAcl() const
Definition: vn.h:167
DomainConfig * domain_config_table() const
Definition: agent.cc:1029
Definition: vn.h:76
std::string GetString(const std::string &key) const
boost::uuids::uuid logical_router_uuid_
Definition: vn.h:143
const VnIpam * GetIpam(const IpAddress &ip) const
Definition: vn.cc:651
DBTableBase * get_table() const
Definition: db_entry.cc:119
VnData * BuildData(IFMapNode *node)
Definition: vn.cc:952
std::pair< std::string, VnIpamLinkData > VnIpamDataPair
Definition: vn.h:85
boost::uuids::uuid uuid_
Definition: vn.h:80
Definition: vn.h:28
void IpamAddChange(IFMapNode *node)
Definition: vn.cc:1440
std::map< std::string, VnIpamLinkData > VnIpamDataMap
Definition: vn.h:84
bool enable_rpf_
Definition: vn.h:309
DomainConfig * domain_config_
Definition: vn.h:402
bool UpdateForwardingMode(Agent *agent)
Definition: vn.cc:345
void CallIpamCb(IFMapNode *node)
Definition: vn.cc:1482
void DelIpamRoutes(Agent *agent, VnIpam *ipam, VrfEntry *vrf)
Definition: vn.cc:547
IpamDomainConfigMap ipam_config_
Definition: vn.h:447
static DBTableBase * CreateTable(DB *db, const std::string &name)
Definition: vn.cc:753
void CallVdnsCb(IFMapNode *node)
Definition: vn.cc:1488
int vnid_
Definition: vn.h:130
bool cfg_igmp_enable_
Definition: vn.h:323
bool IsDeleted() const
Definition: db_entry.h:49
ConfigManager * config_manager() const
Definition: agent.cc:889
boost::asio::ip::address IpAddress
Definition: address.h:13
uint8_t sub_op_
Definition: agent_db.h:106
std::pair< std::string, autogen::VirtualDnsType > VdnsDomainConfigPair
Definition: vn.h:425
VxLanIdRef vxlan_id_ref_
Definition: vn.h:307
virtual ~OperNetworkIpam()
Definition: vn.cc:1566
Definition: acl.h:62
bool ChangeHandler(Agent *agent, const DBRequest *req)
Definition: vn.cc:133
uint32_t vn_max_flows_
Definition: vn.h:146
virtual AgentSandeshPtr GetAgentSandesh(const AgentSandeshArguments *args, const std::string &context)
Definition: vn.cc:1400
Agent * agent() const
Definition: agent_db.h:213
void DelVn(const boost::uuids::uuid &vn_uuid)
Definition: vn.cc:1204
std::unique_ptr< DBRequestData > data
Definition: db_table.h:49
VnEntry(Agent *agent, boost::uuids::uuid id)
Definition: vn.cc:87
virtual ~VnEntry()
Definition: vn.cc:98
uint32_t vn_max_flows() const
Definition: vn.h:259
DBTableWalkRef AllocWalker(WalkFn walk_fn, WalkCompleteFn walk_complete)
Definition: db_table.cc:613
virtual const char * Typename() const =0
bool cfg_igmp_enable_
Definition: vn.h:145
void Terminate()
Definition: vn.cc:1421
string vrf_name_
Definition: vn.h:123
void ConfigManagerEnqueue(IFMapNode *node)
Definition: vn.cc:1596
AgentDBEntry * FindActiveEntry(const DBEntry *key)
Definition: agent_db.cc:110
int vxlan_id_
Definition: vn.h:129
InterfaceTable * interface_table() const
Definition: agent.h:465
bool Enqueue(DBRequest *req)
Definition: db_table.cc:194
boost::uuids::uuid uuid
bool GetIpam(const std::string &name, autogen::IpamType *ipam)
Definition: vn.cc:1542
AclDBEntryRef acl_
Definition: vn.h:293
AclDBEntryRef mirror_acl_
Definition: vn.h:294
IpAddress GetSubnetAddress() const
Definition: vn.cc:63
Agent::ForwardingMode forwarding_mode() const
Definition: vn.h:195
adjacency_iterator end(DBGraph *graph)
const string & GetName() const
Definition: vrf.h:100
static std::string UuidToString(const boost::uuids::uuid &id)
Definition: string_util.h:138
virtual ~OperVirtualDns()
Definition: vn.cc:1585
const boost::uuids::uuid & GetUuid() const
Definition: acl.h:112
IFMapTable * table()
Definition: ifmap_node.h:29
bool pbb_etree_enable() const
Definition: vn.h:210
void NotifyAllEntries()
Definition: db_table.cc:596
boost::uuids::uuid acl_id_
Definition: vn.h:124
IFMapNode * FindTarget(IFMapAgentTable *table, IFMapNode *node, std::string node_type)
Definition: vn.cc:888
virtual KeyPtr GetDBRequestKey() const
Definition: vn.cc:112
void ConfigManagerEnqueue(IFMapNode *node)
Definition: vn.cc:1577
void UpdateRoutesInVrf(VrfEntry *vrf)
static Ip4Address GetIp4SubnetAddress(const Ip4Address &prefix, uint16_t plen)
Definition: address.cc:179
void set_fabric_vn_uuid(const boost::uuids::uuid &uuid)
Definition: agent.h:1365
std::unique_ptr< DBRequestKey > KeyPtr
Definition: db_entry.h:25
VdnsDomainConfigMap vdns_config_
Definition: vn.h:448
virtual ~VnTable()
Definition: vn.cc:746
bool GetIpamVdnsData(const IpAddress &vm_addr, autogen::IpamType *ipam_type, autogen::VirtualDnsType *vdns_type) const
Definition: vn.cc:684
bool ApplyIpam(Agent *agent, VnIpam *ipam, VrfEntry *old_vrf, bool del)
Definition: vn.cc:380
bool installed
Definition: vn.h:34
OperDhcpOptions oper_dhcp_options
Definition: vn.h:38
void ReleaseWalker(DBTableWalkRef &walk)
Definition: db_table.cc:619
OperDB * oper_db() const
Definition: agent.cc:1013
static Ip6Address GetIp6SubnetAddress(const Ip6Address &prefix, uint16_t plen)
Definition: address.cc:200
bool flood_unknown_unicast() const
Definition: vn.h:199
IFMapDependencyManager * dependency_manager()
Definition: operdb_init.h:61
bool IsSubnetMember(const IpAddress &ip) const
Definition: vn.cc:73
virtual void SetKey(const DBRequestKey *key)
Definition: vn.cc:116
const DBGraph * GetGraph() const
std::string GetProject() const
Definition: vn.cc:716
Definition: db.h:24
Agent::ForwardingMode forwarding_mode() const
void WalkAgain(DBTableWalkRef walk)
Definition: db_table.cc:631
IFMapNode * FindAdjacentIFMapNode(IFMapNode *node, const char *type)
void Init()
Definition: db_table.cc:387
IFMapAgentTable * cfg_vm_interface_table() const
Definition: cfg_init.h:22
bool cfg_igmp_enable() const
Definition: vn.h:234
GlobalVrouter * global_vrouter() const
Definition: operdb_init.h:54
void VDnsAddChange(IFMapNode *node)
Definition: vn.cc:1467
VnIpam(const std::string &ip, uint32_t len, const std::string &gw, const std::string &dns, bool dhcp, const std::string &name, const std::vector< autogen::DhcpOptionType > &dhcp_options, const std::vector< autogen::RouteType > &host_routes, uint32_t alloc)
Definition: vn.cc:48
OperNetworkIpam(Agent *agent, DomainConfig *domain_config)
Definition: vn.cc:1562
uint8_t type
Definition: load_balance.h:109
IpAddress default_gw
Definition: vn.h:31
virtual ~DomainConfig()
Definition: vn.cc:1415
bool IpamChanged(const autogen::IpamType &old, const autogen::IpamType &cur) const
Definition: vn.cc:1494
virtual bool OperDBDelete(DBEntry *entry, const DBRequest *req)
Definition: vn.cc:790
Definition: agent.h:358
void VnEntryWalkDone(DBTable::DBTableWalkRef walk_ref, DBTableBase *partition)
Definition: vn.cc:831
virtual std::unique_ptr< DBEntry > AllocEntry(const DBRequestKey *k) const
Definition: vn.cc:764
boost::uuids::uuid uuid_
Definition: vn.h:291
AgentRouteWalkerManager * agent_route_walk_manager() const
Definition: operdb_init.h:91
Definition: vrf.h:22
void ConfigAddChange(IFMapNode *node)
Definition: vn.cc:1592
void ConfigAddChange(IFMapNode *node)
Definition: vn.cc:1573
void AllocWalker()
Definition: vn.cc:603
uint32_t GetAllocUnitFromIpam(const IpAddress &ip) const
Definition: vn.cc:676
virtual bool OperDBResync(DBEntry *entry, const DBRequest *req)
Definition: vn.cc:818
AgentRouteWalkerPtr route_resync_walker_
Definition: vn.h:312
bool HandleIpamChange(Agent *agent, VnIpam *old_ipam, VnIpam *new_ipam)
Definition: vn.cc:449
boost::asio::ip::address_v6 Ip6Address
Definition: address.h:15
UuidList mp_list_
Definition: vn.h:322
std::vector< Callback > ipam_callback_
Definition: vn.h:449
std::unique_ptr< DBRequestKey > key
Definition: db_table.h:48
bool pbb_evpn_enable_
Definition: vn.h:316
std::vector< VnIpam > ipam_
Definition: vn.h:297
IFMapAgentTable * cfg_multicast_policy_table() const
Definition: cfg_init.h:158
bool GetVnHostRoutes(const std::string &ipam, std::vector< OperDhcpOptions::HostRoute > *routes) const
Definition: vn.cc:620
IFMapAgentTable * cfg_vn_network_ipam_table() const
Definition: cfg_init.h:48
const AclDBEntry * GetMirrorAcl() const
Definition: vn.h:168
virtual bool OperDBOnChange(DBEntry *entry, const DBRequest *req)
Definition: vn.cc:804
DBOperation oper
Definition: db_table.h:42
uint32_t plen
Definition: vn.h:30
bool AddIpamRoutes(Agent *agent, VnIpam *ipam)
Definition: vn.cc:526
string name_
Definition: vn.h:292
std::pair< std::string, autogen::IpamType > IpamDomainConfigPair
Definition: vn.h:423
virtual bool IsLess(const DBEntry &rhs) const
Definition: vn.cc:101
void ConfigDelete(IFMapNode *node)
Definition: vn.cc:1569
void ReleaseWalker()
Definition: vn.cc:612
VxLanId * Locate(uint32_t vxlan_id, const boost::uuids::uuid &vn, const std::string &vrf, bool flood_unknown_unicast, bool mirror_destination, bool learning_enabled, bool bridge)
Definition: vxlan.cc:242
IpAddress ip_prefix
Definition: vn.h:29
bool flood_unknown_unicast_
Definition: vn.h:133
PhysicalDeviceVnTable * physical_device_vn_table() const
Definition: agent.h:635
Agent::ForwardingMode forwarding_mode_
Definition: vn.h:311
std::vector< Callback > vdns_callback_
Definition: vn.h:450
const Peer * local_peer() const
Definition: agent.h:1022
bool underlay_forwarding_
Definition: vn.h:141
uint32_t vn_max_flows_
Definition: vn.h:324
bool DBEntrySandesh(Sandesh *sresp, std::string &name) const
Definition: vn.cc:1223
const std::vector< VnIpam > & GetVnIpam() const
Definition: vn.h:171
class boost::shared_ptr< AgentSandesh > AgentSandeshPtr
Definition: agent_db.h:18
VxLanNetworkIdentifierMode vxlan_network_identifier_mode() const
Definition: agent.h:1148
bool dhcp_enable
Definition: vn.h:35
VnEntry * Find(const boost::uuids::uuid &vn_uuid)
Definition: vn.cc:759
boost::uuids::uuid mirror_acl_id_
Definition: vn.h:125
const std::string & name() const
Definition: ifmap_node.h:48
boost::uuids::uuid health_check_uuid_
Definition: vn.h:326
AgentQosConfigConstRef qos_config_
Definition: vn.h:313
void AddHostRoute(const IpAddress &address, bool policy)
Definition: vn.cc:559
VnIpamDataMap vn_ipam_data_
Definition: vn.h:128
IpAddress dns_server
Definition: vn.h:33
int active_vxlan_id_
Definition: vn.h:303
std::vector< boost::uuids::uuid > UuidList
Definition: agent.h:203
UuidList slo_list_
Definition: vn.h:140
IFMapAgentTable * cfg_health_check_table() const
Definition: cfg_init.h:106
Definition: vn.h:151
IFMapNode * ifmap_node() const
Definition: oper_db.h:59
bool admin_state() const
Definition: vn.h:197
bool dhcp_enable_v6
Definition: vn.h:36
bool admin_state_
Definition: vn.h:131
bool bridging_
Definition: vn.h:304
VrfTable * vrf_table() const
Definition: agent.h:485
virtual bool Delete(DBEntry *entry, const DBRequest *req)
Definition: vxlan.cc:217
Definition: vn.h:331
bool UpdateVxlan(Agent *agent, bool op_del)
Definition: vn.cc:320
bool underlay_forwarding_
Definition: vn.h:319
IFMapAgentTable * cfg_qos_table() const
Definition: cfg_init.h:82
IFMapObject * GetObject()
Definition: ifmap_node.cc:63
void set_host_routes(const HostOptionsList &host_routes)
boost::uuids::uuid qos_config_uuid_
Definition: vn.h:135
DomainConfig * domain_config_
Definition: vn.h:416
IFMapAgentTable * cfg_acl_table() const
Definition: cfg_init.h:28
int GetCfgVnId(autogen::VirtualNetwork *cfg_vn)
Definition: vn.cc:899
VrfEntry * GetVrf() const
Definition: vn.h:170
std::string ipam_name
Definition: vn.h:37
AclDBEntryRef mirror_cfg_acl_
Definition: vn.h:295
boost::uuids::uuid mirror_cfg_acl_id_
Definition: vn.h:126
void CfgForwardingFlags(IFMapNode *node, bool *rpf, bool *flood_unknown_unicast, Agent::ForwardingMode *forwarding_mode, bool *mirror_destination)
Definition: vn.cc:906
boost::function< void(IFMapNode *)> Callback
Definition: vn.h:426
AgentQosConfigTable * qos_config_table() const
Definition: agent.h:554
VxLanTable * vxlan_table() const
Definition: agent.h:535
bool CanInstallIpam(const VnIpam *ipam)
Definition: vn.cc:396
void AddVn(const boost::uuids::uuid &vn_uuid, const string &name, const boost::uuids::uuid &acl_id, const string &vrf_name, const std::vector< VnIpam > &ipam, const VnData::VnIpamDataMap &vn_ipam_data, int vn_id, int vxlan_id, bool admin_state, bool enable_rpf, bool flood_unknown_unicast, bool pbb_etree_enable, bool pbb_evpn_enable, bool layer2_control_word)
Definition: vn.cc:1178
bool flood_unknown_unicast_
Definition: vn.h:310
const boost::uuids::uuid & health_check_uuid() const
Definition: vn.h:242
bool layer3_forwarding() const
Definition: vn.h:192
void BuildVnIpamData(const std::vector< autogen::IpamSubnetType > &subnets, const std::string &ipam_name, std::vector< VnIpam > *vn_ipam)
Definition: vn.cc:926
virtual DBEntry * OperDBAdd(const DBRequest *req)
Definition: vn.cc:770
boost::uuids::uuid health_check_uuid_
Definition: vn.h:148
void IpamDelete(IFMapNode *node)
Definition: vn.cc:1434
virtual void Clear()
Definition: vn.cc:749
bool layer2_control_word_
Definition: vn.h:317
MirrorCfgTable * mirror_cfg_table() const
Definition: agent.h:470
OperVirtualDns(Agent *agent, DomainConfig *domain_config)
Definition: vn.cc:1581
const AgentQosConfig * qos_config() const
Definition: vn.h:201
bool mirror_destination_
Definition: vn.h:136
void Init()
Definition: vn.cc:1418
void DelHostRoute(const IpAddress &address)
Definition: vn.cc:572
IFMapAgentTable * cfg_vrf_table() const
Definition: cfg_init.h:29
Agent::ForwardingMode TranslateForwardingMode(const std::string &mode) const
Definition: agent.cc:1095
void RegisterIpamCb(Callback cb)
Definition: vn.cc:1424
const std::string & linklocal_vrf_name()
Definition: agent.h:921
int vxlan_id_
Definition: vn.h:299
int vnid_
Definition: vn.h:300
bool layer2_control_word() const
Definition: vn.h:218
static bool IsGwHostRouteRequired(const Agent *agent)
Definition: vn.cc:443
IFMapAgentTable * cfg_vn_table() const
Definition: cfg_init.h:26
bool vxlan_routing_vn_
Definition: vn.h:142
const boost::uuids::uuid & GetUuid() const
Definition: vn.h:161
bool mac_ip_learning_enable_
Definition: vn.h:325
const string & GetName() const
Definition: vn.h:162
OperDhcpOptions oper_dhcp_options_
Definition: vn.h:66
void AddSubnetRoute(VnIpam *ipam)
Definition: vn.cc:587
std::vector< VnIpam > ipam_
Definition: vn.h:127
bool GetVDns(const std::string &vdns, autogen::VirtualDnsType *vdns_type)
Definition: vn.cc:1550
UuidList mp_list_
Definition: vn.h:144
boost::intrusive_ptr< DBTableWalk > DBTableWalkRef
Definition: db_table.h:169
void GlobalVrouterConfigChanged()
Definition: vn.cc:838
virtual bool ProcessConfig(IFMapNode *node, DBRequest &req, const boost::uuids::uuid &u)
Definition: vn.cc:1164
Agent::ForwardingMode forwarding_mode_
Definition: vn.h:134
Definition: vn.h:83
AgentConfig * cfg() const
Definition: agent.cc:865
boost::uuids::uuid logical_router_uuid_
Definition: vn.h:321
bool pbb_etree_enable_
Definition: vn.h:315
void AddVnNode(IFMapNode *node)
const std::string & fabric_vn_name() const
Definition: agent.h:901
IFMapAgentTable * cfg_slo_table() const
Definition: cfg_init.h:150
bool bridging() const
Definition: vn.h:191
bool SkipNode(IFMapNode *node)
bool GetIpamName(const IpAddress &vm_addr, std::string *ipam_name) const
Definition: vn.cc:630
AclTable * acl_table() const
Definition: agent.h:515
bool vxlan_routing_vn_
Definition: vn.h:320
DomainConfig(Agent *)
Definition: vn.cc:1412
const UuidList & mp_list() const
Definition: vn.h:230
adjacency_iterator begin(DBGraph *graph)
VnData::VnIpamDataMap vn_ipam_data_
Definition: vn.h:298
virtual bool IFNodeToReq(IFMapNode *node, DBRequest &req, const boost::uuids::uuid &u)
Definition: vn.cc:1148
VrfEntryRef vrf_
Definition: vn.h:296
bool IsIp6SubnetMember(const Ip6Address &ip, const Ip6Address &subnet, uint8_t plen)
Definition: address_util.cc:29
DBTable::DBTableWalkRef walk_ref_
Definition: vn.h:387
bool VnEntryWalk(DBTablePartBase *partition, DBEntryBase *entry)
Definition: vn.cc:823
bool Resync(Agent *agent)
Definition: vn.cc:123
bool GetPrefix(const Ip6Address &ip, Ip6Address *prefix, uint8_t *plen) const
Definition: vn.cc:700
void VDnsDelete(IFMapNode *node)
Definition: vn.cc:1461
Definition: acl.h:92
void UpdateHostRoute(Agent *agent, const IpAddress &old_address, const IpAddress &new_address, bool policy)
Definition: vn.cc:515
bool pbb_etree_enable_
Definition: vn.h:137
const boost::uuids::uuid GetMirrorUuid(const std::string &vn_name) const
Definition: cfg_mirror.cc:335
const AclDBEntry * GetMirrorCfgAcl() const
Definition: vn.h:169
void DelSubnetRoute(VnIpam *ipam)
Definition: vn.cc:595
virtual string ToString() const
Definition: vn.cc:106
bool UpdateIpam(Agent *agent, std::vector< VnIpam > &new_ipam)
Definition: vn.cc:403
bool layer2_control_word_
Definition: vn.h:139
IpAddress GetGatewayFromIpam(const IpAddress &ip) const
Definition: vn.cc:660
void GlobalVrouterConfigChanged()
Definition: interface.cc:409
void set_options(const DhcpOptionsList &options)
void RegisterVdnsCb(Callback cb)
Definition: vn.cc:1428
bool ApplyAllIpam(Agent *agent, VrfEntry *old_vrf, bool del)
Definition: vn.cc:370
bool GetIpamData(const IpAddress &vm_addr, std::string *ipam_name, autogen::IpamType *ipam_type) const
Definition: vn.cc:641
static VnTable * vn_table_
Definition: vn.h:378
bool admin_state_
Definition: vn.h:306
VnTable(DB *db, const std::string &name)
Definition: vn.cc:740