7 #include <boost/bind/bind.hpp>
8 #include <boost/foreach.hpp>
19 #include "bgp/routing-instance/routing_instance_analytics_types.h"
25 using namespace boost::placeholders;
30 :
LifetimeActor(tree_manager->table_->routing_instance()->server()->
32 tree_manager_(tree_manager) {
38 return tree_manager_->MayDelete();
42 tree_manager_->Shutdown();
46 tree_manager_->table_->DestroyTreeManager();
64 : sg_entry_(sg_entry),
66 global_tree_route_(NULL),
69 rd_(route->GetPrefix().route_distinguisher()),
70 router_id_(route->GetPrefix().router_id()) {
106 bool changed =
false;
139 for (McastForwarderList::iterator it =
tree_links_.begin();
141 if (*it == forwarder)
return forwarder;
158 for (McastForwarderList::iterator it =
tree_links_.begin();
160 if (*it == forwarder) {
172 for (McastForwarderList::iterator it =
tree_links_.begin();
174 (*it)->RemoveLink(
this);
242 attr_spec.push_back(&nexthop);
244 attr_spec.push_back(&source_rd);
246 for (McastForwarderList::const_iterator it =
tree_links_.begin();
255 attr_spec.push_back(&efspec);
260 attr_spec.push_back(&ext);
297 for (McastForwarderList::const_iterator it =
tree_links_.begin();
299 BgpOListElem elem((*it)->address(), (*it)->label(), (*it)->encap());
300 olist_spec->
elements.push_back(elem);
323 vector<string> encaps;
329 for (EdgeForwarding::EdgeList::const_iterator it =
336 olist_spec->
elements.push_back(elem);
365 attr_spec.push_back(&olist_spec);
382 : partition_(partition),
386 local_tree_route_(NULL),
387 tree_result_route_(NULL),
388 on_work_queue_(false) {
416 uint8_t level = forwarder->
level();
430 uint8_t level = forwarder->
level();
442 uint8_t level = forwarder->
level();
483 for (ForwarderSet::reverse_iterator rit = forwarders->rbegin();
484 rit != forwarders->rend(); ++rit) {
486 if (forwarder->
label()) {
510 tbl_partition->
Add(route);
518 attr_spec.push_back(&nexthop);
520 attr_spec.push_back(&source_rd);
528 attr_spec.push_back(&edspec);
533 attr_spec.push_back(&ext);
539 tbl_partition->
Notify(route);
589 for (ForwarderSet::iterator it = forwarders->begin();
590 it != forwarders->end(); ++it) {
591 (*it)->DeleteGlobalTreeRoute();
592 (*it)->AddGlobalTreeRoute();
601 assert(!forwarders->empty());
602 ForwarderSet::const_iterator it = forwarders->begin();
603 return (*it)->global_tree_route();
614 ForwarderSet::const_iterator it = forwarders->begin();
615 if (it == forwarders->end())
619 if ((*it)->router_id() != router_id)
653 for (ForwarderSet::iterator it = forwarders->begin();
654 it != forwarders->end(); ++it) {
656 (*it)->ReleaseLabel();
670 vec.reserve(forwarders->size());
671 for (ForwarderSet::iterator it = forwarders->begin();
672 it != forwarders->end(); ++it) {
675 if (!forwarder->
label())
677 vec.push_back(forwarder);
683 for (McastForwarderList::iterator it = vec.begin(); it != vec.end(); ++it) {
684 int idx = it - vec.begin();
688 int parent_idx = (idx - 1) / degree;
689 McastForwarderList::iterator parent_it = vec.begin() + parent_idx;
690 assert(parent_it != vec.end());
693 forwarder->
AddLink(parent_forwarder);
694 parent_forwarder->
AddLink(forwarder);
723 vector<string> *tunnel_encap)
const {
751 : tree_manager_(tree_manager),
754 work_queue_(
TaskScheduler::GetInstance()->GetTaskId(
"db::DBTable"),
781 SGList::const_iterator it =
sg_list_.find(&temp_sg_entry);
782 return (it !=
sg_list_.end() ? *it : NULL);
812 Ip4Address *address, vector<string> *encap)
const {
839 if (sg_entry->
empty()) {
874 listener_id_(
DBTable::kInvalidId),
875 table_delete_ref_(this, table->
deleter()) {
918 for (
size_t part_id = 0; part_id <
partitions_.size(); part_id++) {
1000 }
else if (forwarder->
Update(route)) {
1073 for (PartitionList::const_iterator it =
partitions_.begin();
1075 if (!(*it)->empty())
1141 Ip4Address *address, vector<string> *encap)
const {
boost::asio::ip::address_v4 Ip4Address
std::vector< BgpAttribute * > BgpAttrSpec
boost::intrusive_ptr< const BgpAttr > BgpAttrPtr
std::vector< McastForwarder * > McastForwarderList
const EdgeForwarding * edge_forwarding() const
LabelBlockPtr label_block() const
const IpAddress & nexthop() const
const EdgeDiscovery * edge_discovery() const
const ExtCommunity * ext_community() const
TypePtr Locate(Type *attr)
const BgpAttr * GetAttr() const
bool RemovePath(BgpPath::PathSource src, const IPeer *peer=NULL, uint32_t path_id=0)
const BgpPath * BestPath() const
void InsertPath(BgpPath *path)
uint32_t bgp_identifier() const
RoutingInstance * routing_instance()
DBState * GetState(DBTableBase *tbl_base, ListenerId listener) const
DBTableBase * get_table() const
void ClearState(DBTableBase *tbl_base, ListenerId listener)
DBTablePartBase * get_table_partition() const
void SetState(DBTableBase *tbl_base, ListenerId listener, DBState *state)
ListenerId Register(ChangeCallback callback, const std::string &name="unspecified")
void Unregister(ListenerId listener)
void Notify(DBEntryBase *entry)
void Delete(DBEntryBase *)
virtual void Add(DBEntry *entry)
DBEntry * Find(const DBEntry *entry)
virtual DBTablePartBase * GetTablePartition(const DBRequestKey *key)
Ip4Address source() const
Ip4Address router_id() const
const RouteDistinguisher & route_distinguisher() const
virtual bool IsValid() const
const ErmVpnPrefix & GetPrefix() const
void GetMvpnSourceAddress(ErmVpnRoute *ermvpn_route, Ip4Address *address) const
virtual int PartitionCount() const
virtual size_t Hash(const DBEntry *entry) const
void RemoveLink(McastForwarder *forwarder)
void AddGlobalOListElems(BgpOListSpec *olist_spec)
void AddGlobalTreeRoute()
void DeleteGlobalTreeRoute()
McastForwarder(McastSGEntry *sg_entry, ErmVpnRoute *route)
void AddLink(McastForwarder *forwarder)
LabelBlockPtr label_block_
Ip4Address address() const
McastForwarder * FindLink(McastForwarder *forwarder)
std::vector< std::string > encap() const
ErmVpnRoute * global_tree_route_
McastForwarderList tree_links_
void AddLocalOListElems(BgpOListSpec *olist_spec)
std::vector< std::string > encap_
bool Update(ErmVpnRoute *route)
std::string ToString() const
UpdateInfo * GetUpdateInfo(ErmVpnTable *table)
WorkQueue< McastSGEntry * > work_queue_
McastManagerPartition(McastTreeManager *tree_manager, size_t part_id)
bool GetForestNodePMSI(ErmVpnRoute *rt, uint32_t *label, Ip4Address *address, std::vector< std::string > *encap) const
ErmVpnRoute * GetGlobalTreeRootRoute(const Ip4Address &source, const Ip4Address &group) const
void EnqueueSGEntry(McastSGEntry *sg_entry)
bool ProcessSGEntry(McastSGEntry *sg_entry)
McastSGEntry * LocateSGEntry(Ip4Address group, Ip4Address source)
DBTablePartBase * GetTablePartition()
void NotifyForestNode(const Ip4Address &source, const Ip4Address &group)
const RoutingInstance * routing_instance() const
McastSGEntry * FindSGEntry(const Ip4Address &group, const Ip4Address &source)
McastTreeManager * tree_manager_
void AddForwarder(McastForwarder *forwarder)
std::vector< ForwarderSet * > forwarder_sets_
McastForwarder * forest_node_
void set_tree_result_route(ErmVpnRoute *route)
Ip4Address source() const
std::string ToString() const
std::set< McastForwarder *, McastForwarderCompare > ForwarderSet
McastSGEntry(McastManagerPartition *partition, Ip4Address group, Ip4Address source)
void clear_on_work_queue()
ErmVpnRoute * local_tree_route_
std::vector< bool > update_needed_
void UpdateLocalTreeRoute()
bool IsForestNode(McastForwarder *forwarder)
void DeleteLocalTreeRoute()
bool GetForestNodePMSI(uint32_t *label, Ip4Address *address, std::vector< std::string > *encap) const
void clear_tree_result_route()
void DeleteForwarder(McastForwarder *forwarder)
McastManagerPartition * partition_
const ErmVpnRoute * tree_result_route() const
void UpdateRoutes(uint8_t level)
const RouteDistinguisher & GetSourceRd() const
bool IsTreeBuilder(uint8_t level) const
void ChangeForwarder(McastForwarder *forwarder)
ErmVpnRoute * tree_result_route_
McastManagerPartition * partition()
ErmVpnRoute * GetGlobalTreeRootRoute() const
virtual bool MayDelete() const
McastTreeManager * tree_manager_
DeleteActor(McastTreeManager *tree_manager)
McastManagerPartition * GetPartition(int part_id)
void RouteListener(DBTablePartBase *tpart, DBEntryBase *db_entry)
DBTablePartBase * GetTablePartition(size_t part_id)
void TreeResultListener(McastManagerPartition *partition, ErmVpnRoute *route)
PartitionList partitions_
LifetimeActor * deleter()
void NotifyForestNode(int part_id, const Ip4Address &source, const Ip4Address &group)
void TreeNodeListener(McastManagerPartition *partition, ErmVpnRoute *route)
virtual bool GetForestNodePMSI(ErmVpnRoute *rt, uint32_t *label, Ip4Address *address, std::vector< std::string > *encap) const
McastTreeManager(ErmVpnTable *table)
virtual UpdateInfo * GetUpdateInfo(ErmVpnRoute *route)
virtual void Initialize()
virtual ErmVpnRoute * GetGlobalTreeRootRoute(const Ip4Address &source, const Ip4Address &group) const
virtual ~McastTreeManager()
boost::scoped_ptr< DeleteActor > deleter_
const Ip4Address & source_address() const
static RouteDistinguisher kZeroRd
std::string ToString() const
The TaskScheduler keeps track of what tasks are currently schedulable. When a task is enqueued it is ...
bool Enqueue(QueueEntryT entry)
void Shutdown(bool delete_entries=true)
static const std::string integerToString(const NumberType &num)
void SetLabels(uint32_t first_label, uint32_t last_label)
void SetIp4Address(Ip4Address addr)
LabelBlockPtr label_block
void SetOutboundIp4Address(Ip4Address addr)
void SetInboundIp4Address(Ip4Address addr)
Ip4Address outbound_address
Ip4Address inbound_address
#define CHECK_CONCURRENCY(...)
void STLDeleteValues(Container *container)