8 #include <boost/foreach.hpp>
9 #include <boost/assign/list_of.hpp>
25 #include "bgp/routing-instance/service_chaining_types.h"
30 using boost::system::error_code;
96 int plen = prefix.prefixlen();
106 route =
static_cast<BgpRoute *
>(partition->
Find(&inet_route));
113 partition->
Add(route);
127 route =
static_cast<BgpRoute *
>(partition->
Find(&inet6_route));
134 partition->
Add(route);
145 string type_rd_tag(
"5-0:0-0-");
146 string prefix_str = type_rd_tag + addr.to_string() +
"/" +
147 boost::lexical_cast<std::string>(plen);
152 route =
static_cast<BgpRoute *
>(partition->
Find(&evpn_route));
159 partition->
Add(route);
182 bool aggregate,
BgpTable *bgptable) {
186 bool path_updated =
false;
196 connected_->name()));
200 conn_ri = connected_routing_instance();
211 if (existing_path != NULL) {
213 if ((attr.get() == existing_path->
GetAttr()) &&
237 (path_updated ?
"Updated " :
"Added ") <<
238 (aggregate ?
"Aggregate" :
"ExtConnected") <<
239 " ServiceChain path " << route->
ToString() <<
241 " in table " << bgptable->
name() <<
242 " .Path label: " << label);
245 template <
typename T>
253 return manager_->MayDelete();
258 manager_->Terminate();
265 template <
typename T>
269 bool head,
bool retain_as_path)
274 connected_(connected),
275 connected_route_(NULL),
276 service_chain_addr_(addr),
277 group_oper_state_up_(group ? false : true),
278 connected_table_unregistered_(false),
279 dest_table_unregistered_(false),
282 retain_as_path_(retain_as_path),
283 src_table_delete_ref_(this, src_table()->
deleter()),
284 dest_table_delete_ref_(this, dest_table()->
deleter()),
285 connected_table_delete_ref_(this, connected_table()->
deleter()) {
286 for (vector<string>::const_iterator it = subnets.begin();
287 it != subnets.end(); ++it) {
295 prefix =
"5-0:0-0-" + prefix;
314 template <
typename T>
316 return src_->GetTable(GetFamily());
319 template <
typename T>
321 return connected_->GetTable(GetConnectedFamily());
324 template <
typename T>
326 return dest_->GetTable(GetFamily());
333 template <
typename T>
351 if (prefix_to_routelist_map_.size() != config.
prefix.size())
353 for (vector<string>::const_iterator it = config.
prefix.begin();
354 it != config.
prefix.end(); ++it) {
357 if (prefix_to_routelist_map_.find(ipam_subnet) ==
358 prefix_to_routelist_map_.end()) {
372 template <
typename T>
380 if (table == dest_table() && !dest_table_unregistered()) {
384 if (!IsEvpnType5Route(route)) {
390 if (IsConnectedRoute(route)) {
395 if (aggregate_enable() && IsAggregate(route))
398 if (aggregate_enable() && IsMoreSpecific(route, &aggregate_match)) {
401 type = ServiceChainRequestT::MORE_SPECIFIC_DELETE;
403 type = ServiceChainRequestT::MORE_SPECIFIC_ADD_CHG;
420 int src_vn_index = src_->virtual_network_index();
421 int dest_vn_index = dest_->virtual_network_index();
422 if (!vn_index || dest_vn_index != vn_index) {
423 if (src_vn_index == vn_index)
425 if (!dest_->virtual_network_allow_transit())
441 type = ServiceChainRequestT::EXT_CONNECT_ROUTE_DELETE;
443 type = ServiceChainRequestT::EXT_CONNECT_ROUTE_ADD_CHG;
446 }
else if ((table == connected_table()) &&
447 !connected_table_unregistered() &&
448 IsConnectedRoute(route,
true)) {
459 type = ServiceChainRequestT::CONNECTED_ROUTE_DELETE;
461 type = ServiceChainRequestT::CONNECTED_ROUTE_ADD_CHG;
498 manager_->Enqueue(req);
502 template <
typename T>
504 return (
string(
"ServiceChain " ) + service_chain_addr_.to_string());
507 template <
typename T>
509 connected_route_ = connected;
510 connected_path_ids_.clear();
511 if (!connected_route_)
514 for (Route::PathList::iterator it = connected->
GetPathList().begin();
523 if (connected_route_->BestPath()->PathCompare(*path,
true))
528 connected_path_ids_.insert(path_id);
532 template <
typename T>
534 return (connected_route_ && connected_route_->IsValid());
537 template <
typename T>
539 PrefixT *aggregate_match)
const {
541 const PrefixT &ip_prefix = ip_route->GetPrefix();
542 for (
typename PrefixToRouteListMap::const_iterator it =
543 prefix_to_route_list_map()->begin();
544 it != prefix_to_route_list_map()->end(); ++it) {
545 if (ip_prefix.IsMoreSpecific(it->first)) {
546 *aggregate_match = it->first;
553 template <
typename T>
556 for (
typename PrefixToRouteListMap::const_iterator it =
557 prefix_to_route_list_map()->begin();
558 it != prefix_to_route_list_map()->end(); ++it) {
559 if (it->first == ip_route->GetPrefix())
570 template <
typename T>
572 bool is_conn_table)
const {
576 return (service_chain_addr() == inet_route->
GetPrefix().
addr());
579 return (service_chain_addr() == inet6_route->
GetPrefix().
addr());
586 return (service_chain_addr() == ip_route->GetPrefix().addr());
596 template <
typename T>
618 template <
typename T>
652 template <
typename T>
668 GetTablePartition(&rt_key));
672 if (service_chain_route && !service_chain_route->
IsDeleted()) {
673 DeleteServiceChainRouteInternal(service_chain_route, partition,
674 bgptable, aggregate);
688 GetReplicationFamilyInfo(repl_partition, repl_sc_route, repl_table,
690 if (repl_sc_route && !repl_sc_route->
IsDeleted()) {
691 DeleteServiceChainRouteInternal(repl_sc_route, repl_partition,
692 repl_table, aggregate);
697 template <
typename T>
705 for (ConnectedPathIdList::const_iterator it = GetConnectedPathIds().begin();
706 it != GetConnectedPathIds().end(); ++it) {
707 uint32_t path_id = *it;
710 "Removed " << (aggregate ?
"Aggregate" :
"ExtConnected") <<
711 " ServiceChain path " << service_chain_route->
ToString() <<
713 " in table " << bgptable->
name());
716 if (!service_chain_route->
HasPaths()) {
717 partition->
Delete(service_chain_route);
719 partition->
Notify(service_chain_route);
746 template <
typename T>
767 if (service_chain_route == NULL) {
768 service_chain_route =
new RouteT(prefix);
769 partition->
Add(service_chain_route);
774 UpdateServiceChainRouteInternal(orig_route, old_path_ids,
775 service_chain_route, partition,
776 bgptable, aggregate);
789 GetReplicationFamilyInfo(repl_partition, repl_sc_route, repl_table,
791 UpdateServiceChainRouteInternal(orig_route, old_path_ids,
792 repl_sc_route, repl_partition,
793 repl_table, aggregate);
797 template <
typename T>
803 int vn_index = dest_routing_instance()->virtual_network_index();
804 BgpServer *server = dest_routing_instance()->server();
818 bool load_balance_present =
false;
819 const Community *orig_community =
nullptr;
821 const AsPath *orig_aspath =
nullptr;
824 const BgpPath *orig_path = orig_route->BestPath();
825 const BgpAttr *orig_attr =
nullptr;
828 if (orig_path !=
nullptr)
829 orig_attr = orig_path->
GetAttr();
830 if (orig_attr !=
nullptr) {
836 orig_aspath = orig_attr->
as_path();
838 if (ext_community !=
nullptr) {
842 sgid_list.push_back(comm);
847 load_balance_present =
true;
851 if (large_community !=
nullptr) {
852 for(
const auto &comm : large_community->
communities()) {
854 tag_list.push_back(comm);
873 origin_vn_trans_bytes);
876 orig_ovnpath, origin_vn_bytes);
880 for (Route::PathList::iterator it =
881 connected_route()->GetPathList().begin();
882 it != connected_route()->GetPathList().end(); ++it) {
883 BgpPath *connected_path =
static_cast<BgpPath *
>(it.operator->());
890 if (connected_route()->BestPath()->PathCompare(*connected_path,
true))
897 if (connected_route()->DuplicateForwardingPath(connected_path))
925 connected_->name()));
929 conn_ri = connected_routing_instance();
932 "Adding primary RI " << conn_ri->
name() <<
" route targets " <<
933 "to service-chain route for EVPN table " << bgptable->
name());
944 new_ext_community.get(), export_list);
949 new_ext_community.get(), sgid_list);
953 new_large_community.get(), tag_list);
958 new_ext_community.get());
975 new_ext_community.get(), origin_vn4_bytes);
977 new_ext_community.get(), origin_vn_trans_bytes);
980 new_ext_community.get(), origin_vn_bytes);
989 vector<string> tunnel_encaps = boost::assign::list_of(
"vxlan");
990 BOOST_FOREACH(
string encap, tunnel_encaps) {
991 encaps_list.push_back(
TunnelEncap(encap).GetExtCommunity());
993 new_ext_community = extcomm_db->
994 ReplaceTunnelEncapsulationAndLocate(new_ext_community.get(),
1000 attr, new_ext_community);
1003 new_large_community);
1012 if (retain_as_path() && orig_aspath) {
1025 if (src_ != connected_ && peer && peer->
IsXmppPeer()) {
1026 int instance_id = -1;
1028 bgptable, &instance_id);
1049 vpn_route->GetPrefix().route_distinguisher());
1054 if (!orig_rd.
IsZero() && new_attr->source_rd() == orig_rd)
1060 ProcessServiceChainPath(path_id, connected_path, new_attr,
1061 service_chain_route, partition,
1062 aggregate, bgptable);
1063 new_path_ids.insert(path_id);
1067 for (ConnectedPathIdList::const_iterator it = old_path_ids.begin();
1068 it != old_path_ids.end(); ++it) {
1069 uint32_t path_id = *it;
1070 if (new_path_ids.find(path_id) != new_path_ids.end())
1073 partition->
Notify(service_chain_route);
1076 "Removed " << (aggregate ?
"Aggregate" :
"ExtConnected") <<
1077 " ServiceChain path " << service_chain_route->
ToString() <<
1079 " in table " << bgptable->
name());
1084 if (!service_chain_route->
HasPaths())
1085 partition->
Delete(service_chain_route);
1088 template <
typename T>
1091 typename PrefixToRouteListMap::iterator it =
1092 prefix_to_routelist_map_.find(aggregate);
1093 assert(it != prefix_to_routelist_map_.end());
1095 if (it->second.empty()) {
1099 it->second.insert(more_specific);
1103 template <
typename T>
1106 typename PrefixToRouteListMap::iterator it =
1107 prefix_to_routelist_map_.find(aggregate);
1108 assert(it != prefix_to_routelist_map_.end());
1109 it->second.erase(more_specific);
1110 return it->second.empty();
1113 template <
typename T>
1116 info->set_state(
"deleted");
1117 }
else if (!IsConnectedRouteValid()) {
1118 info->set_state(
"down");
1119 }
else if (!group_oper_state_up()) {
1120 info->set_state(
"group down");
1122 info->set_state(
"active");
1125 ConnectedRouteInfo connected_rt_info;
1126 connected_rt_info.set_service_chain_addr(
1127 service_chain_addr().to_string());
1128 if (connected_route()) {
1129 ShowRoute show_route;
1130 connected_route()->FillRouteInfo(connected_table(), &show_route);
1131 connected_rt_info.set_connected_rt(show_route);
1133 info->set_connected_route(connected_rt_info);
1135 vector<PrefixToRouteListInfo> more_vec;
1136 for (
typename PrefixToRouteListMap::const_iterator it =
1137 prefix_to_route_list_map()->begin();
1138 it != prefix_to_route_list_map()->end(); ++it) {
1139 PrefixToRouteListInfo prefix_list_info;
1140 prefix_list_info.set_prefix(it->first.ToString());
1143 RouteT rt_key(it->first);
1146 prefix_list_info.set_aggregate(
true);
1147 ShowRoute show_route;
1149 prefix_list_info.set_aggregate_rt(show_route);
1151 prefix_list_info.set_aggregate(
false);
1154 vector<string> rt_list;
1155 for (RouteList::iterator rt_it = it->second.begin();
1156 rt_it != it->second.end(); ++rt_it) {
1157 rt_list.push_back((*rt_it)->ToString());
1159 prefix_list_info.set_more_specific_list(rt_list);
1160 more_vec.push_back(prefix_list_info);
1162 info->set_more_specifics(more_vec);
1164 vector<ExtConnectRouteInfo> ext_connecting_rt_info_list;
1165 for (ExtConnectRouteList::const_iterator it =
1166 ext_connecting_routes().begin();
1167 it != ext_connecting_routes().end(); ++it) {
1168 ExtConnectRouteInfo ext_rt_info;
1169 ext_rt_info.set_ext_rt_prefix((*it)->ToString());
1172 RouteT rt_key(ext_route->GetPrefix());
1175 if (ext_connecting) {
1176 ShowRoute show_route;
1178 ext_rt_info.set_ext_rt_svc_rt(show_route);
1180 ext_connecting_rt_info_list.push_back(ext_rt_info);
1182 info->set_ext_connecting_rt_info_list(ext_connecting_rt_info_list);
1183 info->set_aggregate_enable(aggregate_enable());
1188 : manager_(manager),
1190 oper_state_up_(false) {
1252 template <
typename T>
1254 return server_->condition_listener(GetSCFamily());
1257 template <
typename T>
1275 (listener_->GetMatchState(table, route, info));
1278 switch (req->
type_) {
1279 case ServiceChainRequestT::MORE_SPECIFIC_ADD_CHG: {
1293 aggregate_match, NULL, path_ids,
true);
1296 case ServiceChainRequestT::MORE_SPECIFIC_DELETE: {
1305 case ServiceChainRequestT::CONNECTED_ROUTE_ADD_CHG: {
1311 UpdateServiceChainGroup(info->
group());
1325 UpdateServiceChainRoutes(info, path_ids);
1328 case ServiceChainRequestT::CONNECTED_ROUTE_DELETE: {
1330 UpdateServiceChainGroup(info->
group());
1331 DeleteServiceChainRoutes(info);
1336 case ServiceChainRequestT::EXT_CONNECT_ROUTE_ADD_CHG: {
1349 ext_route->GetPrefix(), ext_route, path_ids,
false);
1352 case ServiceChainRequestT::EXT_CONNECT_ROUTE_DELETE: {
1361 case ServiceChainRequestT::UPDATE_ALL_ROUTES: {
1373 UpdateServiceChainRoutes(info, path_ids);
1376 case ServiceChainRequestT::DELETE_ALL_ROUTES: {
1377 DeleteServiceChainRoutes(info);
1380 case ServiceChainRequestT::STOP_CHAIN_DONE: {
1384 listener_->UnregisterMatchCondition(table, info);
1390 listener_->UnregisterMatchCondition(table, info);
1409 listener_->RemoveMatchState(table, route, info);
1413 listener_->UnregisterMatchCondition(
1417 listener_->UnregisterMatchCondition(
1431 template <
typename T>
1434 listener_(GetListener()),
1437 TaskScheduler::GetInstance()->GetTaskId(
"bgp::Config"), 0)),
1440 TaskScheduler::GetInstance()->GetTaskId(
"bgp::ServiceChain"), 0)),
1441 aggregate_host_route_(false),
1443 server_delete_ref_(this, server->
deleter()) {
1461 template <
typename T>
1463 assert(group_set_.empty());
1464 assert(group_map_.empty());
1467 template <
typename T>
1469 process_queue_->Shutdown();
1474 server_delete_ref_.Reset(NULL);
1477 template <
typename T>
1482 template <
typename T>
1484 if (!chain_set_.empty() || !pending_chains_.empty())
1486 if (!group_set_.empty() || !group_map_.empty())
1491 template <
typename T>
1493 if (!deleter_->IsDeleted())
1495 deleter_->RetryDelete();
1498 template <
typename T>
1501 if (ServiceChainIsPending(rtinstance)) {
1506 return (chain ? chain->
group() : NULL);
1510 template <
typename T>
1512 const string &group_name) {
1513 GroupMap::iterator loc = group_map_.find(group_name);
1514 return (loc != group_map_.end() ? loc->second : NULL);
1517 template <
typename T>
1519 const string &group_name) {
1522 GroupMap::iterator loc = group_map_.find(group_name);
1525 string temp_group_name(group_name);
1527 group_map_.insert(temp_group_name, group);
1532 template <
typename T>
1538 group_set_.insert(group);
1539 group_trigger_->Set();
1542 template <
typename T>
1547 if (group->
empty()) {
1548 string temp_group_name(group->
name());
1549 group_map_.erase(temp_group_name);
1630 template <
typename T>
1632 process_queue_->Enqueue(req);
1635 template <
typename T>
1637 string *reason)
const {
1638 typename PendingChainList::const_iterator loc =
1639 pending_chains_.find(rtinstance);
1640 if (loc != pending_chains_.end()) {
1642 *reason = loc->second.reason;
1648 template <
typename T>
1650 if (ServiceChainIsPending(rtinstance))
1658 template <
typename T>
1660 ShowServicechainInfo *info)
const {
1661 string pending_reason;
1662 if (ServiceChainIsPending(rtinstance, &pending_reason)) {
1663 info->set_state(
"pending");
1664 info->set_pending_reason(pending_reason);
1676 template <
typename T>
1682 std::scoped_lock lock(mutex_);
1683 ServiceChainMap::iterator it = chain_set_.find(rtinstance);
1684 if (it != chain_set_.end()) {
1688 "No update in ServiceChain config : " << rtinstance->
name());
1708 string reason =
"Waiting for deletion of previous incarnation";
1709 AddPendingServiceChain(rtinstance, group, reason);
1717 listener_->RemoveMatchCondition(chain->
dest_table(), chain, cb);
1735 DeletePendingServiceChain(rtinstance);
1747 string reason =
"Destination routing instance does not exist";
1748 AddPendingServiceChain(rtinstance, group, reason);
1754 string reason =
"Destination routing instance is being deleted";
1755 AddPendingServiceChain(rtinstance, group, reason);
1761 string reason =
"Destination virtual network index is unknown";
1762 AddPendingServiceChain(rtinstance, group, reason);
1768 connected_ri = rtinstance;
1769 assert(!rtinstance->
deleted());
1775 if (!connected_ri) {
1776 string reason =
"Connected routing instance does not exist";
1777 AddPendingServiceChain(rtinstance, group, reason);
1782 if (connected_ri->
deleted()) {
1783 string reason =
"Connected routing instance is being deleted";
1784 AddPendingServiceChain(rtinstance, group, reason);
1793 string reason =
"Service chain address is invalid";
1794 AddPendingServiceChain(rtinstance, group, reason);
1804 connected_table = connected_ri->
GetTable(GetConnectedFamily());
1805 assert(connected_table);
1811 rtinstance, dest, connected_ri, config.
prefix, chain_addr,
1814 if (aggregate_host_route()) {
1820 chain_set_.insert(make_pair(rtinstance, chain));
1821 listener_->AddMatchCondition(
1823 listener_->AddMatchCondition(
1829 template <
typename T>
1831 const string &instance)
const {
1833 server_->routing_instance_mgr()->GetRoutingInstance(instance);
1836 ServiceChainMap::const_iterator it = chain_set_.find(rtinstance);
1837 if (it == chain_set_.end())
1839 ServiceChainT *chain =
static_cast<ServiceChainT *
>(it->second.get());
1843 template <
typename T>
1846 ServiceChainMap::const_iterator it = chain_set_.find(rtinstance);
1847 if (it == chain_set_.end())
1853 template <
typename T>
1856 for (
typename PendingChainList::iterator it = pending_chains_.begin(), next;
1857 it != pending_chains_.end(); it = next) {
1864 pending_chains_.erase(it);
1868 LocateServiceChain(rtinstance, *sc_config);
1874 template <
typename T>
1880 template <
typename T>
1882 if (pending_chains_.empty())
1884 resolve_trigger_->Set();
1887 template <
typename T>
1898 template <
typename T>
1903 std::scoped_lock lock(mutex_);
1904 if (ServiceChainIsPending(rtinstance)) {
1908 DeletePendingServiceChain(rtinstance);
1927 listener_->RemoveMatchCondition(chain->
dest_table(), chain, cb);
1931 template <
typename T>
1933 bool group_oper_state_up) {
1944 if (group_oper_state_up) {
1945 req_type = ServiceChainRequestT::UPDATE_ALL_ROUTES;
1947 req_type = ServiceChainRequestT::DELETE_ALL_ROUTES;
1954 template <
typename T>
1960 for (
typename ServiceChainT::PrefixToRouteListMap::iterator it =
1961 vn_prefix_list->begin(); it != vn_prefix_list->end(); ++it) {
1962 if (!it->second.empty())
1967 for (
typename ServiceChainT::ExtConnectRouteList::iterator it =
1972 ext_route->GetPrefix(), ext_route, old_path_ids,
false);
1976 template <
typename T>
1981 for (
typename ServiceChainT::PrefixToRouteListMap::iterator it =
1982 vn_prefix_list->begin(); it != vn_prefix_list->end(); ++it) {
1987 for (
typename ServiceChainT::ExtConnectRouteList::iterator it =
1995 template <
typename T>
2016 template <
typename T>
2018 resolve_trigger_->set_disable();
2021 template <
typename T>
2023 resolve_trigger_->set_enable();
2026 template <
typename T>
2028 group_trigger_->set_disable();
2031 template <
typename T>
2033 group_trigger_->set_enable();
2036 template <
typename T>
2039 for (ServiceChainMap::const_iterator it = chain_set_.begin();
2040 it != chain_set_.end(); ++it) {
boost::asio::ip::address IpAddress
boost::intrusive_ptr< const AsPath > AsPathPtr
boost::intrusive_ptr< const BgpAttr > BgpAttrPtr
#define BGP_LOG_FLAG_TRACE
#define BGP_LOG_STR(obj, level, flags, arg)
boost::intrusive_ptr< const OriginVnPath > OriginVnPathPtr
BgpAttrPtr ReplaceAsPathAndLocate(const BgpAttr *attr, AsPathPtr aspath)
BgpAttrPtr ReplaceExtCommunityAndLocate(const BgpAttr *attr, ExtCommunityPtr extcomm)
BgpAttrPtr ReplaceSourceRdAndLocate(const BgpAttr *attr, const RouteDistinguisher &source_rd)
BgpAttrPtr ReplaceOriginVnPathAndLocate(const BgpAttr *attr, OriginVnPathPtr ovnpath)
BgpAttrPtr ReplaceLargeCommunityAndLocate(const BgpAttr *attr, LargeCommunityPtr largecomm)
BgpAttrPtr ReplaceCommunityAndLocate(const BgpAttr *attr, CommunityPtr community)
const LargeCommunity * large_community() const
const AsPath * as_path() const
const OriginVnPath * origin_vn_path() const
const Community * community() const
const RouteDistinguisher & source_rd() const
const IpAddress & nexthop() const
const ExtCommunity * ext_community() const
boost::function< void(BgpTable *, ConditionMatch *)> RequestDoneCb
void SetMatchState(BgpTable *table, BgpRoute *route, ConditionMatch *obj, ConditionMatchState *state=NULL)
ConditionMatchState * GetMatchState(BgpTable *table, BgpRoute *route, ConditionMatch *obj)
const ServiceChainConfig * service_chain_info(SCAddress::Family family) const
void UnregisterPeerRegistrationCallback(int id)
int RegisterPeerRegistrationCallback(PeerRegistrationCallback callback)
bool GetRegistrationInfo(const IPeer *peer, const BgpTable *table, int *instance_id=NULL, uint64_t *subscription_gen_id=NULL) const
bool IsVrfOriginated() const
uint32_t GetLabel() const
uint32_t GetFlags() const
static std::string PathIdString(uint32_t path_id)
virtual bool IsReplicated() const
const BgpAttr * GetAttr() const
PathSource GetSource() const
const BgpPath * FindPath(BgpPath::PathSource src) const
bool RemovePath(BgpPath::PathSource src, const IPeer *peer=NULL, uint32_t path_id=0)
const BgpPath * BestPath() const
virtual bool IsValid() const
void FillRouteInfo(const BgpTable *table, ShowRouteBrief *show_route) const
void InsertPath(BgpPath *path)
const BgpRoute * src_rt() const
const BgpTable * src_table() const
ExtCommunityDB * extcomm_db()
RoutingInstanceMgr * routing_instance_mgr()
as_t autonomous_system() const
OriginVnPathDB * ovnpath_db()
BgpMembershipManager * membership_mgr()
LargeCommunityDB * largecomm_db()
RoutingInstance * routing_instance()
virtual Address::Family family() const =0
uint32_t num_matchstate() const
virtual std::string ToString() const =0
const std::string & name() const
void Notify(DBEntryBase *entry)
void Delete(DBEntryBase *)
virtual void Add(DBEntry *entry)
DBEntry * Find(const DBEntry *entry)
DBEntry * Find(const DBEntry *entry)
virtual DBTablePartBase * GetTablePartition(const DBRequestKey *key)
static EvpnPrefix FromString(const std::string &str, boost::system::error_code *errorp=NULL)
Address::Family family() const
const EvpnPrefix & GetPrefix() const
virtual bool IsXmppPeer() const =0
virtual void UpdateServiceChainGroup(ServiceChainGroup *group)=0
virtual void UpdateServiceChain(RoutingInstance *rtinstance, bool group_oper_state_up)=0
virtual bool ServiceChainIsUp(RoutingInstance *rtinstance) const =0
const Inet6Prefix & GetPrefix() const
const Ip4Prefix & GetPrefix() const
static bool IsPresent(const BgpPath *path)
const bytes_type & GetExtCommunity() const
OriginVnPathPtr PrependAndLocate(const OriginVnPath *ovnpath, const OriginVnPath::OriginVnValue &value)
boost::array< uint8_t, 8 > OriginVnValue
bool Contains(const OriginVnValue &value) const
const bytes_type & GetExtCommunity() const
uint32_t GetAddress() const
std::string ToString() const
const bytes_type & GetExtCommunity() const
const PathList & GetPathList() const
RoutingInstance * GetRoutingInstance(const std::string &name)
void UnregisterInstanceOpCallback(int id)
static std::string GetPrimaryRoutingInstanceName(const string &name_in)
int RegisterInstanceOpCallback(RoutingInstanceCb cb)
const std::string & name() const
int virtual_network_index() const
const BgpInstanceConfig * config() const
const RouteTargetList & GetExportList() const
BgpTable * GetTable(Address::Family fmly)
bool IsMasterRoutingInstance() const
ServiceChainGroup(IServiceChainMgr *manager, const std::string &name)
void DeleteRoutingInstance(RoutingInstance *rtinstance)
void AddRoutingInstance(RoutingInstance *rtinstance)
ServiceChainSet chain_set_
IServiceChainMgr * manager_
DeleteActor(ServiceChainMgr< T > *manager)
ServiceChainMgr< T > * manager_
virtual bool MayDelete() const
void UpdateServiceChainGroup(ServiceChainGroup *group)
virtual BgpConditionListener * GetListener()
void UpdateServiceChainRoutes(ServiceChainT *chain, const typename ServiceChainT::ConnectedPathIdList &old_path_ids)
void DeleteServiceChainRoutes(ServiceChainT *chain)
ServiceChainGroup * LocateServiceChainGroup(const std::string &group_name)
Address::Family GetConnectedFamily() const
SCAddress::Family GetSCFamily() const
virtual uint32_t GetDownServiceChainCount() const
virtual void StopServiceChain(RoutingInstance *rtinstance)
bool ProcessServiceChainGroups()
virtual void DisableGroupTrigger()
ServiceChainT * FindServiceChain(const std::string &instance) const
virtual void EnableGroupTrigger()
virtual void EnableResolveTrigger()
virtual bool LocateServiceChain(RoutingInstance *rtinstance, const ServiceChainConfig &config)
virtual ~ServiceChainMgr()
ServiceChainGroup * FindServiceChainGroup(RoutingInstance *rtinstance)
void StopServiceChainDone(BgpTable *table, ConditionMatch *info)
ServiceChainMgr(BgpServer *server)
static int service_chain_task_id_
bool ResolvePendingServiceChain()
void RoutingInstanceCallback(std::string name, int op)
void Enqueue(ServiceChainRequestT *req)
bool RequestHandler(ServiceChainRequestT *req)
virtual void DisableResolveTrigger()
void PeerRegistrationCallback(IPeer *peer, BgpTable *table, bool unregister)
virtual void UpdateServiceChain(RoutingInstance *rtinstance, bool group_oper_state_up)
virtual bool FillServiceChainInfo(RoutingInstance *rtinstance, ShowServicechainInfo *info) const
boost::scoped_ptr< WorkQueue< ServiceChainRequestT * > > process_queue_
virtual bool ServiceChainIsPending(RoutingInstance *rtinstance, std::string *reason=NULL) const
virtual bool ServiceChainIsUp(RoutingInstance *rtinstance) const
Address::Family GetFamily() const
bool group_oper_state_up() const
const ConnectedPathIdList & GetConnectedPathIds()
SCAddress::Family GetSCFamily() const
bool dest_table_unregistered() const
bool IsEvpnType5Route(BgpRoute *route) const
virtual std::string ToString() const
void set_dest_table_unregistered()
PrefixToRouteListMap * prefix_to_route_list_map()
std::set< uint32_t > ConnectedPathIdList
bool AddMoreSpecific(PrefixT aggregate, BgpRoute *more_specific)
bool CompareServiceChainConfig(const ServiceChainConfig &config)
void DeleteServiceChainRouteInternal(BgpRoute *service_chain_route, DBTablePartition *partition, BgpTable *bgptable, bool aggregate)
void UpdateServiceChainRouteInternal(const RouteT *orig_route, const ConnectedPathIdList &old_path_ids, BgpRoute *sc_route, DBTablePartition *partition, BgpTable *bgptable, bool aggregate)
BgpRoute * connected_route() const
void RemoveMatchState(BgpRoute *route, ServiceChainState *state)
void UpdateServiceChainRoute(PrefixT prefix, const RouteT *orig_route, const ConnectedPathIdList &old_path_ids, bool aggregate)
PrefixToRouteListMap prefix_to_routelist_map_
bool unregistered() const
virtual bool Match(BgpServer *server, BgpTable *table, BgpRoute *route, bool deleted)
std::map< PrefixT, RouteList > PrefixToRouteListMap
void SetConnectedRoute(BgpRoute *connected)
void FillServiceChainInfo(ShowServicechainInfo *info) const
bool DeleteMoreSpecific(PrefixT aggregate, BgpRoute *more_specific)
const ExtConnectRouteList & ext_connecting_routes() const
void ProcessServiceChainPath(uint32_t path_id, BgpPath *path, BgpAttrPtr attr, BgpRoute *&route, DBTablePartition *&partition, bool aggregate, BgpTable *bgptable)
BgpTable * dest_table() const
void set_group_oper_state_up(bool up)
void GetReplicationFamilyInfo(DBTablePartition *&partition, BgpRoute *&route, BgpTable *&table, PrefixT prefix, bool create)
BgpTable * connected_table() const
bool IsConnectedRoute(BgpRoute *route, bool is_conn_table=false) const
bool IsMoreSpecific(BgpRoute *route, PrefixT *aggregate_match) const
RoutingInstance * src_routing_instance() const
void set_connected_table_unregistered()
BgpTable * src_table() const
bool IsConnectedRouteValid() const
std::set< BgpRoute * > RouteList
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)
bool IsAggregate(BgpRoute *route) const
ServiceChainGroup * group() const
Address::Family GetFamily() const
bool connected_table_unregistered() const
void DeleteServiceChainRoute(PrefixT prefix, bool aggregate)
void set_aggregate_enable()
const bytes_type & GetExtCommunity() const
The TaskScheduler keeps track of what tasks are currently schedulable. When a task is enqueued it is ...
int GetTaskId(const std::string &name)
static TaskScheduler * GetInstance()
static PhysicalDevice::ManagementProtocol FromString(const string &proto)
static int GetOriginVnIndex(const BgpTable *table, const BgpRoute *route)
ConditionMatchPtr ServiceChainPtr
std::vector< std::string > prefix
std::string source_routing_instance
std::string service_chain_id
std::string service_chain_address
std::string routing_instance
ServiceChainGroup * group
#define CHECK_CONCURRENCY(...)