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