5 #ifndef SRC_BGP_BGP_EVPN_H_
6 #define SRC_BGP_BGP_EVPN_H_
8 #include <boost/ptr_container/ptr_map.hpp>
9 #include <boost/scoped_ptr.hpp>
10 #include <tbb/spin_rw_mutex.h>
371 const SG &
sg()
const;
662 typedef boost::ptr_map<const EthernetSegmentId, EvpnSegment>
SegmentMap;
760 evpn_state->
refcount_.fetch_and_increment();
768 int prev = evpn_state->
refcount_.fetch_and_decrement();
771 if (evpn_state->
states()) {
772 EvpnState::StatesMap::iterator iter =
773 evpn_state->
states()->find(evpn_state->
sg());
774 if (iter != evpn_state->
states()->end()) {
775 assert(iter->second == evpn_state);
776 evpn_state->
states()->erase(iter);
787 #define EVPN_RT_LOG(rt, ...) \
788 RTINSTANCE_LOG(EvpnRoute, this->table()->routing_instance(), \
789 SandeshLevel::UT_DEBUG, \
790 RTINSTANCE_LOG_FLAG_ALL, \
791 (rt)->GetPrefix().source().to_string(), \
792 (rt)->GetPrefix().group().to_string(), \
793 (rt)->ToString(), ##__VA_ARGS__)
795 #define EVPN_ERMVPN_RT_LOG(rt, ...) \
796 RTINSTANCE_LOG(EvpnErmVpnRoute, this->table()->routing_instance(), \
797 SandeshLevel::UT_DEBUG, \
798 RTINSTANCE_LOG_FLAG_ALL, \
799 (rt)->GetPrefix().source().to_string(), \
800 (rt)->GetPrefix().group().to_string(), \
801 (rt)->ToString(), ##__VA_ARGS__)
803 #define EVPN_TRACE(type, ...) \
804 RTINSTANCE_LOG(type, this->table()->routing_instance(), \
805 SandeshLevel::UT_DEBUG, RTINSTANCE_LOG_FLAG_ALL, ##__VA_ARGS__)
807 #endif // SRC_BGP_BGP_EVPN_H_
tbb::spin_rw_mutex segment_rw_mutex_
bool operator==(const RemotePe &rhs) const
Equality operator for EvpnSegment::RemotePe. Do not compare esi_valid and single_active fields since ...
int intrusive_ptr_add_ref(const AsPath *cpath)
LifetimeActor * deleter()
Return the LifetimeActor for the EvpnManager.
bool ProcessSegmentUpdateSet()
Process the set of EvpnSegments that need to be updated.
const EvpnState::StatesMap & states() const
EvpnMcastNode(EvpnManagerPartition *partition, EvpnRoute *route, uint8_t type)
Constructor for EvpnMcastNode. The type indicates whether this is a local or remote EvpnMcastNode...
const EvpnMcastNodeList & remote_mcast_node_list() const
DISALLOW_COPY_AND_ASSIGN(EvpnManagerPartition)
tbb::atomic< int > db_states_count_
DISALLOW_COPY_AND_ASSIGN(EvpnMacState)
void Shutdown()
Initiate shutdown for the EvpnManager.
boost::intrusive_ptr< EvpnState > EvpnStatePtr
DISALLOW_COPY_AND_ASSIGN(EvpnMcastNode)
bool UpdatePeList()
Update the PE list for this EvpnSegment. This should be called when the AutoDisocvery route is update...
This class represents the EvpnManager state associated with a MAC route.
friend void intrusive_ptr_release(EvpnState *evpn_state)
Decrement refcount of an evpn_state. If the refcount falls to 1, it implies that there is no more ref...
ErmVpnRoute * global_ermvpn_tree_rt_
Ip4Address replicator_address() const
void ErmVpnRouteListener(DBTablePartBase *tpart, DBEntryBase *db_entry)
ErmVpnTable route listener callback function.
bool ProcessMacRouteAliasing()
Update aliased BgpPaths for the EvpnRoute based on the remote PEs for the EvpnSegment. Return true if the list of aliased paths is modified.
std::vector< EvpnManagerPartition * > PartitionList
BgpServer * server()
Return the BgpServer for the EvpnManagerPartition.
void TriggerMacRouteUpdate()
Trigger an update of all dependent MAC routes for this EvpnSegment. Note that the bgp::EvpnSegment ta...
bool empty() const
Return true if the EvpnManagerPartition is empty i.e. it has no local or remote EvpnMcastNodes and no...
std::map< SG, EvpnState * > StatesMap
boost::scoped_ptr< DeleteActor > deleter_
SegmentSet segment_delete_set_
EvpnManager(EvpnTable *table)
void AddInclusiveMulticastRoute()
Add Inclusive Multicast route for this EvpnLocalMcastNode. The attributes are based on the Broadcast ...
LifetimeRef< EvpnManager > table_delete_ref_
bool ProcessSegmentDeleteSet()
Process the set of EvpnSegments that can potentially be deleted. Remove the EvpnSegment from the map ...
EvpnMcastNodeList leaf_node_list_
void set_segment(EvpnSegment *segment)
void AutoDiscoveryRouteListener(EvpnRoute *route)
DBListener callback handler for AutoDisocvery routes in the EvpnTable.
bool RemoveMcastNodeFromList(EvpnState::SG &sg, EvpnMcastNode *node, EvpnMcastNodeList *list)
Delete an EvpnMcastNode from the EvpnManagerPartition.
EvpnManagerPartition * GetPartition(size_t part_id)
Get the EvpnManagerPartition for the given partition id.
EvpnMcastNodeList local_mcast_node_list_
tbb::atomic< int > refcount_
bool MayDelete() const
Return true if it's safe to delete this EvpnSegment.
This class represents (in the context of an EVPN instance) a local vRouter that's connected to a cont...
boost::asio::ip::address IpAddress
const EvpnMcastNodeList & local_mcast_node_list() const
const_iterator end() const
DISALLOW_COPY_AND_ASSIGN(EvpnManager)
DBTablePartition * table_partition_
void DisableMacUpdateProcessing()
Disable processing of the update lists in all partitions. For testing only.
bool assisted_replication_leaf_
RemotePeList::const_iterator const_iterator
friend class BgpEvpnAliasingTest
bool assisted_replication_supported_
void EnableMacUpdateProcessing()
Enable processing of the update lists in all partitions. For testing only.
void FreePartitions()
Free the EvpnManagerPartitions.
void SetDBState(EvpnRoute *route, EvpnMcastNode *dbstate)
Set DB State and update count.
EvpnMacState(EvpnManager *evpn_manager, EvpnRoute *route)
std::set< EvpnRoute * > EvpnRouteList
void NotifyReplicatorNodeRoutes()
Go through all replicator EvpnMcastNodes and notify associated Broadcast MAC route.
void ManagedDelete()
Trigger deletion of the EvpnManager and propagate the delete to any dependents.
const ErmVpnTable * table() const
void AddAliasedPath(AliasedPathList::const_iterator it)
Add the BgpPath specified by the iterator to the aliased path list. Also inserts the BgpPath to the B...
friend void intrusive_ptr_add_ref(EvpnState *evpn_state)
Increment refcont atomically.
void set_global_ermvpn_tree_rt(ErmVpnRoute *global_ermvpn_tree_rt)
void AddMacRoute(size_t part_id, EvpnRoute *route)
Add the given MAC route as a dependent of this EvpnSegment.
EvpnState::StatesMap & states()
bool edge_replication_not_supported() const
void clear_esi_ad_route()
void AllocPartitions()
Allocate the EvpnManagerPartitions.
SG(const Ip4Address &source, const Ip4Address &group)
int ermvpn_listener_id() const
EvpnManager * evpn_manager_
void NotifyIrClientNodeRoutes(bool exclude_edge_replication_supported)
Go through all ingress replication client EvpnMcastNodes and notify the associated Broadcast MAC rout...
const EvpnTable * table() const
Return the EvpnTable for the EvpnManagerPartition.
std::map< EvpnRoute *, BgpAttrPtr > RoutesMap
This class represents (in the context of an EVPN instance) a remote vRouter or PE discovered via BGP...
virtual void TriggerUpdate()
Handle update of EvpnRemoteMcastNode.
EvpnSegment * FindSegment(const EthernetSegmentId &esi)
Find the EvpnSegment for the given EthernetSegmentId.
EvpnMcastNodeList remote_mcast_node_list_
void SelectiveMulticastRouteListener(EvpnManagerPartition *partition, EvpnRoute *route)
DBListener callback handler for SelectiveMulticast routes in the EvpnTable.
DBTablePartition * GetTablePartition()
Get the DBTablePartition for the EvpnTable for our partition id.
boost::intrusive_ptr< const BgpAttr > BgpAttrPtr
virtual void Initialize()
Initialize the EvpnManager. We allocate the EvpnManagerPartitions and register a DBListener for the E...
RemotePe(const BgpPath *path)
void DeleteMacRoute(size_t part_id, EvpnRoute *route)
Delete the given MAC route as a dependent of this EvpnSegment. Trigger deletion of the EvpnSegment if...
EvpnState::StatesMap states_
void ClearDBState(EvpnRoute *route)
Create DB State and update count. If there is no DB State associated in the table, resume table deletion if the deletion was pending.
bool UpdateAttributes(EvpnRoute *route)
Update the label and attributes for a EvpnMcastNode. Return true if either of them changed...
boost::scoped_ptr< TaskTrigger > segment_update_trigger_
const EthernetSegmentId & esi() const
void RouteListener(DBTablePartBase *tpart, DBEntryBase *db_entry)
DBListener callback handler for the EvpnTable.
void EnableSegmentDeleteProcessing()
Enable processing of the delete list. For testing only.
virtual void TriggerUpdate()
Handle update of EvpnLocalMcastNode.
const ErmVpnTable * ermvpn_table() const
virtual void TriggerUpdate()=0
Handle update of EvpnLocalMcastNode.
void TriggerSegmentUpdate(EvpnSegment *segment)
Trigger update of the given EvpnSegment. The EvpnSegment is added to a set of EvpnSegments for which ...
friend class BgpEvpnManagerTest
const EvpnManager * manager() const
std::map< SG, std::set< EvpnMcastNode * > > EvpnMcastNodeList
DISALLOW_COPY_AND_ASSIGN(EvpnState)
This class represents the EVPN manager for an EvpnTable in a VRF.
This class represents a remote EVPN segment that has 2 or more PEs that are multi-homed to it...
void InclusiveMulticastRouteListener(EvpnManagerPartition *partition, EvpnRoute *route)
DBListener callback handler for InclusiveMulticast routes in the EvpnTable.
void DeleteAliasedPath(AliasedPathList::const_iterator it)
Delete the BgpPath specified by the iterator from the aliased path list. Also deletes the BgpPath fro...
void TriggerMacRouteUpdate(EvpnRoute *route)
Add the given MAC route to the update list. This method gets called either when the MAC route itself ...
void EnableMacUpdateProcessing()
Enable processing of the update list. For testing only.
virtual ~EvpnRemoteMcastNode()
DISALLOW_COPY_AND_ASSIGN(EvpnLocalMcastNode)
SegmentSet segment_update_set_
std::set< EvpnSegment * > SegmentSet
RoutesSet & smet_routes()
PartitionList partitions_
EvpnManager * evpn_manager_
std::vector< RouteList > RouteListVector
DISALLOW_COPY_AND_ASSIGN(EvpnSegment)
EvpnSegment * LocateSegment(const EthernetSegmentId &esi)
Find or create the EvpnSegment for the given EthernetSegmentId.
EvpnMcastNodeList replicator_node_list_
Ip4Address replicator_address_
DISALLOW_COPY_AND_ASSIGN(EvpnRemoteMcastNode)
virtual void Terminate()
Terminate the EvpnManager. We free the EvpnManagerPartitions and unregister from the EvpnTable...
std::set< EvpnRoute * > RoutesSet
EvpnManager * evpn_manager_
void AddMcastNode(EvpnMcastNode *node, EvpnRoute *route)
Add an EvpnMcastNode to the EvpnManagerPartition.
BgpPath * LocateAliasedPath(const EvpnSegment::RemotePe *remote_pe, uint32_t label)
Find or create the matching aliased BgpPath.
const EvpnMcastNodeList & leaf_node_list() const
void TriggerSegmentDelete(EvpnSegment *segment)
Trigger deletion of the given EvpnSegment. The EvpnSegment is added to a set of EvpnSegments that can...
const_iterator begin() const
void FillShowInfo(ShowEvpnTable *sevt) const
Fill information for introspect command. Note that all IM routes are always in partition 0...
EvpnMcastNodeList * local_mcast_node_list()
boost::asio::ip::address_v4 Ip4Address
Simple structure to hold <S,G>. Source as "0.0.0.0" can be used to encode <*,G> as well...
EvpnLocalMcastNode(EvpnManagerPartition *partition, EvpnRoute *route)
Constructor for EvpnLocalMcastNode.
bool single_active() const
AliasedPathList aliased_path_list_
virtual UpdateInfo * GetUpdateInfo(EvpnRoute *route)
Construct export state for the given EvpnRoute. Note that the route only needs to be exported to the ...
const RoutesSet & smet_routes() const
virtual ~EvpnLocalMcastNode()
void MacAdvertisementRouteListener(EvpnManagerPartition *partition, EvpnRoute *route)
DBListener callback handler for MacAdvertisement routes in the EvpnTable.
bool GetForestNodeAddress(ErmVpnRoute *rt, Ip4Address *address) const
EvpnRoute * esi_ad_route()
EvpnStatePtr LocateState(EvpnRoute *route)
This class holds Evpn state for a particular <S,G> at any given time.
EvpnStatePtr GetState(const SG &sg)
EvpnManagerPartition * partition_
void UpdateMcastNode(EvpnMcastNode *node, EvpnRoute *route)
Update an EvpnMcastNode in the EvpnManagerPartition. Need to remove/add EvpnMcastNode from the replic...
DBTablePartition * GetTablePartition(size_t part_id)
Get the DBTablePartition for the EvpnTable for given partition id.
RouteListVector route_lists_
const StatesMap * states() const
ErmVpnTable * ermvpn_table_
EvpnMcastNodeList * leaf_node_list()
bool ProcessMacUpdateList()
Process the MAC route update list for this EvpnManagerPartition.
EvpnRoute * inclusive_mcast_route_
EvpnMcastNodeList regular_node_list_
const EvpnSegment * segment() const
This class represents a partition in the EvpnManager.
void EnableSegmentUpdateProcessing()
Enable processing of the update list. For testing only.
void intrusive_ptr_release(const AsPath *cpath)
bool assisted_replication_supported() const
boost::scoped_ptr< TaskTrigger > segment_delete_trigger_
UpdateInfo * GetUpdateInfo(EvpnRoute *route)
void NotifyNodeRoute(EvpnMcastNode *node)
Notify the Broadcast MAC route for the given EvpnMcastNode.
void DisableSegmentDeleteProcessing()
Disable processing of the delete list. For testing only.
EvpnRemoteMcastNode(EvpnManagerPartition *partition, EvpnRoute *route)
std::list< RemotePe > RemotePeList
EvpnStatePtr CreateState(const SG &sg)
EvpnManagerPartition(EvpnManager *evpn_manager, size_t part_id)
EvpnSegment(EvpnManager *evpn_manager, const EthernetSegmentId &esi)
const EvpnTable * table() const
void DisableMacUpdateProcessing()
Disable processing of the update list. For testing only.
boost::scoped_ptr< TaskTrigger > mac_update_trigger_
void DeleteMcastNode(EvpnMcastNode *node, EvpnRoute *route)
Delete an EvpnMcastNode from the EvpnManagerPartition.
void set_esi_ad_route(EvpnRoute *esi_ad_route)
Ip4Address address() const
const BgpAttr * attr() const
boost::ptr_map< const EthernetSegmentId, EvpnSegment > SegmentMap
std::set< EvpnRoute * > RouteList
bool operator<(const SG &other) const
EvpnState(const SG &sg, StatesMap *states, EvpnManager *manager)
A global MVPN state for a given <S.G> within a EvpnProjectManager.
ErmVpnTable * ermvpn_table()
friend class BgpEvpnManagerTest
ErmVpnRoute * global_ermvpn_tree_rt()
std::set< BgpPath * > AliasedPathList
EvpnRouteList mac_update_list_
bool MayDelete() const
Trigger deletion of the EvpnManager and propagate the delete to any dependents.
bool assisted_replication_leaf() const
This is the base class for a multicast node in an EVPN instance. The node could either represent a lo...
void set_state(EvpnStatePtr state)
void NotifyForestNode(EvpnRoute *route, ErmVpnTable *table)
EvpnMcastNodeList ir_client_node_list_
bool edge_replication_not_supported_
EvpnRoute * inclusive_mcast_route()
EvpnMcastNodeList * remote_mcast_node_list()
void DisableSegmentUpdateProcessing()
Disable processing of the update list. For testing only.
bool IsUsableGlobalTreeRootRoute(ErmVpnRoute *ermvpn_route) const
Check whether an ErmVpnRoute is locally originated GlobalTreeRoute.
EvpnRoute * esi_ad_route_
void DeleteInclusiveMulticastRoute()
Delete Inclusive Multicast route for this EvpnLocalMcastNode.
void RetryDelete()
Attempt to enqueue a delete for the EvpnManager.