OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
agent_path.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #include <boost/uuid/uuid_io.hpp>
6 #include <boost/lexical_cast.hpp>
7 #include <boost/foreach.hpp>
8 #include <cmn/agent_cmn.h>
9 #include <route/route.h>
10 #include <init/agent_param.h>
11 
12 #include <vnc_cfg_types.h>
13 #include <agent_types.h>
14 
15 #include <filter/acl.h>
16 
17 #include <oper/peer.h>
18 #include <oper/vrf.h>
19 #include <oper/interface_common.h>
20 #include <oper/nexthop.h>
21 #include <oper/tunnel_nh.h>
22 #include <oper/vn.h>
23 #include <oper/mirror_table.h>
24 #include <oper/vxlan.h>
25 #include <oper/mpls.h>
26 #include <oper/route_common.h>
27 #include <oper/ecmp_load_balance.h>
28 #include <oper/agent_sandesh.h>
29 #include <oper/tsn_elector.h>
30 
31 using namespace std;
32 using namespace boost::asio;
33 
34 //Helpers
35 bool RebakeLabel(MplsTable *table, uint32_t label, NextHop *nh) {
36  bool ret = false;
37  if (label != MplsTable::kInvalidLabel) {
38  MplsLabelKey key(label);
39  MplsLabel *mpls = static_cast<MplsLabel *>(table->
40  FindActiveEntry(&key));
41  if (mpls && mpls->ChangeNH(nh)) {
42  ret = true;
43  //Send notify of change
44  mpls->get_table_partition()->Notify(mpls);
45  }
46  }
47  return ret;
48 }
49 
50 //AgentPath
52  Path(), peer_(peer), nh_(NULL), label_(MplsTable::kInvalidLabel),
53  vxlan_id_(VxLanTable::kInvalidvxlan_id), dest_vn_list_(),
54  origin_vn_(""), sync_(false), force_policy_(false), sg_list_(),
55  tunnel_dest_(0), tunnel_bmap_(TunnelType::AllType()),
56  tunnel_type_(TunnelType::ComputeType(TunnelType::AllType())),
57  vrf_name_(""), gw_ip_(), unresolved_(true),
58  is_subnet_discard_(false), dependant_rt_(rt), path_preference_(),
59  local_ecmp_mpls_label_(rt), composite_nh_key_(NULL), subnet_service_ip_(),
60  arp_mac_(), arp_interface_(NULL), arp_valid_(false),
61  ecmp_suppressed_(false), is_local_(false), is_health_check_service_(false),
62  peer_sequence_number_(0), etree_leaf_(false), layer2_control_word_(false),
63  inactive_(false), copy_local_path_(false), parent_rt_(rt), dependent_table_(NULL) {
64 }
65 
67  clear_sg_list();
68 }
69 
70 uint32_t AgentPath::GetTunnelBmap() const {
72  if ((type == (1 << TunnelType::VXLAN)) && (vxlan_id_ != 0)) {
73  return (1 << TunnelType::VXLAN);
74  } else {
75  return tunnel_bmap_;
76  }
77 }
78 
79 uint32_t AgentPath::GetActiveLabel() const {
81  return vxlan_id_;
82  } else {
83  return label_;
84  }
85 }
86 
88  return nh_.get();
89 }
90 
91 const NextHop* AgentPath::ComputeNextHop(Agent *agent) const {
92  if (nh_) {
93  return nh_.get();
94  }
95 
96  if (unresolved_ == true) {
97  DiscardNH key;
98  return static_cast<NextHop *>
99  (agent->nexthop_table()->FindActiveEntry(&key));
100  }
101 
102  // Send back discard NH if dependant_rt_ is not set
103  if (dependant_rt_.get() == NULL) {
104  DiscardNH key;
105  return static_cast<NextHop *>
106  (agent->nexthop_table()->FindActiveEntry(&key));
107  }
108 
109  //Indirect route's path, get direct route's NH
110  const NextHop *nh = dependant_rt_.get()->GetActiveNextHop();
111  if (nh == NULL) {
112  DiscardNH key;
113  return static_cast<NextHop *>
114  (agent->nexthop_table()->FindActiveEntry(&key));
115  }
116  return nh;
117 }
118 
119 bool AgentPath::ChangeNH(Agent *agent, NextHop *nh) {
120  // If NH is not found, point route to discard NH
121  bool ret = false;
122  if (nh == NULL) {
123  nh = agent->nexthop_table()->discard_nh();
124  }
125 
126  if (nh_ != nh) {
127  nh_ = nh;
128  if (nh && nh->GetType() == NextHop::TUNNEL) {
129  TunnelNH *tunnel_nh = static_cast<TunnelNH *>(nh);
130  tunnel_dest_ = *tunnel_nh->GetDip();
131  }
132  ret = true;
133  }
134 
135  if (peer_ && (peer_->GetType() == Peer::ECMP_PEER) &&
137  if (RebakeLabel(agent->mpls_table(), label_, nh))
138  ret = true;
139  }
140 
141  if (PostChangeNH(agent, nh)) {
142  ret = true;
143  }
144  return ret;
145 }
146 
148  return false;
149 }
150 
152  if (nh_->GetType() != NextHop::COMPOSITE){
153  return false;
154  }
155 
156  Agent *agent =
157  static_cast<AgentRouteTable *>(sync_route->get_table())->agent();
158  CompositeNH *cnh = static_cast<CompositeNH *>(nh_.get());
159 
160  //Compute new tunnel type
161  TunnelType::Type new_tunnel_type;
162  //Only MPLS types are supported for multicast
163  if ((sync_route->is_multicast()) && (peer_->GetType() ==
165  new_tunnel_type = TunnelType::ComputeType(TunnelType::MplsType());
166  if (new_tunnel_type == TunnelType::VXLAN) {
167  new_tunnel_type = TunnelType::MPLS_GRE;
168  }
169  } else {
170  new_tunnel_type = TunnelType::ComputeType(tunnel_bmap_);
171  }
172 
173  CompositeNH *new_composite_nh = NULL;
174  new_composite_nh = cnh->ChangeTunnelType(agent, new_tunnel_type);
175  if (ChangeNH(agent, new_composite_nh)) {
176  //Update composite NH key list to reflect new type
177  if (composite_nh_key_)
178  composite_nh_key_->ChangeTunnelType(new_tunnel_type);
179  return true;
180  }
181  return false;
182 }
183 
185  bool ret = false;
186  if (nh_.get() == NULL || nh_->GetType() != NextHop::INTERFACE) {
187  return ret;
188  }
189 
190  const InterfaceNH *intf_nh = static_cast<const InterfaceNH *>(nh_.get());
191  if (intf_nh->GetInterface()->type() != Interface::VM_INTERFACE) {
192  return ret;
193  }
194 
195  const VmInterface *vm_port =
196  static_cast<const VmInterface *>(intf_nh->GetInterface());
197 
198  bool policy = vm_port->policy_enabled();
199  if (force_policy_) {
200  policy = true;
201  }
202 
203  NextHop *nh = NULL;
204  if (intf_nh->PolicyEnabled() != policy) {
205  //Make path point to policy enabled interface
207  vm_port->GetUuid(),
208  vm_port->name()),
209  policy, intf_nh->GetFlags(),
210  intf_nh->GetDMac());
211  nh = static_cast<NextHop *>
212  (agent->nexthop_table()->FindActiveEntry(&key));
213  // If NH is not found, point route to discard NH
214  if (nh == NULL) {
215  LOG(DEBUG, "Interface NH for <"
216  << boost::lexical_cast<std::string>(vm_port->GetUuid())
217  << " : policy = " << policy);
218  nh = agent->nexthop_table()->discard_nh();
219  }
220  if (ChangeNH(agent, nh) == true) {
221  ret = true;
222  }
223  }
224 
225  return ret;
226 }
227 
228 bool AgentPath::UpdateTunnelType(Agent *agent, const AgentRoute *sync_route) {
229  //Return if there is no change in tunnel type for non Composite NH.
230  //For composite NH component needs to be traversed.
231  // if tunnel type is MPLS over MPLS, transport tunnel
232  // type might be changed ( mpls over gre or mpls over udp)
233  // so check nh transport tunnel type and trigger update if there
234  // is any change
237  (nh_.get() && nh_.get()->GetType() != NextHop::COMPOSITE)) {
238  return false;
239  }
240 
245  }
247  const TunnelNH *tunnel_nh = static_cast<const TunnelNH*>(nh_.get());
248  if (nh_.get() && nh_->GetType() == NextHop::TUNNEL) {
249  if (tunnel_nh->GetTunnelType().GetType() == TunnelType::MPLS_OVER_MPLS) {
250  const LabelledTunnelNH *label_tunnel_nh =
251  static_cast<const LabelledTunnelNH*>(nh_.get());
252  // check if transport tunnel type is changed
253  if (label_tunnel_nh->GetTransportTunnelType() ==
255  return false;
256  }
257  LabelledTunnelNHKey *tnh_key =
259  *(label_tunnel_nh->GetSip()),
260  *(label_tunnel_nh->GetDip()),
261  false, tunnel_type_,
262  label_tunnel_nh->rewrite_dmac(),
263  label_tunnel_nh->GetTransportLabel());
264  nh_req.key.reset(tnh_key);
265  nh_req.data.reset(new TunnelNHData());
266  agent->nexthop_table()->Process(nh_req);
267 
268  LabelledTunnelNHKey nh_key(agent->fabric_vrf_name(),
269  *(label_tunnel_nh->GetSip()),
270  tunnel_dest_, false, tunnel_type_,
271  label_tunnel_nh->rewrite_dmac(),
272  label_tunnel_nh->GetTransportLabel());
273  NextHop *nh = static_cast<NextHop *>
274  (agent->nexthop_table()->FindActiveEntry(&nh_key));
275  ChangeNH(agent, nh);
276  } else {
277 
278  TunnelNHKey *tnh_key =
279  new TunnelNHKey(agent->fabric_vrf_name(), *(tunnel_nh->GetSip()),
280  tunnel_dest_, false, tunnel_type_);
281  nh_req.key.reset(tnh_key);
282  nh_req.data.reset(new TunnelNHData());
283  agent->nexthop_table()->Process(nh_req);
284 
285  TunnelNHKey nh_key(agent->fabric_vrf_name(), *(tunnel_nh->GetSip()),
286  tunnel_dest_, false, tunnel_type_);
287  NextHop *nh = static_cast<NextHop *>
288  (agent->nexthop_table()->FindActiveEntry(&nh_key));
289  ChangeNH(agent, nh);
290  }
291  }
292 
293  if (nh_.get() && nh_->GetType() == NextHop::COMPOSITE) {
294  RebakeAllTunnelNHinCompositeNH(sync_route);
295  }
296  return true;
297 }
298 
300 {
301  if (nh_ == nh) {
302  return;
303  }
304  // change NH ,
305  // assumptions here is that composite nh grid order would be different
306  // but elements would be same , so importing previous active nh
307  // would make sure the holes are already set in proper order
308  // ex: previous nh order A,B, C, new path nh order would be BCA
309  // ex2: previous nh order _,B,C, new path nh order is just B,C
310  ChangeNH(agent, nh);
311  // will there be a race condition while removing the active path,
312  // adding new component nh?
313  // this can be handled by calling reorder composite nh method
314  if (composite_nh_key_ == NULL) {
315  return;
316  }
317  boost::scoped_ptr<CompositeNHKey> composite_nh_key(
318  composite_nh_key_->Clone());
319  bool comp_nh_policy = false;
320  //TODO: optimize here , compare compositenh_key from path and nh?
321  ReorderCompositeNH(agent, composite_nh_key.get(), comp_nh_policy, NULL);
322  composite_nh_key->SetPolicy(comp_nh_policy);
323  ChangeCompositeNH(agent, composite_nh_key.get());
324 
325 }
326 
327 bool AgentPath::ResolveGwNextHops(Agent *agent, const AgentRoute *sync_route) {
328 
330  return false;
331  }
332  if (ecmp_member_list_.size() == 0) {
333  return false;
334  }
335  NextHop *nh = NULL;
336  InetUnicastAgentRouteTable *table = NULL;
337  table = static_cast<InetUnicastAgentRouteTable *>
338  (agent->fabric_inet4_mpls_table());
339  assert(table != NULL);
340  //if ecmp member list size is one then it is non ecmp route sync
341  if (ecmp_member_list_.size() == 1) {
343  InetUnicastRouteEntry *uc_rt = table->FindRoute(member->GetGwIpAddr());
344  const NextHop *anh;
345  if (uc_rt == NULL || uc_rt->prefix_length() == 0 || (anh = uc_rt->GetActiveNextHop()) == NULL) {
346  set_unresolved(true);
347  member->UpdateDependentRoute(NULL);
348  member->SetUnresolved(true);
349  } else {
350  set_unresolved(false);
352  DBEntryBase::KeyPtr key =
353  anh->GetDBRequestKey();
354  const NextHopKey *nh_key =
355  static_cast<const NextHopKey*>(key.get());
356  nh = static_cast<NextHop *>(agent->nexthop_table()->
357  FindActiveEntry(nh_key));
358  assert(nh !=NULL);
359  //Reset to new gateway route, no nexthop for indirect route
360  member->UpdateDependentRoute(uc_rt);
361  member->SetUnresolved(false);
362  set_nexthop(NULL);
363  }
364  if (nh != NULL) {
365  ChangeNH(agent, nh);
366  }
367  } else {
368  // this flag is set if atleast one member is unresolved
369  bool path_unresolved = false;
370  // if this flag is false , then
371  // composite NH is created with one compoenent NH as discard
372  // and avoid reording teh existing composite NH
373  // this flag is set to true if atleast one member is resolved
374  bool is_ecmp_member_resolved = false;
375  ComponentNHKeyList comp_nh_list;
376  bool comp_nh_policy = false;
377  AgentPathEcmpComponentPtrList::const_iterator ecmp_member_it =
378  ecmp_member_list_.begin();
379  while (ecmp_member_it != ecmp_member_list_.end()) {
380  InetUnicastRouteEntry *uc_rt =
381  table->FindRoute((*ecmp_member_it)->GetGwIpAddr());
382  const NextHop *anh;
383  if (uc_rt == NULL || uc_rt->prefix_length() == 0 || (anh = uc_rt->GetActiveNextHop()) == NULL) {
384  (*ecmp_member_it)->UpdateDependentRoute(NULL);
385  (*ecmp_member_it)->SetUnresolved(true);
386  if (!path_unresolved) {
387  path_unresolved = true;
388  DBEntryBase::KeyPtr key =
390  NextHopKey *nh_key =
391  static_cast<NextHopKey *>(key.release());
392  std::unique_ptr<const NextHopKey> nh_key_ptr(nh_key);
393  ComponentNHKeyPtr component_nh_key(new ComponentNHKey(
394  (*ecmp_member_it)->GetLabel(),
395  std::move(nh_key_ptr)));
396  comp_nh_list.push_back(component_nh_key);
397  }
398  } else {
399  is_ecmp_member_resolved = true;
400  DBEntryBase::KeyPtr key =
401  anh->GetDBRequestKey();
402  NextHopKey *nh_key = static_cast<NextHopKey *>(key.release());
403  if (nh_key->GetType() != NextHop::COMPOSITE) {
404  //By default all component members of composite NH
405  //will be policy disabled, except for component NH
406  //of type composite
407  nh_key->SetPolicy(false);
408  }
409  std::unique_ptr<const NextHopKey> nh_key_ptr(nh_key);
410  ComponentNHKeyPtr component_nh_key(new
411  ComponentNHKey((*ecmp_member_it)->GetLabel(),
412  std::move(nh_key_ptr)));
413  comp_nh_list.push_back(component_nh_key);
414  //Reset to new gateway route, no nexthop for indirect route
415  (*ecmp_member_it)->UpdateDependentRoute(uc_rt);
416  (*ecmp_member_it)->SetUnresolved(false);
417  }
418  ecmp_member_it++;
419  }
421  nh_req.key.reset(new CompositeNHKey(Composite::ECMP, comp_nh_policy,
422  comp_nh_list, vrf_name_));
423  nh_req.data.reset(new CompositeNHData());
424  CompositeNHKey *comp_key =
425  static_cast<CompositeNHKey *>(nh_req.key.get());
426  bool new_comp_nh_policy = false;
427  if ((is_ecmp_member_resolved == false) ||
428  ReorderCompositeNH(agent, comp_key, new_comp_nh_policy,
429  sync_route->FindLocalVmPortPath())) {
430  comp_key->SetPolicy(new_comp_nh_policy);
431  ChangeCompositeNH(agent, comp_key);
432  }
433 
434  set_unresolved(path_unresolved);
435  }
436 
437 
438  return true;
439 }
440 bool AgentPath::Sync(AgentRoute *sync_route) {
441  bool ret = false;
442  bool unresolved = false;
443 
444  Agent *agent = static_cast<AgentRouteTable *>
445  (sync_route->get_table())->agent();
446 
447  // Check if there is change in policy on the interface
448  // If yes update the path to point to policy enabled NH
449  if (UpdateNHPolicy(agent)) {
450  ret = true;
451  }
452  if (ResolveGwNextHops(agent, sync_route)) {
453  return true;
454  }
455  //Handle tunnel type change
456  if (UpdateTunnelType(agent, sync_route)) {
457  ret = true;
458  }
459 
460  //Check if there was a change in local ecmp composite nexthop
461  if (nh_ && nh_->GetType() == NextHop::COMPOSITE &&
462  composite_nh_key_.get() != NULL && (copy_local_path_ ||
463  local_ecmp_mpls_label_.get() != NULL)) {
464  boost::scoped_ptr<CompositeNHKey> composite_nh_key(composite_nh_key_->Clone());
465  bool comp_nh_policy = false;
466  if (ReorderCompositeNH(agent, composite_nh_key.get(), comp_nh_policy,
467  sync_route->FindLocalVmPortPath())) {
468  composite_nh_key->SetPolicy(comp_nh_policy);
469  if (ChangeCompositeNH(agent, composite_nh_key.get())) {
470  ret = true;
471  }
472  }
473  }
474 
475  if (nh_ && nh_->GetType() == NextHop::ARP) {
476  if (CopyArpData()) {
477  ret = true;
478  }
479  }
480 
481  if (vrf_name_ == Agent::NullString()) {
482  return ret;
483  }
484 
485  // check dependant route change
486  // this is needed only for inet routes
487  InetUnicastAgentRouteTable *table = NULL;
488  table = dynamic_cast<InetUnicastAgentRouteTable *>
489  (sync_route->get_table());
490  if (table == NULL) {
491  return ret;
492  }
493 
494  InetUnicastRouteEntry *rt = NULL;
495 
496  rt = table->FindRoute(gw_ip_);
497  if (rt == sync_route) {
498  rt = NULL;
499  }
500  const NextHop *anh;
501  if (rt == NULL || rt->prefix_length() == 0) {
502  if (agent->params()->subnet_hosts_resolvable() == false &&
503  agent->fabric_vrf_name() == vrf_name_) {
504  unresolved = false;
505  assert(gw_ip_.is_v4());
506  table->AddArpReq(vrf_name_, gw_ip_.to_v4(), vrf_name_,
507  agent->vhost_interface(), false,
509  } else {
510  unresolved = true;
511  }
512  } else if ((anh = rt->GetActiveNextHop()) == NULL) {
513  if (agent->params()->subnet_hosts_resolvable() == false &&
514  agent->fabric_vrf_name() == vrf_name_) {
515  unresolved = false;
516  assert(gw_ip_.is_v4());
517  table->AddArpReq(vrf_name_, gw_ip_.to_v4(), vrf_name_,
518  agent->vhost_interface(), false,
520  } else {
521  unresolved = true;
522  }
523  } else if (anh->GetType() == NextHop::RESOLVE) {
524  const ResolveNH *nh =
525  static_cast<const ResolveNH *>(anh);
526  std::string nexthop_vrf = nh->get_interface()->vrf()->GetName();
527  if (nh->get_interface()->vrf()->forwarding_vrf()) {
528  nexthop_vrf = nh->get_interface()->vrf()->forwarding_vrf()->GetName();
529  }
530 
531  assert(gw_ip_.is_v4());
532  table->AddArpReq(vrf_name_, gw_ip_.to_v4(), nexthop_vrf,
535  unresolved = true;
536  } else {
537  unresolved = false;
538  }
539 
540  if (unresolved_ != unresolved) {
542  ret = true;
543  }
544 
545  // Reset to new gateway route, no nexthop for indirect route
546  if (dependant_rt_.get() != rt) {
547  dependant_rt_.reset(rt);
548  ret = true;
549  if (rt) {
550  TunnelType::TypeBmap dep_bmap =
552  if (tunnel_bmap_ & 1 << TunnelType::NATIVE) {
553  dep_bmap |= (1 << TunnelType::NATIVE);
554  }
555  set_tunnel_bmap(dep_bmap);
556  }
557  }
558  return ret;
559 }
560 
561 bool AgentPath::IsLess(const AgentPath &r_path) const {
562  if (peer()->GetType() == r_path.peer()->GetType()) {
563  if (path_preference() != r_path.path_preference()) {
564  //If right path has lesser preference, then
565  //it should be after the current entry
566  //Hence the reverse check
567  return (r_path.path_preference() < path_preference());
568  }
569  }
570 
571  return peer()->IsLess(r_path.peer());
572 }
573 
575  return this;
576 }
577 
579  nh_ = nh;
580 }
581 
583  bool ret = false;
584  if (nh_ && nh_->GetType() == NextHop::ARP) {
585  const ArpNH *arp_nh = static_cast<const ArpNH *>(nh_.get());
586  if (arp_mac() != arp_nh->GetMac()) {
587  set_arp_mac(arp_nh->GetMac());
588  ret = true;
589  }
590 
591  if (arp_interface() != arp_nh->GetInterface()) {
592  set_arp_interface(arp_nh->GetInterface());
593  ret = true;
594  }
595 
596  if (arp_valid() != arp_nh->IsValid()) {
597  set_arp_valid(arp_nh->IsValid());
598  ret = true;
599  }
600  }
601  return ret;
602 }
603 
605  bool ret = false;
606  if (nh_ && nh_->GetType() == NextHop::NDP) {
607  const NdpNH *ndp_nh = static_cast<const NdpNH *>(nh_.get());
608  if (arp_mac() != ndp_nh->GetMac()) {
609  set_arp_mac(ndp_nh->GetMac());
610  ret = true;
611  }
612 
613  if (arp_interface() != ndp_nh->GetInterface()) {
614  set_arp_interface(ndp_nh->GetInterface());
615  ret = true;
616  }
617 
618  if (arp_valid() != ndp_nh->IsValid()) {
619  set_arp_valid(ndp_nh->IsValid());
620  ret = true;
621  }
622  }
623  return ret;
624 }
625 
627  const IpAddress &ip_addr,
628  uint32_t ethernet_tag,
629  const std::string &parent) :
630  AgentPath(evpn_peer, NULL),
631  ip_addr_(ip_addr), ethernet_tag_(ethernet_tag),
632  parent_(parent){
633 }
634 
635 bool EvpnDerivedPath::IsLess(const AgentPath &r_path) const {
636  const EvpnDerivedPath *r_evpn_path =
637  dynamic_cast<const EvpnDerivedPath *>(&r_path);
638  if (r_evpn_path != NULL) {
639  if (r_evpn_path->ip_addr() != ip_addr_) {
640  return (ip_addr_ < r_evpn_path->ip_addr());
641  }
642  }
643 
644  return peer()->IsLess(r_path.peer());
645 }
646 
648  return nexthop();
649 }
650 
652  AgentRouteData(AgentRouteData::ADD_DEL_CHANGE,
653  evpn_rt->is_multicast(), 0),
654  ethernet_tag_(evpn_rt->ethernet_tag()), ip_addr_(evpn_rt->prefix_address()),
655  reference_path_(evpn_rt->GetActivePath()), ecmp_suppressed_(false) {
656  // For debuging add peer of active path in parent as well
657  std::stringstream s;
658  s << evpn_rt->ToString();
659  s << " ";
661  s << reference_path_->peer()->GetName();
662  parent_ = s.str();
663 }
664 
666  AgentRoute *rt) const {
667  const EvpnPeer *evpn_peer = dynamic_cast<const EvpnPeer *>(peer);
668  assert(evpn_peer != NULL);
669  return (new EvpnDerivedPath(evpn_peer, ip_addr_, ethernet_tag_,
670  parent_));
671 }
672 
674  const AgentRoute *rt) {
675  bool ret = false;
676  EvpnDerivedPath *evpn_path = dynamic_cast<EvpnDerivedPath *>(path);
677  assert(evpn_path != NULL);
678 
680  uint32_t label = reference_path_->label();
681  if (evpn_path->label() != label) {
682  evpn_path->set_label(label);
683  ret = true;
684  }
685 
686  uint32_t vxlan_id = reference_path_->vxlan_id();
687  if (evpn_path->vxlan_id() != vxlan_id) {
688  evpn_path->set_vxlan_id(vxlan_id);
689  ret = true;
690  }
691 
692  uint32_t tunnel_bmap = reference_path_->tunnel_bmap();
693  if (evpn_path->tunnel_bmap() != tunnel_bmap) {
694  evpn_path->set_tunnel_bmap(tunnel_bmap);
695  ret = true;
696  }
697 
699  if (evpn_path->tunnel_type() != tunnel_type) {
700  evpn_path->set_tunnel_type(tunnel_type);
701  ret = true;
702  }
703 
705  if (evpn_path->path_preference() != pref) {
706  // Take path preference from parent path
707  evpn_path->set_path_preference(pref);
708  ret = true;
709  }
710 
711  if (evpn_path->nexthop() !=
713  evpn_path->set_nexthop(reference_path_->nexthop());
714  ret = true;
715  }
716 
717  const SecurityGroupList &sg_list = reference_path_->sg_list();
718  if (evpn_path->sg_list() != sg_list) {
719  evpn_path->set_sg_list(sg_list);
720  ret = true;
721  }
722 
723  const TagList &tag_list = reference_path_->tag_list();
724  if (evpn_path->tag_list() != tag_list) {
725  evpn_path->set_tag_list(tag_list);
726  ret = true;
727  }
728 
729  const VnListType &dest_vn_list = reference_path_->dest_vn_list();
730  if (evpn_path->dest_vn_list() != dest_vn_list) {
731  evpn_path->set_dest_vn_list(dest_vn_list);
732  ret = true;
733  }
734 
735  if (evpn_path->ecmp_suppressed() != ecmp_suppressed_) {
737  ret = true;
738  }
739 
740  if (evpn_path->etree_leaf() != reference_path_->etree_leaf()) {
742  ret = true;
743  }
744 
745  if (evpn_path->ResyncControlWord(rt)) {
746  ret = true;
747  }
748 
749  path->set_unresolved(false);
750 
751  return ret;
752 }
753 
755  const AgentRoute *rt) const {
756  const EvpnDerivedPath *evpn_path =
757  dynamic_cast<const EvpnDerivedPath *>(path);
758  assert(evpn_path != NULL);
759 
760  if (evpn_path->ethernet_tag() != ethernet_tag())
761  return false;
762 
763  return (evpn_path->ip_addr() == ip_addr());
764 }
765 
767  const AgentRoute *rt) {
768  bool ret = false;
769  NextHop *nh = NULL;
770 
772  agent->pkt_interface_mac());
773  nh = static_cast<NextHop *>(agent->nexthop_table()->FindActiveEntry(&key));
774  VnListType dest_vn_list;
775  dest_vn_list.insert(dest_vn_name_);
776  if (path->dest_vn_list() != dest_vn_list) {
777  path->set_dest_vn_list(dest_vn_list);
778  ret = true;
779  }
780 
781  path->set_unresolved(false);
782  if (path->ChangeNH(agent, nh) == true)
783  ret = true;
784 
785  return ret;
786 }
787 
789  InetUnicastRouteEntry *uc_rt =
790  static_cast<InetUnicastRouteEntry *>(rt);
791  AgentRouteTable *table = static_cast<AgentRouteTable *>(rt->get_table());
792  if ((table->GetTableType() != Agent::INET4_UNICAST) &&
793  (table->GetTableType() != Agent::INET6_UNICAST))
794  return false;
795 
796  return uc_rt->UpdateRouteFlags(false, false, true);
797 }
798 
800  const AgentRoute *rt) {
801  bool ret = false;
802 
803  path->set_unresolved(false);
804 
805  VnListType dest_vn_list;
806  dest_vn_list.insert(dest_vn_name_);
807  if (path->dest_vn_list() != dest_vn_list) {
808  path->set_dest_vn_list(dest_vn_list);
809  ret = true;
810  }
811 
812  if (path->label() != mpls_label_) {
813  path->set_label(mpls_label_);
814  ret = true;
815  }
816 
817  if (path->vxlan_id() != vxlan_id_) {
818  path->set_vxlan_id(vxlan_id_);
819  ret = true;
820  }
821 
824  ret = true;
825  }
826 
827  if (path->peer() && path->peer()->GetType() == Peer::BGP_PEER) {
828  //Copy entire path preference for BGP peer path,
829  //since allowed-address pair config doesn't modify
830  //preference on BGP path
831  if (path->path_preference() != path_preference_) {
833  ret = true;
834  }
835  }
836 
837  if (path->ChangeNH(agent, agent->nexthop_table()->l2_receive_nh()) == true)
838  ret = true;
839 
840  return ret;
841 }
842 
844  AgentRouteTable *table = static_cast<AgentRouteTable *>(rt->get_table());
845  if ((table->GetTableType() != Agent::INET4_UNICAST) &&
846  (table->GetTableType() != Agent::INET6_UNICAST))
847  return false;
848 
849  InetUnicastRouteEntry *uc_rt = static_cast<InetUnicastRouteEntry *>(rt);
850 
851  return uc_rt->UpdateRouteFlags(false, false, true);
852 }
853 
855  const AgentRoute *rt) {
856  bool ret = false;
857  NextHop *nh = NULL;
859  agent->pkt_interface_mac());
860  nh = static_cast<NextHop *>(agent->nexthop_table()->FindActiveEntry(&key));
861  if (path->dest_vn_list() != dest_vn_list_) {
863  ret = true;
864  }
865 
866  if (path->label() != label_) {
867  path->set_label(label_);
868  ret = true;
869  }
870 
873  if (tunnel_type != path->tunnel_type()) {
874  path->set_tunnel_type(tunnel_type);
875  ret = true;
876  }
877 
878  path->set_unresolved(false);
879  if (path->ChangeNH(agent, nh) == true)
880  ret = true;
881 
882  return ret;
883 }
884 
886  const AgentRoute *rt) {
887  bool ret = false;
888 
889  VnListType dest_vn_list;
890  dest_vn_list.insert(vn_);
891  if (path->dest_vn_list() != dest_vn_list) {
892  path->set_dest_vn_list(dest_vn_list);
893  ret = true;
894  }
895 
896  NextHop *nh = agent->nexthop_table()->discard_nh();
897  path->set_unresolved(false);
898  if (path->ChangeNH(agent, nh) == true) {
899  ret = true;
900  }
901 
902  return ret;
903 }
904 
906  const AgentRoute *rt) {
907  bool ret = false;
908  NextHop *nh = NULL;
909  SecurityGroupList path_sg_list;
910  TagList path_tag_list;
911  CommunityList path_communities;
912 
913  //TODO Based on key table type pick up interface
915  VmInterface *vm_port = static_cast<VmInterface *>
916  (agent->interface_table()->FindActiveEntry(&intf_key));
917 
918  bool policy = false;
919  if (vm_port) {
920  // Use policy based NH if policy enabled on interface
921  if (vm_port->policy_enabled()) {
922  policy = true;
923  ret = true;
924  }
925  }
926 
927  if (native_encap_) {
929  }
930 
931  if (tunnel_bmap_ != path->tunnel_bmap()) {
933  ret = true;
934  }
935 
937  if (new_tunnel_type == TunnelType::VXLAN &&
939  new_tunnel_type = TunnelType::ComputeType(TunnelType::MplsType());
940  }
941 
942  if (path->tunnel_type() != new_tunnel_type) {
943  path->set_tunnel_type(new_tunnel_type);
944  ret = true;
945  }
946 
947  // If policy force-enabled in request, enable policy
949  if (force_policy_) {
950  policy = true;
951  }
952 
954  if (vm_port) {
955  mac = vm_port->vm_mac();
956  const InetUnicastRouteEntry *ip_rt =
957  dynamic_cast<const InetUnicastRouteEntry *>(rt);
958  if (ip_rt) {
959  mac = vm_port->GetIpMac(ip_rt->prefix_address(), ip_rt->prefix_length());
960  }
961  const EvpnRouteEntry *evpn_rt =
962  dynamic_cast<const EvpnRouteEntry *>(rt);
963  if (evpn_rt && vm_port->mac_ip_learning_enable()) {
964  mac = evpn_rt->mac();
965  }
966  }
967  if (vm_port && vm_port->mac_ip_learning_enable()) {
968  MplsLabel *mpls = agent->mpls_table()->FindMplsLabel(mpls_label_);
969  if (mpls != NULL) {
970  const InterfaceNH *label_nh = dynamic_cast<const InterfaceNH *>(mpls->nexthop());
971  if (label_nh) {
972  const MacAddress nh_dmac = label_nh->GetDMac();
973  if (mac == vm_port->vm_mac() && nh_dmac != vm_port->vm_mac()) {
974  mac = nh_dmac;
975  }
976  }
977  }
978  }
979  InterfaceNHKey key(intf_.Clone(), policy, flags_, mac);
980  nh = static_cast<NextHop *>(agent->nexthop_table()->FindActiveEntry(&key));
981 
982  if (path->label() != mpls_label_) {
983  path->set_label(mpls_label_);
984  ret = true;
985  }
986 
987  if (path->vxlan_id() != vxlan_id_) {
988  path->set_vxlan_id(vxlan_id_);
989  ret = true;
990  }
991 
992  if (path->dest_vn_list() != dest_vn_list_) {
994  ret = true;
995  }
996 
997  path_sg_list = path->sg_list();
998  if (path_sg_list != sg_list_) {
999  path->set_sg_list(sg_list_);
1000  ret = true;
1001  }
1002 
1003  path_tag_list = path->tag_list();
1004  if (path_tag_list != tag_list_) {
1005  path->set_tag_list(tag_list_);
1006  ret = true;
1007  }
1008 
1009  path_communities = path->communities();
1010  if (path_communities != communities_) {
1012  ret = true;
1013  }
1014 
1015  //Priority and sequence no of path are updated from path
1016  //preference state machine
1017  //Path preference value enqueued here would be copied
1018  //only if
1019  //1> ecmp field is set to true, meaning path would be
1020  // active-active
1021  //2> static preference is set, meaning external entity
1022  // would specify the preference of this path(ex LBaaS)
1023  //3> Change in priority when static preference is set
1025  path->peer() == agent->fabric_rt_export_peer()) {
1027  ret = true;
1028  }
1029 
1030  if (path->peer() && path->peer()->GetType() == Peer::BGP_PEER) {
1031  //Copy entire path preference for BGP peer path,
1032  //since allowed-address pair config doesn't modify
1033  //preference on BGP path
1034  if (path->path_preference() != path_preference_) {
1036  ret = true;
1037  }
1038  }
1039 
1040  // When BGP path was added, the policy flag in BGP path was based on
1041  // interface config at that instance. If the policy flag changes in
1042  // path for "Local Peer", we should change policy flag on BGP peer
1043  // also. Check if policy has changed and enable SYNC of all path in
1044  // this case
1045  // Ideally his is needed only for LocalPath. But, having code for all
1046  // paths does not have any problem
1047  bool old_policy = false;
1048  bool new_policy = false;
1049  if (path->ComputeNextHop(agent) && path->ComputeNextHop(agent)->PolicyEnabled())
1050  old_policy = true;
1051  if (nh && nh->PolicyEnabled())
1052  new_policy = true;
1053  if (old_policy != new_policy) {
1054  sync_route_ = true;
1055  }
1056 
1057  if (path->subnet_service_ip() != subnet_service_ip_) {
1059  ret = true;
1060  }
1061 
1062  path->set_unresolved(false);
1063  path->SyncRoute(sync_route_);
1064 
1065  if (ecmp_load_balance_ != path->ecmp_load_balance()) {
1067  ret = true;
1068  }
1069 
1070  if (path->ChangeNH(agent, nh) == true)
1071  ret = true;
1072 
1073  if (is_local_ != path->is_local()) {
1074  path->set_is_local(is_local_);
1075  ret = true;
1076  }
1077 
1080  ret = true;
1081  }
1082 
1083  if (etree_leaf_ != path->etree_leaf()) {
1084  path->set_etree_leaf(etree_leaf_);
1085  ret = true;
1086  }
1087 
1088  if (native_vrf_id_ != path->native_vrf_id()) {
1090  ret = true;
1091  }
1093 
1094  return ret;
1095 }
1096 
1098  AgentRouteTable *table = static_cast<AgentRouteTable *>(rt->get_table());
1099  if ((table->GetTableType() != Agent::INET4_UNICAST) &&
1100  (table->GetTableType() != Agent::INET6_UNICAST)) {
1101  return false;
1102  }
1103 
1104  /* Route Reflect will not have the field populated and we do not
1105  * want to override the route type for reflected routes */
1106  if (intf_route_type().empty()) {
1107  return false;
1108  }
1109 
1110  if (intf_route_type().compare(rt->intf_route_type()) != 0) {
1112  return true;
1113  }
1114 
1115  return false;
1116 }
1117 
1118 
1120  const AgentRoute *rt) {
1121  bool ret = false;
1122  NextHop *nh = NULL;
1123  SecurityGroupList path_sg_list;
1124  TagList path_tag_list;
1125  CommunityList path_communities;
1126 
1127  VrfEntry *vrf = static_cast<VrfEntry *>
1128  (agent->vrf_table()->FindActiveEntry(&vrf_key_));
1129 
1130  if (vrf != NULL) {
1131  //Create PBB NH
1133  nh_req.key.reset(new PBBNHKey(vrf_key_.name_, dmac_, isid_));
1134  nh_req.data.reset(new PBBNHData());
1135  agent->nexthop_table()->Process(nh_req);
1136 
1137  PBBNHKey pbb_nh_key(vrf_key_.name_, dmac_, isid_);
1138  nh = static_cast<NextHop *>(agent->nexthop_table()->
1139  FindActiveEntry(&pbb_nh_key));
1140  }
1141 
1142  if (path->dest_vn_list() != dest_vn_list_) {
1144  ret = true;
1145  }
1146 
1147  path_sg_list = path->sg_list();
1148  if (path_sg_list != sg_list_) {
1149  path->set_sg_list(sg_list_);
1150  ret = true;
1151  }
1152 
1153  path_tag_list = path->tag_list();
1154  if (path_tag_list != tag_list_) {
1155  path->set_tag_list(tag_list_);
1156  ret = true;
1157  }
1158 
1159  //Copy over entire path preference structure, whenever there is a
1160 
1161  if (path->ChangeNH(agent, nh) == true) {
1162  ret = true;
1163  }
1164 
1165  path->set_unresolved(false);
1166  return ret;
1167 }
1168 
1170  const AgentRoute *rt) {
1171  bool ret = false;
1172  NextHop *nh = NULL;
1173  SecurityGroupList path_sg_list;
1174  TagList path_tag_list;
1175 
1176  assert(intf_.type_ == Interface::VM_INTERFACE);
1177  VlanNHKey key(intf_.uuid_, tag_);
1178 
1179  nh = static_cast<NextHop *>(agent->nexthop_table()->FindActiveEntry(&key));
1180  if (nh) {
1181  assert(nh->GetType() == NextHop::VLAN);
1182  }
1183 
1184  if (path->label() != label_) {
1185  path->set_label(label_);
1186  ret = true;
1187  }
1188 
1189  if (path->dest_vn_list() != dest_vn_list_) {
1191  ret = true;
1192  }
1193 
1194  path_sg_list = path->sg_list();
1195  if (path_sg_list != sg_list_) {
1196  path->set_sg_list(sg_list_);
1197  ret = true;
1198  }
1199 
1200  path_tag_list = path->tag_list();
1201  if (path_tag_list != tag_list_) {
1202  path->set_tag_list(tag_list_);
1203  ret = true;
1204  }
1205 
1206  //Copy over entire path preference structure, whenever there is a
1207 
1208  //Copy over entire path preference structure, whenever there is a
1209  //transition from active-active to active-backup struture
1212  ret = true;
1213  }
1214 
1217  if (tunnel_type != path->tunnel_type()) {
1218  path->set_tunnel_type(tunnel_type);
1219  ret = true;
1220  }
1221 
1222  path->set_unresolved(false);
1223  if (path->ChangeNH(agent, nh) == true) {
1224  ret = true;
1225  }
1226 
1227  return ret;
1228 }
1229 
1231  const AgentRoute *rt) {
1232  bool ret = false;
1233  NextHop *nh = NULL;
1234  ResolveNHKey key(intf_key_.get(), policy_);
1235 
1236  nh = static_cast<NextHop *>(agent->nexthop_table()->FindActiveEntry(&key));
1237  path->set_unresolved(false);
1238 
1239  VnListType dest_vn_list;
1240  dest_vn_list.insert(dest_vn_name_);
1241  if (path->dest_vn_list() != dest_vn_list) {
1242  path->set_dest_vn_list(dest_vn_list);
1243  ret = true;
1244  }
1245 
1246  if (path->label() != label_) {
1247  path->set_label(label_);
1248  ret = true;
1249  }
1250 
1251  if (path->sg_list() != path_sg_list_) {
1252  path->set_sg_list(path_sg_list_);
1253  ret = true;
1254  }
1255 
1256  //By default resolve route on gateway interface
1257  //is supported with MPLSoGRE or MplsoUdp port
1259  TunnelType::Type new_tunnel_type =
1261  if (path->tunnel_type() != new_tunnel_type) {
1262  path->set_tunnel_type(new_tunnel_type);
1263  }
1264 
1265  if (path->ChangeNH(agent, nh) == true)
1266  ret = true;
1267 
1268  return ret;
1269 }
1270 
1272  const AgentRoute *rt) {
1273  bool ret = false;
1274  NextHop *nh = NULL;
1275 
1276  //TODO check if it needs to know table type
1277  ReceiveNHKey key(intf_->Clone(), policy_);
1278  nh = static_cast<NextHop *>(agent->nexthop_table()->FindActiveEntry(&key));
1279  path->set_unresolved(false);
1280 
1281  VnListType dest_vn_list;
1282  dest_vn_list.insert(vn_);
1283  if (path->dest_vn_list() != dest_vn_list) {
1284  path->set_dest_vn_list(dest_vn_list);
1285  ret = true;
1286  }
1287 
1288  if (path->label() != label_) {
1289  path->set_label(label_);
1290  ret = true;
1291  }
1292 
1294 
1295  if (path->ChangeNH(agent, nh) == true)
1296  ret = true;
1297 
1298  return ret;
1299 }
1300 
1302  AgentRouteTable *table = static_cast<AgentRouteTable *>(rt->get_table());
1303  if ((table->GetTableType() != Agent::INET4_UNICAST) &&
1304  (table->GetTableType() != Agent::INET6_UNICAST))
1305  return false;
1306 
1307  InetUnicastRouteEntry *uc_rt =
1308  static_cast<InetUnicastRouteEntry *>(rt);
1309 
1310  // Receive route can be a /32 route of multicast-subnet route
1311  // proxy_arp_ is set only for host route. So, set ipam_host_route_ if
1312  // proxy_arp_ enabled
1313  return uc_rt->UpdateRouteFlags(false, ipam_host_route_, proxy_arp_);
1314 }
1315 
1317  AgentPath(peer, NULL), original_nh_(),
1318  evpn_label_(MplsTable::kInvalidLabel),
1319  fabric_label_(MplsTable::kInvalidLabel) {
1320 }
1321 
1323  bool ret = false;
1324  if (!peer())
1325  return false;
1326 
1327  if (peer()->GetType() != Peer::MULTICAST_PEER)
1328  return false;
1329 
1330  //Bake for label in path
1331  if (RebakeLabel(agent->mpls_table(), label(), nh))
1332  ret = true;
1333 
1334  //If path label is not same as evpn label, then rebake evpn label
1335  if ((label() != evpn_label_) &&
1336  RebakeLabel(agent->mpls_table(), evpn_label_, nh))
1337  ret = true;
1338 
1339  //If path label is not same as fmg label, then rebake fmg label
1340  if ((label() != fabric_label_) &&
1341  RebakeLabel(agent->mpls_table(), fabric_label_, nh))
1342  ret = true;
1343 
1344  return ret;
1345 }
1346 
1348  CompositeNH *cnh,
1349  const TsnElector *te) {
1350  ComponentNHKeyList new_component_nh_key_list;
1351  for (ComponentNHKeyList::const_iterator it =
1352  cnh->component_nh_key_list().begin();
1353  it != cnh->component_nh_key_list().end(); it++) {
1354  if ((*it) == NULL)
1355  continue;
1356  const TunnelNHKey *tunnel_nh_key =
1357  static_cast<const TunnelNHKey *>((*it)->nh_key());
1358  if (std::find(te->ManagedPhysicalDevices().begin(),
1359  te->ManagedPhysicalDevices().end(),
1360  tunnel_nh_key->dip().to_string()) !=
1361  te->ManagedPhysicalDevices().end()) {
1362  new_component_nh_key_list.push_back(*it);
1363  }
1364  }
1365  set_original_nh(cnh);
1367  nh_req.key.reset(new CompositeNHKey(Composite::EVPN, false,
1368  new_component_nh_key_list,
1369  cnh->vrf()->GetName()));
1370  nh_req.data.reset(new CompositeNHData(cnh->pbb_nh(),
1371  cnh->learning_enabled(), false));
1372  agent->nexthop_table()->Process(nh_req);
1373  NextHop *new_nh = static_cast<NextHop *>(agent->nexthop_table()->
1374  FindActiveEntry(nh_req.key.get()));
1375  assert(new_nh);
1376  return new_nh;
1377 }
1378 
1380  AgentRoute *rt) const {
1381  return (new MulticastRoutePath(peer));
1382 }
1383 
1385  const AgentRoute *rt) {
1386  bool ret = false;
1387  NextHop *nh = NULL;
1388 
1390  nh = static_cast<NextHop *>(agent->nexthop_table()->
1391  FindActiveEntry(composite_nh_req_.key.get()));
1392  assert(nh);
1393 
1395  MulticastRoutePath *multicast_path =
1396  dynamic_cast<MulticastRoutePath *>(path);
1397  multicast_path->set_original_nh(nh);
1398  const TsnElector *te = agent->oper_db()->tsn_elector();
1399  CompositeNH *cnh = dynamic_cast<CompositeNH *>(nh);
1400  if (cnh && (cnh->composite_nh_type() == Composite::EVPN)) {
1401  if (te->IsMaster() == false)
1402  path->set_inactive(true);
1403  nh = multicast_path->UpdateNH(agent, cnh, te);
1404  }
1405  }
1407  path,
1408  vn_name_,
1409  false,
1410  vxlan_id_,
1411  ((label_ == MplsTable::kInvalidLabel) ? path->label() : label_),
1412  tunnel_type_,
1413  nh, rt, ha_stale_);
1414  return ret;
1415 }
1416 
1418  AgentPath *path,
1419  const std::string &vn_name,
1420  bool unresolved,
1421  uint32_t vxlan_id,
1422  uint32_t label,
1423  uint32_t tunnel_type,
1424  NextHop *nh,
1425  const AgentRoute *rt,
1426  bool ha_stale) {
1427  VnListType dest_vn_list;
1428  dest_vn_list.insert(vn_name);
1429  path->set_dest_vn_list(dest_vn_list);
1430  path->set_unresolved(unresolved);
1431  path->set_vxlan_id(vxlan_id);
1432  if ((path->peer() != agent->local_vm_peer()) &&
1433  (path->peer() != agent->local_peer()))
1434  path->set_label(label);
1435 
1436  //Setting of tunnel is only for simulated TOR.
1437  path->set_tunnel_bmap(tunnel_type);
1438  TunnelType::Type new_tunnel_type =
1439  TunnelType::ComputeType(tunnel_type);
1440  if (new_tunnel_type == TunnelType::VXLAN &&
1441  vxlan_id == VxLanTable::kInvalidvxlan_id) {
1442  new_tunnel_type = TunnelType::ComputeType(TunnelType::MplsType());
1443  }
1444 
1445  if (path->tunnel_type() != new_tunnel_type) {
1446  path->set_tunnel_type(new_tunnel_type);
1447  }
1448 
1449  uint32_t old_pref = path->path_preference().preference();
1450  if (ha_stale) {
1451  if (old_pref != PathPreference::HA_STALE) {
1453  }
1454  } else {
1455  if (old_pref != PathPreference::LOW) {
1457  }
1458  }
1459 
1460  path->ChangeNH(agent, nh);
1461 
1462  path->ResyncControlWord(rt);
1463 
1464  return true;
1465 }
1466 
1468  const AgentRoute *rt) const {
1469  return (vxlan_id() == path->vxlan_id());
1470 }
1471 
1473  const AgentRoute *rt) {
1474  bool ret = false;
1475  //ECMP flag will not be changed by path preference module,
1476  //hence retain value in path
1477  if (!path) {
1478  return ret;
1479  }
1480 
1484  if (path &&
1485  path->path_preference() != path_preference_) {
1487  ret = true;
1488  }
1489  return ret;
1490 }
1491 
1492 // Subnet Route route data
1494  const std::string &dest_vn_name) :
1495  AgentRouteData(AgentRouteData::ADD_DEL_CHANGE, false, 0),
1496  dest_vn_name_(dest_vn_name) {
1497  nh_req_.Swap(&nh_req);
1498 }
1499 
1501  const AgentRoute *rt) {
1502  agent->nexthop_table()->Process(nh_req_);
1503  NextHop *nh = static_cast<NextHop *>(agent->nexthop_table()->
1504  FindActiveEntry(nh_req_.key.get()));
1505  assert(nh);
1506 
1507  bool ret = false;
1508 
1509  if (path->ChangeNH(agent, nh) == true) {
1510  ret = true;
1511  }
1512  path->set_is_subnet_discard(true);
1513 
1514  VnListType dest_vn_list;
1515  dest_vn_list.insert(dest_vn_name_);
1516  if (path->dest_vn_list() != dest_vn_list) {
1517  path->set_dest_vn_list(dest_vn_list);
1518  ret = true;
1519  }
1520 
1521  //Resync of subnet route is needed for identifying if arp flood flag
1522  //needs to be enabled for all the smaller subnets present w.r.t. this subnet
1523  //route.
1524  AgentRouteTable *table = static_cast<AgentRouteTable *>(rt->get_table());
1525  assert((table->GetTableType() == Agent::INET4_UNICAST) ||
1526  (table->GetTableType() == Agent::INET6_UNICAST));
1527 
1528  InetUnicastAgentRouteTable *uc_rt_table =
1529  static_cast<InetUnicastAgentRouteTable *>(table);
1530  const InetUnicastRouteEntry *uc_rt =
1531  static_cast<const InetUnicastRouteEntry *>(rt);
1532  uc_rt_table->ResyncSubnetRoutes(uc_rt, true);
1533  return ret;
1534 }
1535 
1537  InetUnicastRouteEntry *uc_rt = static_cast<InetUnicastRouteEntry *>(rt);
1538 
1539  return uc_rt->UpdateRouteFlags(true, false, false);
1540 }
1541 
1543 // Sandesh routines below (route_sandesh.cc)
1545 //TODO make it generic
1546 void UnresolvedNH::HandleRequest() const {
1547 
1549  if (!vrf) {
1550  ErrorResp *resp = new ErrorResp();
1551  resp->set_context(context());
1552  resp->Response();
1553  return;
1554  }
1555 
1556  int count = 0;
1557  std::string empty("");
1558  AgentRouteTable *rt_table = static_cast<AgentRouteTable *>
1559  (vrf->GetInet4UnicastRouteTable());
1560  NhListResp *resp = new NhListResp();
1561 
1562  //TODO - Convert inet4ucroutetable to agentroutetable
1563  AgentRouteTable::UnresolvedNHTree::const_iterator it;
1564  it = rt_table->unresolved_nh_begin();
1565  for (;it != rt_table->unresolved_nh_end(); it++) {
1566  count++;
1567  const NextHop *nh = *it;
1568  nh->DBEntrySandesh(resp, empty);
1569  if (count == 1) {
1570  resp->set_context(context()+"$");
1571  resp->Response();
1572  count = 0;
1573  resp = new NhListResp();
1574  }
1575  }
1576 
1577  resp->set_context(context());
1578  resp->Response();
1579  return;
1580 }
1581 
1582 //TODO IMplement filltrace in path class
1583 void AgentRoute::FillTrace(RouteInfo &rt_info, Trace event,
1584  const AgentPath *path) const {
1585  Agent *agent = static_cast<AgentRouteTable *>(get_table())->agent();
1586  rt_info.set_ip(ToString());
1587  rt_info.set_vrf(vrf()->GetName());
1588 
1589  switch(event) {
1590  case ADD:{
1591  rt_info.set_op("ADD");
1592  break;
1593  }
1594 
1595  case DEL: {
1596  rt_info.set_op("DELETE");
1597  break;
1598  }
1599 
1600  case ADD_PATH:
1601  case DELETE_PATH:
1602  case STALE_PATH:
1603  case CHANGE_PATH: {
1604  if (event == ADD_PATH) {
1605  rt_info.set_op("PATH ADD");
1606  } else if (event == CHANGE_PATH) {
1607  rt_info.set_op("PATH CHANGE");
1608  } else if (event == DELETE_PATH) {
1609  rt_info.set_op("PATH DELETE");
1610  } else if (event == STALE_PATH) {
1611  rt_info.set_op("PATH STALE");
1612  }
1613 
1614  if (path == NULL) {
1615  rt_info.set_nh_type("<NULL>");
1616  break;
1617  }
1618 
1619  if (path->peer()) {
1620  rt_info.set_peer(path->peer()->GetName());
1621  }
1622  rt_info.set_ecmp(path->path_preference().ecmp());
1623  const NextHop *nh = path->ComputeNextHop(agent);
1624  if (nh == NULL) {
1625  rt_info.set_nh_type("<NULL>");
1626  break;
1627  }
1628 
1629  switch (nh->GetType()) {
1630  case NextHop::TUNNEL: {
1631  const TunnelNH *tun = static_cast<const TunnelNH *>(nh);
1632  rt_info.set_nh_type("TUNNEL");
1633  rt_info.set_dest_server(tun->GetDip()->to_string());
1634  rt_info.set_dest_server_vrf(tun->GetVrf()->GetName());
1635  break;
1636  }
1637 
1638  case NextHop::ARP:{
1639  rt_info.set_nh_type("DIRECT");
1640  break;
1641  }
1642 
1643  case NextHop::NDP:{
1644  rt_info.set_nh_type("DIRECT");
1645  break;
1646  }
1647 
1648  case NextHop::INTERFACE: {
1649  const InterfaceNH *intf_nh = static_cast<const InterfaceNH *>(nh);
1650  rt_info.set_nh_type("INTERFACE");
1651  rt_info.set_intf(intf_nh->GetInterface()->name());
1652  break;
1653  }
1654 
1655  case NextHop::RECEIVE: {
1656  const ReceiveNH *rcv_nh = static_cast<const ReceiveNH *>(nh);
1657  rt_info.set_nh_type("RECEIVE");
1658  rt_info.set_intf(rcv_nh->GetInterface()->name());
1659  break;
1660  }
1661 
1662  case NextHop::DISCARD: {
1663  rt_info.set_nh_type("DISCARD");
1664  break;
1665  }
1666 
1667  case NextHop::VLAN: {
1668  rt_info.set_nh_type("VLAN");
1669  break;
1670  }
1671 
1672  case NextHop::RESOLVE: {
1673  rt_info.set_nh_type("RESOLVE");
1674  break;
1675  }
1676 
1677  case NextHop::COMPOSITE: {
1678  rt_info.set_nh_type("COMPOSITE");
1679  break;
1680  }
1681 
1682  case NextHop::L2_RECEIVE: {
1683  rt_info.set_nh_type("L2_RECEIVE");
1684  break;
1685  }
1686 
1687  case NextHop::PBB: {
1688  const PBBNH *pbb_nh = static_cast<const PBBNH *>(nh);
1689  rt_info.set_nh_type("PBB");
1690  rt_info.set_mac(pbb_nh->dest_bmac().ToString());
1691  if (pbb_nh->vrf()) {
1692  rt_info.set_dest_server_vrf(pbb_nh->vrf()->GetName());
1693  }
1694  break;
1695  }
1696 
1697  case NextHop::VRF: {
1698  const VrfNH *vrf_nh = static_cast<const VrfNH *>(nh);
1699  rt_info.set_nh_type("VRF");
1700  rt_info.set_vrf_nh_name(vrf_nh->GetVrf()->GetName());
1701  break;
1702  }
1703 
1704  default:
1705  assert(0);
1706  break;
1707  }
1708  break;
1709  }
1710  }
1711 }
1712 
1713 void AgentPath::GetDestinationVnList(std::vector<std::string> *vn_list) const {
1714  for (VnListType::const_iterator vnit = dest_vn_list().begin();
1715  vnit != dest_vn_list().end(); ++vnit) {
1716  vn_list->push_back(*vnit);
1717  }
1718 }
1719 
1720 void AgentPath::SetSandeshData(PathSandeshData &pdata) const {
1721  const NextHop *nh = nexthop();
1722  if (nh != NULL) {
1723  nh->SetNHSandeshData(pdata.nh);
1724  }
1725  pdata.set_peer(const_cast<Peer *>(peer())->GetName());
1726  std::vector<std::string> vn_list;
1727  GetDestinationVnList(&vn_list);
1728  pdata.set_dest_vn_list(vn_list);
1729  pdata.set_origin_vn(origin_vn());
1730  pdata.set_unresolved(unresolved() ? "true" : "false");
1731 
1732  if (!gw_ip().is_unspecified()) {
1733  pdata.set_gw_ip(gw_ip().to_string());
1734  pdata.set_vrf(vrf_name());
1735  }
1736 
1737  if (ecmp_suppressed()) {
1738  pdata.set_ecmp_suppressed(true);
1739  }
1740 
1741  pdata.set_sg_list(sg_list());
1742  pdata.set_communities(communities());
1743  pdata.set_tag_list(tag_list());
1744  pdata.set_vxlan_id(vxlan_id());
1745  pdata.set_label(label());
1746  if (nh != NULL && nh->GetType() == NextHop::PBB) {
1747  const PBBNH *pbb_nh = static_cast<const PBBNH *>(nh);
1748  if (pbb_nh->child_nh() != NULL) {
1749  const TunnelNH *tun_nh = dynamic_cast<const TunnelNH *>(pbb_nh->child_nh());
1750  if (tun_nh != NULL) {
1751  pdata.set_active_tunnel_type((tun_nh->GetTunnelType()).ToString());
1752  }
1753  }
1754  } else {
1755  pdata.set_active_tunnel_type(
1757  }
1758  pdata.set_supported_tunnel_type(
1760  PathPreferenceSandeshData path_preference_data;
1761  path_preference_data.set_sequence(path_preference_.sequence());
1762  path_preference_data.set_preference(path_preference_.preference());
1763  path_preference_data.set_ecmp(path_preference_.is_ecmp());
1764  if ((peer()->GetType() != Peer::BGP_PEER) && (peer()->GetType() != Peer::ECMP_PEER )) {
1765  path_preference_data.set_wait_for_traffic(
1767  }
1768  if (path_preference_.dependent_ip().is_unspecified() == false) {
1769  std::ostringstream str;
1770  str << path_preference_.vrf() << " : " <<path_preference_.dependent_ip().to_string();
1771  path_preference_data.set_dependent_ip(str.str());
1772  }
1773  pdata.set_path_preference_data(path_preference_data);
1774  pdata.set_active_label(GetActiveLabel());
1775  if (peer()->GetType() == Peer::MAC_VM_BINDING_PEER) {
1776  const MacVmBindingPath *dhcp_path =
1777  static_cast<const MacVmBindingPath *>(this);
1778  pdata.set_flood_dhcp(dhcp_path->flood_dhcp() ? "true" : "false");
1779  pdata.set_vm_name(dhcp_path->vm_interface()->ToString());
1780  }
1781  std::vector<std::string> string_vector;
1782  ecmp_load_balance_.GetStringVector(string_vector);
1783  std::vector<std::string>::iterator string_vector_iter =
1784  string_vector.begin();
1785  std::stringstream ss;
1786  while (string_vector_iter != string_vector.end()) {
1787  ss << (*string_vector_iter);
1788  ss << ",";
1789  string_vector_iter++;
1790  }
1791  pdata.set_ecmp_hashing_fields(ss.str());
1792  pdata.set_peer_sequence_number(peer_sequence_number());
1793  const BgpPeer *bgp_peer = dynamic_cast<const BgpPeer *>(peer());
1794  bool is_stale = false;
1795  if (bgp_peer) {
1796  if (peer_sequence_number() < bgp_peer->ChannelSequenceNumber())
1797  is_stale = true;
1798  }
1799  pdata.set_stale(is_stale);
1800  pdata.set_etree_leaf(etree_leaf());
1801  pdata.set_layer2_control_word(layer2_control_word());
1802  pdata.set_inactive(inactive());
1803 }
1804 
1807 }
1808 
1809 bool AgentPath::dest_vn_match(const std::string &vn) const {
1810  if (dest_vn_list_.find(vn) != dest_vn_list_.end())
1811  return true;
1812  return false;
1813 }
1814 
1816  return local_ecmp_mpls_label_.get();
1817 }
1818 
1819 //In case of composite NH in fabric VRF, if BGP path has router
1820 //id of compute node then copy the ECMP peer or local VM peer path
1821 //to composite NH.
1822 //In case of overlay mode MPLS label was used to frame local nexthop
1823 //list which is not feasible in this fabric VRF
1825  const AgentPath *local_path) {
1826 
1827  if (local_path == NULL) {
1828  return;
1829  }
1830 
1831  DBEntryBase::KeyPtr key_nh = local_path->nexthop()->GetDBRequestKey();
1832  NextHopKey *nh_key = static_cast<NextHopKey *>(key_nh.get());
1833  nh_key->SetPolicy(false);
1834  std::unique_ptr<const NextHopKey> nh_key_p(nh_key->Clone());
1835 
1836  ComponentNHKeyList comp_nh_list;
1837  if (nh_key_p->GetType() == NextHop::COMPOSITE) {
1838  //Append the list of component NH list from local ecmp peer
1839  const CompositeNHKey *comp_nh_key =
1840  static_cast<const CompositeNHKey *>(nh_key);
1841  comp_nh_list = comp_nh_key->component_nh_key_list();
1842  } else {
1843  //Append the interface NH to composite NH list
1844  ComponentNHKeyPtr new_comp_nh(new ComponentNHKey(0, std::move(nh_key_p)));
1845  comp_nh_list.push_back(new_comp_nh);
1846  }
1847 
1848  composite_nh_key->ReplaceLocalNexthop(comp_nh_list);
1849 }
1850 
1852  CompositeNHKey *composite_nh_key,
1853  bool &comp_nh_policy,
1854  const AgentPath *path) {
1855  if (copy_local_path_) {
1856  CopyLocalPath(composite_nh_key, path);
1857  }
1858 
1859  //Find local composite mpls label, if present
1860  //This has to be done, before expanding component NH
1861  BOOST_FOREACH(ComponentNHKeyPtr component_nh_key,
1862  composite_nh_key->component_nh_key_list()) {
1863  if (component_nh_key.get() == NULL ||
1864  component_nh_key->nh_key()->GetType() != NextHop::COMPOSITE) {
1865  continue;
1866  }
1867  const CompositeNHKey *composite_key =
1868  static_cast<const CompositeNHKey *>(component_nh_key->nh_key());
1869  // composite NH, check composite nh type
1870  // if it is not local ecmp , skip processing
1871  if (composite_key->composite_nh_type() !=
1873  continue;
1874  }
1875  //Get mpls label allocated for this composite NH
1876  MplsLabel *mpls = agent->mpls_table()->
1877  FindMplsLabel(component_nh_key->label());
1878  if (!mpls) {
1879  //If a mpls label is deleted,
1880  //wait for bgp to update latest list
1882  return false;
1883  }
1884 
1885  if (mpls == local_ecmp_mpls_label_.get()) {
1886  break;
1887  }
1889  //Check if MPLS is pointing to same NH as mentioned in key list.
1890  //It may so happen that by the time this request is serviced(say in
1891  //case of remote route add from CN), mpls label ahs been re-used for
1892  //some other purpose. If it is so then ignore the request and wait for
1893  //another update.
1894  const NextHopKey *nh_key_1 = component_nh_key->nh_key();
1895  DBEntryBase::KeyPtr key = mpls->nexthop()->GetDBRequestKey();
1896  const NextHopKey *nh_key_2 = static_cast<const NextHopKey*>(key.get());
1897  if (nh_key_1->IsEqual(*nh_key_2) == false) {
1898  return false;
1899  }
1900  break;
1901  }
1902 
1903  //Make a copy of composite NH, so that aggregarate mpls
1904  //label allocated for local composite ecmp is maintained
1905  //as data in path
1906  CompositeNHKey *comp_key = composite_nh_key->Clone();
1907  //Reorder the keys so that, existing component NH maintain
1908  //there previous position
1909  //For example take a composite NH with members A, B, C
1910  //in that exact order,If B gets deleted,
1911  //the new composite NH created should be A <NULL> C in that order,
1912  //irrespective of the order user passed it in
1913  comp_nh_policy = composite_nh_key->Reorder(agent, label_,
1914  ComputeNextHop(agent));
1915  //Copy the unchanged component NH list to path data
1916  set_composite_nh_key(comp_key);
1917  return true;
1918 }
1919 
1921  CompositeNHKey *composite_nh_key) {
1923  nh_req.key.reset(composite_nh_key->Clone());
1924  nh_req.data.reset(new CompositeNHData());
1925 
1926  NextHop *nh = static_cast<NextHop *>(agent->nexthop_table()->
1927  FindActiveEntry(composite_nh_key));
1928  if (!nh) {
1929  agent->nexthop_table()->Process(nh_req);
1930  nh = static_cast<NextHop *>(agent->nexthop_table()->
1931  FindActiveEntry(composite_nh_key));
1932  }
1933 
1934  // NH can be NULL in the following scenario
1935  // when VMI is deleted and it is the only member of VRF
1936  // and VMI is part of AAP, then local ecmp route path
1937  // is deleted from route and vrf delete would trigger route deletions
1938  // in the VRF. while deleting the active path, import Nh from prev active
1939  // path function copies the previous active path's NH to current active path
1940  // and recalucalate composite NH based on composite nh key of current
1941  // active path. if component nh key element of composite nh key is
1942  // interface nh key which is already deleted then processing nh req would
1943  // result NULL, in that case return false.
1944  //assert(nh);
1945  if (nh == NULL) {
1946  return false;
1947  }
1948 
1949  if (ChangeNH(agent, nh) == true) {
1950  return true;
1951  }
1952  return false;
1953 }
1954 
1955 const Ip4Address *AgentPath::NexthopIp(Agent *agent) const {
1956  if (peer_ == NULL) {
1957  return agent->router_ip_ptr();
1958  }
1959 
1960  return peer_->NexthopIp(agent, this);
1961 }
1962 
1964  AgentPath(peer, NULL), vm_interface_(NULL), flood_dhcp_(false) {
1965 }
1966 
1967 bool MacVmBindingPath::IsLess(const AgentPath &r_path) const {
1968  return peer()->IsLess(r_path.peer());
1969 }
1970 
1972  return nexthop();
1973 }
1974 
1976  AgentRoute *rt) const {
1977  const Peer *mac_vm_binding_peer =
1978  dynamic_cast<const Peer *>(peer);
1979  assert(mac_vm_binding_peer != NULL);
1980  return (new MacVmBindingPath(mac_vm_binding_peer));
1981 }
1982 
1984  const AgentRoute *rt) {
1985  bool ret = false;
1986  MacVmBindingPath *dhcp_path =
1987  dynamic_cast<MacVmBindingPath *>(path);
1988 
1989  NextHop *nh = agent->nexthop_table()->discard_nh();
1990  if (path->ChangeNH(agent, nh) == true)
1991  ret = true;
1992 
1993  if (dhcp_path->flood_dhcp() != flood_dhcp_) {
1994  dhcp_path->set_flood_dhcp(flood_dhcp_);
1995  ret = true;
1996  }
1997 
1998  if (dhcp_path->vm_interface() != vm_intf_) {
1999  dhcp_path->set_vm_interface(vm_intf_);
2000  ret = true;
2001  }
2002 
2003  return ret;
2004 }
2005 
2007  const EcmpLoadBalance &ecmp_load_balance,
2008  DBRequest &nh_req) {
2009 
2010  NextHop *nh = NULL;
2011  nh = static_cast<NextHop *>(agent->nexthop_table()->
2012  FindActiveEntry(nh_req.key.get()));
2013  CompositeNH *cnh = dynamic_cast< CompositeNH *>(nh);
2014  if (cnh) {
2016  cnh->CompEcmpHashFields());
2017  } else {
2018  agent->nexthop_table()->Process(nh_req);
2019  nh = static_cast<NextHop *>(agent->nexthop_table()->
2020  FindActiveEntry(nh_req.key.get()));
2021  CompositeNH *cnh = static_cast< CompositeNH *>(nh);
2022  if (cnh) {
2024  cnh->CompEcmpHashFields());
2025  }
2026  }
2027 }
2028 
2031 }
2032 
2034  const BridgeRouteEntry *bridge_rt =
2035  dynamic_cast<const BridgeRouteEntry *>(rt);
2036  if (!bridge_rt || rt->vrf() == NULL) {
2037  return false;
2038  }
2039 
2040  if (layer2_control_word() != bridge_rt->vrf()->layer2_control_word()) {
2042  return true;
2043  }
2044 
2045  return false;
2046 }
2047 
2049  AgentRoute *rt,
2050  VrfEntryConstRef routing_vrf) :
2051  AgentPath(peer, rt), routing_vrf_(routing_vrf) {
2052  l3_vrf_vxlan_id_ = routing_vrf.get()->vxlan_id();
2053 }
2054 
2056 }
2057 
2059  return routing_vrf_.get();
2060 }
2061 
2063  routing_vrf_.reset(vrf);
2064 }
2065 
2067  const AgentRoute *rt) const {
2068  const VrfEntry *l3_vrf = routing_vrf_.get();
2069  if (!l3_vrf)
2070  return;
2071 
2072  const InetUnicastRouteEntry *inet_rt =
2073  dynamic_cast<const InetUnicastRouteEntry *>(rt);
2074  if (!inet_rt) {
2075  return;
2076  }
2077  const EvpnAgentRouteTable *evpn_table =
2078  static_cast<EvpnAgentRouteTable *>(l3_vrf->GetEvpnRouteTable());
2079  evpn_table->Delete(agent->local_vm_export_peer(), l3_vrf->GetName(),
2080  MacAddress(), inet_rt->prefix_address(),
2082 }
2083 
2085  const SecurityGroupList &sg_list,
2086  const CommunityList &communities,
2087  const PathPreference &path_preference,
2088  const EcmpLoadBalance &ecmp_load_balance,
2089  const TagList &tag_list,
2090  VrfEntryConstRef vrf_entry,
2091  uint32_t vxlan_id,
2092  const VnListType& vn_list,
2093  const std::string& origin_vn):
2094  AgentRouteData(AgentRouteData::ADD_DEL_CHANGE, false, 0),
2095  sg_list_(sg_list),
2096  communities_(communities),
2097  path_preference_(path_preference),
2098  ecmp_load_balance_(ecmp_load_balance),
2099  tag_list_(tag_list),
2100  routing_vrf_(vrf_entry), vxlan_id_(vxlan_id),
2101  dest_vn_list_(vn_list),
2102  origin_vn_(origin_vn) {
2103  nh_req_.Swap(&nh_req);
2104 }
2105 
2107  AgentRoute *rt) const {
2108  return (new EvpnRoutingPath(peer, rt, routing_vrf_));
2109 }
2110 
2112  AgentPath *path,
2113  const AgentRoute *rt) {
2114  bool ret = false;
2115  EvpnRoutingPath *evpn_path = static_cast<EvpnRoutingPath *>(path);
2116 
2117  //Process nexthop
2118  agent->nexthop_table()->Process(nh_req_);
2119  NextHop *nh = static_cast<NextHop *>(agent->nexthop_table()->
2120  FindActiveEntry(nh_req_.key.get()));
2121 
2122  InterfaceNH *intf_nh = dynamic_cast<InterfaceNH *>(nh);
2123  if (intf_nh) {
2124  intf_nh->set_delete_on_zero_refcount(true);
2125  }
2126  if (routing_vrf_.get() != evpn_path->routing_vrf()) {
2127  //Remove from old vrf
2128  evpn_path->DeleteEvpnType5Route(agent, rt);
2129  evpn_path->set_routing_vrf(routing_vrf_.get());
2130  ret = true;
2131  }
2132 
2133  if (path->ChangeNH(agent, nh) == true) {
2134  ret = true;
2135  }
2136 
2137  if (sg_list_ != path->sg_list()) {
2138  path->set_sg_list(sg_list_);
2139  ret = true;
2140  }
2141 
2142  /* Setting the origin_vn in the route path */
2143  if (path->origin_vn() != origin_vn_) {
2144  path->set_origin_vn(origin_vn_);
2145  ret = true;
2146  }
2147 
2148  // Set dest vn
2150 
2151  if (communities_ != path->communities()) {
2153  ret =true;
2154  }
2155 
2156  if (path_preference_ != path->path_preference()) {
2158  ret = true;
2159  }
2160 
2161  if (ecmp_load_balance_ != path->ecmp_load_balance()) {
2163  ret =true;
2164  }
2165 
2166  if (tag_list_ != path->tag_list()) {
2167  path->set_tag_list(tag_list_);
2168  ret =true;
2169  }
2170 
2173  path->set_vxlan_id(vxlan_id_);
2174 
2175  return ret;
2176 }
2177 
2179  const AgentRoute *rt) const {
2180  EvpnRoutingPath *evpn_path = dynamic_cast<EvpnRoutingPath *>(path);
2181  if (!evpn_path) {
2182  return true;
2183  }
2184  if (rt->vrf() != evpn_path->routing_vrf()) {
2185  //Remove from old vrf
2186  evpn_path->DeleteEvpnType5Route(agent, rt);
2187  }
2188  return true;
2189 }
2191  InetUnicastRouteEntry *uc_rt =
2192  dynamic_cast<InetUnicastRouteEntry *>(rt);
2193  if (!uc_rt) {
2194  return false;
2195  }
2196  return uc_rt->UpdateRouteFlags(false, false, true);
2197 }
2199  AgentRoute *rt):
2200  addr_(addr), label_(label), dependent_rt_(rt) {}
2201 
const std::string & GetName() const
Definition: peer.h:86
VrfEntryConstRef routing_vrf_
Definition: agent_path.h:1218
MulticastRoutePath(const Peer *peer)
Definition: agent_path.cc:1316
MacAddress dmac_
Definition: agent_path.h:740
uint8_t prefix_length() const
!
InterfaceKey * Clone() const
uint32_t ethernet_tag() const
Definition: agent_path.h:565
static const MacAddress & ZeroMac()
Definition: mac_address.h:158
uint32_t TypeBmap
Definition: nexthop.h:248
uint32_t const GetTransportLabel() const
Definition: tunnel_nh.h:100
boost::scoped_ptr< CompositeNHKey > composite_nh_key_
Definition: agent_path.h:494
EvpnRoutingData(DBRequest &nh_req, const SecurityGroupList &sg_list, const CommunityList &communities, const PathPreference &path_preference, const EcmpLoadBalance &ecmp_load_balance, const TagList &tag_list, VrfEntryConstRef vrf_entry, uint32_t vxlan_id, const VnListType &vn_list, const std::string &origin_vn="")
Definition: agent_path.cc:2084
AgentPath * FindLocalVmPortPath() const
Definition: agent_route.cc:742
bool force_policy_
Definition: agent_path.h:699
const CommunityList communities_
Definition: agent_path.h:1214
const Interface * GetInterface() const
Definition: nexthop.h:1293
void set_path_preference(const PathPreference &rp)
Definition: agent_path.h:331
uint32_t l3_vrf_vxlan_id_
Definition: agent_path.h:1237
virtual bool AddChangePathExtended(Agent *, AgentPath *, const AgentRoute *)
Definition: agent_path.cc:1472
bool inactive() const
Definition: agent_path.h:420
bool IsEqual(const NextHopKey &rhs) const
Definition: nexthop.h:481
uint32_t vxlan_id_
Definition: agent_path.h:698
const VnListType & dest_vn_list() const
Definition: agent_path.h:258
void set_vm_interface(const VmInterface *vm_interface)
Definition: agent_path.h:1091
std::string dest_vn_name_
Definition: agent_path.h:813
void ReplaceLocalNexthop(const ComponentNHKeyList &new_comp_nh)
Definition: nexthop.cc:1774
void set_communities(const CommunityList &communities)
Definition: agent_path.h:293
uint32_t fabric_label_
Definition: agent_path.h:870
void ResetEcmpHashFields()
Definition: agent_path.cc:2029
const MacAddress & vm_mac() const
SecurityGroupList sg_list_
Definition: agent_path.h:704
Type type() const
Definition: interface.h:112
const VrfEntry * GetVrf() const
Definition: tunnel_nh.h:35
bool ChangeNH(Agent *agent, NextHop *nh)
Definition: agent_path.cc:119
uint32_t tunnel_type_
Definition: agent_path.h:909
bool ResyncSubnetRoutes(const InetUnicastRouteEntry *rt, bool val)
const Ip4Address & dip() const
Definition: nexthop.h:999
TsnElector * tsn_elector() const
Definition: operdb_init.h:94
void set_unresolved(bool unresolved)
Definition: agent_path.h:285
const Peer * local_vm_export_peer() const
Definition: agent.h:1040
uint32_t mpls_label_
Definition: agent_path.h:697
static Agent * GetInstance()
Definition: agent.h:436
static void Delete(const Peer *peer, const std::string &vrf_name, const MacAddress &mac, const IpAddress &ip_addr, uint32_t ethernet_tag)
Definition: vrf.h:86
bool learning_enabled() const
Definition: nexthop.h:423
const TagList & tag_list() const
Definition: agent_path.h:249
const PathPreference & path_preference() const
Definition: agent_path.h:329
bool CopyArpData()
Definition: agent_path.cc:582
DependencyRef< AgentRoute, AgentRoute > dependant_rt_
Definition: agent_path.h:489
const IpAddress subnet_service_ip() const
Definition: agent_path.h:274
AgentRouteTable * GetEvpnRouteTable() const
Definition: vrf.cc:330
void set_local_ecmp_mpls_label(MplsLabel *mpls)
Definition: agent_path.cc:1805
const IpAddress & ip_addr() const
Definition: agent_path.h:561
virtual AgentPath * CreateAgentPath(const Peer *peer, AgentRoute *rt) const
Definition: agent_path.cc:665
static std::string GetString(uint32_t type)
Definition: nexthop.h:278
NextHop * l2_receive_nh() const
Definition: nexthop.h:1974
void set_original_nh(NextHopRef nh)
Definition: agent_path.h:854
const boost::uuids::uuid & GetUuid() const
Definition: interface.h:113
bool ChangeNH(NextHop *nh)
Definition: mpls.cc:97
VnListType dest_vn_list_
Definition: agent_path.h:840
const VrfEntry * GetVrf() const
Definition: nexthop.h:1444
NextHopTable * nexthop_table() const
Definition: agent.h:475
DBTableBase * get_table() const
Definition: db_entry.cc:119
virtual const NextHop * ComputeNextHop(Agent *agent) const
Definition: agent_path.cc:1971
const MacAddress & GetMac() const
Definition: nexthop.h:836
static void AddArpReq(const string &route_vrf_name, const Ip4Address &ip, const string &nh_vrf_name, const Interface *intf, bool policy, const VnListType &dest_vn_list, const SecurityGroupList &sg_list, const TagList &tag_list)
void ImportPrevActiveNH(Agent *agent, NextHop *nh)
Definition: agent_path.cc:299
void set_intf_route_type(const std::string &intf_route_type)
Definition: agent_route.h:278
virtual bool AddChangePathExtended(Agent *agent, AgentPath *path, const AgentRoute *rt)
Definition: agent_path.cc:1500
void set_routing_vrf(const VrfEntry *vrf)
Definition: agent_path.cc:2062
DependencyRef< AgentRoute, MplsLabel > local_ecmp_mpls_label_
Definition: agent_path.h:492
uint32_t vxlan_id_
Definition: agent_path.h:908
TunnelType::Type tunnel_type() const
Definition: agent_path.h:266
UnresolvedNHTree::const_iterator unresolved_nh_end() const
Definition: agent_route.h:152
Agent supports multiple route tables - Inet-unicast (IPv4/IPv6), Inet-multicast, bridge, EVPN (Type2/Type5). This base class contains common code for all types of route tables.
Definition: agent_route.h:109
VnListType dest_vn_list_
Definition: agent_path.h:742
virtual bool UpdateRoute(AgentRoute *rt)
Definition: agent_path.cc:2190
uint32_t preference() const
Definition: agent_path.h:41
IpAddress gw_ip_
Definition: agent_path.h:481
void set_sg_list(const SecurityGroupList &sg)
Definition: agent_path.h:291
const Interface * vhost_interface() const
Definition: agent.h:935
const std::string & intf_route_type() const
Definition: agent_route.h:277
bool RebakeAllTunnelNHinCompositeNH(const AgentRoute *sync_route)
Definition: agent_path.cc:151
const Interface * GetInterface() const
Definition: nexthop.h:926
DBRequest nh_req_
Definition: agent_path.h:926
const NextHop * nexthop() const
Definition: mpls.h:80
boost::asio::ip::address IpAddress
Definition: address.h:13
virtual bool PostChangeNH(Agent *agent, NextHop *nh)
Definition: agent_path.cc:147
void set_vxlan_id(uint32_t vxlan_id)
Definition: agent_path.h:281
EcmpLoadBalance ecmp_load_balance_
Definition: agent_path.h:509
Type GetType() const
Definition: nexthop.h:303
uint32_t GetTunnelBmap() const
Definition: agent_path.cc:70
PathPreference path_preference_
Definition: agent_path.h:843
bool ipam_host_route_
Definition: agent_path.h:956
boost::shared_ptr< AgentPathEcmpComponent > AgentPathEcmpComponentPtr
Definition: agent_path.h:228
std::vector< int > SecurityGroupList
Definition: agent.h:201
bool is_multicast() const
Definition: agent_route.h:274
const MacAddress & GetMac() const
Definition: nexthop.h:925
std::unique_ptr< DBRequestData > data
Definition: db_table.h:49
virtual ~AgentPath()
Definition: agent_path.cc:66
IpAddress ip_addr_
Definition: agent_path.h:570
InetUnicastAgentRouteTable * fabric_inet4_mpls_table() const
Definition: agent.h:589
std::string ToString() const
InterfaceKey * Clone() const
virtual bool CanDeletePath(Agent *agent, AgentPath *path, const AgentRoute *rt) const
Definition: agent_path.cc:1467
virtual bool AddChangePathExtended(Agent *agent, AgentPath *path, const AgentRoute *rt)
Definition: agent_path.cc:1230
UnresolvedNHTree::const_iterator unresolved_nh_begin() const
Definition: agent_route.h:149
InetUnicastAgentRouteTable * GetInet4UnicastRouteTable() const
Definition: vrf.cc:319
virtual bool AddChangePathExtended(Agent *agent, AgentPath *path, const AgentRoute *rt)
Definition: agent_path.cc:1169
AgentDBEntry * FindActiveEntry(const DBEntry *key)
Definition: agent_db.cc:110
InterfaceTable * interface_table() const
Definition: agent.h:465
virtual bool AddChangePathExtended(Agent *agent, AgentPath *path, const AgentRoute *rt)
Definition: agent_path.cc:1119
const Ip4Address * GetDip() const
Definition: tunnel_nh.h:37
const VrfEntry * routing_vrf() const
Definition: agent_path.cc:2058
static TypeBmap MplsType()
Definition: nexthop.h:312
EvpnDerivedPath(const EvpnPeer *evpn_peer, const IpAddress &ip_addr, uint32_t ethernet_tag, const std::string &parent)
Definition: agent_path.cc:626
ObjectType * get() const
Definition: dependency.h:49
TunnelType::TypeBmap tunnel_bmap_
Definition: agent_path.h:844
string vn_name_
Definition: agent_path.h:906
void set_native_vrf_id(uint32_t vrf_id)
Definition: agent_path.h:404
InetUnicastRouteEntry * FindRoute(const IpAddress &ip)
EcmpHashFields ecmp_hash_fields_
Definition: agent_path.h:519
void set_is_health_check_service(bool val)
Definition: agent_path.h:384
boost::shared_ptr< const ComponentNHKey > ComponentNHKeyPtr
Definition: nexthop.h:1639
const string & GetName() const
Definition: vrf.h:100
bool policy_
Definition: agent_path.h:793
VrfEntryConstRef routing_vrf_
Definition: agent_path.h:1236
const SecurityGroupList sg_list_
Definition: agent_path.h:1213
std::string dest_vn_name_
Definition: agent_path.h:791
std::string vn_
Definition: agent_path.h:957
bool CopyNdpData()
Definition: agent_path.cc:604
bool IsLess(const Peer *rhs) const
Definition: peer.h:73
virtual bool IsLess(const AgentPath &right) const
Definition: agent_path.cc:1967
virtual bool AddChangePathExtended(Agent *agent, AgentPath *path, const AgentRoute *rt)
Definition: agent_path.cc:1384
virtual AgentPath * CreateAgentPath(const Peer *peer, AgentRoute *rt) const
Definition: agent_path.cc:1975
TagList tag_list_
Definition: agent_path.h:468
EvpnRoutingPath(const Peer *peer, AgentRoute *rt, VrfEntryConstRef routing_vrf)
Definition: agent_path.cc:2048
void set_is_local(bool is_local)
Definition: agent_path.h:376
void set_vrf(const std::string &vrf)
Definition: agent_path.h:100
const MplsLabel * local_ecmp_mpls_label() const
Definition: agent_path.cc:1815
const std::string dest_vn_name_
Definition: agent_path.h:634
NextHopRef nh_
Definition: agent_path.h:446
MplsTable * mpls_table() const
Definition: agent.h:510
VrfEntry * vrf() const
Definition: interface.h:115
std::unique_ptr< DBRequestKey > KeyPtr
Definition: db_entry.h:25
bool ChangeCompositeNH(Agent *agent, CompositeNHKey *nh)
Definition: agent_path.cc:1920
bool ReorderCompositeNH(Agent *agent, CompositeNHKey *nh, bool &comp_nh_policy, const AgentPath *local_path)
Definition: agent_path.cc:1851
void SetNHSandeshData(NhSandeshData &data) const
Definition: nexthop.cc:3172
void SetDynamicLearntRouteFlag(bool is_learnt_route)
Definition: agent_path.h:436
bool is_health_check_service_
Definition: agent_path.h:712
Type GetType() const
Definition: nexthop.h:405
Base class for all Route entries in agent.
Definition: agent_route.h:224
const VrfEntry * vrf() const
Definition: nexthop.h:1875
void Swap(DBRequest *rhs)
Definition: db_table.cc:43
virtual bool CanDeletePath(Agent *agent, AgentPath *path, const AgentRoute *rt) const
Definition: agent_path.cc:754
virtual bool AddChangePathExtended(Agent *agent, AgentPath *path, const AgentRoute *rt)
Definition: agent_path.cc:854
virtual CompositeNHKey * Clone() const
Definition: nexthop.cc:2398
CompositeNHKey * composite_nh_key()
Definition: agent_path.h:335
static bool CopyPathParameters(Agent *agent, AgentPath *path, const std::string &dest_vn_name, bool unresolved, uint32_t vxlan_id, uint32_t label, uint32_t tunnel_type, NextHop *nh, const AgentRoute *rt, bool ha_stale=false)
Definition: agent_path.cc:1417
virtual bool IsLess(const AgentPath &right) const
Definition: agent_path.cc:561
AgentPath(const Peer *peer, AgentRoute *rt)
Definition: agent_path.cc:51
virtual const AgentPath * UsablePath() const
Definition: agent_path.cc:574
uint64_t ChannelSequenceNumber() const
Definition: peer.cc:335
boost::scoped_ptr< const InterfaceKey > intf_key_
Definition: agent_path.h:631
OperDB * oper_db() const
Definition: agent.cc:1013
int tunnel_bmap_
Definition: agent_path.h:953
std::vector< ComponentNHKeyPtr > ComponentNHKeyList
Definition: nexthop.h:1641
std::string ToString() const
Definition: mac_address.cc:53
std::string name_
Definition: interface.h:245
virtual bool UpdateRoute(AgentRoute *rt)
Definition: agent_path.cc:1097
const Ip4Address & tunnel_dest() const
Definition: agent_path.h:272
virtual bool AddChangePathExtended(Agent *agent, AgentPath *path, const AgentRoute *rt)
Definition: agent_path.cc:1271
const Interface * GetInterface() const
Definition: nexthop.h:837
TunnelType::Type const GetTransportTunnelType() const
Definition: tunnel_nh.h:109
Ip4Address tunnel_dest_
Definition: agent_path.h:472
NextHop::Type GetType() const
Definition: nexthop.h:499
void GetStringVector(std::vector< std::string > &string_vector) const
TunnelType::TypeBmap tunnel_bmap_
Definition: agent_path.h:474
const std::string & fabric_vrf_name() const
Definition: agent.h:903
TunnelType::TypeBmap tunnel_bmap_
Definition: agent_path.h:707
const Type GetType() const
Definition: peer.h:87
bool ecmp() const
Definition: agent_path.h:45
bool layer2_control_word() const
Definition: agent_path.h:396
virtual bool AddChangePathExtended(Agent *agent, AgentPath *path, const AgentRoute *rt)
Definition: agent_path.cc:766
void set_tunnel_bmap(TunnelType::TypeBmap bmap)
Definition: agent_path.h:289
const AgentPath * GetActivePath() const
Definition: agent_route.cc:876
NextHop * nexthop() const
Definition: agent_path.cc:87
uint8_t GetFlags() const
Definition: nexthop.h:1300
bool is_local() const
Definition: agent_path.h:372
uint32_t vxlan_id_
Definition: agent_path.h:1219
bool sync_route_
Definition: agent_path.h:702
std::string parent_
Definition: agent_path.h:609
string name_
Definition: vrf.h:38
void FillTrace(RouteInfo &route, Trace event, const AgentPath *path) const
Definition: agent_path.cc:1583
bool RebakeLabel(MplsTable *table, uint32_t label, NextHop *nh)
Definition: agent_path.cc:35
bool IsValid() const
Definition: nexthop.h:406
virtual bool AddChangePathExtended(Agent *agent, AgentPath *path, const AgentRoute *rt)
Definition: agent_path.cc:2111
VrfEntry * FindVrfFromId(size_t index)
Definition: vrf.cc:884
bool layer2_control_word() const
Definition: vrf.h:139
const ManagedPhysicalDevicesList & ManagedPhysicalDevices() const
Definition: tsn_elector.cc:183
SecurityGroupList sg_list_
Definition: agent_path.h:467
virtual ~EvpnRoutingPath()
Definition: agent_path.cc:2055
void set_dependent_ip(const IpAddress &ip)
Definition: agent_path.h:96
static const uint32_t kInvalidvxlan_id
Definition: vxlan.h:141
virtual bool UpdateRoute(AgentRoute *rt)
Definition: agent_path.cc:1301
void set_arp_interface(const Interface *intf)
Definition: agent_path.h:350
uint8_t type
Definition: load_balance.h:109
void set_ecmp_suppressed(bool suppresed)
Definition: agent_path.h:358
virtual bool AddChangePathExtended(Agent *agent, AgentPath *path, const AgentRoute *rt)
Definition: agent_path.cc:1983
bool is_local_
Definition: agent_path.h:711
DBRequest nh_req_
Definition: agent_path.h:1212
Definition: agent.h:358
bool etree_leaf_
Definition: agent_path.h:713
std::string vrf_name_
Definition: agent_path.h:479
const IpAddress & gw_ip() const
Definition: agent_path.h:268
Definition: path.h:10
PathPreference & path_preference_non_const()
Definition: agent_path.h:330
bool UpdateRouteFlags(bool ipam_subnet_route, bool ipam_host_route, bool proxy_arp)
bool unresolved_
Definition: agent_path.h:485
MacVmBindingPath(const Peer *peer)
Definition: agent_path.cc:1963
const std::string & vrf() const
Definition: agent_path.h:72
const TunnelType & GetTunnelType() const
Definition: tunnel_nh.h:42
const NextHop * child_nh() const
Definition: nexthop.h:1167
void set_subnet_service_ip(const IpAddress &ip)
Definition: agent_path.h:303
InetInterfaceKey intf_
Definition: agent_path.h:765
const NextHop * GetActiveNextHop() const
Definition: agent_route.cc:881
uint32_t label() const
Definition: agent_path.h:264
void set_layer2_control_word(bool layer2_control_word)
Definition: agent_path.h:400
uint32_t ethernet_tag_
Definition: agent_path.h:607
std::unique_ptr< DBRequestKey > key
Definition: db_table.h:48
uint32_t label_
Definition: agent_path.h:633
uint32_t native_vrf_id_
Definition: agent_path.h:716
virtual bool AddChangePathExtended(Agent *agent, AgentPath *path, const AgentRoute *rt)
Definition: agent_path.cc:673
EcmpLoadBalance ecmp_load_balance_
Definition: agent_path.h:710
Definition: nexthop.h:820
VmInterfaceKey intf_
Definition: agent_path.h:837
Definition: nexthop.h:909
bool is_health_check_service() const
Definition: agent_path.h:380
Definition: trace.h:220
std::string vn_
Definition: agent_path.h:1054
virtual AgentPath * CreateAgentPath(const Peer *peer, AgentRoute *rt) const
Definition: agent_path.cc:2106
uint32_t native_vrf_id() const
Definition: agent_path.h:408
TagList tag_list_
Definition: agent_path.h:744
static const std::string & NullString()
Definition: agent.h:437
const Peer * peer() const
Definition: agent_path.h:263
const VmInterface * vm_interface() const
Definition: agent_path.h:1088
bool is_learnt_route_
Definition: agent_path.h:717
EcmpHashFields & CompEcmpHashFields()
Definition: nexthop.h:1912
IpAddress ip_addr_
Definition: agent_path.h:608
const Interface * GetInterface() const
Definition: nexthop.h:686
const std::string & origin_vn() const
Definition: agent_path.h:259
const Peer * local_peer() const
Definition: agent.h:1022
const bool unresolved() const
Definition: agent_path.h:271
void set_preference(uint32_t preference)
Definition: agent_path.h:82
const AgentPath * reference_path_
Definition: agent_path.h:612
const std::string & vrf_name() const
Definition: agent_path.h:269
NextHop * discard_nh() const
Definition: nexthop.h:1971
bool etree_leaf() const
Definition: agent_path.h:388
bool policy_enabled() const
const Ip4Address * GetSip() const
Definition: tunnel_nh.h:36
Interface::Type type_
Definition: interface.h:243
std::vector< std::string > CommunityList
Definition: bgp_config.h:347
void SetSandeshData(PathSandeshData &data) const
Definition: agent_path.cc:1720
virtual bool PostChangeNH(Agent *agent, NextHop *nh)
Definition: agent_path.cc:1322
bool native_encap_
Definition: agent_path.h:714
COMPOSITETYPE composite_nh_type() const
Definition: nexthop.h:1842
AgentParam * params() const
Definition: agent.h:1218
COMPOSITETYPE composite_nh_type() const
Definition: nexthop.h:1726
PeerConstPtr peer_
Definition: agent_path.h:444
Definition: peer.h:44
VmInterfaceKey intf_
Definition: agent_path.h:696
uint32_t isid_
Definition: agent_path.h:741
uint8_t flags_
Definition: agent_path.h:703
uint64_t peer_sequence_number() const
Definition: agent_path.h:415
std::set< std::string > VnListType
Definition: agent.h:212
bool is_ecmp() const
Definition: agent_path.h:49
const VmInterface * vm_intf_
Definition: agent_path.h:1121
virtual KeyPtr GetDBRequestKey() const =0
bool force_policy_
Definition: agent_path.h:466
const SecurityGroupList path_sg_list_
Definition: agent_path.h:635
void set_tunnel_dest(const Ip4Address &tunnel_dest)
Definition: agent_path.h:297
const MacAddress & mac() const
static Type ComputeType(TypeBmap bmap)
Definition: nexthop.cc:33
const std::string origin_vn_
Definition: agent_path.h:1221
virtual bool IsLess(const AgentPath &right) const
Definition: agent_path.cc:635
virtual bool UpdateRoute(AgentRoute *rt)
Definition: agent_path.cc:843
virtual bool CanDeletePath(Agent *agent, AgentPath *path, const AgentRoute *rt) const
Definition: agent_path.cc:2178
virtual const PrefixType & prefix_address() const
Returns the value of a stored prefix address (IPv4, IPv6 or MAC address)
Definition: agent_route.h:375
const MacAddress & rewrite_dmac() const
Definition: tunnel_nh.h:41
boost::asio::ip::address_v4 Ip4Address
Definition: address.h:14
virtual std::string ToString() const
Definition: agent_path.h:325
uint32_t mpls_label_
Definition: agent_path.h:815
EvpnPeer * evpn_peer() const
uint32_t GetActiveLabel() const
Definition: agent_path.cc:79
static const uint32_t kInvalidLabel
Definition: mpls.h:101
VrfKey vrf_key_
Definition: agent_path.h:739
VrfTable * vrf_table() const
Definition: agent.h:485
bool ResolveGwNextHops(Agent *agent, const AgentRoute *sync_route)
Definition: agent_path.cc:327
bool UpdateNHPolicy(Agent *agent)
Definition: agent_path.cc:184
virtual bool Sync(AgentRoute *sync_route)
Definition: agent_path.cc:440
uint32_t evpn_label_
Definition: agent_path.h:869
void clear_sg_list()
Definition: agent_path.h:294
void set_inactive(bool inactive)
Definition: agent_path.h:421
AgentPathEcmpComponentPtrList ecmp_member_list_
Definition: agent_path.h:533
std::string dest_vn_name_
Definition: agent_path.h:927
virtual AgentPath * CreateAgentPath(const Peer *peer, AgentRoute *rt) const
Definition: agent_path.cc:1379
Definition: mpls.h:99
const MacAddress & GetIpMac(const IpAddress &, const uint8_t plen) const
virtual const NextHop * ComputeNextHop(Agent *agent) const
Definition: agent_path.cc:647
const MacAddress & GetDMac() const
Definition: nexthop.h:1294
void UpdateEcmpHashFields(const Agent *agent, const EcmpLoadBalance &ecmp_load_balance, DBRequest &nh_req)
Definition: agent_path.cc:2006
void set_tag_list(const TagList &tag)
Definition: agent_path.h:292
void set_nexthop(NextHop *nh)
Definition: agent_path.cc:578
const TagList tag_list_
Definition: agent_path.h:1217
virtual std::string ToString() const =0
boost::scoped_ptr< InterfaceKey > intf_
Definition: agent_path.h:951
void set_is_subnet_discard(bool discard)
Definition: agent_path.h:300
CommunityList communities_
Definition: agent_path.h:706
SecurityGroupList sg_list_
Definition: agent_path.h:841
void RemoveUnresolvedRoute(const AgentRoute *rt)
Definition: agent_route.cc:412
void set_origin_vn(const std::string &origin_vn)
Definition: agent_path.h:284
bool IsMaster() const
Definition: tsn_elector.cc:176
uint32_t vxlan_id_
Definition: agent_path.h:450
AgentPathEcmpComponent(IpAddress addr, uint32_t label, AgentRoute *rt)
Definition: agent_path.cc:2198
void Process(DBRequest &req)
Definition: nexthop.cc:367
VnListType dest_vn_list_
Definition: agent_path.h:768
uint32_t label_
Definition: agent_path.h:952
TagList tag_list_
Definition: agent_path.h:705
const VnListType dest_vn_list_
Definition: agent_path.h:1220
PathPreference path_preference_
Definition: agent_path.h:708
virtual bool UpdateRoute(AgentRoute *rt)
Definition: agent_path.cc:788
Definition: mpls.h:52
uint32_t label_
Definition: agent_path.h:448
VnListType dest_vn_list_
Definition: agent_path.h:700
bool proxy_arp_
Definition: agent_path.h:955
void set_flood_dhcp(bool flood_dhcp)
Definition: agent_path.h:1095
bool dest_vn_match(const std::string &vn) const
Definition: agent_path.cc:1809
void set_etree_leaf(bool leaf)
Definition: agent_path.h:392
virtual bool UpdateRoute(AgentRoute *rt)
Definition: agent_path.cc:1536
void DeleteEvpnType5Route(Agent *agent, const AgentRoute *rt) const
Definition: agent_path.cc:2066
void set_arp_valid(bool valid)
Definition: agent_path.h:355
void set_composite_nh_key(CompositeNHKey *key)
Definition: agent_path.h:332
VrfEntry * forwarding_vrf() const
Definition: vrf.h:217
virtual bool flood_dhcp() const
Definition: agent_path.h:1094
bool Reorder(Agent *agent, uint32_t label, const NextHop *nh)
Definition: nexthop.cc:2740
AgentRoute * GetParentRoute()
Definition: agent_path.h:428
#define LOG(_Level, _Msg)
Definition: logging.h:33
VnListType dest_vn_list_
Definition: agent_path.h:452
EvpnDerivedPathData(const EvpnRouteEntry *evpn_rt)
Definition: agent_path.cc:651
VrfEntry * vrf() const
Definition: agent_route.h:275
CompositeNH * ChangeTunnelType(Agent *agent, TunnelType::Type type) const
Definition: nexthop.cc:2302
TagList tag_list_
Definition: agent_path.h:842
MplsLabel * FindMplsLabel(uint32_t label)
Definition: mpls.cc:399
uint32_t vxlan_id() const
Definition: agent_path.h:891
bool ecmp_suppressed() const
Definition: agent_path.h:357
bool arp_valid() const
Definition: agent_path.h:354
void set_label(uint32_t label)
Definition: agent_path.h:282
void set_arp_mac(const MacAddress &mac)
Definition: agent_path.h:346
bool pbb_nh() const
Definition: nexthop.h:1914
const std::string & name() const
Definition: interface.h:114
uint32_t label_
Definition: agent_path.h:907
const Interface * get_interface() const
Definition: nexthop.h:754
const Peer * local_vm_peer() const
Definition: agent.h:1023
static const MacAddress & pkt_interface_mac()
Definition: agent.h:440
const Ip4Address * NexthopIp(Agent *agent) const
Definition: agent_path.cc:1955
bool UpdateTunnelType(Agent *agent, const AgentRoute *sync_route)
Definition: agent_path.cc:228
bool PolicyEnabled() const
Definition: nexthop.h:407
void set_dest_vn_list(const VnListType &dest_vn_list)
Definition: agent_path.h:283
DBRequest composite_nh_req_
Definition: agent_path.h:910
virtual const NextHop * ComputeNextHop(Agent *agent) const
Definition: agent_path.cc:91
bool wait_for_traffic() const
Definition: agent_path.h:42
IpamSubnetRoute(DBRequest &nh_req, const std::string &dest_vn_name)
Definition: agent_path.cc:1493
bool ConfigChanged(const PathPreference &rhs) const
Definition: agent_path.h:142
PathPreference path_preference_
Definition: agent_path.h:190
AgentMode agent_mode() const
Definition: agent_param.h:380
PacketInterfaceKey intf_
Definition: agent_path.h:790
uint16_t tag_
Definition: agent_path.h:838
void SetPolicy(bool policy)
Definition: nexthop.h:495
bool subnet_hosts_resolvable() const
Definition: agent_param.h:353
const Peer * fabric_rt_export_peer() const
Definition: agent.h:1037
DBTablePartBase * get_table_partition() const
Definition: db_entry.cc:115
const PathPreference path_preference_
Definition: agent_path.h:1215
void set_ecmp(bool ecmp)
Definition: agent_path.h:88
PathPreference path_preference_
Definition: agent_path.h:490
virtual bool AddChangePathExtended(Agent *agent, AgentPath *path, const AgentRoute *rt)
Definition: agent_path.cc:885
const IpAddress & dependent_ip() const
Definition: agent_path.h:68
uint32_t label_
Definition: agent_path.h:839
bool copy_local_path_
Definition: agent_path.h:528
virtual std::string ToString() const
void Notify(DBEntryBase *entry)
const VrfEntry * vrf() const
Definition: nexthop.h:1146
bool ResyncControlWord(const AgentRoute *rt)
Definition: agent_path.cc:2033
uint32_t ethernet_tag() const
Definition: agent_path.h:599
uint32_t tunnel_bmap() const
Definition: agent_path.h:267
void reset(ObjectType *ptr)
Definition: dependency.h:32
bool mac_ip_learning_enable() const
void set_delete_on_zero_refcount(bool val)
Definition: nexthop.h:1346
const Interface * arp_interface() const
Definition: agent_path.h:349
void set_tunnel_type(TunnelType::Type type)
Definition: agent_path.h:290
virtual bool AddChangePathExtended(Agent *agent, AgentPath *path, const AgentRoute *rt)
Definition: agent_path.cc:799
const CommunityList & communities() const
Definition: agent_path.h:250
const ComponentNHKeyList & component_nh_key_list() const
Definition: nexthop.h:1719
Definition: peer.h:257
void set_force_policy(bool force_policy)
Definition: agent_path.h:287
const PathPreference path_preference_
Definition: agent_path.h:816
const EcmpLoadBalance ecmp_load_balance_
Definition: agent_path.h:1216
bool DBEntrySandesh(Sandesh *sresp, std::string &name) const
Definition: nexthop.cc:3455
const Ip4Address * router_ip_ptr() const
Definition: agent.h:668
IpAddress subnet_service_ip_
Definition: agent_path.h:709
virtual NextHopKey * Clone() const =0
boost::uuids::uuid uuid_
Definition: interface.h:244
virtual bool AddChangePathExtended(Agent *agent, AgentPath *path, const AgentRoute *rt)
Definition: agent_path.cc:905
InterfaceKey * Clone() const
uint32_t sequence() const
Definition: agent_path.h:40
static TypeBmap VxlanType()
Definition: nexthop.h:311
void GetDestinationVnList(std::vector< std::string > *vn_list) const
Definition: agent_path.cc:1713
const MacAddress dest_bmac() const
Definition: nexthop.h:1147
const IpAddress & ip_addr() const
Definition: agent_path.h:595
uint32_t vxlan_id_
Definition: agent_path.h:814
TunnelType::Type tunnel_type_
Definition: agent_path.h:476
const SecurityGroupList & sg_list() const
Definition: agent_path.h:248
uint32_t vxlan_id() const
Definition: agent_path.h:265
SecurityGroupList sg_list_
Definition: agent_path.h:743
const EcmpLoadBalance & ecmp_load_balance() const
Definition: agent_path.h:365
const std::string & intf_route_type() const
Definition: agent_path.h:688
virtual Agent::RouteTableType GetTableType() const =0
void CalculateChangeInEcmpFields(const EcmpLoadBalance &ecmp_load_balance, EcmpHashFields &ecmp_hash_fields)
void set_ecmp_load_balance(const EcmpLoadBalance &ecmp_load_balance)
Definition: agent_path.h:368
NextHop * UpdateNH(Agent *agent, CompositeNH *cnh, const TsnElector *te)
Definition: agent_path.cc:1347
void CopyLocalPath(CompositeNHKey *composite_nh_key, const AgentPath *local_path)
Definition: agent_path.cc:1824
void SyncRoute(bool sync)
Definition: agent_path.h:318
std::vector< int > TagList
Definition: agent.h:202
const ComponentNHKeyList & component_nh_key_list() const
Definition: nexthop.h:1872
MacAddress arp_mac() const
Definition: agent_path.h:345