OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
vxlan_routing_manager.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #ifndef __AGENT_OPER_VXLAN_ROUTING_H
6 #define __AGENT_OPER_VXLAN_ROUTING_H
7 
8 #include <cmn/agent_cmn.h>
9 #include <cmn/agent.h>
10 #include <oper/oper_db.h>
11 #include <base/logging.h>
12 
13 class BgpPeer;
14 namespace autogen {
15  struct EnetNextHopType;
16  struct NextHopType;
17 }
18 
19 
24 
26  RouteParameters(const IpAddress& nh_addr,
27  const MacAddress& mac,
28  const VnListType& vns,
29  const SecurityGroupList& sgs,
30  const CommunityList& comms,
31  const TagList& tags,
32  const PathPreference& ppref,
33  const EcmpLoadBalance& ecmp,
34  uint64_t seq_n):
35  nh_addresses_(1, nh_addr),
36  nh_addr_(nh_addresses_.at(0)),
37  nh_mac_(mac),
38  vn_list_(vns), sg_list_(sgs),
39  communities_(comms), tag_list_(tags),
40  path_preference_(ppref),
41  ecmp_load_balance_(ecmp),
42  sequence_number_(seq_n) {
43  }
44 
48  nh_addr_(rp.nh_addr_),
49  nh_mac_(rp.nh_mac_),
55  }
56 
57  // template <class ITEM_T
58  // static std::vector<typename ITEM_T> ItemToVector(const ITEM_T& item) {
59  // return std::vector<ITEM_T>();
60  // }
61 
62  // template<class ITEM_T>
63  // RouteParameters(const ITEM_T& item,
64  // const VnListType& vns,
65  // const SecurityGroupList& sgs,
66  // const TagList& tags,
67  // const PathPreference& ppref,
68  // const EcmpLoadBalance& ecmp,
69  // uint64_t seq_n):
70  // nh_addr_(nh_addr),
71  // vn_list_(vns), sg_list_(sgs),
72  // tag_list_(tags), path_preference_(ppref),
73  // ecmp_load_balance_(ecmp),
74  // sequence_number_(seq_n) {
75  // }
76 
78  const std::vector<IpAddress> nh_addresses_;
79 
83 
86 
90 
93 
96 
99 
102 
105 
108 
109 private:
110 
112  RouteParameters();
113 };
114 
119 struct VxlanRoutingState : public DBState {
120 
124  VrfEntry *vrf);
125 
127  virtual ~VxlanRoutingState();
128 
132 
136 
140 
143 
146 
149 };
150 
155 struct VxlanRoutingVnState : public DBState {
156 
158  typedef std::set<const VmInterface *> VmiList;
159 
161  typedef VmiList::iterator VmiListIter;
162 
165 
167  virtual ~VxlanRoutingVnState();
168 
172  void AddVmi(const VnEntry *vn, const VmInterface *vmi);
173 
176  void DeleteVmi(const VnEntry *vn, const VmInterface *vmi);
177 
180 
183  std::set<const VmInterface *> vmi_list_;
184 
188 
191 
195 
198 };
199 
202 struct VxlanRoutingVmiState : public DBState {
203 
206 
208  virtual ~VxlanRoutingVmiState();
209 
213 
216 };
217 
227 public:
228 
231  VxlanRoutingRouteWalker(const std::string &name,
233 
235  virtual ~VxlanRoutingRouteWalker();
236 
239  virtual bool RouteWalkNotify(DBTablePartBase *partition, DBEntryBase *e);
240 
241 private:
242 
245 
247 };
248 
249 
263 public:
264 
267  struct RoutedVrfInfo {
268 
271  typedef std::set<const VnEntry *> BridgeVnList;
272 
275  typedef std::map<const VnEntry *, std::string> BridgeVrfNamesList;
276 
279  typedef BridgeVnList::iterator BridgeVnListIter;
280 
283  routing_vrf_(NULL), bridge_vn_list_() {
284  }
285 
287  virtual ~RoutedVrfInfo() {
288  }
289 
293 
297 
301 
305  };
306 
309  typedef std::map<boost::uuids::uuid, RoutedVrfInfo> LrVrfInfoMap;
310 
312  typedef LrVrfInfoMap::iterator LrVrfInfoMapIter;
313 
317  typedef std::map<const VnEntry *, boost::uuids::uuid> VnLrSet;
318 
320  typedef VnLrSet::iterator VnLrSetIter;
321 
325  typedef std::map<const InetUnicastAgentRouteTable *, DBTable::DBTableWalkRef>
327 
331 
333  virtual ~VxlanRoutingVrfMapper();
334 
338  DBTableBase *partition);
339 
343  DBTableBase *partition);
344 
348  DBTableBase *partition);
349 
355 
357  bool IsEmpty() const {
358  return ((vn_lr_set_.size() == 0) &&
359  (lr_vrf_info_map_.size() == 0));
360  }
361 
362 private:
363 
365  friend class VxlanRoutingManager;
366 
369  void WalkBridgeVrfs(const RoutedVrfInfo &routing_vrf_info);
370 
373  void WalkRoutingVrf(const boost::uuids::uuid &lr_uuid,
374  const VnEntry *vn, bool update, bool withdraw);
375 
379 
381  const VrfEntry *GetRoutingVrfUsingVn(const VnEntry *vn);
382 
386 
388  const VrfEntry *GetRoutingVrfUsingUuid(const boost::uuids::uuid &lr_uuid);
389 
392 
395 
399 
404 
407 
410 
412 };
413 
424 public:
425 
429  VxlanRoutingManager(Agent *agent);
430 
432  virtual ~VxlanRoutingManager();
433 
436  void Register();
437 
440  void Shutdown();
441 
444  void VnNotify(DBTablePartBase *partition, DBEntryBase *e);
445 
448  void BridgeVnNotify(const VnEntry *vn, VxlanRoutingVnState *vn_state);
449 
452  void RoutingVnNotify(const VnEntry *vn, VxlanRoutingVnState *vn_state);
453 
456  void VrfNotify(DBTablePartBase *partition, DBEntryBase *e);
457 
460  void VmiNotify(DBTablePartBase *partition, DBEntryBase *e);
461 
464  bool RouteNotify(DBTablePartBase *partition, DBEntryBase *e);
465 
467 
468 private:
469 
472  bool InetRouteNotify(DBTablePartBase *partition, DBEntryBase *e);
473 
476  bool EvpnRouteNotify(DBTablePartBase *partition, DBEntryBase *e);
477 
483 
487  const VrfEntry *routing_vrf);
488 
491  void WhenRoutingEvpnRouteWasDeleted(const EvpnRouteEntry *routing_evpn_rt,
492  const Peer* delete_from_peer);
493 
494 public:
495 
499  (const VrfEntry *routing_vrf, DBTablePartBase *partition, DBEntryBase *e);
500 
506  DBEntryBase *e,
507  const boost::uuids::uuid &uuid,
508  const VnEntry *vn,
509  bool update = false);
510 
513  void HandleSubnetRoute(const VrfEntry *vrf, bool bridge_vrf = false);
514 
515 private:
516 
518  void RoutingVrfDeleteAllRoutes(VrfEntry* rt_vrf);
519 
522  void DeleteSubnetRoute(const VrfEntry *vrf);
523  //void DeleteSubnetRoute(const VrfEntry *vrf, VnIpam *ipam = NULL);
524 
527  void DeleteSubnetRoute(const VnEntry *vn,
528  const std::string& vrf_name);
529 
532  void DeleteIpamRoutes(const VnEntry *vn,
533  const std::string& vrf_name,
534  const IpAddress& ipam_prefix,
535  const uint32_t plen);
536 
539  void UpdateSubnetRoute(const VrfEntry *vrf,
540  const VrfEntry *routing_vrf);
541 public:
542 
544  void FillSandeshInfo(VxlanRoutingResp *resp);
545 
548  return vn_listener_id_;
549  }
550 
553  return vrf_listener_id_;
554  }
555 
558  return vmi_listener_id_;
559  }
560 
564  return vrf_mapper_;
565  }
566 
569  return walker_.get();
570  }
571 
572 private:
573 
575 
579 
582 
585 
589 
592 
595 
598 
602 
605  static uint32_t loc_sequence_;
606 
609  static tbb::mutex mutex_;
610 
612 
616 
618  friend class ControllerEcmpRoute;
619 
621  friend class AgentXmppChannel;
622 
625 
628  friend class VxlanRoutingVrfMapper;
629 
631  friend class MetadataProxy;
632 
634 
636  static uint32_t GetNewLocalSequence(const AgentPath*);
637 
640  static bool is_ipv4_string(const std::string& prefix_str);
641 
644  static bool is_ipv6_string(const std::string& prefix_str);
645 
647  static uint32_t ipv4_prefix_len(const std::string& prefix_str);
648 
650  static std::string ipv4_prefix(const std::string& prefix_str);
651 
653  static uint32_t ipv6_prefix_len(const std::string& prefix_str);
654 
656  static std::string ipv6_prefix(const std::string& prefix_str);
657 
659  static bool IsVxlanAvailable(const Agent* agent);
660 
664  std::string GetOriginVn(const VrfEntry* routing_vrf,
665  const IpAddress& ip_addr,
666  const uint8_t& plen);
667 
670  static bool RoutePrefixIsEqualTo(const EvpnRouteEntry* route,
671  const IpAddress& prefix_ip,
672  const uint32_t prefix_len);
673 
676  static bool RoutePrefixIsEqualTo(const InetUnicastRouteEntry* route,
677  const IpAddress& prefix_ip,
678  const uint32_t prefix_len);
679 
683  static bool IsHostRoute(const IpAddress& prefix_ip, uint32_t prefix_len);
684 
687  static bool IsHostRoute(const EvpnRouteEntry *rt);
688 
693 
697  bool IsVrfLocalRoute(EvpnRouteEntry *routing_evpn_rt,
698  VrfEntry *bridge_vrf);
699 
702  bool IsLocalRoute(EvpnRouteEntry *routing_evpn_rt,
703  VrfEntry *bridge_vrf);
704 
707  static bool HasVrfNexthop(const AgentRoute* rt);
708 
711  bool HasBgpPeerPath(EvpnRouteEntry *evpn_rt);
712 
716  static bool IsRoutingVrf(const VrfEntry* vrf);
717 
721  static bool IsBridgeVrf(const VrfEntry* vrf);
722 
726  static bool IsRoutingVrf(const std::string vrf_name, const Agent *agent);
727 
729  static const AgentPath* FindPathWithGivenPeer(
730  const AgentRoute *inet_rt,
731  const Peer::Type peer_type);
732 
736  const AgentRoute *inet_rt,
737  const Peer::Type peer_type,
738  const NextHop::Type nh_type,
739  bool strict_match = true);
740 
744  const AgentRoute *inet_rt,
745  const Peer::Type peer_type,
746  bool strict_match = true);
747 
752  const AgentRoute *inet_rt,
753  bool strict_match = true);
754 
758  const AgentRoute *inet_rt,
759  bool strict_match = true);
760 
765 
769  void AdvertiseBGPaaSRoute(const IpAddress& prefix_ip, uint32_t prefix_len,
770  const AgentPath* path, EvpnAgentRouteTable *evpn_table);
771 
774  static MacAddress NbComputeMac(const Ip4Address& compute_ip,
775  const Agent *agent);
776 
778 
782  const MacAddress& dmac) const;
783 
785  void XmppAdvertiseEvpnRoute(const IpAddress& prefix_ip,
786  const int prefix_len, uint32_t vxlan_id, const std::string vrf_name,
787  const RouteParameters& params, const Peer *bgp_peer);
788 
790  void XmppAdvertiseInetRoute(const IpAddress& prefix_ip,
791  const int prefix_len, uint32_t vxlan_id, const std::string vrf_name,
792  const RouteParameters& params, const Peer *bgp_peer);
793 
795  void XmppAdvertiseInetRoute(const IpAddress& prefix_ip,
796  const int prefix_len, const std::string vrf_name,
797  const AgentPath*);
798 
802  EvpnAgentRouteTable *inet_table, const IpAddress& prefix_ip,
803  const int prefix_len, uint32_t vxlan_id, const std::string vrf_name,
804  const RouteParameters& params, const Peer *bgp_peer);
805 
809  EvpnAgentRouteTable *inet_table, const IpAddress& prefix_ip,
810  const int prefix_len, uint32_t vxlan_id, const std::string vrf_name,
811  const RouteParameters& params, const Peer *bgp_peer);
812 
816  InetUnicastAgentRouteTable *inet_table, const IpAddress& prefix_ip,
817  const int prefix_len, uint32_t vxlan_id, const std::string vrf_name,
818  const RouteParameters& params, const Peer *bgp_peer);
819 
823  InetUnicastAgentRouteTable *inet_table, const IpAddress& prefix_ip,
824  const int prefix_len, const std::string vrf_name,
825  const AgentPath* path);
826 
830  InetUnicastAgentRouteTable *inet_table, const IpAddress& prefix_ip,
831  const int prefix_len, const std::string vrf_name,
832  const AgentPath* path);
833 
835 
838  template <class ItType>
839  static std::vector<IpAddress> ItemNexthopsToVector(ItType *item);
840 
844  template<typename NhType>
845  static void AddInterfaceComponentToList(
846  const std::string& prefix_str,
847  const std::string& vrf_name,
848  const NhType &nh_item,
849  ComponentNHKeyList& comp_nh_list);
850 
853  static AgentRoute *FindEvpnOrInetRoute(const Agent *agent,
854  const std::string &vrf_name,
855  const IpAddress &ip_addr,
856  uint32_t prefix_len,
857  const autogen::EnetNextHopType &nh_item);
858 
861  static AgentRoute *FindEvpnOrInetRoute(const Agent *agent,
862  const std::string &vrf_name,
863  const IpAddress &ip_addr,
864  uint32_t prefix_len,
865  const autogen::NextHopType &nh_item);
866 
868 
871  static void DeleteOldInterfacePath(const IpAddress &prefix_ip,
872  const uint32_t plen,
873  const Peer *peer,
874  EvpnAgentRouteTable *evpn_table);
875 
879  static void CopyInterfacePathToEvpnTable(const AgentPath* path,
880  const IpAddress &prefix_ip,
881  const uint32_t plen,
882  const Peer *peer,
883  const RouteParameters &params,
884  EvpnAgentRouteTable *evpn_table);
885 
887  static void DeleteOldInterfacePath(const IpAddress &prefix_ip,
888  const uint32_t plen,
889  const Peer *peer,
890  InetUnicastAgentRouteTable *inet_table);
891 
895  void CopyPathToInetTable(const AgentPath* path,
896  const IpAddress &prefix_ip,
897  const uint32_t plen,
898  const Peer *peer,
899  const RouteParameters &params,
900  InetUnicastAgentRouteTable *inet_table);
901 
902 public:
903 
905  static void PrintEvpnTable(const VrfEntry* const_vrf);
906 
908  static void PrintInetTable(const VrfEntry* const_vrf);
909 
911  static void ListAttachedVns();
912 
914 };
915 
916 #include <oper/vxlan_templates.cc>
917 
918 #endif
void AddVmi(const VnEntry *vn, const VmInterface *vmi)
Adds a VmInterface (LR port) to a Logical Router and connects the given VirtualNetwork (to which the ...
void XmppAdvertiseEvpnTunnel(EvpnAgentRouteTable *inet_table, const IpAddress &prefix_ip, const int prefix_len, uint32_t vxlan_id, const std::string vrf_name, const RouteParameters &params, const Peer *bgp_peer)
Advertises in the EVPN table a tunnel route that arrived via XMPP channel. Must be called only from X...
const TagList & tag_list_
A list of tags.
void VrfNotify(DBTablePartBase *partition, DBEntryBase *e)
A handler for changes (new/update/delete) in a VRF instance (VrfEntry class).
static tbb::mutex mutex_
virtual ~VxlanRoutingManager()
Destroys the VxlanRoutingManager instance.
Agent * agent() const
VxlanRoutingVnState(VxlanRoutingManager *mgr)
Constructs new instance using VxlanRoutingManager.
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.
VxlanRoutingVmiState()
Constructs new instance of VxlanRoutingVmiState.
DBTable::ListenerId vrf_listener_id_
An ID of the listener to changes in VrfTable.
std::set< const VmInterface * > vmi_list_
A list of VmInterface (router&#39;s ports) connected to a Logical Router (LR)
LrVrfInfoMap::iterator LrVrfInfoMapIter
A typedef for iterator of LrVrfInfoMap.
static bool IsBridgeVrf(const VrfEntry *vrf)
Determines whether the pointer to the VRF instance is of bridge type.
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
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 ...
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.
void WhenBridgeInetIntfWasDeleted(const InetUnicastRouteEntry *inet_rt, const VrfEntry *routing_vrf)
Handles deletion of a route in the EVPN table of the routing VRF instance.
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.
void RoutingVrfRouteWalkDone(DBTable::DBTableWalkRef walk_ref, DBTableBase *partition)
Handles completion of route walk in the EVPN table of a routing VRF instance.
VxlanRoutingRouteWalker(const std::string &name, VxlanRoutingManager *mgr, Agent *agent)
Constructs a new instance using the given name, pointer to the VxlanRoutingManager and pointer to the...
void DeleteVmi(const VnEntry *vn, const VmInterface *vmi)
Deletes the VmInterface from set of connected interfaces and disconnects the given VirtualNetwork fro...
DISALLOW_COPY_AND_ASSIGN(VxlanRoutingVrfMapper)
boost::asio::ip::address IpAddress
Definition: address.h:13
RouteParameters(const IpAddress &nh_addr, const MacAddress &mac, const VnListType &vns, const SecurityGroupList &sgs, const CommunityList &comms, const TagList &tags, const PathPreference &ppref, const EcmpLoadBalance &ecmp, uint64_t seq_n)
Constructs RouteParameters object from components.
DISALLOW_COPY_AND_ASSIGN(VxlanRoutingManager)
std::vector< int > SecurityGroupList
Definition: agent.h:201
AgentRouteWalker * walker()
Returns a pointer to the AgentRouteWalkerPtr object.
int ListenerId
Definition: db_table.h:62
void HandleSubnetRoute(const VrfEntry *vrf, bool bridge_vrf=false)
Handles routing routes (with VrfNH) update in the routing VRF instance.
bool WithdrawEvpnRouteFromRoutingVrf(const VrfEntry *routing_vrf, DBTablePartBase *partition, DBEntryBase *e)
Deletes a given EVPN route from EVPN table of the routing VRF instance.
const boost::uuids::uuid GetLogicalRouterUuidUsingRoute(const AgentRoute *rt)
Find the UUID of the LR using a given route (AgentRoute).
boost::uuids::uuid uuid
DISALLOW_COPY_AND_ASSIGN(VxlanRoutingRouteWalker)
const VxlanRoutingVrfMapper & vrf_mapper() const
Returns the map between LR uuids and associated bridge and routing VRF instances. ...
Listens to Inet routes in a bridge VRF instance. Started when l3vrf is added/deleted or when a bridge...
const VrfEntry * GetRoutingVrfUsingAgentRoute(const AgentRoute *rt)
Find the routing VRF instance using a given route (AgentRoute).
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.
InetTableWalker inet6_table_walker_
The set of walkers for Inet IPv6 tables of bridge VRF instances.
A structure to hold path parameters during the transfer (routes leaking) of data between VRF instance...
const VrfEntry * GetRoutingVrfUsingUuid(const boost::uuids::uuid &lr_uuid)
Find the routing VRF instance using a given LR UUID.
uint64_t sequence_number_
An ID of sequence.
static bool is_ipv4_string(const std::string &prefix_str)
Determines whether the address string contains an IPv4 address as substring or not.
bool IsLocalRoute(EvpnRouteEntry *routing_evpn_rt, VrfEntry *bridge_vrf)
Determines if the given EVPN route is already present in the given VRF.
The class is used to store following information:
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 VrfEntry * GetRoutingVrfUsingVn(const VnEntry *vn)
Find the routing VRF instance using a given virtual network.
void UpdateSubnetRoute(const VrfEntry *vrf, const VrfEntry *routing_vrf)
Updates subnet routes (actually, paths with VrfNH) in the given bridge VRF.
VrfEntryRef vrf_ref_
Holds a reference to a VrfEntry when VirtualNetwork&#39;s reference stored in VrfGet() is null...
const SecurityGroupList & sg_list_
A list of security groups.
void XmppAdvertiseInetTunnel(InetUnicastAgentRouteTable *inet_table, const IpAddress &prefix_ip, const int prefix_len, uint32_t vxlan_id, const std::string vrf_name, const RouteParameters &params, const Peer *bgp_peer)
Advertises in the Inet table a tunnel route that arrived via XMPP channel. Must be called only from X...
DBTable::ListenerId evpn_id_
ID of a listener that tracks changes in the EVPN table of a routing VRF instance. ...
const VnEntry * routing_vn_
A pointer to the routing virtual network (VirtualNetwork) connected to a LR.
std::vector< ComponentNHKeyPtr > ComponentNHKeyList
Definition: nexthop.h:1641
const VrfEntry * routing_vrf_
A pointer to the routing VRF instance (L3 VRF) connected to a LR.
VnEntryRef vn_entry_
Reference (smart pointer) to the virtual network (VirtualNetwork) to which VmInterface belongs to...
VxlanRoutingManager * mgr_
A pointer to the VxlanRoutingManager instance.
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.
RouteParameters(const RouteParameters &rp)
Copy constructor.
DBTable::ListenerId vmi_listener_id_
An ID of the listener to changes in InterfaceTable.
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 std::vector< IpAddress > ItemNexthopsToVector(ItType *item)
Templates.
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...
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...
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.
VxlanRoutingManager * mgr_
A pointer to the instance of VxlanRoutingManager.
static void AddInterfaceComponentToList(const std::string &prefix_str, const std::string &vrf_name, const NhType &nh_item, ComponentNHKeyList &comp_nh_list)
Adds an interface or a composite of interfaces nexthops to the list of components NH keys needed for ...
void ClearRedundantVrfPath(DBEntryBase *e)
Removes redundant VrfNH path from a given route. These routes might arise with small chance in a brid...
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.
DBTable::ListenerId vn_listener_id() const
Returns the ID of the listener to changes in the VnTable.
VnLrSet vn_lr_set_
The map between pointer to VirtualNetwork (a bridge or routing virtual network connected to some LR) ...
boost::intrusive_ptr< VnEntry > VnEntryRef
Definition: agent.h:68
VmiList::iterator VmiListIter
A typedef for the iterator of VxlanRoutingVnState::VmiList.
const VnListType & vn_list_
A list of path destination virtual networks used in policy lookups.
virtual ~VxlanRoutingRouteWalker()
Destructs an instance of VxlanRoutingRouteWalker.
static uint32_t GetNewLocalSequence(const AgentPath *)
Auxilliary functions.
Definition: agent.h:358
virtual bool RouteWalkNotify(DBTablePartBase *partition, DBEntryBase *e)
Runs route leaking process when L3 VRF instance is added/deleted or when a bridge VRF is attached / d...
std::map< const VnEntry *, std::string > BridgeVrfNamesList
A typedef to store the correspondence between bridge virtual network (VirtualNetwork) pointer and a n...
bool RouteNotify(DBTablePartBase *partition, DBEntryBase *e)
Handler for changes (new/update/delete) in a route (EVPN or Inet). Main entry point for routes leakin...
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...
void WalkRoutingVrf(const boost::uuids::uuid &lr_uuid, const VnEntry *vn, bool update, bool withdraw)
Walks the EVPN table of the routing VRF instance of a given LR.
std::map< const InetUnicastAgentRouteTable *, DBTable::DBTableWalkRef > InetTableWalker
A typedef for a storage of all walkers on Inet tables, if needed the walk can be restarted instead of...
virtual ~VxlanRoutingVmiState()
Destroys an instance of VxlanRoutingVmiState.
const IpAddress & nh_addr_
A nexthop IP address of the tunnel. Contains first IP address of nh_addresses_ in case of a composite...
void VnNotify(DBTablePartBase *partition, DBEntryBase *e)
A handler for changes (new/update/delete) in a virtual network (VnEntry class).
virtual ~VxlanRoutingState()
Destroys an instance.
boost::uuids::uuid logical_router_uuid_
UUID of the LR to which this VmInterface is connected.
friend class AgentXmppChannelVxlanInterface
Allows access to Xmpp advertisement functions via external class.
boost::uuids::uuid logical_router_uuid() const
Returns the UUID of the Logical Router.
static uint32_t loc_sequence_
An always increasing counter for new paths (used to signal controoler about new routes).
AgentRouteWalkerManager * mgr()
RouteParameters()
Disallow default constructor.
std::vector< std::string > CommunityList
Definition: bgp_config.h:347
void FillSandeshInfo(VxlanRoutingResp *resp)
Updates Sandesh response.
void Register()
Registers handlers for events associated with changes in virtual networks (VnTable class) and VRF ins...
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
void XmppAdvertiseEvpnInterface(EvpnAgentRouteTable *inet_table, const IpAddress &prefix_ip, const int prefix_len, uint32_t vxlan_id, const std::string vrf_name, const RouteParameters &params, const Peer *bgp_peer)
Advertises in the EVPN table an interface route that arrived via XMPP channel. Must be called only fr...
RoutedVrfInfo()
Constructs an instance of RoutedVrfInfo.
std::set< std::string > VnListType
Definition: agent.h:212
bool EvpnRouteNotify(DBTablePartBase *partition, DBEntryBase *e)
Performs routes leaking between the EVPN table of the routing VRF instance and the Inet table of the ...
boost::intrusive_ptr< AgentRouteWalker > AgentRouteWalkerPtr
void BridgeInet6RouteWalkDone(DBTable::DBTableWalkRef walk_ref, DBTableBase *partition)
Handles completion of route walk in an Inet IPv6 table of a bridge VRF instance.
Tracks movement of a VmInterface amongth LRs. This is used to associate VmInterface with a LR and a V...
AgentRouteTable * inet4_table_
A pointer to the IPv4 Inet table of a bridge VRF instance.
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
VxlanRoutingManager(Agent *agent)
Constructs instance of the class and links to the Agent class instance. Since only one agent class in...
const PathPreference & path_preference_
A reference to the PathPreference of the path.
void WalkBridgeInetTables(InetUnicastAgentRouteTable *inet4, InetUnicastAgentRouteTable *inet6)
Walks given Inet tables (IPv4 and IPv6).
void TryDeleteLogicalRouter(LrVrfInfoMapIter &it)
Attempts to delete the given LR.
AgentRouteTable * evpn_table_
A pointer to the EVPN table of a routing VRF instance.
BridgeVrfNamesList bridge_vrf_names_list_
The list of bridge virtual networks (VirtualNetwork) names connected to a LR.
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...
void BridgeInet4RouteWalkDone(DBTable::DBTableWalkRef walk_ref, DBTableBase *partition)
Handles completion of route walk in the Inet IPv4 table of a bridge VRF instance. ...
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...
const MacAddress & nh_mac_
A nexthop MAC address (usually it is a MAC of the router).
const std::vector< IpAddress > nh_addresses_
A list of nexthops IP addreses of a composite tunnel.
VxlanRoutingVrfMapper vrf_mapper_
A map between LR uuids and associated bridge and routing VRF instances.
DBTable::ListenerId inet4_id_
ID of a listener that tracks changes in the IPv4 Inet table of a bridge VRF instance.
std::set< const VmInterface * > VmiList
A typedef for a set of pointers to VmInterface.
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.
void XmppAdvertiseEvpnRoute(const IpAddress &prefix_ip, const int prefix_len, uint32_t vxlan_id, const std::string vrf_name, const RouteParameters &params, const Peer *bgp_peer)
Advertises an EVPN route received using XMPP channel.
void WhenRoutingEvpnRouteWasDeleted(const EvpnRouteEntry *routing_evpn_rt, const Peer *delete_from_peer)
Handles deletion of a route in the Inet table of the routing VRF instance.
void XmppAdvertiseInetInterfaceOrComposite(InetUnicastAgentRouteTable *inet_table, const IpAddress &prefix_ip, const int prefix_len, const std::string vrf_name, const AgentPath *path)
Advertises in the Inet table an interface route that arrived via XMPP channel. Must be called only fr...
static void DeleteOldInterfacePath(const IpAddress &prefix_ip, const uint32_t plen, const Peer *peer, EvpnAgentRouteTable *evpn_table)
Routes copying functions.
bool InetRouteNotify(DBTablePartBase *partition, DBEntryBase *e)
Routes leaking functions.
This state tracks all virtual machine interfaces (VmInterface) attached to a Logical Router (LR)...
The structure holds information about virtual networks connected to a logical router (LR) ...
AgentRouteTable * inet6_table_
A pointer to the IPv6 Inet table of a bridge VRF instance.
DBTable::ListenerId vrf_listener_id() const
Returns the ID of the listener to changes in the VrfTable.
VxlanRoutingVrfMapper(VxlanRoutingManager *mgr)
Constructs a new instance of VxlanRoutingVrfMapper using the given pointer to VxlanRoutingManager.
This state tracks inet and evpn table listeners. The state establishes link between Inet tables of a ...
void Shutdown()
Unregisters handlers for events associated with changes in virtual networks (VnTable class) and VRF i...
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...
virtual ~VxlanRoutingVrfMapper()
Destroys an instance of VxlanRoutingVrfMapper().
static bool HasVrfNexthop(const AgentRoute *rt)
Determines whether the given route has the path with a VRF nexthop (VrfNH)
boost::intrusive_ptr< DBTableWalk > DBTableWalkRef
Definition: db_table.h:169
BridgeVnList::iterator BridgeVnListIter
A type for iterator of the list of bridge virtual networks connected to a LR.
void DeleteIpamRoutes(const VnEntry *vn, const std::string &vrf_name, const IpAddress &ipam_prefix, const uint32_t plen)
Delete routes to IPAM, specified by IP prefix and prefix length.
LrVrfInfoMap lr_vrf_info_map_
The map between Logical router UUID and RoutedVrfInfo.
void VmiNotify(DBTablePartBase *partition, DBEntryBase *e)
Handler for changes (new/update/delete) in a VMI (VmInterface class).
InetTableWalker inet4_table_walker_
The set of walkers for Inet IPv4 tables of bridge VRF instances.
bool is_routing_vn_
Returns true when state is associated with a routing VirtualNetwork.
static const Peer * routing_vrf_interface_peer_
Internal data of this class.
void RoutingVrfDeleteAllRoutes(VrfEntry *rt_vrf)
deletes all routes in EVPN table of routing VRF
void DeleteSubnetRoute(const VrfEntry *vrf)
Deletes subnet routes (actually, paths with VrfNH) in the given bridge VRF. This function is demanded...
virtual ~RoutedVrfInfo()
Destroys an instance of RoutedVrfInfo.
std::map< const VnEntry *, boost::uuids::uuid > VnLrSet
A typedef to store map between pointer to VirtualNetwork (a bridge or routing virtual network connect...
VxlanRoutingManager * mgr_
A pointer to the VxlanRoutingManager instance.
bool LeakRoutesIntoBridgeTables(DBTablePartBase *partition, DBEntryBase *e, const boost::uuids::uuid &uuid, const VnEntry *vn, bool update=false)
Performs advertisement and deletion of routing routes (with VrfNH) in bridge VRF instances. External tunnels and routes with a prefix that is not present in bridge VRF instance are selected for leaking.
AgentRouteWalkerPtr walker_
A pointer to the walker to loop over INET tables in bridge VRF instances.
virtual ~VxlanRoutingVnState()
Destroys a VxlanRoutingVnState object.
DBTable::ListenerId vmi_listener_id() const
Returns the ID of the listener to changes in the InterfaceTable.
const EcmpLoadBalance & ecmp_load_balance_
A reference to EcmpLoadBalance of the path.
DBTable::ListenerId inet6_id_
ID of a listener that tracks changes in the IPv6 Inet table of a bridge VRF instance.
bool IsEmpty() const
Determines whether object is empty or not.
TunnelNHKey * AllocateTunnelNextHopKey(const IpAddress &dip, const MacAddress &dmac) const
XMPP Advertising functions.
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.
void RoutingVnNotify(const VnEntry *vn, VxlanRoutingVnState *vn_state)
A handler for changes (new/update/delete) in the virtual network from a routing VRF.
static const Peer * routing_vrf_vxlan_bgp_peer_
A pointer to the Peer where all BGP routes are stored.
DBTable::ListenerId vn_listener_id_
An ID of the listener to changes in VnTable.
void BridgeVnNotify(const VnEntry *vn, VxlanRoutingVnState *vn_state)
A handler for changes (new/update/delete) in the virtual network from a bridge VRF.
void WalkBridgeVrfs(const RoutedVrfInfo &routing_vrf_info)
Walks Inet tables of all bridge VRF instances connected to a LR (given in routing_vrf_info parameter)...
void XmppAdvertiseInetRoute(const IpAddress &prefix_ip, const int prefix_len, uint32_t vxlan_id, const std::string vrf_name, const RouteParameters &params, const Peer *bgp_peer)
Advertises an Inet route received using XMPP channel.
boost::uuids::uuid logical_router_uuid_
A UUID of the Logical Router.
Type
Definition: peer.h:48
std::vector< int > TagList
Definition: agent.h:202
VnLrSet::iterator VnLrSetIter
A typedef for iterator of VnLrSet.
VxlanRoutingState(VxlanRoutingManager *mgr, VrfEntry *vrf)
Construct new instance using the given VxlanRoutingManager and VRF instance (VrfEntry).