11 #include <boost/assign/list_of.hpp>
12 #include <boost/foreach.hpp>
13 #include <boost/tuple/tuple.hpp>
25 #include "bgp/bgp_peer_types.h"
42 using boost::assign::list_of;
43 using boost::assign::map_list_of;
44 using boost::system::error_code;
49 using std::numeric_limits;
50 using std::ostringstream;
235 if (family_config.
family ==
"inet") {
237 }
else if (family_config.
family ==
"inet6") {
247 if (!family_attributes) {
302 " size " << msgsize);
347 "EndOfRib Send Timer rescheduled for family " <<
350 "due to non-empty output queue (" << output_depth <<
")");
365 "EndOfRib Send Timer rescheduled for family " <<
368 "as bgp (under restart) has not completed initial configuration"
379 "EndOfRib Send Timer rescheduled for family " <<
382 "as bgp is still under [re-]starting phase");
392 "EndOfRib Send Timer rescheduled for family " <<
395 "as new route-targets are still being added to the table");
408 "EndOfRib Send Timer scheduled for family " <<
417 assert(!peer_info.get_name().empty());
460 return close_manager_->MembershipPathCallback(tpart, route, path);
472 rtinstance_(instance),
474 peer_port_(config->source_port()),
475 peer_name_(config->name()),
476 router_type_(config->router_type()),
478 index_(server->RegisterPeer(this)),
480 TaskScheduler::GetInstance()->GetTaskId(
"bgp::StateMachine"),
482 prefix_limit_idle_timer_(
484 "BGP prefix limit idle timer",
485 TaskScheduler::GetInstance()->GetTaskId(
"bgp::StateMachine"),
487 prefix_limit_trigger_(
boost::bind(&
BgpPeer::CheckPrefixLimits, this),
488 TaskScheduler::GetInstance()->GetTaskId(
"bgp::StateMachine"),
490 buffer_capacity_(GetBufferCapacity()),
492 keepalive_timer_(
TimerManager::CreateTimer(*server->ioservice(),
493 "BGP keepalive timer",
494 TaskScheduler::GetInstance()->GetTaskId(
"bgp::StateMachine"),
496 eor_send_timer_start_time_(0),
498 admin_down_(config->admin_down()),
499 passive_(config->passive()),
500 resolve_paths_(config->router_type() ==
"bgpaas-client"),
501 as_override_(config->as_override()),
502 cluster_id_(config->cluster_id()),
503 origin_override_(config->origin_override()),
505 graceful_close_(true),
506 as4_supported_(false),
507 vpn_tables_registered_(false),
508 hold_time_(config->hold_time()),
509 local_as_(config->local_as()),
510 peer_as_(config->peer_as()),
511 local_bgp_id_(config->local_identifier()),
513 family_primary_path_count_(
Address::NUM_FAMILIES),
514 peer_type_((config->peer_as() == config->local_as()) ?
520 instance_delete_ref_(this, instance ? instance->
deleter() : NULL),
522 total_flap_count_(0),
524 dscp_listener_id_(-1),
526 asn_listener_id_(-1),
599 BgpPeerInfoData peer_info;
606 peer_info.set_route_origin(
609 peer_info.set_route_origin(
"-");
613 peer_info.set_peer_type(
631 BgpPeerInfoData peer_info;
633 peer_info.set_deleted(
true);
636 PeerStatsData peer_stats_data;
637 peer_stats_data.set_name(
ToUVEKey());
638 peer_stats_data.set_deleted(
true);
639 assert(!peer_stats_data.get_name().empty());
640 BGP_UVE_SEND2(PeerStatsUve, peer_stats_data,
"ObjectBgpPeer");
642 PeerFlapData peer_flap_data;
643 peer_flap_data.set_name(
ToUVEKey());
644 peer_flap_data.set_deleted(
true);
645 assert(!peer_flap_data.get_name().empty());
659 char *buffer_capacity_str = getenv(
"BGP_PEER_BUFFER_SIZE");
660 if (buffer_capacity_str) {
661 size_t env_buffer_capacity = strtoul(buffer_capacity_str, NULL, 0);
666 return env_buffer_capacity;
678 uint32_t ribout_cid)
const {
681 if (!server_cluster_id)
return true;
686 if (ribout_cid && ribout_cid != server_cluster_id) {
707 attrs.push_back(&nexthop);
709 attrs.push_back(&origin);
715 RouteTargetList::const_iterator it) {
735 for (RouteTargetList::const_iterator it =
rtargets_.begin();
743 RouteTargetList::const_iterator it) {
761 for (RouteTargetList::const_iterator it =
rtargets_.begin();
909 if (dscp_value != 0xFF) {
921 string logstr = socket_name +
" socket kernel " + oper +
" of key id "
941 if (!family_attributes || family_attributes->
prefix_limit == 0)
967 family_attributes_list[family] = family_attributes;
971 family_attributes_list.begin(), family_attributes_list.end(),
1004 bool admin_down_changed =
false;
1005 BgpPeerInfoData peer_info;
1011 admin_down_changed =
true;
1039 peer_info.set_route_origin(
"-");
1082 "Updated Local Autonomous System from " <<
1094 "Updated Hold Time from " <<
1106 "Updated Peer Autonomous System from " <<
1115 boost::system::error_code ec;
1126 peer_info.set_peer_type(
1151 "Session cleared due to configuration change");
1294 const BgpPath *old_path, uint32_t path_flags)
const {
1397 membership_mgr->
Register(
this, table, policy);
1438 vector<Address::Family> family_list = list_of
1445 table,
"Register peer with the table");
1454 if (mgr !=
nullptr) {
1457 if (vxlan_ri !=
nullptr) {
1460 table,
"Register ribin for peer with the table");
1475 table,
"Register peer with the table");
1478 vector<Address::Family> vpn_family_list = list_of
1486 table,
"Register ribin for peer with the table");
1510 static const uint8_t cap_mp[][4] = {
1543 BOOST_FOREACH(
const FamilyToCapabilityMap::value_type &val,
1544 family_to_cap_map) {
1558 (
const uint8_t *)(&asn), 4);
1590 SandeshLevel::SYS_INFO;
1601 if (init_)
return skip_;
1603 skip_ = getenv(
"BGP_SKIP_UPDATE_SEND") != NULL;
1611 : origin_override(config.origin_override),
1612 origin(
BgpAttr::OriginFromString(config.origin)) {
1621 if (origin_override && origin != rhs.
origin) {
1633 const string *msg_str) {
1701 int code,
int subcode,
const string &data) {
1711 vector<BgpProto::OpenMessage::OptParam *>::const_iterator it;
1712 for (it = msg->
opt_params.begin(); it < msg->opt_params.end(); ++it) {
1714 (*it)->capabilities.end());
1715 (*it)->capabilities.clear();
1720 vector<BgpProto::OpenMessage::Capability *>::iterator c_it;
1728 BgpPeerInfoData peer_info;
1732 vector<string> families;
1733 vector<BgpProto::OpenMessage::Capability *>::iterator cap_it;
1738 uint8_t *data = (*cap_it)->capability.data();
1748 peer_info.set_families(families);
1767 if (!
peer_close_->SetGRCapabilities(&peer_info)) {
1783 BgpPeerInfoData peer_info;
1785 vector<string> families = vector<string>();
1786 peer_info.set_families(families);
1789 peer_info.set_graceful_restart_families(vector<string>());
1794 vector<BgpProto::OpenMessage::Capability *>::iterator it;
1798 uint8_t *data = (*it)->capability.data();
1800 uint8_t safi_value =
get_value(data + 3, 1);
1801 if (afi == af_value && safi == safi_value) {
1812 template <
typename TableT,
typename PrefixT>
1818 for (vector<BgpProtoPrefix *>::const_iterator it = nlri->
nlri.begin();
1819 it != nlri->
nlri.end(); ++it) {
1823 uint32_t l3_label = 0;
1824 int result = PrefixT::FromProtoPrefix(
server_, **it,
1826 family, &prefix, &new_attr, &label, &l3_label);
1830 "MP NLRI parse error for " <<
1838 req.
data.reset(
new typename TableT::RequestData(
1839 new_attr, flags, label, l3_label, 0));
1841 req.
key.reset(
new typename TableT::RequestKey(prefix,
this));
1842 table->Enqueue(&req);
1846 template <
typename PrefixT>
1850 for (vector<BgpProtoPrefix *>::const_iterator it = nlri->
nlri.begin();
1851 it != nlri->
nlri.end(); ++it) {
1855 uint32_t l3_label = 0;
1856 int result = PrefixT::FromProtoPrefix(
server_, **it,
1858 family, &prefix, &new_attr, &label, &l3_label);
1862 "MP NLRI parse error for " <<
1867 ProcessBgpaas(oper, prefix.addr(), prefix.prefixlen(), new_attr, flags);
1878 if (mgr ==
nullptr) {
1883 if (vxlan_ri ==
nullptr) {
1895 req.
data.reset(NULL);
1948 return numeric_limits<uint32_t>::max() - med;
1972 uint32_t reach_count = 0, unreach_count = 0;
1979 "Cannot find inet table");
1984 for (vector<BgpProtoPrefix *>::const_iterator it =
1992 "Withdrawn route parse error for inet route");
2004 req.
data.reset(NULL);
2010 reach_count += msg->
nlri.size();
2011 for (vector<BgpProtoPrefix *>::const_iterator it = msg->
nlri.begin();
2012 it != msg->
nlri.end(); ++it) {
2018 "NLRI parse error for inet route");
2036 for (vector<BgpAttribute *>::const_iterator ait =
2051 reach_count += nlri->
nlri.size();
2053 unreach_count += nlri->
nlri.size();
2060 "AFI "<< nlri->
afi <<
" SAFI " << (
int) nlri->
safi <<
2070 "EndOfRib marker family " <<
2072 " size " << msgsize);
2086 ProcessNlri<InetTable, Ip4Prefix>(
2087 family, oper, nlri, attr, flags);
2090 ProcessNlriBgpaas<Ip4Prefix>(
2091 family, oper, nlri, attr, flags);
2095 ProcessNlri<InetVpnTable, InetVpnPrefix>(
2096 family, oper, nlri, attr, flags);
2099 ProcessNlri<Inet6Table, Inet6Prefix>(
2100 family, oper, nlri, attr, flags);
2103 ProcessNlriBgpaas<Inet6Prefix>(
2104 family, oper, nlri, attr, flags);
2108 ProcessNlri<Inet6VpnTable, Inet6VpnPrefix>(
2109 family, oper, nlri, attr, flags);
2112 ProcessNlri<EvpnTable, EvpnPrefix>(
2113 family, oper, nlri, attr, flags);
2116 ProcessNlri<ErmVpnTable, ErmVpnPrefix>(
2117 family, oper, nlri, attr, flags);
2120 ProcessNlri<MvpnTable, MvpnPrefix>(
2121 family, oper, nlri, attr, flags);
2124 ProcessNlri<RTargetTable, RTargetPrefix>(
2125 family, oper, nlri, attr, flags);
2137 "Update size " << msgsize <<
2138 " reach " << reach_count <<
" unreach " << unreach_count);
2144 return std::vector<std::string>();
2153 bool tunnel_encap_found =
false;
2154 if (ext_community) {
2155 for (ExtCommunity::ExtCommunityList::const_iterator iter =
2160 tunnel_encap_found =
true;
2166 if (!ext_community || !tunnel_encap_found) {
2168 BOOST_FOREACH(
const string &encap_string,
2175 ext_community ? ext_community.get() : NULL, encap_list);
2213 string error_message) {
2215 "Timer error: " << error_name <<
" " << error_message);
2219 string error_message) {
2221 "Timer error: " << error_name <<
" " << error_message);
2232 vector<Address::Family> vpn_family_list = list_of
2240 table,
"Register peer with the table");
2250 "EndOfRib Receive Timer scheduled for family " <<
2252 " to fire after " << timeout <<
" second(s)");
2259 string error_message) {
2261 "Timer error: " << error_name <<
" " << error_message);
2286 int keepalive_time_msecs =
state_machine_->keepalive_time_msecs();
2287 if (keepalive_time_msecs <= 0)
2343 for (
size_t i = 0; i < size; i ++) {
2344 if (!(i % 32)) out <<
"\n";
2345 if (!(i % 4)) out <<
" 0x";
2346 snprintf(buf,
sizeof(buf),
"%02X", msg[i]);
2361 if (minfo == NULL) {
2365 "Error while parsing message at " << ec.
type_name);
2384 bool update_nh =
false;
2390 Ip4Address::bytes_type bt = { { 0 } };
2392 nlri->
nexthop.begin() +
sizeof(bt), bt.begin());
2396 Ip4Address::bytes_type bt = { { 0 } };
2398 copy(nlri->
nexthop.begin() + rdsize,
2399 nlri->
nexthop.begin() + rdsize +
sizeof(bt), bt.begin());
2405 Ip4Address::bytes_type bt = { { 0 } };
2407 nlri->
nexthop.begin() +
sizeof(bt), bt.begin());
2419 for (
int idx = 0; idx < 2; ++idx) {
2420 Ip6Address::bytes_type bt = { { 0 } };
2421 if ((idx + 1) *
sizeof(bt) > nlri->
nexthop.size())
2423 copy(nlri->
nexthop.begin() + idx *
sizeof(bt),
2424 nlri->
nexthop.begin() + (idx + 1) *
sizeof(bt), bt.begin());
2426 if (v6_addr.is_v4_mapped()) {
2431 if (!v6_addr.is_link_local()) {
2438 Ip6Address::bytes_type bt = { { 0 } };
2440 copy(nlri->
nexthop.begin() + rdsize,
2441 nlri->
nexthop.begin() + rdsize +
sizeof(bt), bt.begin());
2443 if (v6_addr.is_v4_mapped()) {
2492 PeerProtoStats *proto_stats) {
2493 proto_stats->set_open(stats.
open);
2494 proto_stats->set_keepalive(stats.
keepalive);
2495 proto_stats->set_close(stats.
close);
2496 proto_stats->set_update(stats.
update);
2503 PeerUpdateStats *rt_stats) {
2504 rt_stats->set_reach(stats.
reach);
2505 rt_stats->set_unreach(stats.
unreach);
2511 PeerSocketStats *peer_socket_stats) {
2512 peer_socket_stats->set_calls(socket_stats.
calls);
2513 peer_socket_stats->set_bytes(socket_stats.
bytes);
2514 if (socket_stats.
calls) {
2515 peer_socket_stats->set_average_bytes(
2518 peer_socket_stats->set_blocked_count(socket_stats.
blocked_count);
2521 peer_socket_stats->set_blocked_duration(os.str());
2524 os << boost::posix_time::microseconds(
2526 peer_socket_stats->set_average_blocked_duration(os.str());
2544 PeerProtoStats proto_stats;
2547 bnr->set_rx_proto_stats(proto_stats);
2551 bnr->set_tx_proto_stats(proto_stats);
2554 PeerUpdateStats rt_stats;
2557 bnr->set_rx_update_stats(rt_stats);
2561 bnr->set_tx_update_stats(rt_stats);
2564 PeerSocketStats peer_socket_stats;
2568 bnr->set_rx_socket_stats(peer_socket_stats);
2572 bnr->set_tx_socket_stats(peer_socket_stats);
2576 vector<ShowBgpNeighborFamily> show_family_attributes_list;
2580 ShowBgpNeighborFamily show_family_attributes;
2581 show_family_attributes.set_family(
2583 show_family_attributes.set_loop_count(
2585 show_family_attributes.set_prefix_limit(
2587 show_family_attributes.set_idle_timeout(
2590 show_family_attributes.set_gateway_address(
2593 show_family_attributes_list.push_back(show_family_attributes);
2595 nbr->set_family_attributes_list(show_family_attributes_list);
2599 BgpNeighborResp *bnr,
bool summary)
const {
2611 bnr->set_route_origin(
"-");
2619 bnr->set_encoding(
"BGP");
2648 bnr->set_configured_hold_time(
state_machine_->GetConfiguredHoldTime());
2653 bnr->set_routing_instances(vector<BgpNeighborRoutingInstance>());
2826 BgpPeerInfoData peer_info;
2828 PeerFlapInfo flap_info;
2831 peer_info.set_flap_info(flap_info);
2834 PeerFlapData peer_flap_data;
2835 peer_flap_data.set_name(
ToUVEKey());
2836 peer_flap_data.set_flap_info(flap_info);
2837 assert(!peer_flap_data.get_name().empty());
2845 BgpPeerInfoData peer_info;
2847 PeerFlapInfo flap_info;
2848 peer_info.set_flap_info(flap_info);
2851 PeerFlapData peer_flap_data;
2852 peer_flap_data.set_name(
ToUVEKey());
2853 peer_flap_data.set_flap_info(flap_info);
2854 assert(!peer_flap_data.get_name().empty());
2866 if ((
session_ != NULL) && (dscp_value != 0xFF)) {
boost::asio::ip::address_v6 Ip6Address
boost::asio::ip::address IpAddress
boost::asio::ip::address_v4 Ip4Address
std::vector< BgpAttribute * > BgpAttrSpec
boost::intrusive_ptr< const BgpAttr > BgpAttrPtr
#define BGP_LOG_FLAG_SYSLOG
#define BGP_LOG_PEER(type, peer, level, flags, dir, arg)
#define BGP_LOG_WARNING_STR(obj, flags, arg)
#define BGP_LOG_PEER_WARNING(type, peer, flags, dir, arg)
#define BGP_LOG_PEER_TABLE(peer, level, flags, tbl, arg)
#define BGP_UVE_SEND2(type, object, arg)
#define BGP_LOG_PEER_NOTICE(type, peer, flags, dir, arg)
#define BGP_TRACE_PEER_PACKET(peer, msg, size, level)
#define BGP_LOG_FLAG_TRACE
#define BGP_UVE_SEND(type, object)
#define BGP_LOG_PEER_CRITICAL(type, peer, flags, dir, arg)
#define BGP_LOG_STR(obj, level, flags, arg)
static void FillSocketStats(const IPeerDebugStats::SocketStats &socket_stats, PeerSocketStats *peer_socket_stats)
static void FillProtoStats(const IPeerDebugStats::ProtoStats &stats, PeerProtoStats *proto_stats)
static void FillRouteUpdateStats(const IPeerDebugStats::UpdateStats &stats, PeerUpdateStats *rt_stats)
static bool SkipUpdateSend()
static Family FamilyFromString(const std::string &family)
static Ip4Address V4FromV4MappedV6(const Ip6Address &v6_address)
static std::string FamilyToString(Family fmly)
const AsPath4ByteSpec & path() const
const AsPathSpec & path() const
AuthenticationKeyChain::const_iterator const_iterator
std::vector< std::string > KeysToStringDetail() const
std::string KeyTypeToString() const
static std::pair< uint16_t, uint8_t > FamilyToAfiSafi(Address::Family family)
static Afi FamilyToAfi(Address::Family family)
static Safi FamilyToSafi(Address::Family family)
static Address::Family AfiSafiToFamily(uint16_t afi, uint8_t safi)
static std::string ToString(uint16_t afi, uint8_t safi)
BgpAttrPtr ReplaceLocalPreferenceAndLocate(const BgpAttr *attr, uint32_t local_pref)
BgpAttrPtr ReplaceNexthopAndLocate(const BgpAttr *attr, const IpAddress &addr)
BgpAttrPtr ReplaceSubProtocolAndLocate(const BgpAttr *attr, const std::string &sbp)
BgpAttrPtr ReplaceOriginAndLocate(const BgpAttr *attr, BgpAttrOrigin::OriginType origin)
const AsPath * as_path() const
static std::string OriginToString(BgpAttrOrigin::OriginType origin)
const ClusterList * cluster_list() const
int IsAsPathLoop(as_t asn, uint8_t max_loop_count=0) const
const ExtCommunity * ext_community() const
const AsPath4Byte * aspath_4byte() const
void set_ext_community(ExtCommunityPtr extcomm)
const Ip4Address & originator_id() const
static const int kDefaultPort
static const char * kMasterInstance
uint8_t control_dscp() const
void RegisterRibIn(IPeer *peer, BgpTable *table)
virtual void Register(IPeer *peer, BgpTable *table, const RibExportPolicy &policy, int instance_id=-1)
void FillPeerMembershipInfo(const IPeer *peer, BgpNeighborResp *resp) const
uint32_t GetRibOutQueueDepth(const IPeer *peer, const BgpTable *table) const
AddressFamilyList GetAddressFamilies() const
const OriginOverrideConfig & origin_override() const
uint32_t cluster_id() const
uint16_t source_port() const
const AuthenticationData & auth_data() const
uint32_t local_identifier() const
std::string router_type() const
const IpAddress & gateway_address(Address::Family family) const
std::string private_as_action() const
uint8_t loop_count() const
const FamilyAttributesList & family_attributes_list() const
uint32_t local_as() const
TypePtr Locate(Type *attr)
virtual bool MayDelete() const
DeleteActor(BgpPeer *peer)
virtual void GetRxRouteUpdateStats(UpdateStats *stats) const
virtual uint64_t num_flaps() const
virtual string last_event() const
virtual void GetRxProtoStats(ProtoStats *stats) const
virtual void GetTxSocketStats(IPeerDebugStats::SocketStats *stats) const
virtual string last_state_change_at() const
ProtoStats proto_stats_[2]
virtual string ToString() const
virtual void GetRxErrorStats(RxErrorStats *stats) const
virtual void GetTxProtoStats(ProtoStats *stats) const
virtual void UpdateTxReachRoute(uint64_t count)
virtual void GetRxRouteStats(RxRouteStats *stats) const
virtual void GetRxSocketStats(IPeerDebugStats::SocketStats *stats) const
virtual string last_flap() const
virtual string last_state() const
virtual string last_error() const
UpdateStats update_stats_[2]
virtual void UpdateTxUnreachRoute(uint64_t count)
virtual void GetTxRouteUpdateStats(UpdateStats *stats) const
Timer * prefix_limit_idle_timer_
virtual bool IsXmppPeer() const
uint64_t get_rx_notification() const
static const int kRouteTargetEndOfRibTimeSecs
bool PrefixLimitIdleTimerRunning() const
uint64_t get_tx_route_unreach() const
static const int kEndOfRibSendRetryTime
uint32_t GetEndOfRibReceiveTime(Address::Family family) const
virtual bool CanUseMembershipManager() const
void inc_rx_route_unreach(uint64_t count)
void RegisterToVpnTables()
virtual bool FlushUpdate()
static const size_t kMinBufferCapacity
const std::string peer_address_string() const
virtual BgpProto::BgpPeerType PeerType() const
virtual bool MpNlriAllowed(uint16_t afi, uint8_t safi)
virtual const std::string GetStateName() const
virtual time_t GetEorSendTimerElapsedTime() const
virtual bool ProcessSession() const
uint32_t PeerAddress() const
void RoutingInstanceCallback(const std::string &vrf_name, int op)
boost::scoped_ptr< PeerStats > peer_stats_
RoutingInstance * GetRoutingInstance()
BgpProto::BgpPeerType peer_type_
StateMachine * state_machine()
KeyType inuse_authkey_type_
virtual const std::string & ToUVEKey() const
virtual bool IsInGRTimerWaitState() const
void LogInstallAuthKeys(const std::string &socket_name, const std::string &oper, const AuthenticationKey &auth_key, KeyType key_type)
uint64_t get_connect_error() const
boost::scoped_ptr< StateMachine > state_machine_
uint64_t get_rx_keepalive() const
std::string BytesToHexString(const u_int8_t *msg, size_t size)
Timer * eor_send_timer_[Address::NUM_FAMILIES]
bool IsRouterTypeBGPaaS() const
BgpAttrPtr GetMpNlriNexthop(BgpMpNlri *nlri, BgpAttrPtr attr)
void SetSessionSocketAuthKey(TcpSession *session)
void StopKeepaliveTimerUnlocked()
void Close(bool graceful)
std::vector< std::string > configured_families_
void DeleteRTargets(as_t as)
const BgpNeighborConfig * config_
TcpSession::Endpoint endpoint() const
void ASNUpdateCallback(as_t old_asn, as_t old_local_asn)
virtual int GetPrimaryPathCount() const
bool IsCloseInProgress() const
size_t GetBufferCapacity() const
void ProcessNlriBgpaas(Address::Family family, DBRequest::DBOperation oper, const BgpMpNlri *nlri, BgpAttrPtr attr, uint32_t flags)
std::string transport_address_string() const
void EndOfRibTimerErrorHandler(std::string error_name, std::string error_message)
void increment_flap_count()
virtual bool IsReady() const
bool ProcessFamilyAttributesConfig(const BgpNeighborConfig *config)
uint64_t get_tx_keepalive() const
tbb::atomic< int > primary_path_count_
std::string GetInuseAuthKeyValue() const
int membership_req_pending() const
virtual void UpdateCloseRouteStats(Address::Family family, const BgpPath *old_path, uint32_t path_flags) const
virtual void ProcessPathTunnelEncapsulation(const BgpPath *path, BgpAttr *attr, ExtCommunityDB *extcomm_db, const BgpTable *table) const
std::string local_bgp_identifier_string() const
virtual BgpServer * server()
const std::string & peer_name() const
void FillCloseInfo(BgpNeighborResp *resp) const
virtual bool send_ready() const
virtual void SetDataCollectionKey(BgpPeerInfo *peer_info) const
void inc_connect_timer_expired()
void ReceiveEndOfRIB(Address::Family family, size_t msgsize)
bool EndOfRibReceiveTimerExpired(Address::Family family)
bool ProcessAuthKeyChainConfig(const BgpNeighborConfig *config)
RibExportPolicy BuildRibExportPolicy(Address::Family family) const
boost::scoped_ptr< BgpPeerClose > peer_close_
uint64_t get_rx_end_of_rib() const
std::string peer_basename_
void SendKeepalive(bool from_timer)
std::vector< BgpProto::OpenMessage::Capability * > capabilities_
void PrefixLimitIdleTimerErrorHandler(std::string error_name, std::string error_message)
virtual bool SendUpdate(const uint8_t *msg, size_t msgsize, const std::string *msg_str)
void inc_rx_route_reach(uint64_t count)
RoutingInstance * rtinstance_
void StopPrefixLimitIdleTimer()
uint64_t get_socket_reads() const
bool FlushUpdateUnlocked()
virtual bool MembershipPathCallback(DBTablePartBase *tpart, BgpRoute *route, BgpPath *path)
StateMachine::State GetState() const
const std::vector< std::string > & negotiated_families() const
void KeepaliveTimerErrorHandler(std::string error_name, std::string error_message)
uint64_t get_tx_route_reach() const
std::vector< tbb::atomic< uint32_t > > family_primary_path_count_
virtual const std::string & ToString() const
void BGPPeerInfoSend(const BgpPeerInfoData &peer_info) const
RouteTargetList rtargets_
std::map< Address::Family, const uint8_t * > FamilyToCapabilityMap
virtual int GetTotalPathCount() const
bool KeepaliveTimerExpired()
tbb::atomic< int > total_path_count_
boost::scoped_ptr< DeleteActor > deleter_
void inc_tx_notification()
AuthenticationData auth_data_
virtual bool IsServerStartingUp() const
static const size_t kMaxBufferCapacity
static const std::vector< Address::Family > supported_families_
virtual uint32_t bgp_identifier() const
void BGPaaSAddRTarget(as_t as, BgpTable *table, BgpAttrPtr attr, RouteTargetList::const_iterator it)
void SendNotification(BgpSession *, int code, int subcode=0, const std::string &data=std::string())
void set_session(BgpSession *session)
void SendOpen(TcpSession *session)
virtual bool ReceiveMsg(BgpSession *session, const u_int8_t *msg, size_t size)
void MembershipRequestCallback(BgpTable *table)
void ProcessBgpaas(DBRequest::DBOperation oper, IpAddress addr, uint8_t addr_len, BgpAttrPtr attr, uint32_t flags)
void inc_hold_timer_expired()
uint64_t get_rx_route_total() const
boost::scoped_ptr< PeerCloseManager > close_manager_
void ClearListenSocketAuthKey()
virtual void UpdatePrimaryPathCount(int count, Address::Family family) const
uint64_t get_open_error() const
uint64_t get_socket_writes() const
time_t eor_send_timer_start_time_
virtual const std::vector< std::string > GetDefaultTunnelEncap(const Address::Family family) const
virtual uint32_t local_bgp_identifier() const
void StartPrefixLimitIdleTimer(uint32_t plim_idle_time_msecs)
std::string gateway_address_string(Address::Family family) const
uint64_t get_tx_update() const
bool SetCapabilities(const BgpProto::OpenMessage *msg)
void FillNeighborInfo(const BgpSandeshContext *bsc, BgpNeighborResp *bnr, bool summary) const
uint64_t get_rx_route_reach() const
void StartKeepaliveTimer()
OriginOverride origin_override_
uint64_t get_hold_timer_expired() const
uint32_t GetPathFlags(Address::Family family, const BgpAttr *attr) const
void inc_rx_notification()
std::string router_type() const
bool KeepaliveTimerRunning()
TaskTrigger prefix_limit_trigger_
uint64_t total_flap_count_
void FillBgpNeighborFamilyAttributes(BgpNeighborResp *nbr) const
uint64_t flap_count() const
BgpSession * CreateSession()
tbb::spin_mutex spin_mutex_
std::string last_flap_at() const
void ResetInuseAuthKeyInfo()
virtual void SendEndOfRIB(Address::Family family)
std::vector< std::string > negotiated_families_
FamilyAttributesList family_attributes_list_
void SetInuseAuthKeyInfo(const AuthenticationKey &key, KeyType type)
void ProcessUpdate(const BgpProto::Update *msg, size_t msgsize=0)
BgpTable * GetRTargetTable()
BgpAttrPtr GetRouteTargetRouteAttr() const
uint64_t get_rx_route_unreach() const
virtual bool notification() const
virtual time_t GetRTargetTableLastUpdatedTimeStamp() const
AuthenticationKey inuse_auth_key_
void BGPaaSDeleteRTarget(as_t as, BgpTable *table, RouteTargetList::const_iterator it)
bool EndOfRibSendTimerExpired(Address::Family family)
bool PrefixLimitIdleTimerExpired()
virtual void BindLocalEndpoint(BgpSession *session)
uint64_t get_rx_update() const
virtual IPeerDebugStats * peer_stats()
Timer * eor_receive_timer_[Address::NUM_FAMILIES]
std::vector< uint8_t > buffer_
virtual uint32_t GetOutputQueueDepth(Address::Family family) const
void SetListenSocketAuthKey(const AuthenticationKey &auth_key, KeyType key_type)
void ProcessNlri(Address::Family family, DBRequest::DBOperation oper, const BgpMpNlri *nlri, BgpAttrPtr attr, uint32_t flags)
void DSCPUpdateCallback(uint8_t dscp_value)
bool AcceptSession(BgpSession *session)
const BgpNeighborConfig * config() const
uint64_t get_tx_route_total() const
TcpSession::Endpoint endpoint_
virtual void SendEndOfRIBActual(Address::Family family)
void ConfigUpdate(const BgpNeighborConfig *config)
uint64_t get_tx_end_of_rib() const
std::vector< BgpPeerFamilyAttributes * > FamilyAttributesList
int GetTaskInstance() const
bool IsCloseGraceful() const
bool IsFamilyNegotiated(Address::Family family)
virtual bool Is4ByteAsSupported() const
void NotifyEstablished(bool established)
uint64_t get_update_error() const
void ProcessEndpointConfig(const BgpNeighborConfig *config)
bool GetBestAuthKey(AuthenticationKey *auth_key, KeyType *key_type) const
PeerCloseManager * close_manager()
uint64_t get_connect_timer_expired() const
void StartEndOfRibReceiveTimer(Address::Family family)
virtual IPeerClose * peer_close()
virtual bool CheckSplitHorizon(uint32_t cluster_id=0, uint32_t ribout_cid=0) const
virtual void StartKeepaliveTimerUnlocked()
std::string bgp_identifier_string() const
tbb::atomic< int > membership_req_pending_
bool AttemptGRHelperMode(int code, int subcode) const
string private_as_action_
uint16_t peer_port() const
bool vpn_tables_registered_
void SetSessionSocketOptionDscp(TcpSession *session)
void Register(BgpTable *table, const RibExportPolicy &policy)
virtual void SetAdminState(bool down, int subcode=BgpProto::Notification::AdminShutdown)
bool LookupFamily(Address::Family family)
bool peer_is_control_node_
static void FillBgpNeighborDebugState(BgpNeighborResp *bnr, const IPeerDebugStats *peer)
virtual void TriggerPrefixLimitCheck() const
uint32_t GetLocalPrefFromMed(uint32_t med) const
void AddRTargets(as_t as)
LifetimeActor * deleter()
BgpPeer(BgpServer *server, RoutingInstance *instance, const BgpNeighborConfig *config)
static const int kMinMessageSize
static BgpMessage * Decode(const uint8_t *data, size_t size, ParseErrorContext *ec=NULL, bool as4=false)
static int Encode(const BgpMessage *msg, uint8_t *data, size_t size, EncodeOffsets *offsets=NULL, bool as4=false)
void decrement_deleting_count()
uint32_t cluster_id() const
boost::asio::io_context * ioservice()
bool enable_4byte_as() const
uint32_t GetEndOfRibSendTime() const
void IncrementUpBgpaasPeerCount()
void DecrementUpPeerCount()
void UnregisterPeer(BgpPeer *peer)
RoutingInstanceMgr * routing_instance_mgr()
void IncrementUpPeerCount()
uint32_t bgp_identifier() const
uint32_t GetEndOfRibReceiveTime() const
void DecrementUpBgpaasPeerCount()
void decrement_deleting_bgpaas_count()
BgpGlobalQosConfig * global_qos()
void UnregisterASNUpdateCallback(int listener)
void UnregisterDSCPUpdateCallback(int listener)
virtual std::string ToString() const
int RegisterDSCPUpdateCallback(DSCPUpdateCb cb)
bool IsServerStartingUp() const
as_t local_autonomous_system() const
const std::string & localname() const
time_t GetRTargetTableLastUpdatedTimeStamp() const
BgpSessionManager * session_manager()
int RegisterASNUpdateCallback(ASNUpdateCb callback)
BgpMembershipManager * membership_mgr()
void increment_deleting_count()
void increment_deleting_bgpaas_count()
virtual TcpSession * CreateSession()
void SendNotification(int code, int subcode, const std::string &data=std::string())
void set_peer(BgpPeer *peer)
void LocatePathResolver()
virtual Address::Family family() const =0
const ClusterListSpec & cluster_list() const
static bool end_of_rib_computed()
bool Enqueue(DBRequest *req)
virtual void UpdateRouteStats(Address::Family family, const BgpPath *old_path, uint32_t path_flags) const =0
virtual std::string last_error() const =0
virtual uint64_t num_flaps() const =0
virtual void GetRxRouteUpdateStats(UpdateStats *stats) const =0
virtual std::string last_state() const =0
virtual std::string last_state_change_at() const =0
virtual void GetRxProtoStats(ProtoStats *stats) const =0
virtual std::string last_flap() const =0
virtual void GetTxSocketStats(SocketStats *stats) const =0
virtual void GetTxRouteUpdateStats(UpdateStats *stats) const =0
virtual std::string last_event() const =0
virtual void GetTxProtoStats(ProtoStats *stats) const =0
virtual void GetRxSocketStats(SocketStats *stats) const =0
static int FromProtoPrefix(const BgpProtoPrefix &proto_prefix, Ip4Prefix *prefix)
virtual void DestroyIPeer(IPeer *ipeer)
static const size_t kSize
static RouteDistinguisher kZeroRd
RoutingInstance * GetRoutingInstance(const std::string &name)
RoutingInstance * GetDefaultRoutingInstance()
int RegisterInstanceOpCallback(RoutingInstanceCb cb)
const std::string & name() const
const std::string & routing_instance_vxlan() const
PeerManager * peer_manager()
const RouteTargetList & GetImportList() const
BgpTable * GetTable(Address::Family fmly)
static SandeshLevel::type LoggingLevel()
static SandeshLevel::type LoggingUtLevel()
const std::string last_notification_in_error() const
const std::string & last_event() const
const std::string last_state_change_at() const
const std::string & LastStateName() 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()
int HardwareThreadCount()
int SetListenSocketMd5Option(uint32_t peer_ip, const std::string &md5_password)
const io::SocketStats & GetSocketStats() const
virtual Socket * socket() const
int SetMd5SocketOption(uint32_t peer_ip, const std::string &md5_password)
void set_observer(EventObserver observer)
boost::asio::ip::tcp::endpoint Endpoint
Endpoint remote_endpoint() const
virtual bool Send(const uint8_t *data, size_t size, size_t *sent)
int SetDscpSocketOption(uint8_t value)
static bool DeleteTimer(Timer *Timer)
static Timer * CreateTimer(boost::asio::io_context &service, const std::string &name, int task_id=Timer::GetTimerTaskId(), int task_instance=Timer::GetTimerInstanceId(), bool delete_on_completion=false)
bool Start(int time, Handler handler, ErrorHandler error_handler=NULL)
bool Reschedule(int time)
const bytes_type & GetExtCommunity() const
static void UpdateStats(FlowEvent *event, FlowStats *stats)
static uint64_t get_value(const uint8_t *data, int size)
const string MatchProtocolToString(MatchProtocol::MatchProtocolType protocol)
bool set_synchronize(const SetType *set1, const SetType *set2, AddFunctor add_fn, DelFunctor del_fn)
static const std::string integerToString(const NumberType &num)
bool AsLeftMostMatch(as_t as) const
bool AsLeftMostMatch(as2_t as) const
std::vector< std::string > default_tunnel_encap_list
std::vector< BgpProtoPrefix * > nlri
std::vector< uint8_t > nexthop
IpAddress gateway_address
BgpPeerFamilyAttributes(const BgpNeighborConfig *config, const BgpFamilyAttributesConfig &family_config)
std::vector< std::string > default_tunnel_encap_list
boost::asio::ip::tcp::endpoint endpoint
OriginOverride(const BgpNeighborConfig::OriginOverrideConfig &config)
bool operator!=(const OriginOverride &rhs) const
BgpAttrOrigin::OriginType origin
std::vector< Capability * > capabilities
virtual const std::string ToString() const
std::vector< OptParam * > opt_params
std::vector< BgpAttribute * > path_attributes
std::vector< BgpProtoPrefix * > withdrawn_routes
std::vector< BgpProtoPrefix * > nlri
bool ClusterListLoop(uint32_t cluster_id) const
std::unique_ptr< DBRequestKey > key
std::unique_ptr< DBRequestData > data
tbb::atomic< uint64_t > notification
tbb::atomic< uint64_t > open
tbb::atomic< uint64_t > update
tbb::atomic< uint64_t > keepalive
tbb::atomic< uint64_t > close
tbb::atomic< uint64_t > total_path_count
tbb::atomic< uint64_t > primary_path_count
tbb::atomic< uint64_t > calls
tbb::atomic< uint64_t > blocked_duration_usecs
tbb::atomic< uint64_t > blocked_count
tbb::atomic< uint64_t > bytes
tbb::atomic< uint64_t > reach
tbb::atomic< uint64_t > unreach
tbb::atomic< uint64_t > end_of_rib
void SetRemovePrivatePolicy(bool all, bool replace, bool peer_loop_check)
tbb::atomic< uint64_t > read_calls
tbb::atomic< uint64_t > write_calls
tbb::atomic< uint64_t > write_blocked
tbb::atomic< uint64_t > write_blocked_duration_usecs
tbb::atomic< uint64_t > write_bytes
tbb::atomic< uint64_t > read_bytes
#define CHECK_CONCURRENCY(...)
static std::string UTCUsecToString(uint64_t tstamp)
static time_t UTCTimestamp()
static boost::posix_time::ptime UTCUsecToPTime(uint64_t tusec)
static uint64_t UTCTimestampUsec()
int STLSortedCompare(InputIterator first1, InputIterator last1, InputIterator first2, InputIterator last2, CompareOp op)
void STLDeleteValues(Container *container)