7 #include <boost/foreach.hpp>
8 #include <boost/assign/list_of.hpp>
24 #include "bgp/routing-instance/service_chaining_types.h"
29 using boost::system::error_code;
95 int plen = prefix.prefixlen();
105 route =
static_cast<BgpRoute *
>(partition->
Find(&inet_route));
112 partition->
Add(route);
126 route =
static_cast<BgpRoute *
>(partition->
Find(&inet6_route));
133 partition->
Add(route);
144 string type_rd_tag(
"5-0:0-0-");
145 string prefix_str = type_rd_tag + addr.to_string() +
"/" +
146 boost::lexical_cast<std::string>(plen);
151 route =
static_cast<BgpRoute *
>(partition->
Find(&evpn_route));
158 partition->
Add(route);
181 bool aggregate,
BgpTable *bgptable) {
185 bool path_updated =
false;
195 connected_->name()));
199 conn_ri = connected_routing_instance();
210 if (existing_path != NULL) {
212 if ((attr.get() == existing_path->
GetAttr()) &&
236 (path_updated ?
"Updated " :
"Added ") <<
237 (aggregate ?
"Aggregate" :
"ExtConnected") <<
238 " ServiceChain path " << route->
ToString() <<
240 " in table " << bgptable->
name() <<
241 " .Path label: " << label);
244 template <
typename T>
252 return manager_->MayDelete();
257 manager_->Terminate();
264 template <
typename T>
268 bool head,
bool retain_as_path)
273 connected_(connected),
274 connected_route_(NULL),
275 service_chain_addr_(addr),
276 group_oper_state_up_(group ? false : true),
277 connected_table_unregistered_(false),
278 dest_table_unregistered_(false),
281 retain_as_path_(retain_as_path),
282 src_table_delete_ref_(this, src_table()->
deleter()),
283 dest_table_delete_ref_(this, dest_table()->
deleter()),
284 connected_table_delete_ref_(this, connected_table()->
deleter()) {
285 for (vector<string>::const_iterator it = subnets.begin();
286 it != subnets.end(); ++it) {
294 prefix =
"5-0:0-0-" + prefix;
313 template <
typename T>
315 return src_->GetTable(GetFamily());
318 template <
typename T>
320 return connected_->GetTable(GetConnectedFamily());
323 template <
typename T>
325 return dest_->GetTable(GetFamily());
332 template <
typename T>
350 if (prefix_to_routelist_map_.size() != config.
prefix.size())
352 for (vector<string>::const_iterator it = config.
prefix.begin();
353 it != config.
prefix.end(); ++it) {
356 if (prefix_to_routelist_map_.find(ipam_subnet) ==
357 prefix_to_routelist_map_.end()) {
371 template <
typename T>
379 if (table == dest_table() && !dest_table_unregistered()) {
383 if (!IsEvpnType5Route(route)) {
389 if (IsConnectedRoute(route)) {
394 if (aggregate_enable() && IsAggregate(route))
397 if (aggregate_enable() && IsMoreSpecific(route, &aggregate_match)) {
400 type = ServiceChainRequestT::MORE_SPECIFIC_DELETE;
402 type = ServiceChainRequestT::MORE_SPECIFIC_ADD_CHG;
419 int src_vn_index = src_->virtual_network_index();
420 int dest_vn_index = dest_->virtual_network_index();
421 if (!vn_index || dest_vn_index != vn_index) {
422 if (src_vn_index == vn_index)
424 if (!dest_->virtual_network_allow_transit())
440 type = ServiceChainRequestT::EXT_CONNECT_ROUTE_DELETE;
442 type = ServiceChainRequestT::EXT_CONNECT_ROUTE_ADD_CHG;
445 }
else if ((table == connected_table()) &&
446 !connected_table_unregistered() &&
447 IsConnectedRoute(route,
true)) {
458 type = ServiceChainRequestT::CONNECTED_ROUTE_DELETE;
460 type = ServiceChainRequestT::CONNECTED_ROUTE_ADD_CHG;
497 manager_->Enqueue(req);
501 template <
typename T>
503 return (
string(
"ServiceChain " ) + service_chain_addr_.to_string());
506 template <
typename T>
508 connected_route_ = connected;
509 connected_path_ids_.clear();
510 if (!connected_route_)
513 for (Route::PathList::iterator it = connected->
GetPathList().begin();
522 if (connected_route_->BestPath()->PathCompare(*path,
true))
527 connected_path_ids_.insert(path_id);
531 template <
typename T>
533 return (connected_route_ && connected_route_->IsValid());
536 template <
typename T>
538 PrefixT *aggregate_match)
const {
540 const PrefixT &ip_prefix = ip_route->GetPrefix();
541 for (
typename PrefixToRouteListMap::const_iterator it =
542 prefix_to_route_list_map()->begin();
543 it != prefix_to_route_list_map()->end(); ++it) {
544 if (ip_prefix.IsMoreSpecific(it->first)) {
545 *aggregate_match = it->first;
552 template <
typename T>
555 for (
typename PrefixToRouteListMap::const_iterator it =
556 prefix_to_route_list_map()->begin();
557 it != prefix_to_route_list_map()->end(); ++it) {
558 if (it->first == ip_route->GetPrefix())
569 template <
typename T>
571 bool is_conn_table)
const {
575 return (service_chain_addr() == inet_route->
GetPrefix().
addr());
578 return (service_chain_addr() == inet6_route->
GetPrefix().
addr());
585 return (service_chain_addr() == ip_route->GetPrefix().addr());
595 template <
typename T>
617 template <
typename T>
651 template <
typename T>
667 GetTablePartition(&rt_key));
671 if (service_chain_route && !service_chain_route->
IsDeleted()) {
672 DeleteServiceChainRouteInternal(service_chain_route, partition,
673 bgptable, aggregate);
687 GetReplicationFamilyInfo(repl_partition, repl_sc_route, repl_table,
689 if (repl_sc_route && !repl_sc_route->
IsDeleted()) {
690 DeleteServiceChainRouteInternal(repl_sc_route, repl_partition,
691 repl_table, aggregate);
696 template <
typename T>
704 for (ConnectedPathIdList::const_iterator it = GetConnectedPathIds().begin();
705 it != GetConnectedPathIds().end(); ++it) {
706 uint32_t path_id = *it;
709 "Removed " << (aggregate ?
"Aggregate" :
"ExtConnected") <<
710 " ServiceChain path " << service_chain_route->
ToString() <<
712 " in table " << bgptable->
name());
715 if (!service_chain_route->
HasPaths()) {
716 partition->
Delete(service_chain_route);
718 partition->
Notify(service_chain_route);
745 template <
typename T>
766 if (service_chain_route == NULL) {
767 service_chain_route =
new RouteT(prefix);
768 partition->
Add(service_chain_route);
773 UpdateServiceChainRouteInternal(orig_route, old_path_ids,
774 service_chain_route, partition,
775 bgptable, aggregate);
788 GetReplicationFamilyInfo(repl_partition, repl_sc_route, repl_table,
790 UpdateServiceChainRouteInternal(orig_route, old_path_ids,
791 repl_sc_route, repl_partition,
792 repl_table, aggregate);
796 template <
typename T>
802 int vn_index = dest_routing_instance()->virtual_network_index();
803 BgpServer *server = dest_routing_instance()->server();
809 origin_vn_trans.GetExtCommunity();
811 origin_vn4.GetExtCommunity();
817 bool load_balance_present =
false;
820 const AsPath *orig_aspath = NULL;
823 const BgpPath *orig_path = orig_route->BestPath();
824 const BgpAttr *orig_attr = NULL;
827 orig_attr = orig_path->
GetAttr();
833 orig_aspath = orig_attr->
as_path();
839 sgid_list.push_back(comm);
841 tag_list.push_back(comm);
846 load_balance_present =
true;
864 origin_vn_trans_bytes);
867 orig_ovnpath, origin_vn_bytes);
871 for (Route::PathList::iterator it =
872 connected_route()->GetPathList().begin();
873 it != connected_route()->GetPathList().end(); ++it) {
874 BgpPath *connected_path =
static_cast<BgpPath *
>(it.operator->());
881 if (connected_route()->BestPath()->PathCompare(*connected_path,
true))
888 if (connected_route()->DuplicateForwardingPath(connected_path))
915 connected_->name()));
919 conn_ri = connected_routing_instance();
922 "Adding primary RI " << conn_ri->
name() <<
" route targets " <<
923 "to service-chain route for EVPN table " << bgptable->
name());
934 new_ext_community.get(), export_list);
939 new_ext_community.get(), sgid_list);
943 new_ext_community.get(), tag_list);
948 new_ext_community.get());
965 new_ext_community.get(), origin_vn4_bytes);
967 new_ext_community.get(), origin_vn_trans_bytes);
970 new_ext_community.get(), origin_vn_bytes);
979 vector<string> tunnel_encaps = boost::assign::list_of(
"vxlan");
980 BOOST_FOREACH(
string encap, tunnel_encaps) {
981 encaps_list.push_back(
TunnelEncap(encap).GetExtCommunity());
983 new_ext_community = extcomm_db->
984 ReplaceTunnelEncapsulationAndLocate(new_ext_community.get(),
990 attr, new_ext_community);
999 if (retain_as_path() && orig_aspath) {
1012 if (src_ != connected_ && peer && peer->
IsXmppPeer()) {
1013 int instance_id = -1;
1015 bgptable, &instance_id);
1036 vpn_route->GetPrefix().route_distinguisher());
1041 if (!orig_rd.
IsZero() && new_attr->source_rd() == orig_rd)
1047 ProcessServiceChainPath(path_id, connected_path, new_attr,
1048 service_chain_route, partition,
1049 aggregate, bgptable);
1050 new_path_ids.insert(path_id);
1054 for (ConnectedPathIdList::const_iterator it = old_path_ids.begin();
1055 it != old_path_ids.end(); ++it) {
1056 uint32_t path_id = *it;
1057 if (new_path_ids.find(path_id) != new_path_ids.end())
1060 partition->
Notify(service_chain_route);
1063 "Removed " << (aggregate ?
"Aggregate" :
"ExtConnected") <<
1064 " ServiceChain path " << service_chain_route->
ToString() <<
1066 " in table " << bgptable->
name());
1071 if (!service_chain_route->
HasPaths())
1072 partition->
Delete(service_chain_route);
1075 template <
typename T>
1078 typename PrefixToRouteListMap::iterator it =
1079 prefix_to_routelist_map_.find(aggregate);
1080 assert(it != prefix_to_routelist_map_.end());
1082 if (it->second.empty()) {
1086 it->second.insert(more_specific);
1090 template <
typename T>
1093 typename PrefixToRouteListMap::iterator it =
1094 prefix_to_routelist_map_.find(aggregate);
1095 assert(it != prefix_to_routelist_map_.end());
1096 it->second.erase(more_specific);
1097 return it->second.empty();
1100 template <
typename T>
1103 info->set_state(
"deleted");
1104 }
else if (!IsConnectedRouteValid()) {
1105 info->set_state(
"down");
1106 }
else if (!group_oper_state_up()) {
1107 info->set_state(
"group down");
1109 info->set_state(
"active");
1112 ConnectedRouteInfo connected_rt_info;
1113 connected_rt_info.set_service_chain_addr(
1114 service_chain_addr().to_string());
1115 if (connected_route()) {
1116 ShowRoute show_route;
1117 connected_route()->FillRouteInfo(connected_table(), &show_route);
1118 connected_rt_info.set_connected_rt(show_route);
1120 info->set_connected_route(connected_rt_info);
1122 vector<PrefixToRouteListInfo> more_vec;
1123 for (
typename PrefixToRouteListMap::const_iterator it =
1124 prefix_to_route_list_map()->begin();
1125 it != prefix_to_route_list_map()->end(); ++it) {
1126 PrefixToRouteListInfo prefix_list_info;
1127 prefix_list_info.set_prefix(it->first.ToString());
1130 RouteT rt_key(it->first);
1133 prefix_list_info.set_aggregate(
true);
1134 ShowRoute show_route;
1136 prefix_list_info.set_aggregate_rt(show_route);
1138 prefix_list_info.set_aggregate(
false);
1141 vector<string> rt_list;
1142 for (RouteList::iterator rt_it = it->second.begin();
1143 rt_it != it->second.end(); ++rt_it) {
1144 rt_list.push_back((*rt_it)->ToString());
1146 prefix_list_info.set_more_specific_list(rt_list);
1147 more_vec.push_back(prefix_list_info);
1149 info->set_more_specifics(more_vec);
1151 vector<ExtConnectRouteInfo> ext_connecting_rt_info_list;
1152 for (ExtConnectRouteList::const_iterator it =
1153 ext_connecting_routes().begin();
1154 it != ext_connecting_routes().end(); ++it) {
1155 ExtConnectRouteInfo ext_rt_info;
1156 ext_rt_info.set_ext_rt_prefix((*it)->ToString());
1159 RouteT rt_key(ext_route->GetPrefix());
1162 if (ext_connecting) {
1163 ShowRoute show_route;
1165 ext_rt_info.set_ext_rt_svc_rt(show_route);
1167 ext_connecting_rt_info_list.push_back(ext_rt_info);
1169 info->set_ext_connecting_rt_info_list(ext_connecting_rt_info_list);
1170 info->set_aggregate_enable(aggregate_enable());
1175 : manager_(manager),
1177 oper_state_up_(false) {
1239 template <
typename T>
1241 return server_->condition_listener(GetSCFamily());
1244 template <
typename T>
1262 (listener_->GetMatchState(table, route, info));
1265 switch (req->
type_) {
1266 case ServiceChainRequestT::MORE_SPECIFIC_ADD_CHG: {
1280 aggregate_match, NULL, path_ids,
true);
1283 case ServiceChainRequestT::MORE_SPECIFIC_DELETE: {
1292 case ServiceChainRequestT::CONNECTED_ROUTE_ADD_CHG: {
1298 UpdateServiceChainGroup(info->
group());
1312 UpdateServiceChainRoutes(info, path_ids);
1315 case ServiceChainRequestT::CONNECTED_ROUTE_DELETE: {
1317 UpdateServiceChainGroup(info->
group());
1318 DeleteServiceChainRoutes(info);
1323 case ServiceChainRequestT::EXT_CONNECT_ROUTE_ADD_CHG: {
1336 ext_route->GetPrefix(), ext_route, path_ids,
false);
1339 case ServiceChainRequestT::EXT_CONNECT_ROUTE_DELETE: {
1348 case ServiceChainRequestT::UPDATE_ALL_ROUTES: {
1360 UpdateServiceChainRoutes(info, path_ids);
1363 case ServiceChainRequestT::DELETE_ALL_ROUTES: {
1364 DeleteServiceChainRoutes(info);
1367 case ServiceChainRequestT::STOP_CHAIN_DONE: {
1371 listener_->UnregisterMatchCondition(table, info);
1377 listener_->UnregisterMatchCondition(table, info);
1396 listener_->RemoveMatchState(table, route, info);
1400 listener_->UnregisterMatchCondition(
1404 listener_->UnregisterMatchCondition(
1418 template <
typename T>
1421 listener_(GetListener()),
1424 TaskScheduler::GetInstance()->GetTaskId(
"bgp::Config"), 0)),
1427 TaskScheduler::GetInstance()->GetTaskId(
"bgp::ServiceChain"), 0)),
1428 aggregate_host_route_(false),
1430 server_delete_ref_(this, server->
deleter()) {
1448 template <
typename T>
1450 assert(group_set_.empty());
1451 assert(group_map_.empty());
1454 template <
typename T>
1456 process_queue_->Shutdown();
1461 server_delete_ref_.Reset(NULL);
1464 template <
typename T>
1469 template <
typename T>
1471 if (!chain_set_.empty() || !pending_chains_.empty())
1473 if (!group_set_.empty() || !group_map_.empty())
1478 template <
typename T>
1480 if (!deleter_->IsDeleted())
1482 deleter_->RetryDelete();
1485 template <
typename T>
1488 if (ServiceChainIsPending(rtinstance)) {
1493 return (chain ? chain->
group() : NULL);
1497 template <
typename T>
1499 const string &group_name) {
1500 GroupMap::iterator loc = group_map_.find(group_name);
1501 return (loc != group_map_.end() ? loc->second : NULL);
1504 template <
typename T>
1506 const string &group_name) {
1509 GroupMap::iterator loc = group_map_.find(group_name);
1512 string temp_group_name(group_name);
1514 group_map_.insert(temp_group_name, group);
1519 template <
typename T>
1525 group_set_.insert(group);
1526 group_trigger_->Set();
1529 template <
typename T>
1534 if (group->
empty()) {
1535 string temp_group_name(group->
name());
1536 group_map_.erase(temp_group_name);
1617 template <
typename T>
1619 process_queue_->Enqueue(req);
1622 template <
typename T>
1624 string *reason)
const {
1625 typename PendingChainList::const_iterator loc =
1626 pending_chains_.find(rtinstance);
1627 if (loc != pending_chains_.end()) {
1629 *reason = loc->second.reason;
1635 template <
typename T>
1637 if (ServiceChainIsPending(rtinstance))
1645 template <
typename T>
1647 ShowServicechainInfo *info)
const {
1648 string pending_reason;
1649 if (ServiceChainIsPending(rtinstance, &pending_reason)) {
1650 info->set_state(
"pending");
1651 info->set_pending_reason(pending_reason);
1663 template <
typename T>
1669 tbb::mutex::scoped_lock lock(mutex_);
1670 ServiceChainMap::iterator it = chain_set_.find(rtinstance);
1671 if (it != chain_set_.end()) {
1675 "No update in ServiceChain config : " << rtinstance->
name());
1695 string reason =
"Waiting for deletion of previous incarnation";
1696 AddPendingServiceChain(rtinstance, group, reason);
1704 listener_->RemoveMatchCondition(chain->
dest_table(), chain, cb);
1722 DeletePendingServiceChain(rtinstance);
1734 string reason =
"Destination routing instance does not exist";
1735 AddPendingServiceChain(rtinstance, group, reason);
1741 string reason =
"Destination routing instance is being deleted";
1742 AddPendingServiceChain(rtinstance, group, reason);
1748 string reason =
"Destination virtual network index is unknown";
1749 AddPendingServiceChain(rtinstance, group, reason);
1755 connected_ri = rtinstance;
1756 assert(!rtinstance->
deleted());
1762 if (!connected_ri) {
1763 string reason =
"Connected routing instance does not exist";
1764 AddPendingServiceChain(rtinstance, group, reason);
1769 if (connected_ri->
deleted()) {
1770 string reason =
"Connected routing instance is being deleted";
1771 AddPendingServiceChain(rtinstance, group, reason);
1780 string reason =
"Service chain address is invalid";
1781 AddPendingServiceChain(rtinstance, group, reason);
1791 connected_table = connected_ri->
GetTable(GetConnectedFamily());
1792 assert(connected_table);
1798 rtinstance, dest, connected_ri, config.
prefix, chain_addr,
1801 if (aggregate_host_route()) {
1807 chain_set_.insert(make_pair(rtinstance, chain));
1808 listener_->AddMatchCondition(
1810 listener_->AddMatchCondition(
1816 template <
typename T>
1818 const string &instance)
const {
1820 server_->routing_instance_mgr()->GetRoutingInstance(instance);
1823 ServiceChainMap::const_iterator it = chain_set_.find(rtinstance);
1824 if (it == chain_set_.end())
1826 ServiceChainT *chain =
static_cast<ServiceChainT *
>(it->second.get());
1830 template <
typename T>
1833 ServiceChainMap::const_iterator it = chain_set_.find(rtinstance);
1834 if (it == chain_set_.end())
1840 template <
typename T>
1843 for (
typename PendingChainList::iterator it = pending_chains_.begin(), next;
1844 it != pending_chains_.end(); it = next) {
1851 pending_chains_.erase(it);
1855 LocateServiceChain(rtinstance, *sc_config);
1861 template <
typename T>
1867 template <
typename T>
1869 if (pending_chains_.empty())
1871 resolve_trigger_->Set();
1874 template <
typename T>
1885 template <
typename T>
1890 tbb::mutex::scoped_lock lock(mutex_);
1891 if (ServiceChainIsPending(rtinstance)) {
1895 DeletePendingServiceChain(rtinstance);
1914 listener_->RemoveMatchCondition(chain->
dest_table(), chain, cb);
1918 template <
typename T>
1920 bool group_oper_state_up) {
1931 if (group_oper_state_up) {
1932 req_type = ServiceChainRequestT::UPDATE_ALL_ROUTES;
1934 req_type = ServiceChainRequestT::DELETE_ALL_ROUTES;
1941 template <
typename T>
1947 for (
typename ServiceChainT::PrefixToRouteListMap::iterator it =
1948 vn_prefix_list->begin(); it != vn_prefix_list->end(); ++it) {
1949 if (!it->second.empty())
1954 for (
typename ServiceChainT::ExtConnectRouteList::iterator it =
1959 ext_route->GetPrefix(), ext_route, old_path_ids,
false);
1963 template <
typename T>
1968 for (
typename ServiceChainT::PrefixToRouteListMap::iterator it =
1969 vn_prefix_list->begin(); it != vn_prefix_list->end(); ++it) {
1974 for (
typename ServiceChainT::ExtConnectRouteList::iterator it =
1982 template <
typename T>
2003 template <
typename T>
2005 resolve_trigger_->set_disable();
2008 template <
typename T>
2010 resolve_trigger_->set_enable();
2013 template <
typename T>
2015 group_trigger_->set_disable();
2018 template <
typename T>
2020 group_trigger_->set_enable();
2023 template <
typename T>
2026 for (ServiceChainMap::const_iterator it = chain_set_.begin();
2027 it != chain_set_.end(); ++it) {
void FillRouteInfo(const BgpTable *table, ShowRouteBrief *show_route) const
bool AddMoreSpecific(PrefixT aggregate, BgpRoute *more_specific)
const Community * community() const
boost::intrusive_ptr< const AsPath > AsPathPtr
boost::scoped_ptr< WorkQueue< ServiceChainRequestT * > > process_queue_
virtual void EnableGroupTrigger()
ServiceChain(ServiceChainMgrT *manager, ServiceChainGroup *group, RoutingInstance *src, RoutingInstance *dest, RoutingInstance *connected, const std::vector< std::string > &subnets, AddressT addr, bool head, bool retain_as_path)
ServiceChainGroup(IServiceChainMgr *manager, const std::string &name)
ServiceChainT * FindServiceChain(const std::string &instance) const
ServiceChainMgr< T > * manager_
void Enqueue(ServiceChainRequestT *req)
std::set< BgpRoute * > RouteList
const IpAddress & nexthop() const
BgpTable * GetTable(Address::Family fmly)
void PeerRegistrationCallback(IPeer *peer, BgpTable *table, bool unregister)
bool dest_table_unregistered() const
const BgpPath * BestPath() const
int RegisterInstanceOpCallback(RoutingInstanceCb cb)
The TaskScheduler keeps track of what tasks are currently schedulable. When a task is enqueued it is ...
const RouteTargetList & GetExportList() const
RoutingInstance * GetRoutingInstance(const std::string &name)
void set_group_oper_state_up(bool up)
virtual bool MayDelete() const
virtual void StopServiceChain(RoutingInstance *rtinstance)
virtual bool IsXmppPeer() const =0
void GetReplicationFamilyInfo(DBTablePartition *&partition, BgpRoute *&route, BgpTable *&table, PrefixT prefix, bool create)
const ExtConnectRouteList & ext_connecting_routes() const
int virtual_network_index() const
void UpdateServiceChainRoute(PrefixT prefix, const RouteT *orig_route, const ConnectedPathIdList &old_path_ids, bool aggregate)
boost::function< void(BgpTable *, ConditionMatch *)> RequestDoneCb
BgpAttrPtr ReplaceCommunityAndLocate(const BgpAttr *attr, CommunityPtr community)
virtual std::string ToString() const
DBEntry * Find(const DBEntry *entry)
bool IsConnectedRouteValid() const
static std::string PathIdString(uint32_t path_id)
virtual bool ServiceChainIsPending(RoutingInstance *rtinstance, std::string *reason=NULL) const
const ConnectedPathIdList & GetConnectedPathIds()
BgpRoute * connected_route() const
BgpTable * connected_table() const
void FillServiceChainInfo(ShowServicechainInfo *info) const
ConditionMatchState * GetMatchState(BgpTable *table, BgpRoute *route, ConditionMatch *obj)
RoutingInstance * routing_instance()
OriginVnPathPtr PrependAndLocate(const OriginVnPath *ovnpath, const OriginVnPath::OriginVnValue &value)
virtual void UpdateServiceChain(RoutingInstance *rtinstance, bool group_oper_state_up)
boost::asio::ip::address IpAddress
DeleteActor(ServiceChainMgr< T > *manager)
static std::string GetPrimaryRoutingInstanceName(const string &name_in)
bool unregistered() const
RoutingInstanceMgr * routing_instance_mgr()
const OriginVnPath * origin_vn_path() const
void RemoveMatchState(BgpRoute *route, ServiceChainState *state)
virtual void DisableGroupTrigger()
BgpTable * dest_table() const
RoutingInstance * src_routing_instance() const
const std::string & name() const
ServiceChainSet chain_set_
virtual uint32_t GetDownServiceChainCount() const
const BgpPath * FindPath(BgpPath::PathSource src) const
bool IsMoreSpecific(BgpRoute *route, PrefixT *aggregate_match) const
ServiceChainGroup * group
virtual void UpdateServiceChain(RoutingInstance *rtinstance, bool group_oper_state_up)=0
void Delete(DBEntryBase *)
const RouteDistinguisher & source_rd() const
virtual Address::Family family() const =0
uint32_t GetFlags() const
static bool IsPresent(const BgpPath *path)
virtual void UpdateServiceChainGroup(ServiceChainGroup *group)=0
bool GetRegistrationInfo(const IPeer *peer, const BgpTable *table, int *instance_id=NULL, uint64_t *subscription_gen_id=NULL) const
OriginVnPathDB * ovnpath_db()
BgpAttrPtr ReplaceExtCommunityAndLocate(const BgpAttr *attr, ExtCommunityPtr extcomm)
int GetTaskId(const std::string &name)
const bytes_type & GetExtCommunity() const
ServiceChainGroup * LocateServiceChainGroup(const std::string &group_name)
#define BGP_LOG_STR(obj, level, flags, arg)
ServiceChainMgr(BgpServer *server)
bool IsEvpnType5Route(BgpRoute *route) const
boost::intrusive_ptr< const OriginVnPath > OriginVnPathPtr
ServiceChainGroup * FindServiceChainGroup(RoutingInstance *rtinstance)
void StopServiceChainDone(BgpTable *table, ConditionMatch *info)
boost::intrusive_ptr< const BgpAttr > BgpAttrPtr
PrefixToRouteListMap prefix_to_routelist_map_
bool IsAggregate(BgpRoute *route) const
void set_aggregate_enable()
void set_dest_table_unregistered()
PathSource GetSource() const
bool connected_table_unregistered() const
SCAddress::Family GetSCFamily() const
void DeleteRoutingInstance(RoutingInstance *rtinstance)
const ServiceChainConfig * service_chain_info(SCAddress::Family family) const
ExtCommunityDB * extcomm_db()
std::vector< std::string > prefix
static TaskScheduler * GetInstance()
virtual void DisableResolveTrigger()
virtual bool FillServiceChainInfo(RoutingInstance *rtinstance, ShowServicechainInfo *info) const
static int GetOriginVnIndex(const BgpTable *table, const BgpRoute *route)
void UnregisterPeerRegistrationCallback(int id)
std::string routing_instance
#define CHECK_CONCURRENCY(...)
virtual BgpConditionListener * GetListener()
void SetMatchState(BgpTable *table, BgpRoute *route, ConditionMatch *obj, ConditionMatchState *state=NULL)
void UpdateServiceChainRouteInternal(const RouteT *orig_route, const ConnectedPathIdList &old_path_ids, BgpRoute *sc_route, DBTablePartition *partition, BgpTable *bgptable, bool aggregate)
virtual std::string ToString() const =0
PrefixToRouteListMap * prefix_to_route_list_map()
bool RequestHandler(ServiceChainRequestT *req)
BgpAttrPtr ReplaceSourceRdAndLocate(const BgpAttr *attr, const RouteDistinguisher &source_rd)
const BgpInstanceConfig * config() const
bool IsVrfOriginated() const
BgpTable * src_table() const
virtual bool ServiceChainIsUp(RoutingInstance *rtinstance) const
const std::string & name() const
ServiceChainGroup * group() const
void ProcessServiceChainPath(uint32_t path_id, BgpPath *path, BgpAttrPtr attr, BgpRoute *&route, DBTablePartition *&partition, bool aggregate, BgpTable *bgptable)
std::string source_routing_instance
virtual bool LocateServiceChain(RoutingInstance *rtinstance, const ServiceChainConfig &config)
uint32_t GetLabel() const
const Ip4Prefix & GetPrefix() const
void RoutingInstanceCallback(std::string name, int op)
void UnregisterInstanceOpCallback(int id)
const AsPath * as_path() const
const bytes_type & GetExtCommunity() const
void UpdateServiceChainGroup(ServiceChainGroup *group)
void InsertPath(BgpPath *path)
void UpdateServiceChainRoutes(ServiceChainT *chain, const typename ServiceChainT::ConnectedPathIdList &old_path_ids)
virtual void EnableResolveTrigger()
virtual DBTablePartBase * GetTablePartition(const DBRequestKey *key)
bool RemovePath(BgpPath::PathSource src, const IPeer *peer=NULL, uint32_t path_id=0)
const EvpnPrefix & GetPrefix() const
static EvpnPrefix FromString(const std::string &str, boost::system::error_code *errorp=NULL)
bool IsMasterRoutingInstance() const
const ExtCommunity * ext_community() const
void DeleteServiceChainRoutes(ServiceChainT *chain)
int service_chain_task_id_
BgpAttrPtr ReplaceAsPathAndLocate(const BgpAttr *attr, AsPathPtr aspath)
uint32_t GetAddress() const
const BgpRoute * src_rt() const
#define BGP_LOG_FLAG_TRACE
bool ResolvePendingServiceChain()
bool IsConnectedRoute(BgpRoute *route, bool is_conn_table=false) const
std::map< PrefixT, RouteList > PrefixToRouteListMap
const BgpAttr * GetAttr() const
Address::Family GetFamily() const
bool CompareServiceChainConfig(const ServiceChainConfig &config)
DBEntry * Find(const DBEntry *entry)
std::string ToString() const
ConditionMatchPtr ServiceChainPtr
bool Contains(const OriginVnValue &value) const
void DeleteServiceChainRouteInternal(BgpRoute *service_chain_route, DBTablePartition *partition, BgpTable *bgptable, bool aggregate)
SCAddress::Family GetSCFamily() const
BgpMembershipManager * membership_mgr()
IServiceChainMgr * manager_
bool group_oper_state_up() const
virtual bool Match(BgpServer *server, BgpTable *table, BgpRoute *route, bool deleted)
Address::Family GetFamily() const
virtual void Add(DBEntry *entry)
const Inet6Prefix & GetPrefix() const
const BgpTable * src_table() const
virtual bool ServiceChainIsUp(RoutingInstance *rtinstance) const =0
void Notify(DBEntryBase *entry)
void AddRoutingInstance(RoutingInstance *rtinstance)
bool ProcessServiceChainGroups()
uint32_t num_matchstate() const
const bytes_type & GetExtCommunity() const
Address::Family GetConnectedFamily() const
boost::array< uint8_t, 8 > OriginVnValue
virtual bool IsReplicated() const
std::string service_chain_address
as_t autonomous_system() const
std::set< uint32_t > ConnectedPathIdList
BgpAttrPtr ReplaceOriginVnPathAndLocate(const BgpAttr *attr, OriginVnPathPtr ovnpath)
int RegisterPeerRegistrationCallback(PeerRegistrationCallback callback)
static PhysicalDevice::ManagementProtocol FromString(const string &proto)
void SetConnectedRoute(BgpRoute *connected)
virtual bool IsValid() const
void set_connected_table_unregistered()
bool DeleteMoreSpecific(PrefixT aggregate, BgpRoute *more_specific)
Address::Family family() const
std::string service_chain_id
const PathList & GetPathList() const
void DeleteServiceChainRoute(PrefixT prefix, bool aggregate)
virtual ~ServiceChainMgr()