OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
vxlan_auxilliary.cc
Go to the documentation of this file.
1 #include <oper/route_common.h>
4 #include <xmpp_enet_types.h>
5 #include <xmpp_unicast_types.h>
6 #include <oper/tunnel_nh.h>
8 #include <oper/bgp_as_service.h>
9 
10 
11 static void AdvertiseLocalRoute(const IpAddress &prefix_ip,
12  const uint32_t plen,
13  DBRequest &nh_req,
14  const Peer *peer,
15  const RouteParameters& params,
16  EvpnAgentRouteTable *evpn_table);
17 
18 static bool IsGivenTypeCompositeNextHop(const NextHop *nh,
19  NextHop::Type nh_type, bool strict_match = true) {
20  if (nh->GetType() != NextHop::COMPOSITE) {
21  return false;
22  }
23  const CompositeNH *composite_nh =
24  dynamic_cast<const CompositeNH*>(nh);
25  uint32_t comp_nh_count = composite_nh->ComponentNHCount();
26  for (uint32_t i=0; i < comp_nh_count; i++) {
27  const NextHop * c_nh = composite_nh->GetNH(i);
28  if (c_nh != NULL) {
29  // return true if at least one componet is interface
30  if (c_nh->GetType() == nh_type &&
31  !strict_match) {
32  return true;
33  }
34  // return true only if all components are interfaces
35  if (c_nh->GetType() != nh_type &&
36  strict_match) {
37  return false;
38  }
39  }
40  }
41  return strict_match;
42 }
43 
44 // A nexthop is counted as BGPaaS when it has MPLS label and this
45 // label points to the VmInterface linked with the BGPaaS object
46 static bool IsBGPaaSInterfaceNextHop(const Agent* agent, const NextHop* nh) {
47  if (nh->GetType() != NextHop::INTERFACE ||
48  nh->mpls_label() == NULL) {
49  return false;
50  }
51 
52  const InterfaceNH *intf_nh = static_cast<const InterfaceNH *>(nh);
53  const Interface *interface = intf_nh->GetInterface();
54  if (interface->type() != Interface::VM_INTERFACE)
55  return false;
56 
57  const VmInterface *vm_intf =
58  dynamic_cast<const VmInterface*>(interface);
59  const Ip4Address& intf_ip4 = vm_intf->primary_ip_addr();
60  const Ip6Address& intf_ip6 = vm_intf->primary_ip6_addr();
61 
62  if (agent->oper_db()->bgp_as_a_service()->
63  IsBgpService(vm_intf, IpAddress(intf_ip4), IpAddress(intf_ip4))) {
64  return true;
65  }
66  if (agent->oper_db()->bgp_as_a_service()->
67  IsBgpService(vm_intf, IpAddress(intf_ip6), IpAddress(intf_ip6))) {
68  return true;
69  }
70  return false;
71 }
72 
73 // A composite nexthop is counted as BGPaaS when at least one component is
74 // an interface
75 static bool IsBGPaaSCompositeNextHop(const Agent* agent, const NextHop* nh) {
76  if (nh->GetType() != NextHop::COMPOSITE)
77  return false;
78  const CompositeNH *composite_nh = dynamic_cast<const CompositeNH*>(nh);
79  uint32_t n_comps = composite_nh->ComponentNHCount();
80  for (uint32_t i=0; i < n_comps; i++) {
81  const NextHop *c_nh = composite_nh->GetNH(i);
82  if (c_nh != NULL &&
83  IsBGPaaSInterfaceNextHop(agent, c_nh) == true) {
84  return true;
85  }
86  }
87  return false;
88 }
89 
90 //
91 // VxlanRoutingManager members
92 //
93 
95  tbb::mutex::scoped_lock lock(mutex_);
96  const NextHop *path_nh = path->nexthop();
97  if (path_nh->GetType() != NextHop::COMPOSITE) {
98  return 0;
99  }
100  loc_sequence_++;
101  return loc_sequence_;
102 }
103 
104 bool VxlanRoutingManager::is_ipv4_string(const std::string& prefix_str) {
105  return (prefix_str.find(".") != std::string::npos);
106 }
107 
108 bool VxlanRoutingManager::is_ipv6_string(const std::string& prefix_str) {
109  return (prefix_str.find(":") != std::string::npos) &&
110  !is_ipv4_string(prefix_str);
111 }
112 
113 uint32_t VxlanRoutingManager::ipv4_prefix_len(const std::string& prefix_str) {
114  const std::string::size_type slash_pos = prefix_str.rfind("/");
115  if (slash_pos == std::string::npos) {
116  return 32;
117  }
118  const std::string len_str = prefix_str.substr(slash_pos + 1);
119  uint32_t prefix_len = 0;
120  std::istringstream(len_str) >> prefix_len;
121  return std::min(uint32_t(32), prefix_len);
122 }
123 
124 std::string VxlanRoutingManager::ipv4_prefix(const std::string& prefix_str) {
125  std::string::size_type first_dot_pos = 0;
126  std::string::size_type last_colon_pos =
127  prefix_str.rfind(":");
128  std::string::size_type slash_pos = prefix_str.rfind("/");
129  std::string ip_str = "0.0.0.0";
130  if ((first_dot_pos = prefix_str.find(".")) != std::string::npos) {
131  if (first_dot_pos - last_colon_pos >= 2 &&
132  first_dot_pos - last_colon_pos <= 4) {
133  ip_str = prefix_str.substr(last_colon_pos + 1);
134  }
135  if (last_colon_pos == string::npos) {
136  ip_str = prefix_str;
137  }
138  if (slash_pos != string::npos) {
139  ip_str = ip_str.substr(0, slash_pos);
140  }
141  }
142  return ip_str;
143 }
144 
145 uint32_t VxlanRoutingManager::ipv6_prefix_len(const std::string& prefix_str) {
146  const std::string::size_type slash_pos = prefix_str.rfind("/");
147  if (slash_pos == std::string::npos) {
148  return 128;
149  }
150  const std::string len_str = prefix_str.substr(slash_pos + 1);
151  uint32_t prefix_len = 0;
152  std::istringstream(len_str) >> prefix_len;
153  return std::min(uint32_t(128), prefix_len);
154 }
155 
156 std::string VxlanRoutingManager::ipv6_prefix(const std::string& prefix_str) {
157  const std::string zero_mac_str = "00:00:00:00:00:00";
158  const std::string::size_type mac_pos = prefix_str.find(zero_mac_str);
159  std::string ip_str = prefix_str;
160 
161  if (mac_pos != std::string::npos) {
162  ip_str = prefix_str.substr(mac_pos + zero_mac_str.size() + 1);
163  }
164 
165  const std::string::size_type slash_pos = ip_str.rfind("/");
166  if (slash_pos != std::string::npos) {
167  ip_str = ip_str.substr(0, slash_pos);
168  }
169  if (ip_str.find(":") == std::string::npos) {
170  ip_str = "::";
171  }
172  return ip_str;
173 }
174 
176  VxlanRoutingManager *vxlan_rt_mgr = NULL;
177  if (agent->oper_db()) {
178  vxlan_rt_mgr = agent->oper_db()->vxlan_routing_manager();
179  }
180  if (vxlan_rt_mgr == NULL) {
181  return false;
182  }
183  return true;
184 }
185 
186 std::string VxlanRoutingManager::GetOriginVn(const VrfEntry *routing_vrf,
187  const IpAddress& ip_addr,
188  const uint8_t& plen) {
189 
190  std::string origin_vn = "";
191  if (routing_vrf->vn()) {
194  [routing_vrf->vn()->logical_router_uuid()];
196  lr_vrf_info.bridge_vn_list_.begin();
197  while (it != lr_vrf_info.bridge_vn_list_.end()) {
199  (*it)->GetVrf()->GetUcRoute(ip_addr);
200  if (rt && RoutePrefixIsEqualTo(rt, ip_addr, plen)) {
201  origin_vn = (*it)->GetName();
202  break;
203  }
204  it++;
205  }
206  }
207 
208  return origin_vn;
209 }
210 
212  const IpAddress& prefix_ip,
213  const uint32_t prefix_len) {
214  if (route == NULL ||
215  route->prefix_address() != prefix_ip ||
216  route->prefix_length() != prefix_len) {
217  return false;
218  }
219  return true;
220 }
221 
223  const IpAddress& prefix_ip,
224  const uint32_t prefix_len) {
225  if (route == NULL ||
226  route->prefix_address() != prefix_ip ||
227  route->prefix_length() != prefix_len) {
228  return false;
229  }
230  return true;
231 }
232 
233 bool VxlanRoutingManager::IsHostRoute(const IpAddress& prefix_ip, uint32_t prefix_len) {
234  if (prefix_ip.is_v4() && prefix_len == 32)
235  return true;
236  if (prefix_ip.is_v6() && prefix_len == 128)
237  return true;
238  return false;
239 }
240 
242  if (evpn_rt != NULL) {
243  return IsHostRoute(evpn_rt->prefix_address(), evpn_rt->prefix_length());
244  }
245  return false;
246 }
247 
249  if(rt->vrf() == NULL || rt->vrf()->vn() == NULL){
250  LOG(ERROR, "Error in VxlanRoutingManager::IsHostRouteFromLocalSubnet"
251  << ", vrf == NULL || vrf()->vn() == NULL");
252  assert(rt->vrf() && rt->vrf()->vn());
253  }
254 
255  if (IsHostRoute(rt) == false) {
256  return false;
257  }
258 
259  const boost::uuids::uuid lr_uuid =
261  if (lr_uuid == boost::uuids::nil_uuid()) {
262  return false;
263  }
264 
265  const VxlanRoutingVrfMapper::RoutedVrfInfo& vr_info =
266  vrf_mapper_.lr_vrf_info_map_.at(lr_uuid);
268  vr_info.bridge_vn_list_;
269 
270  const VnEntry *bridge_vn = NULL;
272  bridge_vns.begin();
273  while (it_br != bridge_vns.end()) {
274  bridge_vn = *it_br;
275  const std::vector<VnIpam> &VnIpams = bridge_vn->GetVnIpam();
276  for (uint32_t j=0; j < VnIpams.size(); j++) {
277  if (VnIpams[j].IsSubnetMember(rt->prefix_address())) {
278  return true;
279  }
280  }
281  it_br++;
282  }
283  return false;
284 }
285 
287  VrfEntry *bridge_vrf) {
288  // check that the Inet table holds the corresponding route
289  InetUnicastRouteEntry local_vm_route_key(
290  bridge_vrf,
291  routing_evpn_rt->prefix_address(),
292  routing_evpn_rt->prefix_length(), false);
293 
294  InetUnicastAgentRouteTable *inet_table =
295  bridge_vrf->GetInetUnicastRouteTable(routing_evpn_rt->prefix_address());
296  InetUnicastRouteEntry *inet_rt =
297  dynamic_cast<InetUnicastRouteEntry *>
298  (inet_table->FindLPM(local_vm_route_key));
299  if (inet_rt && RoutePrefixIsEqualTo(inet_rt, routing_evpn_rt->prefix_address(),
300  routing_evpn_rt->prefix_length())) {
301  return inet_rt->FindPath(agent_->evpn_routing_peer()) ? false : true;
302  }
303  return false;
304 }
305 
307  const Route::PathList & path_list = rt->GetPathList();
308  for (Route::PathList::const_iterator it = path_list.begin();
309  it != path_list.end(); ++it) {
310  const AgentPath* path =
311  dynamic_cast<const AgentPath*>(it.operator->());
312 
313  if (path != NULL &&
314  path->nexthop() != NULL &&
315  path->nexthop()->GetType() == NextHop::VRF) {
316  return true;
317  }
318  }
319  return false;
320 }
321 
323  const Route::PathList & path_list = evpn_rt->GetPathList();
324  for (Route::PathList::const_iterator it = path_list.begin();
325  it != path_list.end(); ++it) {
326  const AgentPath* path =
327  dynamic_cast<const AgentPath*>(it.operator->());
328  if (path != NULL &&
329  path->peer() != NULL &&
330  path->peer()->GetType() == Peer::BGP_PEER) {
331  return true;
332  }
333  }
334  return false;
335 }
336 
338  return vrf && vrf->vn() &&
339  vrf->vn()->vxlan_routing_vn();
340  // An alternative method
341  // if (vrf == NULL) {
342  // return false;
343  // }
344  // if (vrf->vn() == NULL) {
345  // return false;
346  // }
347  // if (vrf_mapper_.lr_vrf_info_map_.count(
348  // vrf->vn()->logical_router_uuid())) {
349  // const VxlanRoutingVrfMapper::RoutedVrfInfo &lr_vrf_info =
350  // vrf_mapper_.lr_vrf_info_map_.at(vrf->vn()->logical_router_uuid());
351  // if (lr_vrf_info.routing_vrf_ == vrf) {
352  // return true;
353  // }
354  // }
355  // return false;
356 }
357 
359  return vrf && vrf->vn() &&
360  !vrf->vn()->vxlan_routing_vn();
361 }
362 
363 
364 bool VxlanRoutingManager::IsRoutingVrf(const std::string vrf_name,
365  const Agent* agent) {
366  VxlanRoutingManager *vxlan_rt_mgr = NULL;
367  const VrfEntry *vrf_cand = NULL;
368  if (agent->oper_db()) {
369  vxlan_rt_mgr = agent->oper_db()->vxlan_routing_manager();
370  }
371  if (vxlan_rt_mgr == NULL) {
372  return false;
373  }
374  if (agent->vrf_table())
375  vrf_cand = agent->vrf_table()->FindVrfFromName(vrf_name);
376  if (vrf_cand == NULL) {
377  return false;
378  }
379  return vxlan_rt_mgr->IsRoutingVrf(vrf_cand);
380 }
381 
383  const AgentRoute *inet_rt,
384  const Peer::Type peer_type) {
385  if (inet_rt == NULL)
386  return NULL;
387 
388  const Route::PathList & path_list = inet_rt->GetPathList();
389  for (Route::PathList::const_iterator it = path_list.begin();
390  it != path_list.end(); ++it) {
391  const AgentPath* path =
392  dynamic_cast<const AgentPath*>(it.operator->());
393 
394  if (path != NULL &&
395  path->peer()->GetType() == peer_type) {
396  return path;
397  }
398  }
399  return NULL;
400 }
401 
403  const AgentRoute *route,
404  const Peer::Type peer_type,
405  const NextHop::Type nh_type,
406  bool strict_match) {
407  if (route == NULL)
408  return NULL;
409 
410  const Route::PathList & path_list = route->GetPathList();
411  for (Route::PathList::const_iterator it = path_list.begin();
412  it != path_list.end(); ++it) {
413  const AgentPath* path =
414  dynamic_cast<const AgentPath*>(it.operator->());
415 
416  if (path != NULL &&
417  path->nexthop() != NULL &&
418  path->peer() != NULL &&
419  path->peer()->GetType() == peer_type) {
420  if (path->nexthop()->GetType() == nh_type) {
421  return path;
422  }
423  if (IsGivenTypeCompositeNextHop(path->nexthop(), nh_type,
424  strict_match)) {
425  return path;
426  }
427  }
428  }
429  return NULL;
430 }
431 
433  const AgentRoute *inet_rt,
434  const Peer::Type peer_type,
435  bool strict_match) {
436  return FindPathWithGivenPeerAndNexthop(inet_rt,
437  peer_type, NextHop::INTERFACE, strict_match);
438 }
439 
441  const AgentRoute *inet_rt,
442  bool strict_match) {
444  strict_match);
445 }
446 
448  const AgentRoute *inet_rt,
449  bool strict_match) {
451  strict_match);
452 }
453 
454 // Determines whether a route with the prefix is announced using BGPaaS
456  const InetUnicastRouteEntry *inet_rt) {
457  if (inet_rt == NULL) {
458  return NULL;
459  }
460  const AgentPath *bgp_cand_path =
461  FindInterfacePathWithBgpPeer(inet_rt, false);
462  if (bgp_cand_path == NULL) {
463  return NULL;
464  }
465  if (IsBGPaaSInterfaceNextHop(agent_, bgp_cand_path->nexthop())) {
466  return bgp_cand_path;
467  }
468  if (IsBGPaaSCompositeNextHop(agent_, bgp_cand_path->nexthop())) {
469  return bgp_cand_path;
470  }
471  return NULL;
472 }
473 
474 void MakeInterfaceNextHopReq(const NextHop* path_nh,
475  const std::string& vrf_name,
476  DBRequest& nh_req) {
477  NextHopKey * orig_key = dynamic_cast<NextHopKey*>(
478  path_nh->GetDBRequestKey().get())->Clone();
479  nh_req.key.reset(orig_key);
480 
481  InterfaceNHKey *intf_orig_key =
482  dynamic_cast<InterfaceNHKey*>(orig_key);
483  intf_orig_key->set_flags(intf_orig_key->flags() |
485  nh_req.data.reset(new InterfaceNHData(vrf_name));
486 }
487 
489  uint32_t prefix_len, const AgentPath* path,
490  EvpnAgentRouteTable *evpn_table) {
491  if (!path || !path->nexthop()) {
492  return;
493  }
494 
495  PathPreference path_preference = path->path_preference();
496  path_preference.set_loc_sequence(GetNewLocalSequence(path));
497  const RouteParameters params (Ip4Address(), // nh address is not needed here
498  MacAddress(), // nh MAC is not needed here
499  path->dest_vn_list(),
500  path->sg_list(),
501  path->communities(),
502  path->tag_list(),
503  path_preference,
504  path->ecmp_load_balance(),
506  const std::string& vrf_name = evpn_table->vrf_name();
508 
509  if (path->nexthop()->GetType() == NextHop::INTERFACE) {
510  MakeInterfaceNextHopReq(path->nexthop(), vrf_name, nh_req);
511  }
512  const EvpnRouteEntry *prev_evpn_rt = evpn_table->FindRoute(MacAddress(),
513  prefix_ip, prefix_len, 0);
514  const AgentPath *prev_path = NULL;
515  const CompositeNH *prev_nh = NULL;
516  if (RoutePrefixIsEqualTo(prev_evpn_rt, prefix_ip, prefix_len)) {
517  prev_path = FindInterfacePathWithGivenPeer(prev_evpn_rt,
519  }
520  if (prev_path && prev_path->nexthop() &&
521  prev_path->nexthop()->GetType() == NextHop::COMPOSITE) {
522  prev_nh = static_cast<const CompositeNH *>(prev_path->nexthop());
523  }
524 
525  if (path->nexthop()->GetType() == NextHop::COMPOSITE) {
526  const bool comp_nh_policy = false;
527  NextHopKey *nh_key = NULL;
528  // Create a new composite
529  ComponentNHKeyList new_comp_nh_list;
530  const CompositeNH *composite_nh = dynamic_cast<const CompositeNH*>(
531  path->nexthop());
532  const ComponentNHList &components = composite_nh->component_nh_list();
533  const NextHop *first_intf_nh = NULL;
534  for (uint32_t i=0; i < components.size(); i++) {
535  if (components[i].get() &&
536  components[i]->nh() &&
537  components[i]->nh()->GetType() == NextHop::INTERFACE) {
538  if (first_intf_nh == NULL) {
539  first_intf_nh = components[i]->nh();
540  }
541  DBEntryBase::KeyPtr key = components[i]->nh()->
542  GetDBRequestKey();
543  nh_key = static_cast<NextHopKey *>(key.release());
544 
545  std::unique_ptr<const NextHopKey> nh_key_ptr(nh_key);
546  ComponentNHKeyPtr component_nh_key(new ComponentNHKey(
547  MplsTable::kInvalidLabel, std::move(nh_key_ptr)));
548  new_comp_nh_list.push_back(component_nh_key);
549  }
550  }
551  if (new_comp_nh_list.size() < 1) {
552  // That could mean that route was deleted
553  // The corresponding route will be deleted
554  // from the EVPN table later
555  return;
556  } else if (new_comp_nh_list.size() == 1) {
557  // Advertise as a single interface
558  MakeInterfaceNextHopReq(first_intf_nh, vrf_name, nh_req);
559  } else {
560  // Add NULL components if number of new interface components is less
561  // than number of old interface components
562  if (prev_nh && prev_nh->ComponentNHCount() > new_comp_nh_list.size()) {
563  uint32_t n_nulls = 0;
564  n_nulls = prev_nh->ComponentNHCount() - new_comp_nh_list.size();
565  for (uint32_t i_null=0; i_null < n_nulls; i_null++) {
566  ComponentNHKeyPtr component_nh_key;
567  new_comp_nh_list.push_back(component_nh_key);
568  }
569  }
570  CompositeNHKey *new_comp_nh_key =
572  comp_nh_policy, new_comp_nh_list, vrf_name);
573  if (prev_nh) {
574  // Keep new components order consistent
575  // w/ previous configuration
576  new_comp_nh_key->Reorder(agent_, MplsTable::kInvalidLabel,
577  prev_nh);
578  }
579  nh_req.key.reset(new_comp_nh_key);
580  nh_req.data.reset(new CompositeNHData());
581  }
582  }
583  AdvertiseLocalRoute(prefix_ip, prefix_len, nh_req,
584  routing_vrf_interface_peer_, params, evpn_table);
585 }
586 
588  const Agent *agent) {
589  MacAddress compute_mac;
590  VrfEntry *underlay_vrf = agent->fabric_policy_vrf();
591  InetUnicastRouteEntry *router_rt = NULL;
592  router_rt = underlay_vrf->GetUcRoute(compute_ip);
593  if (router_rt != NULL &&
594  router_rt->prefix_address() == compute_ip) {
595  const AgentPath *apath = FindPathWithGivenPeerAndNexthop(router_rt,
597  if (apath) {
598  const TunnelNH * tunl_nh =
599  dynamic_cast<const TunnelNH*>(apath->nexthop());
600  if (tunl_nh->GetDmac()) {
601  compute_mac = *(tunl_nh->GetDmac());
602  }
603  }
604  }
605  return compute_mac;
606 }
607 
608 //Finds route in a EVPN table
610  const std::string &vrf_name,
611  const IpAddress &ip_addr,
612  unsigned int prefix_len,
613  const autogen::EnetNextHopType &nh_item) {
614 
615  const unsigned int ethernet_tag = 0;
616 
617  EvpnRouteEntry *evpn_rt =
619  vrf_name,
620  MacAddress(),
621  ip_addr,
622  prefix_len,
623  ethernet_tag);
624  if (RoutePrefixIsEqualTo(evpn_rt, ip_addr, prefix_len)) {
625  return evpn_rt;
626  }
627  return NULL;
628 }
629 
630 //Finds route in an Inet table
632  const std::string &vrf_name,
633  const IpAddress &ip_addr,
634  unsigned int prefix_len,
635  const autogen::NextHopType &nh_item) {
636 
637  VrfEntry *vrf_entry =
638  agent->vrf_table()->FindVrfFromName(vrf_name);
639  if (vrf_entry == NULL)
640  return NULL;
641 
642  InetUnicastAgentRouteTable *inet_tbl =
643  vrf_entry->GetInetUnicastRouteTable(ip_addr);
644  if (inet_tbl == NULL)
645  return NULL;
646 
647  InetUnicastRouteEntry local_vm_route_key(inet_tbl->vrf_entry(),
648  ip_addr,
649  prefix_len, false);
650  InetUnicastRouteEntry *inet_rt =
651  dynamic_cast<InetUnicastRouteEntry *>
652  (inet_tbl->FindLPM(local_vm_route_key));
653  if (RoutePrefixIsEqualTo(inet_rt, ip_addr, prefix_len)) {
654  return inet_rt;
655  }
656  return NULL;
657 }
658 
659 static bool InitializeNhRequest(const NextHop *path_nh,
660  DBRequest &nh_req,
661  const std::string& vrf_name) {
662  NextHopKey * orig_key = dynamic_cast<NextHopKey*>(
663  path_nh->GetDBRequestKey().get())->Clone();
664 
665  if(orig_key == NULL) {
666  LOG(ERROR, "Error in InitializeNhRequest"
667  << ", orig_key == NULL");
668  assert(orig_key != NULL);
669  }
670 
671  nh_req.key.reset(orig_key);
672  if (path_nh->GetType() == NextHop::INTERFACE) {
673  InterfaceNHKey *intf_orig_key =
674  dynamic_cast<InterfaceNHKey*>(orig_key);
675  if(intf_orig_key == NULL) {
676  LOG(ERROR, "Error in InitializeNhRequest"
677  << ", intf_orig_key == NULL");
678  assert(intf_orig_key != NULL);
679  }
680  // if NH is an interface, then update flags
681  intf_orig_key->set_flags(intf_orig_key->flags() |
683  nh_req.data.reset(new InterfaceNHData(vrf_name));
684  } else if (path_nh->GetType() == NextHop::COMPOSITE) {
685  nh_req.data.reset(new CompositeNHData);
686  } else { // other types of NH are not expected here
687  LOG(ERROR, "Error in InitializeNhRequest"
688  << ", Wrong NH type:" << path_nh->GetType());
689  assert(
690  path_nh->GetType() == NextHop::INTERFACE ||
691  path_nh->GetType() == NextHop::COMPOSITE);
692  return false;
693  }
694  return true;
695 }
696 
697 //
698 // EVPN routes advertising
699 //
700 
701 static void AdvertiseLocalRoute(const IpAddress &prefix_ip,
702  const uint32_t plen,
703  DBRequest &nh_req,
704  const Peer *peer,
705  const RouteParameters& params,
706  EvpnAgentRouteTable *evpn_table
707 ) {
708  EvpnRoutingData *rt_data = new EvpnRoutingData(nh_req,
709  params.sg_list_,
710  params.communities_,
711  params.path_preference_,
712  params.ecmp_load_balance_,
713  params.tag_list_,
714  evpn_table->vrf_entry(),
715  evpn_table->vrf_entry()->vxlan_id(),
716  params.vn_list_);
717  evpn_table->AddType5Route(peer,
718  evpn_table->vrf_entry()->GetName(),
719  prefix_ip,
720  0, // ethernet_tag = 0 for Type5
721  rt_data,
722  plen);
723 }
724 
725 static void AdvertiseInterfaceBgpRoute(const IpAddress &prefix_ip,
726  const uint32_t plen,
727  DBRequest &nh_req,
728  const Peer *peer,
729  const AgentPath* path,
730  EvpnAgentRouteTable *evpn_table
731 ) {
732  const NextHop *path_nh = path->nexthop();
733 
734  const InterfaceNH *intf_nh = dynamic_cast<const InterfaceNH *>
735  (path_nh);
736  const Interface *intf = intf_nh->GetInterface();
737  if (intf->type() != Interface::VM_INTERFACE) {
738  return;
739  }
740  const VmInterface *vm_intf = dynamic_cast<const VmInterface*>
741  (intf);
742  DBEntryBase::KeyPtr tintf_key_ptr = vm_intf->GetDBRequestKey();
743  const VmInterfaceKey* intf_key_ptr =
744  dynamic_cast<const VmInterfaceKey *>(tintf_key_ptr.get());
745 
746  LocalVmRoute *loc_rt_ptr = new LocalVmRoute(
747  *intf_key_ptr,
748  MplsTable::kInvalidLabel, // mpls_label
749  path->vxlan_id(),
750  path->force_policy(),
751  path->dest_vn_list(),
752  intf_nh->GetFlags(), // flags
753  path->sg_list(),
754  path->tag_list(),
755  path->communities(),
756  path->path_preference(),
757  path->subnet_service_ip(),
758  path->ecmp_load_balance(),
759  path->is_local(),
760  path->is_health_check_service(),
761  path->sequence(),
762  path->etree_leaf(),
763  false); // native_encap
764  loc_rt_ptr->set_tunnel_bmap(TunnelType::VxlanType());
765 
766  {
768 
769  req.key.reset(new EvpnRouteKey(peer,
770  evpn_table->vrf_entry()->GetName(),
771  MacAddress(),
772  prefix_ip,
773  plen,
774  0));
775  req.data.reset(loc_rt_ptr);
776  evpn_table->Enqueue(&req);
777  }
778 }
779 
780 static void AdvertiseCompositeInterfaceBgpRoute(const IpAddress &prefix_ip,
781  const uint32_t plen,
782  DBRequest &nh_req,
783  const Peer *peer,
784  const AgentPath* path,
785  EvpnAgentRouteTable *evpn_table
786 ) {
787  const BgpPeer *bgp_peer = dynamic_cast<const BgpPeer*>(peer);
788  std::stringstream prefix_str;
789  prefix_str << prefix_ip.to_string();
790  prefix_str << "/";
791  prefix_str << plen;
792  std::string vrf_name = evpn_table->vrf_name();
793 
795  bgp_peer,
796  path->dest_vn_list(),
797  path->ecmp_load_balance(),
798  path->tag_list(),
799  path->sg_list(),
800  path->path_preference(),
802  nh_req,
803  prefix_str.str(),
804  evpn_table->vrf_name());
805 
807  rt_data->cloned_local_path_list().begin();
808  while (iter != rt_data->cloned_local_path_list().end()) {
809  evpn_table->AddClonedLocalPathReq(bgp_peer, vrf_name,
810  MacAddress(), prefix_ip, 0, (*iter));
811  iter++;
812  }
813 
814  evpn_table->AddRemoteVmRouteReq(bgp_peer,
815  vrf_name, MacAddress(),
816  prefix_ip,
817  plen,
818  0, // ethernet tag is 0 for VxLAN
819  rt_data);
820 }
821 
822 //
823 // Inet routes advertising
824 //
825 static void AdvertiseLocalRoute(const IpAddress &prefix_ip,
826  const uint32_t plen,
827  DBRequest &nh_req,
828  const Peer *peer,
829  const RouteParameters& params,
830  InetUnicastAgentRouteTable *inet_table,
831  const std::string& origin_vn
832 ) {
833  inet_table->AddEvpnRoutingRoute(prefix_ip,
834  plen,
835  inet_table->vrf_entry(),
836  peer,
837  params.sg_list_,
838  params.communities_,
839  params.path_preference_,
840  params.ecmp_load_balance_,
841  params.tag_list_,
842  nh_req,
843  inet_table->vrf_entry()->vxlan_id(),
844  params.vn_list_,
845  origin_vn);
846 }
847 
849  const uint32_t plen,
850  const Peer *peer,
851  EvpnAgentRouteTable *evpn_table) {
852 
853  if (peer != routing_vrf_interface_peer_) {
854  return;
855  }
856 
857  EvpnRouteEntry *rt_entry = evpn_table->FindRoute(MacAddress(),
858  prefix_ip, plen, 0);
859  if (rt_entry && RoutePrefixIsEqualTo(rt_entry, prefix_ip, plen)) {
860  // Delete the old non-BGP path if it exists
861  AgentPath *old_path = rt_entry->FindPath(peer);
862  if (old_path) {
863  rt_entry->DeletePathFromPeer(rt_entry->get_table_partition(),
864  evpn_table, old_path);
865  }
866  }
867 }
868 
870  const IpAddress &prefix_ip,
871  const uint32_t plen,
872  const Peer *peer,
873  const RouteParameters &params,
874  EvpnAgentRouteTable *evpn_table) {
875  const NextHop *path_nh = path != NULL ? path->nexthop() : NULL;
876 
877  if (path_nh == NULL) {
878  return;
879  }
880 
882  if (InitializeNhRequest(path_nh,
883  nh_req, evpn_table->vrf_entry()->GetName()) == false) {
884  return;
885  }
886 
887  if (peer->GetType() == Peer::BGP_PEER) {
888  if (path_nh->GetType() == NextHop::INTERFACE) {
890  prefix_ip, plen, nh_req, peer, path, evpn_table);
891  } else if (path_nh->GetType() == NextHop::COMPOSITE) {
893  prefix_ip, plen, nh_req, peer, path, evpn_table);
894  }
895  } else {
896  AdvertiseLocalRoute(prefix_ip, plen, nh_req, peer, params,
897  evpn_table);
898  }
899 }
900 
902  const uint32_t plen,
903  const Peer *peer,
904  InetUnicastAgentRouteTable *inet_table) {
905  if (peer != routing_vrf_interface_peer_) {
906  return;
907  }
908 
909  InetUnicastRouteEntry old_rt_key(inet_table->vrf_entry(),
910  prefix_ip, plen, false);
911  InetUnicastRouteEntry *rt_entry = inet_table->FindRouteUsingKey(old_rt_key);
912  if (rt_entry && RoutePrefixIsEqualTo(rt_entry, prefix_ip, plen)) {
913  // Delete the old non-BGP path if it exists
914  AgentPath *old_path = rt_entry->FindPath(peer);
915  if (old_path) {
916  rt_entry->DeletePathFromPeer(rt_entry->get_table_partition(),
917  inet_table, old_path);
918  }
919  }
920 }
921 
923  const IpAddress &prefix_ip,
924  const uint32_t plen,
925  const Peer *peer,
926  const RouteParameters &params,
927  InetUnicastAgentRouteTable *inet_table) {
928  const NextHop *path_nh = path != NULL ? path->nexthop() : NULL;
929  if (path_nh == NULL || inet_table == NULL || peer == NULL) {
930  return;
931  }
932 
933 
935  if (InitializeNhRequest(path_nh,
936  nh_req, inet_table->vrf_entry()->GetName()) == false) {
937  return;
938  }
939 
940  std::string origin_vn = "";
941  if (peer->GetType() == Peer::VXLAN_BGP_PEER) {
942  } else {
943  origin_vn = GetOriginVn(inet_table->vrf_entry(), prefix_ip, plen);
944  }
945  AdvertiseLocalRoute(prefix_ip, plen, nh_req, peer, params,
946  inet_table, origin_vn);
947 }
948 
949 
951  if (const_vrf == NULL) {
952  std::cout<< "VxlanRoutingManager::PrintEvpnTable"
953  << ", NULL vrf ptr"
954  << std::endl;
955  return;
956  }
957  VrfEntry* routing_vrf = const_cast<VrfEntry*>(const_vrf);
958  EvpnAgentRouteTable *evpn_table = dynamic_cast<EvpnAgentRouteTable *>
959  (routing_vrf->GetEvpnRouteTable());
960  if (evpn_table == NULL) {
961  std::cout<< "VxlanRoutingManager::PrintEvpnTable"
962  << ", NULL EVPN tbl ptr"
963  << std::endl;
964  return;
965  }
966  EvpnRouteEntry *c_entry = dynamic_cast<EvpnRouteEntry *>
967  (evpn_table->GetTablePartition(0)->GetFirst());
968  if (c_entry) {
969  if (c_entry->IsType5())
970  std::cout << "Evpn Type 5 table:" << std::endl;
971  else
972  std::cout << "Evpn Type 2 table:" << std::endl;
973  }
974  while (c_entry) {
975  const Route::PathList & path_list = c_entry->GetPathList();
976  std::cout<< " IP:" << c_entry->prefix_address()
977  << ", path count = " << path_list.size()
978  << ", ethernet_tag = " << c_entry->ethernet_tag()
979  << std::endl;
980  for (Route::PathList::const_iterator it = path_list.begin();
981  it != path_list.end(); ++it) {
982  const AgentPath* path =
983  dynamic_cast<const AgentPath*>(it.operator->());
984  if (!path)
985  continue;
986  std::cout<< " NH: "
987  << (path->nexthop() ? path->nexthop()->ToString() :
988  "NULL")
989  << ", " << "Peer:"
990  << (path->peer() ? path->peer()->GetName() : "NULL")
991  << std::endl;
992  if (path->nexthop()->GetType() == NextHop::COMPOSITE) {
993  CompositeNH *comp_nh = dynamic_cast<CompositeNH *>
994  (path->nexthop());
995  std::cout<< " n components="
996  << comp_nh->ComponentNHCount()
997  << std::endl;
998  }
999  }
1000  if (evpn_table && evpn_table->GetTablePartition(0))
1001  c_entry = dynamic_cast<EvpnRouteEntry *>
1002  (evpn_table->GetTablePartition(0)->GetNext(c_entry));
1003  else
1004  break;
1005  }
1006 }
1007 
1009  if (const_vrf == NULL) {
1010  std::cout<< "VxlanRoutingManager::PrintInetTable"
1011  << ", NULL vrf ptr"
1012  << std::endl;
1013  return;
1014  }
1015  VrfEntry* routing_vrf = const_cast<VrfEntry*>(const_vrf);
1016  InetUnicastAgentRouteTable *inet_table =
1017  routing_vrf->GetInet4UnicastRouteTable();
1018  if (inet_table == NULL) {
1019  std::cout<< "VxlanRoutingManager::PrintInetTable"
1020  << ", NULL Inet tbl ptr"
1021  << std::endl;
1022  return;
1023  }
1024  InetUnicastRouteEntry *c_entry = dynamic_cast<InetUnicastRouteEntry *>
1025  (inet_table->GetTablePartition(0)->GetFirst());
1026  if (c_entry) {
1027  std::cout << "Inet table:" << std::endl;
1028  }
1029  while (c_entry) {
1030  const Route::PathList & path_list = c_entry->GetPathList();
1031  std::cout<< " IP:" << c_entry->prefix_address()
1032  << ", path count = " << path_list.size() << std::endl;
1033  for (Route::PathList::const_iterator it = path_list.begin();
1034  it != path_list.end(); ++it) {
1035  const AgentPath* path =
1036  dynamic_cast<const AgentPath*>(it.operator->());
1037  if (!path)
1038  continue;
1039  std::cout<< " NH: "
1040  << (path->nexthop() ? path->nexthop()->ToString() :
1041  "NULL")
1042  << ", " << "Peer:"
1043  << (path->peer() ? path->peer()->GetName() : "NULL")
1044  << ", nh ptr = " << path->nexthop()
1045  << ", pt ptr = " << path
1046  << std::endl;
1047  // if (path->nexthop()->GetType() == NextHop::COMPOSITE) {
1048  // CompositeNH *comp_nh = dynamic_cast<CompositeNH *>
1049  // (path->nexthop());
1050  // std::cout<< " n components="
1051  // << comp_nh->ComponentNHCount()
1052  // << std::endl;
1053  // }
1054  }
1055  if (inet_table && inet_table->GetTablePartition(0))
1056  c_entry = dynamic_cast<InetUnicastRouteEntry *>
1057  (inet_table->GetTablePartition(0)->GetNext(c_entry));
1058  else
1059  break;
1060  }
1061 }
1062 
1064  Agent *agent = Agent::GetInstance();
1065  if (agent == NULL) {
1066  std::cout<<"VxlanRoutingManager::ListAttachedVns agent == NULL"<<std::endl;
1067  return;
1068  }
1069  VxlanRoutingManager *vxlan_rt_mgr = agent->oper_db()->vxlan_routing_manager();
1070  if (vxlan_rt_mgr == NULL) {
1071  std::cout<<"VxlanRoutingManager::ListAttachedVns rt mgr = NULL"<<std::endl;
1072  return;
1073  }
1074  VxlanRoutingVrfMapper& vrf_mapper = vxlan_rt_mgr->vrf_mapper_;
1075  VxlanRoutingVrfMapper::LrVrfInfoMap& lr_vrf_info_map = vrf_mapper.lr_vrf_info_map_;
1076  for(VxlanRoutingVrfMapper::LrVrfInfoMap::iterator it = lr_vrf_info_map.begin();
1077  it != lr_vrf_info_map.end(); it++) {
1078  std::cout << "VxlanRoutingManager::ListAttachedVns, "
1079  << "rt VRF = "
1080  << (*it).second.routing_vrf_->GetName()
1081  << std::endl;
1082  std::cout << "VxlanRoutingManager::ListAttachedVns, "
1083  << "size = "
1084  << (*it).second.bridge_vn_list_.size()
1085  << std::endl;
1087  (*it).second.bridge_vn_list_;
1088  for(VxlanRoutingVrfMapper::RoutedVrfInfo::BridgeVnList::iterator it_br = reg_br.begin();
1089  it_br != reg_br.end(); it_br++) {
1090  if ((*it_br))
1091  std::cout<< "VxlanRoutingManager::ListAttachedVns, "
1092  << "br VN = " << (*it_br)->GetName()
1093  << std::endl;
1094  }
1095  }
1096 }
1097 
1098 //
1099 //END-OF-FILE
1100 //
const std::string & GetName() const
Definition: peer.h:86
void AddType5Route(const Peer *peer, const std::string &vrf_name, const IpAddress &ip_addr, uint32_t ethernet_tag, EvpnRoutingData *data, uint8_t plen=0)
uint8_t prefix_length() const
!
const Interface * GetInterface() const
Definition: nexthop.h:1293
EvpnRouteEntry * FindRoute(const MacAddress &mac, const IpAddress &ip_addr, uint32_t plen, uint32_t ethernet_tag)
const TagList & tag_list_
A list of tags.
const VnListType & dest_vn_list() const
Definition: agent_path.h:258
static void AdvertiseLocalRoute(const IpAddress &prefix_ip, const uint32_t plen, DBRequest &nh_req, const Peer *peer, const RouteParameters &params, EvpnAgentRouteTable *evpn_table)
Type type() const
Definition: interface.h:112
const std::string & vrf_name() const
Definition: agent_route.cc:455
static tbb::mutex mutex_
static Agent * GetInstance()
Definition: agent.h:436
void set_flags(uint8_t flags)
Definition: nexthop.h:1215
virtual DBEntryBase * GetFirst()=0
static bool IsHostRoute(const IpAddress &prefix_ip, uint32_t prefix_len)
Determines whether the prefix address and the prefix length point to a host route (/32 for IPv4...
Definition: vrf.h:86
static uint32_t ipv4_prefix_len(const std::string &prefix_str)
Extracts length of IPv4 subnet address from the prefix string.
const TagList & tag_list() const
Definition: agent_path.h:249
const PathPreference & path_preference() const
Definition: agent_path.h:329
InetUnicastRouteEntry * FindLPM(const IpAddress &ip)
bool force_policy() const
Definition: agent_path.h:270
const IpAddress subnet_service_ip() const
Definition: agent_path.h:274
AgentRouteTable * GetEvpnRouteTable() const
Definition: vrf.cc:330
VrfEntry * FindVrfFromName(const string &name)
Definition: vrf.cc:873
static bool IsBridgeVrf(const VrfEntry *vrf)
Determines whether the pointer to the VRF instance is of bridge type.
static bool IsBGPaaSCompositeNextHop(const Agent *agent, const NextHop *nh)
const AgentPath * FindBGPaaSPath(const InetUnicastRouteEntry *rt)
Finds in the given route the path that was announced using BGPaaS. It is expected that this path has ...
void AddClonedLocalPathReq(const Peer *peer, const string &vrf_name, const MacAddress &mac, const IpAddress &ip_addr, uint32_t ethernet_tag, ClonedLocalPath *data)
static std::string ipv4_prefix(const std::string &prefix_str)
Extracts an IPv4 address string from the prefix string.
std::set< const VnEntry * > BridgeVnList
A typedef to store the list of bridge virtual networks connected to a LR.
static MacAddress NbComputeMac(const Ip4Address &compute_ip, const Agent *agent)
Returns the MAC address for the IP of a given neighbouring compute.
static const AgentPath * FindPathWithGivenPeerAndNexthop(const AgentRoute *inet_rt, const Peer::Type peer_type, const NextHop::Type nh_type, bool strict_match=true)
Finds in the given route the path with a specified Peer type and a specified nexthop type...
BridgeVnList bridge_vn_list_
The list of bridge virtual networks (VirtualNetwork) connected to a LR.
boost::asio::ip::address IpAddress
Definition: address.h:13
VrfEntry * fabric_policy_vrf() const
Definition: agent.h:917
std::unique_ptr< DBRequestData > data
Definition: db_table.h:49
InetUnicastAgentRouteTable * GetInet4UnicastRouteTable() const
Definition: vrf.cc:319
const boost::uuids::uuid GetLogicalRouterUuidUsingRoute(const AgentRoute *rt)
Find the UUID of the LR using a given route (AgentRoute).
bool Enqueue(DBRequest *req)
Definition: db_table.cc:194
void DeletePathFromPeer(DBTablePartBase *part, AgentRouteTable *table, AgentPath *path)
Definition: agent_route.cc:654
boost::uuids::uuid uuid
virtual DBEntryBase * GetNext(const DBEntryBase *)=0
const VxlanRoutingVrfMapper & vrf_mapper() const
Returns the map between LR uuids and associated bridge and routing VRF instances. ...
void set_loc_sequence(uint32_t loc_sequence)
Definition: agent_path.h:76
boost::shared_ptr< const ComponentNHKey > ComponentNHKeyPtr
Definition: nexthop.h:1639
const string & GetName() const
Definition: vrf.h:100
static AgentRoute * FindEvpnOrInetRoute(const Agent *agent, const std::string &vrf_name, const IpAddress &ip_addr, uint32_t prefix_len, const autogen::EnetNextHopType &nh_item)
Finds a route with the given prefix address and len in the EVPN table.
A structure to hold path parameters during the transfer (routes leaking) of data between VRF instance...
virtual std::string ToString() const
Definition: nexthop.h:368
static bool is_ipv4_string(const std::string &prefix_str)
Determines whether the address string contains an IPv4 address as substring or not.
VxlanRoutingManager * vxlan_routing_manager() const
Definition: operdb_init.h:98
std::unique_ptr< DBRequestKey > KeyPtr
Definition: db_entry.h:25
The class is used to store following information:
Type GetType() const
Definition: nexthop.h:405
Base class for all Route entries in agent.
Definition: agent_route.h:224
static const AgentPath * FindInterfacePathWithGivenPeer(const AgentRoute *inet_rt, const Peer::Type peer_type, bool strict_match=true)
Finds in the given route the path with the given Peer type and interface nexthop (InterfaceNH).
const SecurityGroupList & sg_list_
A list of security groups.
OperDB * oper_db() const
Definition: agent.cc:1013
std::vector< ComponentNHKeyPtr > ComponentNHKeyList
Definition: nexthop.h:1641
uint32_t ethernet_tag() const
static void PrintEvpnTable(const VrfEntry *const_vrf)
Prints EVPN table of the given VRF instance.
std::map< boost::uuids::uuid, RoutedVrfInfo > LrVrfInfoMap
A typedef to store map between Logical router UUID and RoutedVrfInfo.
void AdvertiseBGPaaSRoute(const IpAddress &prefix_ip, uint32_t prefix_len, const AgentPath *path, EvpnAgentRouteTable *evpn_table)
Advertises BGPaaS interface path in the routing VRF instance by selecting corresponding path componen...
static bool RoutePrefixIsEqualTo(const EvpnRouteEntry *route, const IpAddress &prefix_ip, const uint32_t prefix_len)
Determines whether route prefix in the EVPN route is equal to the given pair of prefix IP address and...
This class manages routes leaking between bridge VRF instances and the routing VRF instance...
const Type GetType() const
Definition: peer.h:87
void CopyPathToInetTable(const AgentPath *path, const IpAddress &prefix_ip, const uint32_t plen, const Peer *peer, const RouteParameters &params, InetUnicastAgentRouteTable *inet_table)
Copies the path to the prefix address into the EVPN table with the given Peer. The function is used d...
NextHop * nexthop() const
Definition: agent_path.cc:87
uint8_t GetFlags() const
Definition: nexthop.h:1300
boost::intrusive::list< Path, PathListMember > PathList
Definition: route.h:20
bool is_local() const
Definition: agent_path.h:372
BgpAsAService * bgp_as_a_service() const
Definition: operdb_init.h:77
VrfEntry * vrf_entry() const
Definition: agent_route.cc:459
static const AgentPath * FindPathWithGivenPeer(const AgentRoute *inet_rt, const Peer::Type peer_type)
Finds in the given route the path with a specified Peer type.
Agent * agent_
A pointer to the Agent instance.
void AddEvpnRoutingRoute(const IpAddress &ip_addr, uint8_t plen, const VrfEntry *vrf, const Peer *peer, const SecurityGroupList &sg_list, const CommunityList &communities, const PathPreference &path_preference, const EcmpLoadBalance &ecmp_load_balance, const TagList &tag_list, DBRequest &nh_req, uint32_t vxlan_id, const VnListType &vn_list, const std::string &origin_vn="")
static bool is_ipv6_string(const std::string &prefix_str)
Determines whether the address string contains an IPv6 address as substring or not.
static bool IsRoutingVrf(const VrfEntry *vrf)
Determines whether the pointer to the VRF instance is of routing type.
KeyPtr GetDBRequestKey() const
const VnListType & vn_list_
A list of path destination virtual networks used in policy lookups.
static uint32_t GetNewLocalSequence(const AgentPath *)
Auxilliary functions.
Definition: agent.h:358
uint32_t sequence() const
Definition: agent_path.h:328
InetUnicastAgentRouteTable * GetInetUnicastRouteTable(const IpAddress &addr) const
Definition: vrf.cc:575
boost::asio::ip::address_v6 Ip6Address
Definition: address.h:15
std::string GetOriginVn(const VrfEntry *routing_vrf, const IpAddress &ip_addr, const uint8_t &plen)
Finds first occurence of a route with the given prefix (IP address and length) in Inet tables of brid...
std::unique_ptr< DBRequestKey > key
Definition: db_table.h:48
bool vxlan_routing_vn() const
Definition: vn.h:255
bool is_health_check_service() const
Definition: agent_path.h:380
const Peer * peer() const
Definition: agent_path.h:263
uint64_t sequence_number() const
Definition: peer.h:94
const ComponentNHList & component_nh_list() const
Definition: nexthop.h:1869
ClonedLocalPathList & cloned_local_path_list()
const std::vector< VnIpam > & GetVnIpam() const
Definition: vn.h:171
static uint32_t loc_sequence_
An always increasing counter for new paths (used to signal controoler about new routes).
bool etree_leaf() const
Definition: agent_path.h:388
static bool InitializeNhRequest(const NextHop *path_nh, DBRequest &nh_req, const std::string &vrf_name)
bool HasBgpPeerPath(EvpnRouteEntry *evpn_rt)
Determines whether the given EVPN route has at least one path originating from BGP/XMPP (has Peer typ...
Definition: peer.h:44
virtual KeyPtr GetDBRequestKey() const =0
virtual const PrefixType & prefix_address() const
Returns the value of a stored prefix address (IPv4, IPv6 or MAC address)
Definition: agent_route.h:375
boost::asio::ip::address_v4 Ip4Address
Definition: address.h:14
static void PrintInetTable(const VrfEntry *const_vrf)
Prints IPv4 Inet table of the given VRF instance.
Definition: vn.h:151
static const uint32_t kInvalidLabel
Definition: mpls.h:101
const PathPreference & path_preference_
A reference to the PathPreference of the path.
VrfTable * vrf_table() const
Definition: agent.h:485
const Ip4Address & primary_ip_addr() const
virtual DBTablePartBase * GetTablePartition(const DBRequestKey *key)
Definition: db_table.cc:436
static void CopyInterfacePathToEvpnTable(const AgentPath *path, const IpAddress &prefix_ip, const uint32_t plen, const Peer *peer, const RouteParameters &params, EvpnAgentRouteTable *evpn_table)
Copies the path to the prefix address into the EVPN table with the given Peer. The function is used d...
const boost::uuids::uuid & logical_router_uuid() const
Definition: vn.h:256
uint8_t prefix_length() const
!
static const AgentPath * FindInterfacePathWithBgpPeer(const AgentRoute *inet_rt, bool strict_match=true)
Finds in the given route the path which has the BGP_PEER Peer type and the Interface nexthop type...
uint32_t vxlan_id() const
Definition: vrf.h:165
ClonedLocalPathList::iterator ClonedLocalPathListIter
VxlanRoutingVrfMapper vrf_mapper_
A map between LR uuids and associated bridge and routing VRF instances.
const Ip6Address & primary_ip6_addr() const
size_t ComponentNHCount() const
Definition: nexthop.h:1815
VnEntry * vn() const
Definition: vrf.h:101
static uint32_t ipv6_prefix_len(const std::string &prefix_str)
Extracts length of IPv6 subnet address from the prefix string.
static bool IsVxlanAvailable(const Agent *agent)
Checks whether VxLAN routing manager is enabled or not.
const CommunityList & communities_
A list of communities.
static void AdvertiseInterfaceBgpRoute(const IpAddress &prefix_ip, const uint32_t plen, DBRequest &nh_req, const Peer *peer, const AgentPath *path, EvpnAgentRouteTable *evpn_table)
void MakeInterfaceNextHopReq(const NextHop *path_nh, const std::string &vrf_name, DBRequest &nh_req)
bool Reorder(Agent *agent, uint32_t label, const NextHop *nh)
Definition: nexthop.cc:2740
#define LOG(_Level, _Msg)
Definition: logging.h:33
VrfEntry * vrf() const
Definition: agent_route.h:275
static void DeleteOldInterfacePath(const IpAddress &prefix_ip, const uint32_t plen, const Peer *peer, EvpnAgentRouteTable *evpn_table)
Routes copying functions.
The structure holds information about virtual networks connected to a logical router (LR) ...
static void AdvertiseCompositeInterfaceBgpRoute(const IpAddress &prefix_ip, const uint32_t plen, DBRequest &nh_req, const Peer *peer, const AgentPath *path, EvpnAgentRouteTable *evpn_table)
std::vector< ComponentNHPtr > ComponentNHList
Definition: nexthop.h:1637
static void ListAttachedVns()
Prints all virtual networks attached to logical routers.
bool IsHostRouteFromLocalSubnet(const EvpnRouteEntry *rt)
Determines whether the given EVPN route is a host one and belongs to a subnet of a local bridge VRF...
static const AgentPath * FindInterfacePathWithLocalVmPeer(const AgentRoute *inet_rt, bool strict_match=true)
Finds in the given route the path which has the LOCAL_VM_PEER peer type and the Interface nexthop typ...
DBTablePartBase * get_table_partition() const
Definition: db_entry.cc:115
static bool HasVrfNexthop(const AgentRoute *rt)
Determines whether the given route has the path with a VRF nexthop (VrfNH)
const uint8_t & flags() const
Definition: nexthop.h:1216
const NextHop * GetNH(uint32_t idx) const
Definition: nexthop.h:1832
BridgeVnList::iterator BridgeVnListIter
A type for iterator of the list of bridge virtual networks connected to a LR.
LrVrfInfoMap lr_vrf_info_map_
The map between Logical router UUID and RoutedVrfInfo.
static const Peer * routing_vrf_interface_peer_
Internal data of this class.
const MacAddress * GetDmac() const
Definition: tunnel_nh.h:39
InetUnicastRouteEntry * GetUcRoute(const IpAddress &addr) const
Definition: vrf.cc:237
static bool IsBGPaaSInterfaceNextHop(const Agent *agent, const NextHop *nh)
virtual AgentPath * FindPath(const Peer *peer) const
Definition: agent_route.cc:864
const CommunityList & communities() const
Definition: agent_path.h:250
const EcmpLoadBalance & ecmp_load_balance_
A reference to EcmpLoadBalance of the path.
bool IsVrfLocalRoute(EvpnRouteEntry *routing_evpn_rt, VrfEntry *bridge_vrf)
Determines if the given EVPN route has an interface NH or a composite of interfaces NH that belongs t...
static std::string ipv6_prefix(const std::string &prefix_str)
Extracts an IPv6 address string from the prefix string.
static TypeBmap VxlanType()
Definition: nexthop.h:311
InetUnicastRouteEntry * FindRouteUsingKey(InetUnicastRouteEntry &key)
const SecurityGroupList & sg_list() const
Definition: agent_path.h:248
uint32_t vxlan_id() const
Definition: agent_path.h:265
static bool IsGivenTypeCompositeNextHop(const NextHop *nh, NextHop::Type nh_type, bool strict_match=true)
const EcmpLoadBalance & ecmp_load_balance() const
Definition: agent_path.h:365
Type
Definition: peer.h:48
void set_tunnel_bmap(TunnelType::TypeBmap bmap)
Definition: agent_path.h:679
const Peer * evpn_routing_peer() const
Definition: agent.h:1027
const PathList & GetPathList() const
Definition: route.h:46
const MplsLabel * mpls_label() const
Definition: nexthop.h:434
static void AddRemoteVmRouteReq(const Peer *peer, const std::string &vrf_name, const MacAddress &mac, const IpAddress &ip_addr, uint32_t plen, uint32_t ethernet_tag, AgentRouteData *data)