OpenSDN source code
vxlan_routing_manager.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Juniper Networks, Inc. All rights reserved.
3  * Copyright (c) 2022 - 2026 Matvey Kraposhin.
4  * Copyright (c) 2024 - 2026 Elena Zizganova.
5  */
6 
7 #include <boost/uuid/uuid_io.hpp>
8 #include <cmn/agent_cmn.h>
9 
10 #include <base/logging.h>
11 #include <oper/operdb_init.h>
12 #include <oper/route_common.h>
13 #include <oper/vrf.h>
14 #include <oper/bridge_route.h>
16 #include <oper/evpn_route.h>
17 #include <oper/agent_route.h>
19 #include <oper/vn.h>
20 #include <oper/vrf.h>
22 #include <oper/tunnel_nh.h> //for tunnel interception
23 
24 using namespace std;
25 
27  VrfEntry *vrf) {
28  inet4_table_ = vrf->GetInet4UnicastRouteTable();
29  inet6_table_ = vrf->GetInet6UnicastRouteTable();
30  evpn_table_ = vrf->GetEvpnRouteTable();
31  std::string nm4 = std::string("vxlan_lstnr.") + inet4_table_->name();
32  std::string nm6 = std::string("vxlan_lstnr.") + inet6_table_->name();
33  std::string nme = std::string("vxlan_lstnr.") + evpn_table_->name();
34 
35  inet4_id_ = inet4_table_->
36  Register(boost::bind(&VxlanRoutingManager::RouteNotify,
37  mgr, _1, _2), nm4);
38  inet6_id_ = inet6_table_->
39  Register(boost::bind(&VxlanRoutingManager::RouteNotify,
40  mgr, _1, _2), nm6);
41  evpn_id_ = evpn_table_->
42  Register(boost::bind(&VxlanRoutingManager::RouteNotify,
43  mgr, _1, _2), nme);
44 }
45 
47  evpn_table_->Unregister(evpn_id_);
48  inet4_table_->Unregister(inet4_id_);
49  inet6_table_->Unregister(inet6_id_);
50 }
51 
53  vmi_list_(), is_routing_vn_(false),
54  logical_router_uuid_(boost::uuids::nil_uuid()), mgr_(mgr) {
55 }
56 
58 }
59 
60 void VxlanRoutingVnState::AddVmi(const VnEntry *vn, const VmInterface *vmi) {
61  if (vmi->logical_router_uuid() == boost::uuids::nil_uuid()) {
62  LOG(ERROR, "Error in VxlanRoutingManager::AddVmi"
63  << ", vmi->logical_router_uuid() == boost::uuids::nil_uuid()");
64  assert(vmi->logical_router_uuid() != boost::uuids::nil_uuid());
65  }
66  VmiListIter it = vmi_list_.find(vmi);
67  if (it != vmi_list_.end()) {
68  return;
69  }
70 
71  vmi_list_.insert(vmi);
72  if ((logical_router_uuid_ != vmi->logical_router_uuid()) &&
73  (*(vmi_list_.begin()) == vmi)) {
74  mgr_->BridgeVnNotify(vn, this);
75  }
76 }
77 
78 void VxlanRoutingVnState::DeleteVmi(const VnEntry *vn, const VmInterface *vmi) {
79  VmiListIter it = vmi_list_.find(vmi);
80  if (it == vmi_list_.end()) {
81  return;
82  }
83  vmi_list_.erase(vmi);
84  mgr_->BridgeVnNotify(vn, this);
85 }
86 
88  vn_entry_(NULL), logical_router_uuid_(boost::uuids::nil_uuid()) {
89 }
90 
92 }
93 
95  if (vmi_list_.size() == 0)
96  return boost::uuids::nil_uuid();
97 
98  return (*(vmi_list_.begin()))->logical_router_uuid();
99 }
100 
102  VxlanRoutingManager *mgr, Agent *agent) :
103  AgentRouteWalker(name, agent), mgr_(mgr) {
104 }
105 
107 }
108 
109 // Only take notification of bridge inet routes.
110 // Change in them will trigger change in rest.
112  DBEntryBase *e) {
113  // Now route leaking is triggered by changes in the Inet table of
114  // a bridge VRF instance
115  const InetUnicastRouteEntry *inet_rt =
116  dynamic_cast<const InetUnicastRouteEntry*>(e);
117  if (inet_rt) {
118  const VrfEntry *vrf = inet_rt->vrf();
119  if (vrf && vrf->vn() && !mgr_->IsRoutingVrf(vrf)) {
120  mgr_->InetRouteNotify(partition, e);
121  }
122  }
123  return true;
124 }
125 
127  mgr_(mgr), lr_vrf_info_map_(), vn_lr_set_(),
128  inet4_table_walker_(), inet6_table_walker_() {
129 }
130 
132 }
133 
135  InetUnicastAgentRouteTable *inet4_table,
136  InetUnicastAgentRouteTable *inet6_table) {
137  // Inet 4
138  {
139  DBTable::DBTableWalkRef walk_ref;
140  InetTableWalker::iterator it = inet4_table_walker_.find(inet4_table);
141  if (it == inet4_table_walker_.end()) {
142  walk_ref = inet4_table->
143  AllocWalker(boost::bind(&VxlanRoutingManager::RouteNotify,
144  mgr_, _1, _2),
146  this, _1, _2));
147  inet4_table_walker_[inet4_table] = walk_ref;
148  } else {
149  walk_ref = it->second;
150  }
151  inet4_table->WalkAgain(walk_ref);
152  //Every time walk is issued for bridge table revisit subnet routes
153  mgr_->HandleSubnetRoute(inet4_table->vrf_entry());
154  }
155  // Inet 6
156  {
157  DBTable::DBTableWalkRef walk_ref;
158  InetTableWalker::iterator it = inet6_table_walker_.find(inet6_table);
159  if (it == inet6_table_walker_.end()) {
160  walk_ref = inet6_table->
161  AllocWalker(boost::bind(&VxlanRoutingManager::RouteNotify,
162  mgr_, _1, _2),
164  this, _1, _2));
165  inet6_table_walker_[inet6_table] = walk_ref;
166  } else {
167  walk_ref = it->second;
168  }
169  inet6_table->WalkAgain(walk_ref);
170  //Every time walk is issued for bridge table revisit subnet routes
171  mgr_->HandleSubnetRoute(inet6_table->vrf_entry());
172  }
173 }
174 
176  const VnEntry *vn, bool update, bool withdraw) {
177  if (lr_uuid == boost::uuids::nil_uuid())
178  return;
179  VxlanRoutingVrfMapper::RoutedVrfInfo &routing_vrf_info =
180  lr_vrf_info_map_[lr_uuid];
181  const VrfEntry *routing_vrf = routing_vrf_info.routing_vrf_;
182  DBTable::DBTableWalkRef walk_ref;
183 
184  if (withdraw) {
185  InetUnicastAgentRouteTable *inet4_table = nullptr;
186  InetUnicastAgentRouteTable *inet6_table = nullptr;
187  const VrfEntry *bridge_vrf = VxlanRoutingManager::VnVrf(vn,
188  routing_vrf_info.bridge_vrf_names_list_[vn]);
189  if (bridge_vrf && routing_vrf) {
190  inet4_table = bridge_vrf->GetInet4UnicastRouteTable();
191  inet6_table = bridge_vrf->GetInet6UnicastRouteTable();
192  }
193  if (inet4_table) {
194  walk_ref = inet4_table->
195  AllocWalker(boost::bind(
197  mgr_, routing_vrf, _1, _2),
199  this, _1, _2));
200  inet4_table->WalkAgain(walk_ref);
201  }
202  if (inet6_table) {
203  walk_ref = inet6_table->
204  AllocWalker(boost::bind(
206  mgr_, routing_vrf, _1, _2),
208  this, _1, _2));
209  inet6_table->WalkAgain(walk_ref);
210  }
211  } else {
212  EvpnAgentRouteTable *evpn_table = NULL;
213  if (routing_vrf) {
214  evpn_table =
215  static_cast<EvpnAgentRouteTable *>(
216  routing_vrf->GetEvpnRouteTable());
217  }
218  if (!evpn_table) {
219  return;
220  }
221 
222  walk_ref = evpn_table->
223  AllocWalker(boost::bind(&VxlanRoutingManager::LeakRoutesIntoBridgeTables,
224  mgr_, _1, _2, lr_uuid, vn, update),
226  this, _1, _2));
227  evpn_table->WalkAgain(walk_ref);
228  }
229 }
230 
232  DBTableBase *partition) {
233  if (walk_ref.get() != NULL)
234  (static_cast<DBTable *>(partition))->ReleaseWalker(walk_ref);
235 }
236 
238  DBTableBase *partition) {
239  const InetUnicastAgentRouteTable *table = static_cast<const InetUnicastAgentRouteTable *>
240  (walk_ref->table());
241  InetTableWalker::iterator it = inet4_table_walker_.find(table);
242  if(it == inet4_table_walker_.end()) {
243  LOG(ERROR, "Error in VxlanRoutingManager::BridgeInet4RouteWalkDone"
244  << ", it == inet4_table_walker_.end()");
245  assert(it != inet4_table_walker_.end());
246  }
247  inet4_table_walker_.erase(it);
248 }
249 
251  DBTableBase *partition) {
252  const InetUnicastAgentRouteTable *table = static_cast<const InetUnicastAgentRouteTable *>
253  (walk_ref->table());
254  InetTableWalker::iterator it = inet6_table_walker_.find(table);
255  if(it == inet6_table_walker_.end()){
256  LOG(ERROR, "Error in VxlanRoutingManager::BridgeInet6RouteWalkDone"
257  << ", it == inet6_table_walker_.end()");
258  assert(it != inet6_table_walker_.end());
259  }
260 
261  inet6_table_walker_.erase(it);
262 }
263 
265  const boost::uuids::uuid &lr_uuid, const VnEntry *vn,
266  std::string bridge_vrf_name) {
267  if (lr_uuid == boost::uuids::nil_uuid())
268  return;
269  VxlanRoutingVrfMapper::RoutedVrfInfo &routing_vrf_info =
270  lr_vrf_info_map_[lr_uuid];
271  const VrfEntry *routing_vrf = routing_vrf_info.routing_vrf_;
272  DBTable::DBTableWalkRef walk_ref;
273 
274  EvpnAgentRouteTable *evpn_table = nullptr;
275  if (routing_vrf != nullptr) {
276  evpn_table =
277  static_cast<EvpnAgentRouteTable *>(
278  routing_vrf->GetEvpnRouteTable());
279  }
280  if (evpn_table == nullptr) {
281  return;
282  }
283 
284  walk_ref = evpn_table->
285  AllocWalker(boost::bind(
287  mgr_, _1, _2, vn, bridge_vrf_name),
289  this, _1, _2));
290  evpn_table->WalkAgain(walk_ref);
291 }
292 
294 (const VxlanRoutingVrfMapper::RoutedVrfInfo &routed_vrf_info)
295 {
296  // Start walk on all l3 tables
298  routed_vrf_info.bridge_vn_list_.begin();
299  while (it != routed_vrf_info.bridge_vn_list_.end()) {
300  const VnEntry *vn = static_cast<const VnEntry *>(*it);
301  const VrfEntry *vrf = VxlanRoutingManager::VnVrf(vn,
302  routed_vrf_info.bridge_vrf_names_list_.at(vn));
303  if (vrf) {
304  InetUnicastAgentRouteTable *inet4_table =
305  static_cast<InetUnicastAgentRouteTable *>
306  (vrf->GetInet4UnicastRouteTable());
307  InetUnicastAgentRouteTable *inet6_table =
308  static_cast<InetUnicastAgentRouteTable *>
309  (vrf->GetInet6UnicastRouteTable());
310  if (!inet4_table || !inet6_table)
311  continue;
312  WalkBridgeInetTables(inet4_table, inet6_table);
313  }
314  it++;
315  }
316 }
317 
319 (const VnEntry *vn) {
320  VnLrSetIter it = vn_lr_set_.find(vn);
321  if (it != vn_lr_set_.end()) {
322  return GetRoutingVrfUsingUuid(it->second);
323  }
324  return NULL;
325 }
326 
328 (const AgentRoute *rt) {
330 }
331 
333 (const boost::uuids::uuid &lr_uuid) {
334  LrVrfInfoMapIter it = lr_vrf_info_map_.find(lr_uuid);
335  if (it != lr_vrf_info_map_.end()) {
336  return it->second.routing_vrf_;
337  }
338  return NULL;
339 }
340 
342 (const AgentRoute *rt) {
343  using boost::uuids::nil_uuid;
344 
346  return rt->vrf()->vn()->logical_router_uuid();
347  }
348 
349  const VnEntry* rt_vn = rt->vrf()->vn();
350  if (!rt_vn) {
351  return nil_uuid();
352  }
353 
354  const VxlanRoutingVnState *vn_state =
355  dynamic_cast<const VxlanRoutingVnState *>(rt_vn->
356  GetAgentDBEntryState(mgr_->vn_listener_id()));
357  if ((vn_state == NULL) || (vn_state->vmi_list_.size() == 0)) {
358  return nil_uuid();
359  }
360 
361  return vn_state->logical_router_uuid_;
362 }
363 
364 // Invoked everytime when a vrf is pulled out of use.
365 // Holds on object till all bridge and routing vrf are gone.
367  if ((it->second.routing_vrf_ == NULL) &&
368  (it->second.bridge_vn_list_.size() == 0)) {
369  lr_vrf_info_map_.erase(it);
370  }
371 }
372 
375 
380  agent_(agent), walker_(), vn_listener_id_(),
381  vrf_listener_id_(), vmi_listener_id_(), vrf_mapper_(this) {
382  //routing_vrf_interface_peer_ = agent_->evpn_routing_peer();
385 }
386 
388 }
389 
391  // Walker to go through routes in bridge evpn tables.
392  walker_.reset(new VxlanRoutingRouteWalker("VxlanRoutingManager", this,
393  agent_));
395  RegisterWalker(static_cast<AgentRouteWalker *>(walker_.get()));
396 
397  // Register all listener ids.
400  this, _1, _2));
402  boost::bind(&VxlanRoutingManager::VrfNotify, this, _1, _2));
404  boost::bind(&VxlanRoutingManager::VmiNotify, this, _1, _2));
405 }
406 
412  ReleaseWalker(walker_.get());
413  walker_.reset(NULL);
414 }
415 
428  VnEntry *vn = dynamic_cast<VnEntry *>(e);
429  VxlanRoutingVnState *vn_state = dynamic_cast<VxlanRoutingVnState *>
431 
432  if (vn->IsDeleted() && vn_state != NULL) {
433  if (vn_state->is_routing_vn_) {
434  RoutingVnNotify(vn, vn_state);
435  } else {
436  BridgeVnNotify(vn, vn_state);
437  }
438 
439  //Delete State
440  vn->ClearState(partition->parent(), vn_listener_id_);
441  delete vn_state;
442  return;
443  }
444 
445  // if the VN had been deleted previously
446  if (!vn_state && vn->IsDeleted()) {
447  return;
448  }
449 
450  if (!vn_state) {
451  vn_state = new VxlanRoutingVnState(this);
452  vn->SetState(partition->parent(), vn_listener_id_, vn_state);
453  }
454 
455  if (vn->vxlan_routing_vn()) {
456  vn_state->is_routing_vn_ = vn->vxlan_routing_vn();
457  }
458 
459  vn_state->vrf_ref_ = vn->GetVrf();
460  if (vn_state->is_routing_vn_) {
461  vn_state->logical_router_uuid_ = vn->logical_router_uuid();
462  RoutingVnNotify(vn, vn_state);
463  } else {
464  BridgeVnNotify(vn, vn_state);
465  }
466 
467  return;
468 }
469 
471  VxlanRoutingVnState *vn_state) {
472  using boost::uuids::nil_uuid;
473 
474  if (vn_state->vmi_list_.size() == 0) {
475  vn_state->logical_router_uuid_ = nil_uuid();
476  }
477 
478  VxlanRoutingVnState::VmiListIter it = vn_state->vmi_list_.begin();
479  while (it != vn_state->vmi_list_.end()) {
480  vn_state->logical_router_uuid_ = (*it)->logical_router_uuid();
481  if ((*it)->logical_router_uuid() != nil_uuid()) {
482  return;
483  }
484  //Delete VMI with no lr uuid, vmi update will handle rest.
485  vn_state->vmi_list_.erase(it);
486  if (vn_state->vmi_list_.size() == 0) {
487  vn_state->logical_router_uuid_ = nil_uuid();
488  return;
489  }
490  it = vn_state->vmi_list_.begin();
491  }
492  return;
493 }
494 
496  VxlanRoutingVnState *vn_state) {
497  using boost::uuids::nil_uuid;
498 
499  if (vn->logical_router_uuid() != nil_uuid()) {
500  return;
501  }
502 
506  VrfEntry *vn_vrf = vn->GetVrf();
507  bool withdraw = false;
508  bool update = true;
509 
510  // Update lr uuid in case some vmi is deleted or added.
511  UpdateLogicalRouterUuid(vn, vn_state);
512  if (vn->IsDeleted() || (vn_vrf == nullptr)) {
513  withdraw = true;
514  update = false;
515  }
516 
517  if (it != vrf_mapper_.vn_lr_set_.end() &&
518  (it->second != vn_state->logical_router_uuid_) &&
519  (vn_state->logical_router_uuid_ != nil_uuid())) {
520  withdraw = true;
521  }
522 
523  if (vn_state->logical_router_uuid_ == nil_uuid()) {
524  withdraw = true;
525  update = false;
526  }
527 
528  if (it != vrf_mapper_.vn_lr_set_.end()) {
529  routing_info_it = vrf_mapper_.lr_vrf_info_map_.find(it->second);
530  }
531 
532  // Handles deletion case
533  if (withdraw) {
534  if (routing_info_it != vrf_mapper_.lr_vrf_info_map_.end()) {
536  routing_info_it->second.bridge_vn_list_.find(vn);
537  std::string vrf_name = "";
538  if (routing_info_it->second.bridge_vrf_names_list_.count(vn) == 1) {
539  vrf_name = routing_info_it->second.bridge_vrf_names_list_.at(vn);
540  DeleteSubnetRoute(vn, vrf_name);
541  }
542  if (br_it != routing_info_it->second.bridge_vn_list_.end()) {
543  vrf_mapper_.WalkRoutingVrf(it->second, vn, false, true);
544  routing_info_it->second.bridge_vn_list_.erase(br_it);
545  routing_info_it->second.bridge_vrf_names_list_.erase(vn);
547  vrf_name);
548  }
549  // Trigger delete of logical router
550  vrf_mapper_.TryDeleteLogicalRouter(routing_info_it);
551  }
552  vrf_mapper_.vn_lr_set_.erase(vn);
553  }
554 
555  if (update) {
557  if (vrf_mapper_.vn_lr_set_[vn] == nil_uuid()) {
558  return;
559  }
560 
563  lr_vrf_info.bridge_vn_list_.insert(vn);
564  if (vn->GetVrf())
565  lr_vrf_info.bridge_vrf_names_list_[vn] = vn->GetVrf()->GetName();
566  else {
567  lr_vrf_info.bridge_vrf_names_list_[vn] = std::string{""};
568  }
569  vrf_mapper_.WalkRoutingVrf(vrf_mapper_.vn_lr_set_[vn], vn, true, false);
570  }
571 
572  // Without vrf walks cant be scheduled
573  if (!vn_state->vrf_ref_.get()) {
574  return;
575  }
576 
577  // Walk Evpn table if withdraw or update was done
578  if (update || withdraw) {
579  InetUnicastAgentRouteTable *inet4_table =
580  static_cast<InetUnicastAgentRouteTable *>(vn_state->vrf_ref_.get()->
581  GetInet4UnicastRouteTable());
582  InetUnicastAgentRouteTable *inet6_table =
583  static_cast<InetUnicastAgentRouteTable *>(vn_state->vrf_ref_.get()->
584  GetInet6UnicastRouteTable());
585  if (inet4_table && inet6_table) {
586  vrf_mapper_.WalkBridgeInetTables(inet4_table, inet6_table);
587  }
588  }
589  return;
590 }
591 
593  if (rt_vrf == nullptr) {
594  return;
595  }
596  // Loop over all EVPN routes and delete them
597 
598  EvpnAgentRouteTable *evpn_table = dynamic_cast<EvpnAgentRouteTable *>
599  (rt_vrf->GetEvpnRouteTable());
600  if (evpn_table == nullptr) {
601  return;
602  }
603  EvpnRouteEntry *c_entry = dynamic_cast<EvpnRouteEntry *>
604  (evpn_table->GetTablePartition(0)->GetFirst());
605 
606  const std::string vrf_name = rt_vrf->GetName();
607  const uint32_t ethernet_tag = 0;
608  const MacAddress mac_addr;
609  while (c_entry != nullptr) {
610  const IpAddress &prefix_ip = c_entry->prefix_address();
611  const uint8_t plen = c_entry->prefix_length();
612  const AgentPath *rt_active_path = c_entry->GetActivePath();
613  const Peer *rt_active_peer = nullptr;
614  const auto &path_list = c_entry->GetPathList();
615  if (rt_active_path != nullptr)
616  rt_active_peer = rt_active_path->peer();
617 
618  // Compute next entry in advance
619  if (c_entry != nullptr && c_entry->get_table_partition()) {
620  c_entry = dynamic_cast<EvpnRouteEntry *>
621  (c_entry->get_table_partition()->GetNext(c_entry));
622  } else {
623  break;
624  }
625 
627  vrf_name, prefix_ip, plen,
628  nullptr);
630  vrf_name, prefix_ip, plen,
631  nullptr);
632 
633  if ((rt_active_peer != nullptr) &&
634  (rt_active_peer->GetType() != Peer::BGP_PEER)) {
635  // Delete routes originated from bridge networks
636  EvpnAgentRouteTable::DeleteReq(rt_active_peer,
637  vrf_name,
638  mac_addr,
639  prefix_ip,
640  plen,
641  ethernet_tag, // ethernet_tag = 0 for Type5
642  nullptr);
643  } else {
644  for (auto &path_ref : path_list) {
646  static_cast<const AgentPath*>
647  (&path_ref)->peer(),
648  vrf_name,
649  mac_addr,
650  prefix_ip,
651  plen,
652  ethernet_tag, // ethernet_tag = 0 for Type5
653  nullptr);
654  }
655  }
656  }
657 }
658 
660  VxlanRoutingVnState *vn_state) {
661 
662  bool withdraw = false;
663  bool update = false;
665 
666  if (vn->IsDeleted() ||
667  (vn->GetVrf() == NULL) ||
668  (vn_state->is_routing_vn_ == false)) {
669  update = false;
670  withdraw = true;
671  } else {
672  update = true;
673  if (it != vrf_mapper_.vn_lr_set_.end()) {
674  // LR uuid changed, so withdraw from old and add new.
675  if (it->second != vn_state->logical_router_uuid_) {
676  withdraw = true;
677  }
678  }
679  }
680 
681  if (withdraw && (it != vrf_mapper_.vn_lr_set_.end())) {
683  vrf_mapper_.lr_vrf_info_map_.find(it->second);
684  // Delete only if parent VN is same as notified VN coz it may so happen
685  // that some other VN has taken the ownership of this LR and
686  // notification of same came before this VN.
687  if (routing_info_it != vrf_mapper_.lr_vrf_info_map_.end()) {
688  if (routing_info_it->second.routing_vn_ == vn) {
690  routing_info_it->second.routing_vrf_);
691  // Routing VN/VRF
692  // Reset parent vn and routing vrf
693  routing_info_it->second.routing_vn_ = nullptr;
694  routing_info_it->second.routing_vrf_ = nullptr;
695  }
696  // Trigger delete of logical router
697  vrf_mapper_.TryDeleteLogicalRouter(routing_info_it);
698  }
699  vrf_mapper_.vn_lr_set_.erase(it);
700  }
701 
702  if (update) {
703  if (vn_state->logical_router_uuid_ == boost::uuids::nil_uuid()) {
704  return;
705  }
706 
707  if (it == vrf_mapper_.vn_lr_set_.end()) {
709  }
710 
711  VxlanRoutingVrfMapper::RoutedVrfInfo &routed_vrf_info =
713  // Take the ownership of LR
714  routed_vrf_info.routing_vn_ = vn;
715  if (routed_vrf_info.routing_vrf_ != vn->GetVrf()) {
716  routed_vrf_info.routing_vrf_ = vn->GetVrf();
717  vrf_mapper_.WalkBridgeVrfs(routed_vrf_info);
718  }
719  }
720 }
721 
727  DBEntryBase *e) {
728  VrfEntry *vrf = static_cast<VrfEntry *>(e);
729  if (vrf->GetName().compare(agent_->fabric_vrf_name()) == 0)
730  return;
731  if (vrf->GetName().compare(agent_->fabric_policy_vrf_name()) == 0)
732  return;
733 
734  VxlanRoutingState *state = dynamic_cast<VxlanRoutingState *>(vrf->
735  GetState(partition->parent(), vrf_listener_id_));
736  if (vrf->IsDeleted()) {
737  if (state) {
738  vrf->ClearState(partition->parent(), vrf_listener_id_);
739  delete state;
740  }
741  } else {
742  // Vrf was added/changed.
743  if (!state) {
744  state = new VxlanRoutingState(this, vrf);
745  vrf->SetState(partition->parent(), vrf_listener_id_, state);
746  }
747  if (vrf->vn() && vrf->vn()->vxlan_routing_vn()) {
748  vrf->set_routing_vrf(true);
749  }
750  }
751 }
752 
754  DBEntryBase *e) {
755  VmInterface *vmi = dynamic_cast<VmInterface *>(e);
756  if (!vmi) {
757  return;
758  }
759 
760  VnEntry *vn = vmi->GetNonConstVn();
761  VxlanRoutingVnState *vn_state = NULL;
762  VxlanRoutingVmiState *vmi_state = dynamic_cast<VxlanRoutingVmiState *>(vmi->
763  GetAgentDBEntryState(vmi_listener_id_));
764  if (vmi->IsDeleted() || (vn == NULL) ||
765  (vmi->logical_router_uuid() == boost::uuids::nil_uuid())) {
766  if (!vmi_state) {
767  return;
768  }
769  vn = vmi_state->vn_entry_.get();
770  vn_state = dynamic_cast<VxlanRoutingVnState *>
772  if (vn_state)
773  vn_state->DeleteVmi(vn, vmi);
774  vmi->ClearState(partition->parent(), vmi_listener_id_);
775  delete vmi_state;
776  return;
777  }
778 
779  if ((vmi->device_type() != VmInterface::VMI_ON_LR) ||
780  (vmi->vmi_type() != VmInterface::ROUTER)) {
781  return;
782  }
783 
784  if (vmi->logical_router_uuid() == boost::uuids::nil_uuid()) {
785  return;
786  }
787 
788  // Without VN no point of update
789  if (!vn) {
790  return;
791  }
792 
793  if (!vmi_state) {
794  vmi_state = new VxlanRoutingVmiState();
795  vmi->SetState(partition->parent(), vmi_listener_id_, vmi_state);
796  vmi_state->vn_entry_ = vn;
797  }
798  // Update logical_router_uuid
799  vmi_state->logical_router_uuid_ = vmi->logical_router_uuid();
800 
801  // Its necessary to add state on VN so as to push VMI. VN notify can come
802  // after VMI notify.
803  VnNotify(vn->get_table_partition(), vn);
804  // Now get VN state and add/delete VMI there
805  vn_state = dynamic_cast<VxlanRoutingVnState *>
807  if (vn_state) {
808  vn_state->AddVmi(vn, vmi);
809  }
810 }
811 
812 void VxlanRoutingManager::HandleSubnetRoute(const VrfEntry *vrf, bool bridge_vrf) {
813  //
814  // New version
815  //
816  if (vrf->vn() && vrf->vn()->vxlan_routing_vn() == false) {
817  const VrfEntry *routing_vrf =
819  if (!routing_vrf || vrf->IsDeleted()) {
820  DeleteSubnetRoute(vrf);
821  vrf->vn()->set_lr_vrf(NULL);
822  } else {
823  UpdateSubnetRoute(vrf, routing_vrf);
824  vrf->vn()->set_lr_vrf(routing_vrf);
825  }
826  }
827 }
828 
830  const std::string& vrf_name,
831  const IpAddress& ipam_prefix,
832  const uint32_t plen) {
833  if (vn == NULL || vrf_name == std::string(""))
834  return;
835 
837 
838  if (lr_it == vrf_mapper_.vn_lr_set_.end() ||
839  lr_it->second == boost::uuids::nil_uuid())
840  return;
841 
843  vrf_mapper_.lr_vrf_info_map_[lr_it->second];
844 
845  if (lr_vrf_info.bridge_vn_list_.size() == 0)
846  return;
847 
848  for (auto bridge_vn_entry : lr_vrf_info.bridge_vn_list_) {
849  if (vn == bridge_vn_entry) {
850  continue;
851  }
852 
853  VrfEntry* it_vrf = VnVrf(bridge_vn_entry, lr_vrf_info.bridge_vrf_names_list_[bridge_vn_entry]);
854  if (it_vrf == nullptr) {
855  continue;
856  }
857 
858  it_vrf->GetInetUnicastRouteTable(ipam_prefix)->
859  Delete(agent_->evpn_routing_peer(), it_vrf->GetName(),
860  ipam_prefix, plen, NULL);
861  }
862 }
863 
864 void VxlanRoutingManager::DeleteSubnetRoute(const VnEntry *vn, const std::string& vrf_name) {
865  if (vn == NULL || vrf_name == std::string(""))
866  return;
867  std::vector<VnIpam> bridge_vn_ipam = vn->GetVnIpam();
868 
869  if (bridge_vn_ipam.size() == 0)
870  return;
871 
873 
874  if (lr_it == vrf_mapper_.vn_lr_set_.end() ||
875  lr_it->second == boost::uuids::nil_uuid())
876  return;
877 
879  vrf_mapper_.lr_vrf_info_map_[lr_it->second];
880 
881  if (lr_vrf_info.bridge_vn_list_.size() == 0)
882  return;
883 
884  for (auto bridge_vn_entry : lr_vrf_info.bridge_vn_list_) {
885  if (vn == bridge_vn_entry) {
886  continue;
887  }
888 
889  for (auto br_ipam : bridge_vn_ipam) {
890  VrfEntry* it_vrf = VnVrf(bridge_vn_entry, lr_vrf_info.bridge_vrf_names_list_[bridge_vn_entry]);
891  if (it_vrf == nullptr) {
892  continue;
893  }
894 
895  it_vrf->GetInetUnicastRouteTable(br_ipam.ip_prefix)->
896  DeleteReq(agent_->evpn_routing_peer(), it_vrf->GetName(),
897  br_ipam.GetSubnetAddress(), br_ipam.plen, NULL);
898  }
899 
900  std::vector<VnIpam> vn_ipam = bridge_vn_entry->GetVnIpam();
901 
902  if (vn_ipam.size() == 0) {
903  continue;
904  }
905  for (auto br_vn_ipam : vn_ipam) {
907  vrf_name, br_vn_ipam.GetSubnetAddress(),
908  br_vn_ipam.plen, NULL);
909  }
910  }
911 }
912 
913 //void VxlanRoutingManager::DeleteSubnetRoute(const VrfEntry *vrf, VnIpam *ipam) {
915  if (vrf == NULL)
916  return;
917  DeleteSubnetRoute(vrf->vn(), vrf->GetName());
918 }
919 
921  const VrfEntry *routing_vrf) {
922  if (!bridge_vrf->vn())
923  return;
924 
925  std::vector<VnIpam> bridge_vn_ipam = bridge_vrf->vn()->GetVnIpam();
926 
927  if (bridge_vn_ipam.size() == 0)
928  return;
929 
931  vrf_mapper_.vn_lr_set_.find(bridge_vrf->vn());
932 
933  if (lr_it == vrf_mapper_.vn_lr_set_.end() ||
934  lr_it->second == boost::uuids::nil_uuid())
935  return;
936 
938  vrf_mapper_.lr_vrf_info_map_[lr_it->second];
939 
940  if (lr_vrf_info.bridge_vn_list_.size() == 0)
941  return;
942 
944  lr_vrf_info.bridge_vn_list_.begin();
945  while (it != lr_vrf_info.bridge_vn_list_.end()) {
946  if (bridge_vrf->vn() == *it) {
947  it++;
948  continue;
949  }
950 
951  for (std::vector<VnIpam>::iterator ipam_itr = bridge_vn_ipam.begin();
952  ipam_itr < bridge_vn_ipam.end(); ipam_itr++) {
954  nh_req.key.reset(new VrfNHKey(routing_vrf->GetName(), false, false));
955  nh_req.data.reset(new VrfNHData(false, false, false));
956  VrfEntry* it_vrf = VnVrf((*it), lr_vrf_info.bridge_vrf_names_list_[(*it)]);
957  if (it_vrf == nullptr) {
958  continue;
959  }
960  it_vrf->GetInetUnicastRouteTable(ipam_itr->ip_prefix)->
961  AddEvpnRoutingRouteReq(ipam_itr->ip_prefix, ipam_itr->plen, routing_vrf,
964  CommunityList(),
965  PathPreference(),
966  EcmpLoadBalance(),
967  TagList(),
968  nh_req,
969  routing_vrf->vxlan_id(),
970  VnListType());
971  }
972 
973  std::vector<VnIpam> vn_ipam = (*it)->GetVnIpam();
974  for (std::vector<VnIpam>::iterator vn_ipam_itr = vn_ipam.begin();
975  vn_ipam_itr != vn_ipam.end(); vn_ipam_itr++) {
976 
978  nh_req.key.reset(new VrfNHKey(routing_vrf->GetName(), false, false));
979  nh_req.data.reset(new VrfNHData(false, false, false));
980  bridge_vrf->GetInetUnicastRouteTable(vn_ipam_itr->ip_prefix)->
981  AddEvpnRoutingRouteReq(vn_ipam_itr->ip_prefix, vn_ipam_itr->plen, routing_vrf,
984  CommunityList(),
985  PathPreference(),
986  EcmpLoadBalance(),
987  TagList(),
988  nh_req,
989  routing_vrf->vxlan_id(),
990  VnListType());
991  }
992  it++;
993  }
994 }
995 
999 void VxlanRoutingManager::FillSandeshInfo(VxlanRoutingResp *resp) {
1001  vrf_mapper_.lr_vrf_info_map_.begin();
1002  std::vector<VxlanRoutingMap> vr_map;
1003  while (it1 != vrf_mapper_.lr_vrf_info_map_.end()) {
1004  VxlanRoutingMap vxlan_routing_map;
1005  vxlan_routing_map.set_logical_router_uuid(UuidToString(it1->first));
1006  vxlan_routing_map.set_routing_vrf(it1->second.routing_vrf_->
1007  GetName());
1008  vxlan_routing_map.set_parent_routing_vn(it1->second.routing_vn_->
1009  GetName());
1011  it1->second.bridge_vn_list_.begin();
1012  while (it2 != it1->second.bridge_vn_list_.end()) {
1013  VxlanRoutingBridgeVrf bridge_vrf;
1014  if ((*it2)->GetVrf()) {
1015  bridge_vrf.set_bridge_vrf((*it2)->GetVrf()->GetName());
1016  }
1017  bridge_vrf.set_bridge_vn((*it2)->GetName());
1018  vxlan_routing_map.bridge_vrfs.push_back(bridge_vrf);
1019  it2++;
1020  }
1021  vr_map.push_back(vxlan_routing_map);
1022  it1++;
1023  }
1024  resp->set_vr_map(vr_map);
1025 }
1026 
1027 void VxlanRoutingReq::HandleRequest() const {
1028  VxlanRoutingResp *resp = new VxlanRoutingResp();
1029  Agent *agent = Agent::GetInstance();
1030  VxlanRoutingManager *vxlan_routing_mgr =
1031  agent->oper_db()->vxlan_routing_manager();
1032  if (vxlan_routing_mgr) {
1033  resp->set_context(context());
1034  vxlan_routing_mgr->FillSandeshInfo(resp);
1035  }
1036  resp->set_more(false);
1037  resp->Response();
1038  return;
1039 }
boost::asio::ip::address IpAddress
Definition: address.h:13
std::vector< uint64_t > TagList
Definition: agent.h:202
std::vector< int > SecurityGroupList
Definition: agent.h:201
std::set< std::string > VnListType
Definition: agent.h:212
std::vector< std::string > CommunityList
Definition: bgp_config.h:347
DBState * GetAgentDBEntryState(int listener_id)
Definition: agent_db.cc:31
const Peer * peer() const
Definition: agent_path.h:263
virtual const PrefixType & prefix_address() const
Returns the value of a stored prefix address (IPv4, IPv6 or MAC address)
Definition: agent_route.h:389
VrfEntry * vrf_entry() const
Definition: agent_route.cc:459
Base class for all Route entries in agent.
Definition: agent_route.h:224
const AgentPath * GetActivePath() const
Definition: agent_route.cc:877
VrfEntry * vrf() const
Definition: agent_route.h:275
Definition: agent.h:360
InterfaceTable * interface_table() const
Definition: agent.h:467
OperDB * oper_db() const
Definition: agent.cc:1016
const std::string & fabric_policy_vrf_name() const
Definition: agent.h:910
VrfTable * vrf_table() const
Definition: agent.h:487
const Peer * local_vm_export_peer() const
Definition: agent.h:1042
const Peer * vxlan_bgp_peer() const
Definition: agent.h:1030
const Peer * evpn_routing_peer() const
Definition: agent.h:1029
VnTable * vn_table() const
Definition: agent.h:497
static Agent * GetInstance()
Definition: agent.h:438
const std::string & fabric_vrf_name() const
Definition: agent.h:905
void ClearState(DBTableBase *tbl_base, ListenerId listener)
Definition: db_entry.cc:73
bool IsDeleted() const
Definition: db_entry.h:48
DBTablePartBase * get_table_partition() const
Definition: db_entry.cc:115
void SetState(DBTableBase *tbl_base, ListenerId listener, DBState *state)
Definition: db_entry.cc:22
ListenerId Register(ChangeCallback callback, const std::string &name="unspecified")
Definition: db_table.cc:207
void Unregister(ListenerId listener)
Definition: db_table.cc:212
const std::string & name() const
Definition: db_table.h:110
DBTableBase * parent()
virtual DBEntryBase * GetNext(const DBEntryBase *)=0
virtual DBEntryBase * GetFirst()=0
void WalkAgain(DBTableWalkRef walk)
Definition: db_table.cc:657
virtual DBTablePartBase * GetTablePartition(const DBRequestKey *key)
Definition: db_table.cc:462
boost::intrusive_ptr< DBTableWalk > DBTableWalkRef
Definition: db_table.h:169
static void DeleteReq(const Peer *peer, const std::string &vrf_name, const MacAddress &mac, const IpAddress &ip_addr, uint32_t plen, uint32_t ethernet_tag, AgentRouteData *data)
uint8_t prefix_length() const
!
static void DeleteReq(const Peer *peer, const string &vrf_name, const IpAddress &addr, uint8_t plen, AgentRouteData *data)
const boost::uuids::uuid & logical_router_uuid() const
Definition: interface.h:148
VxlanRoutingManager * vxlan_routing_manager() const
Definition: operdb_init.h:98
AgentRouteWalkerManager * agent_route_walk_manager() const
Definition: operdb_init.h:91
Definition: peer.h:44
const Type GetType() const
Definition: peer.h:87
@ BGP_PEER
Definition: peer.h:51
const PathList & GetPathList() const
Definition: route.h:46
VmInterface::VmiType vmi_type() const
VnEntry * GetNonConstVn() const
VmInterface::DeviceType device_type() const
Definition: vn.h:151
void set_lr_vrf(const VrfEntry *vrf)
Definition: vn.h:269
const std::vector< VnIpam > & GetVnIpam() const
Definition: vn.h:171
VrfEntry * GetVrf() const
Definition: vn.h:170
const boost::uuids::uuid & logical_router_uuid() const
Definition: vn.h:260
bool vxlan_routing_vn() const
Definition: vn.h:259
Definition: vrf.h:89
const string & GetName() const
Definition: vrf.h:103
void set_routing_vrf(bool val)
Definition: vrf.h:225
InetUnicastAgentRouteTable * GetInet4UnicastRouteTable() const
Definition: vrf.cc:319
InetUnicastAgentRouteTable * GetInet6UnicastRouteTable() const
Definition: vrf.cc:338
InetUnicastAgentRouteTable * GetInetUnicastRouteTable(const IpAddress &addr) const
Definition: vrf.cc:575
AgentRouteTable * GetEvpnRouteTable() const
Definition: vrf.cc:330
uint32_t vxlan_id() const
Definition: vrf.h:168
VnEntry * vn() const
Definition: vrf.h:104
This class manages an operative state of VxLAN logical routers (LR) defined via Config logical-router...
void DeleteIpamRoutes(const VnEntry *vn, const std::string &vrf_name, const IpAddress &ipam_prefix, const uint32_t plen)
Delete routes to IPAM, specified by IP prefix and prefix length.
bool LeakRoutesIntoBridgeTables(DBTablePartBase *partition, DBEntryBase *e, const boost::uuids::uuid &uuid, const VnEntry *vn, bool update=false)
Performs advertisement and deletion of routing routes (with VrfNH) in bridge VRF instances....
bool RouteNotify(DBTablePartBase *partition, DBEntryBase *e)
Handler for changes (new/update/delete) in a route (EVPN or Inet). Main entry point for routes leakin...
void VnNotify(DBTablePartBase *partition, DBEntryBase *e)
A handler for changes (new/update/delete) in a virtual network (VnEntry class).
void HandleSubnetRoute(const VrfEntry *vrf, bool bridge_vrf=false)
Handles routing routes (with VrfNH) update in the routing VRF instance.
void BridgeVnNotify(const VnEntry *vn, VxlanRoutingVnState *vn_state)
A handler for changes (new/update/delete) in the virtual network from a bridge VRF.
void VmiNotify(DBTablePartBase *partition, DBEntryBase *e)
Handler for changes (new/update/delete) in a VMI (VmInterface class).
void RoutingVnNotify(const VnEntry *vn, VxlanRoutingVnState *vn_state)
A handler for changes (new/update/delete) in the virtual network from a routing VRF.
DBTable::ListenerId vrf_listener_id_
An ID of the listener to changes in VrfTable.
DBTable::ListenerId vn_listener_id() const
Returns the ID of the listener to changes in the VnTable.
void UpdateSubnetRoute(const VrfEntry *vrf, const VrfEntry *routing_vrf)
Updates subnet routes (actually, paths with VrfNH) in the given bridge VRF.
bool WithdrawEvpnRouteFromRoutingVrf(const VrfEntry *routing_vrf, DBTablePartBase *partition, DBEntryBase *e)
Deletes a given EVPN route from EVPN table of the routing VRF instance.
static const Peer * routing_vrf_interface_peer_
Internal data of this class.
void Shutdown()
Unregisters handlers for events associated with changes in virtual networks (VnTable class) and VRF i...
friend class VxlanRoutingRouteWalker
Friends declarations.
static const Peer * routing_vrf_vxlan_bgp_peer_
A pointer to the Peer where all BGP routes are stored.
void Register()
Registers handlers for events associated with changes in virtual networks (VnTable class) and VRF ins...
static bool IsRoutingVrf(const VrfEntry *vrf)
Determines whether the pointer to the VRF instance is of routing type.
void VrfNotify(DBTablePartBase *partition, DBEntryBase *e)
A handler for changes (new/update/delete) in a VRF instance (VrfEntry class).
Agent * agent_
A pointer to the Agent instance.
DBTable::ListenerId vn_listener_id_
An ID of the listener to changes in VnTable.
static VrfEntry * VnVrf(const VnEntry *vn, const std::string &vrf_name)
Finds a VRF table (VrfEntry) for the given virtual network (VN). Returns nullptr if no VRF table asso...
void DeleteSubnetRoute(const VrfEntry *vrf)
Deletes subnet routes (actually, paths with VrfNH) in the given bridge VRF. This function is demanded...
AgentRouteWalkerPtr walker_
A pointer to the walker to loop over INET tables in bridge VRF instances.
VxlanRoutingManager(Agent *agent)
Constructs instance of the class and links to the Agent class instance. Since only one agent class in...
virtual ~VxlanRoutingManager()
Destroys the VxlanRoutingManager instance.
bool RemoveRoutesFromRoutingToBridgeVrf(DBTablePartBase *partition, DBEntryBase *e, const VnEntry *vn, std::string bridge_vrf_name)
Performs deletion of external routing routes (with VrfNH) in bridge VRF instances.
void RoutingVrfDeleteAllRoutes(VrfEntry *rt_vrf)
deletes all routes in EVPN table of routing VRF
bool InetRouteNotify(DBTablePartBase *partition, DBEntryBase *e)
Routes leaking functions.
VxlanRoutingVrfMapper vrf_mapper_
A map between LR uuids and associated bridge and routing VRF instances.
void FillSandeshInfo(VxlanRoutingResp *resp)
Updates Sandesh response.
DBTable::ListenerId vmi_listener_id_
An ID of the listener to changes in InterfaceTable.
VxlanRoutingRouteWalker(const std::string &name, VxlanRoutingManager *mgr, Agent *agent)
Constructs a new instance using the given name, pointer to the VxlanRoutingManager and pointer to the...
VxlanRoutingManager * mgr_
A pointer to the VxlanRoutingManager instance.
virtual ~VxlanRoutingRouteWalker()
Destructs an instance of VxlanRoutingRouteWalker.
virtual bool RouteWalkNotify(DBTablePartBase *partition, DBEntryBase *e)
Runs route leaking process when L3 VRF instance is added/deleted or when a bridge VRF is attached / d...
LrVrfInfoMap::iterator LrVrfInfoMapIter
A typedef for iterator of LrVrfInfoMap.
const VrfEntry * GetRoutingVrfUsingUuid(const boost::uuids::uuid &lr_uuid)
Find the routing VRF instance using a given LR UUID.
void WalkBridgeVrfs(const RoutedVrfInfo &routing_vrf_info)
Walks Inet tables of all bridge VRF instances connected to a LR (given in routing_vrf_info parameter)...
InetTableWalker inet4_table_walker_
The set of walkers for Inet IPv4 tables of bridge VRF instances.
LrVrfInfoMap lr_vrf_info_map_
The map between Logical router UUID and RoutedVrfInfo.
void TryDeleteLogicalRouter(LrVrfInfoMapIter &it)
Attempts to delete the given LR.
const boost::uuids::uuid GetLogicalRouterUuidUsingRoute(const AgentRoute *rt)
Find the UUID of the LR using a given route (AgentRoute).
void BridgeInet6RouteWalkDone(DBTable::DBTableWalkRef walk_ref, DBTableBase *partition)
Handles completion of route walk in an Inet IPv6 table of a bridge VRF instance.
const VrfEntry * GetRoutingVrfUsingAgentRoute(const AgentRoute *rt)
Find the routing VRF instance using a given route (AgentRoute).
void WalkRoutingVrfRemoveExternalRoutes(const boost::uuids::uuid &lr_uuid, const VnEntry *vn, std::string bridge_vrf_name)
Walks the EVPN table of the routing VRF instance of a given LR to find and remove external routes fro...
const VrfEntry * GetRoutingVrfUsingVn(const VnEntry *vn)
Find the routing VRF instance using a given virtual network.
VnLrSet vn_lr_set_
The map between pointer to VirtualNetwork (a bridge or routing virtual network connected to some LR) ...
void RoutingVrfRouteWalkDone(DBTable::DBTableWalkRef walk_ref, DBTableBase *partition)
Handles completion of route walk in the EVPN table of a routing VRF instance.
InetTableWalker inet6_table_walker_
The set of walkers for Inet IPv6 tables of bridge VRF instances.
VxlanRoutingVrfMapper(VxlanRoutingManager *mgr)
Constructs a new instance of VxlanRoutingVrfMapper using the given pointer to VxlanRoutingManager.
void BridgeInet4RouteWalkDone(DBTable::DBTableWalkRef walk_ref, DBTableBase *partition)
Handles completion of route walk in the Inet IPv4 table of a bridge VRF instance.
void WalkRoutingVrf(const boost::uuids::uuid &lr_uuid, const VnEntry *vn, bool update, bool withdraw)
Walks the EVPN table of the routing VRF instance of a given LR.
virtual ~VxlanRoutingVrfMapper()
Destroys an instance of VxlanRoutingVrfMapper().
VxlanRoutingManager * mgr_
A pointer to the VxlanRoutingManager instance.
void WalkBridgeInetTables(InetUnicastAgentRouteTable *inet4, InetUnicastAgentRouteTable *inet6)
Walks given Inet tables (IPv4 and IPv6).
VnLrSet::iterator VnLrSetIter
A typedef for iterator of VnLrSet.
#define LOG(_Level, _Msg)
Definition: logging.h:34
static std::string UuidToString(const boost::uuids::uuid &id)
Definition: string_util.h:138
@ 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
This state tracks inet and EVPN table listeners. It establishes link between inet tables of a bridge ...
VxlanRoutingState(VxlanRoutingManager *mgr, VrfEntry *vrf)
Construct new instance using the given VxlanRoutingManager and VRF instance (VrfEntry).
virtual ~VxlanRoutingState()
Destroys an instance.
Tracks movement of a VmInterface among LRs. This is used to associate VmInterface with a LR and a VN,...
VnEntryRef vn_entry_
Reference (smart pointer) to the virtual network (VirtualNetwork) to which VmInterface belongs to.
virtual ~VxlanRoutingVmiState()
Destroys an instance of VxlanRoutingVmiState.
boost::uuids::uuid logical_router_uuid_
UUID of the LR to which this VmInterface is connected.
VxlanRoutingVmiState()
Constructs new instance of VxlanRoutingVmiState.
This state tracks all virtual machine interfaces (VmInterface) attached to a Logical Router (LR)....
VrfEntryRef vrf_ref_
Holds a reference to a VrfEntry when VirtualNetwork's reference stored in VrfGet() is null.
bool is_routing_vn_
Returns true when state is associated with a routing VirtualNetwork.
boost::uuids::uuid logical_router_uuid() const
Returns the UUID of the Logical Router.
void AddVmi(const VnEntry *vn, const VmInterface *vmi)
Adds a VmInterface (LR port) to a Logical Router and connects the given VirtualNetwork (to which the ...
VxlanRoutingManager * mgr_
A pointer to the instance of VxlanRoutingManager.
VxlanRoutingVnState(VxlanRoutingManager *mgr)
Constructs new instance using VxlanRoutingManager.
void DeleteVmi(const VnEntry *vn, const VmInterface *vmi)
Deletes the VmInterface from set of connected interfaces and disconnects the given VirtualNetwork fro...
virtual ~VxlanRoutingVnState()
Destroys a VxlanRoutingVnState object.
VmiList::iterator VmiListIter
A typedef for the iterator of VxlanRoutingVnState::VmiList.
boost::uuids::uuid logical_router_uuid_
A UUID of the Logical Router.
std::set< const VmInterface * > vmi_list_
A list of VmInterface (router's ports) connected to a Logical Router (LR)
The structure holds information about virtual networks connected to a logical router (LR)
BridgeVnList::iterator BridgeVnListIter
A type for iterator of the list of bridge virtual networks connected to a LR.
BridgeVnList bridge_vn_list_
The list of bridge virtual networks (VirtualNetwork) connected to a LR.
BridgeVrfNamesList bridge_vrf_names_list_
The list of bridge virtual networks (VirtualNetwork) names connected to a LR.
const VnEntry * routing_vn_
A pointer to the routing virtual network (VirtualNetwork) connected to a LR.
VrfEntry * routing_vrf_
A pointer to the routing VRF instance (L3 VRF) connected to a LR.
boost::uuids::uuid uuid
void UpdateLogicalRouterUuid(const VnEntry *vn, VxlanRoutingVnState *vn_state)