7 #include <boost/bind.hpp>
8 #include <boost/foreach.hpp>
19 #include "bgp/routing-instance/routing_instance_analytics_types.h"
63 : sg_entry_(sg_entry),
65 global_tree_route_(NULL),
68 rd_(route->GetPrefix().route_distinguisher()),
69 router_id_(route->GetPrefix().router_id()) {
105 bool changed =
false;
138 for (McastForwarderList::iterator it =
tree_links_.begin();
140 if (*it == forwarder)
return forwarder;
157 for (McastForwarderList::iterator it =
tree_links_.begin();
159 if (*it == forwarder) {
171 for (McastForwarderList::iterator it =
tree_links_.begin();
173 (*it)->RemoveLink(
this);
231 tbl_partition->
Add(route);
241 attr_spec.push_back(&nexthop);
243 attr_spec.push_back(&source_rd);
245 for (McastForwarderList::const_iterator it =
tree_links_.begin();
254 attr_spec.push_back(&efspec);
259 attr_spec.push_back(&ext);
265 tbl_partition->
Notify(route);
296 for (McastForwarderList::const_iterator it =
tree_links_.begin();
298 BgpOListElem elem((*it)->address(), (*it)->label(), (*it)->encap());
299 olist_spec->
elements.push_back(elem);
322 vector<string> encaps;
328 for (EdgeForwarding::EdgeList::const_iterator it =
335 olist_spec->
elements.push_back(elem);
364 attr_spec.push_back(&olist_spec);
381 : partition_(partition),
385 local_tree_route_(NULL),
386 tree_result_route_(NULL),
387 on_work_queue_(false) {
415 uint8_t level = forwarder->
level();
429 uint8_t level = forwarder->
level();
441 uint8_t level = forwarder->
level();
482 for (ForwarderSet::reverse_iterator rit = forwarders->rbegin();
483 rit != forwarders->rend(); ++rit) {
485 if (forwarder->
label()) {
509 tbl_partition->
Add(route);
517 attr_spec.push_back(&nexthop);
519 attr_spec.push_back(&source_rd);
527 attr_spec.push_back(&edspec);
532 attr_spec.push_back(&ext);
538 tbl_partition->
Notify(route);
588 for (ForwarderSet::iterator it = forwarders->begin();
589 it != forwarders->end(); ++it) {
590 (*it)->DeleteGlobalTreeRoute();
591 (*it)->AddGlobalTreeRoute();
600 assert(!forwarders->empty());
601 ForwarderSet::const_iterator it = forwarders->begin();
602 return (*it)->global_tree_route();
613 ForwarderSet::const_iterator it = forwarders->begin();
614 if (it == forwarders->end())
618 if ((*it)->router_id() != router_id)
652 for (ForwarderSet::iterator it = forwarders->begin();
653 it != forwarders->end(); ++it) {
655 (*it)->ReleaseLabel();
669 vec.reserve(forwarders->size());
670 for (ForwarderSet::iterator it = forwarders->begin();
671 it != forwarders->end(); ++it) {
674 if (!forwarder->
label())
676 vec.push_back(forwarder);
682 for (McastForwarderList::iterator it = vec.begin(); it != vec.end(); ++it) {
683 int idx = it - vec.begin();
687 int parent_idx = (idx - 1) / degree;
688 McastForwarderList::iterator parent_it = vec.begin() + parent_idx;
689 assert(parent_it != vec.end());
692 forwarder->
AddLink(parent_forwarder);
693 parent_forwarder->
AddLink(forwarder);
722 vector<string> *tunnel_encap)
const {
750 : tree_manager_(tree_manager),
753 work_queue_(
TaskScheduler::GetInstance()->GetTaskId(
"db::DBTable"),
778 McastSGEntry temp_sg_entry(const_cast<McastManagerPartition *>(
this),
780 SGList::const_iterator it =
sg_list_.find(&temp_sg_entry);
781 return (it !=
sg_list_.end() ? *it : NULL);
811 Ip4Address *address, vector<string> *encap)
const {
838 if (sg_entry->
empty()) {
873 listener_id_(
DBTable::kInvalidId),
874 table_delete_ref_(this, table->
deleter()) {
917 for (
size_t part_id = 0; part_id <
partitions_.size(); part_id++) {
999 }
else if (forwarder->
Update(route)) {
1072 for (PartitionList::const_iterator it =
partitions_.begin();
1074 if (!(*it)->empty())
1140 Ip4Address *address, vector<string> *encap)
const {
virtual ErmVpnRoute * GetGlobalTreeRootRoute(const Ip4Address &source, const Ip4Address &group) const
void SetIp4Address(Ip4Address addr)
boost::scoped_ptr< DeleteActor > deleter_
McastManagerPartition(McastTreeManager *tree_manager, size_t part_id)
ErmVpnRoute * GetGlobalTreeRootRoute(const Ip4Address &source, const Ip4Address &group) const
bool GetForestNodePMSI(ErmVpnRoute *rt, uint32_t *label, Ip4Address *address, std::vector< std::string > *encap) const
void DeleteLocalTreeRoute()
void ChangeForwarder(McastForwarder *forwarder)
const IpAddress & nexthop() const
void STLDeleteValues(Container *container)
McastForwarder * FindLink(McastForwarder *forwarder)
const BgpPath * BestPath() const
The TaskScheduler keeps track of what tasks are currently schedulable. When a task is enqueued it is ...
TypePtr Locate(Type *attr)
const ErmVpnPrefix & GetPrefix() const
LabelBlockPtr label_block() const
const RoutingInstance * routing_instance() const
void Shutdown(bool delete_entries=true)
void AddGlobalTreeRoute()
DBState * GetState(DBTableBase *tbl_base, ListenerId listener) const
bool IsTreeBuilder(uint8_t level) const
void clear_on_work_queue()
void RouteListener(DBTablePartBase *tpart, DBEntryBase *db_entry)
DBTableBase * get_table() const
std::vector< bool > update_needed_
DBEntry * Find(const DBEntry *entry)
LabelBlockPtr label_block_
UpdateInfo * GetUpdateInfo(ErmVpnTable *table)
McastTreeManager(ErmVpnTable *table)
RoutingInstance * routing_instance()
void SetState(DBTableBase *tbl_base, ListenerId listener, DBState *state)
void NotifyForestNode(int part_id, const Ip4Address &source, const Ip4Address &group)
void SetOutboundIp4Address(Ip4Address addr)
void clear_tree_result_route()
virtual void Initialize()
virtual ~McastTreeManager()
LabelBlockPtr label_block
ErmVpnRoute * local_tree_route_
std::vector< BgpAttribute * > BgpAttrSpec
void AddLocalOListElems(BgpOListSpec *olist_spec)
bool ProcessSGEntry(McastSGEntry *sg_entry)
bool GetForestNodePMSI(uint32_t *label, Ip4Address *address, std::vector< std::string > *encap) const
McastSGEntry * FindSGEntry(const Ip4Address &group, const Ip4Address &source)
std::vector< std::string > encap_
void Delete(DBEntryBase *)
McastManagerPartition * partition_
void Unregister(ListenerId listener)
const Ip4Address & source_address() const
std::set< McastForwarder *, McastForwarderCompare > ForwarderSet
virtual UpdateInfo * GetUpdateInfo(ErmVpnRoute *route)
ListenerId Register(ChangeCallback callback, const std::string &name="unspecified")
void DeleteGlobalTreeRoute()
bool Update(ErmVpnRoute *route)
void DeleteForwarder(McastForwarder *forwarder)
const RouteDistinguisher & GetSourceRd() const
void TreeResultListener(McastManagerPartition *partition, ErmVpnRoute *route)
boost::intrusive_ptr< const BgpAttr > BgpAttrPtr
void UpdateRoutes(uint8_t level)
Ip4Address inbound_address
void UpdateLocalTreeRoute()
void SetInboundIp4Address(Ip4Address addr)
ErmVpnRoute * tree_result_route_
static const std::string integerToString(const NumberType &num)
WorkQueue< McastSGEntry * > work_queue_
std::string ToString() const
DeleteActor(McastTreeManager *tree_manager)
void SetLabels(uint32_t first_label, uint32_t last_label)
McastSGEntry * LocateSGEntry(Ip4Address group, Ip4Address source)
Ip4Address router_id() const
#define CHECK_CONCURRENCY(...)
void RemoveLink(McastForwarder *forwarder)
virtual size_t Hash(const DBEntry *entry) const
Ip4Address address() const
const RouteDistinguisher & route_distinguisher() const
static RouteDistinguisher kZeroRd
McastSGEntry(McastManagerPartition *partition, Ip4Address group, Ip4Address source)
Ip4Address source() const
std::vector< std::string > encap() const
void ClearState(DBTableBase *tbl_base, ListenerId listener)
PartitionList partitions_
boost::asio::ip::address_v4 Ip4Address
DBTablePartBase * GetTablePartition(size_t part_id)
virtual bool MayDelete() const
void InsertPath(BgpPath *path)
virtual int PartitionCount() const
std::vector< McastForwarder * > McastForwarderList
bool IsForestNode(McastForwarder *forwarder)
virtual DBTablePartBase * GetTablePartition(const DBRequestKey *key)
void DestroyTreeManager()
bool RemovePath(BgpPath::PathSource src, const IPeer *peer=NULL, uint32_t path_id=0)
std::vector< ForwarderSet * > forwarder_sets_
ErmVpnRoute * global_tree_route_
ErmVpnRoute * GetGlobalTreeRootRoute() const
uint32_t bgp_identifier() const
const ExtCommunity * ext_community() const
void AddGlobalOListElems(BgpOListSpec *olist_spec)
Ip4Address outbound_address
std::string ToString() const
McastTreeManager * tree_manager_
void set_tree_result_route(ErmVpnRoute *route)
const BgpAttr * GetAttr() const
McastForwarderList tree_links_
std::string ToString() const
void AddLink(McastForwarder *forwarder)
const ErmVpnRoute * tree_result_route() const
const EdgeForwarding * edge_forwarding() const
void GetMvpnSourceAddress(ErmVpnRoute *ermvpn_route, Ip4Address *address) const
McastForwarder(McastSGEntry *sg_entry, ErmVpnRoute *route)
virtual void Add(DBEntry *entry)
DBTablePartBase * get_table_partition() const
const EdgeDiscovery * edge_discovery() const
void Notify(DBEntryBase *entry)
LifetimeActor * deleter()
bool Enqueue(QueueEntryT entry)
void EnqueueSGEntry(McastSGEntry *sg_entry)
Ip4Address source() const
void TreeNodeListener(McastManagerPartition *partition, ErmVpnRoute *route)
virtual bool GetForestNodePMSI(ErmVpnRoute *rt, uint32_t *label, Ip4Address *address, std::vector< std::string > *encap) const
DBTablePartBase * GetTablePartition()
McastManagerPartition * partition()
McastManagerPartition * GetPartition(int part_id)
McastTreeManager * tree_manager_
void NotifyForestNode(const Ip4Address &source, const Ip4Address &group)
virtual bool IsValid() const
void AddForwarder(McastForwarder *forwarder)
McastForwarder * forest_node_