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;
120 stats->
calls = socket_stats.read_calls;
121 stats->
bytes = socket_stats.read_bytes;
128 stats->
calls = socket_stats.write_calls;
129 stats->
bytes = socket_stats.write_bytes;
132 socket_stats.write_blocked_duration_usecs;
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)),
479 trigger_(boost::bind(&
BgpPeer::ResumeClose, 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),
530 BgpStaticObjectFactory::Create<PeerCloseManager>(static_cast<IPeerClose*>(
peer_close_.get())));
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;
1017 clear_session =
true;
1023 clear_session =
true;
1029 clear_session =
true;
1039 peer_info.set_route_origin(
"-");
1041 clear_session =
true;
1048 clear_session =
true;
1066 clear_session =
true;
1069 clear_session =
true;
1075 clear_session =
true;
1082 "Updated Local Autonomous System from " <<
1087 peer_info.set_local_asn(local_as_);
1088 clear_session =
true;
1094 "Updated Hold Time from " <<
1099 peer_info.set_hold_time(hold_time_);
1100 clear_session =
true;
1106 "Updated Peer Autonomous System from " <<
1111 peer_info.set_peer_asn(peer_as_);
1112 clear_session =
true;
1115 boost::system::error_code ec;
1120 clear_session =
true;
1126 peer_info.set_peer_type(
1128 clear_session =
true;
1134 clear_session =
true;
1140 clear_session =
true;
1148 if (!admin_down_changed && !
admin_down_ && clear_session) {
1151 "Session cleared due to configuration change");
1156 if (admin_down_changed || clear_session) {
1294 const BgpPath *old_path, uint32_t path_flags)
const {
1345 if (session == NULL)
1397 membership_mgr->
Register(
this, table, policy);
1438 vector<Address::Family> family_list = list_of
1445 table,
"Register peer with the table");
1458 table,
"Register peer with the table");
1461 vector<Address::Family> vpn_family_list = list_of
1469 table,
"Register ribin for peer with the table");
1493 static const uint8_t cap_mp[][4] = {
1526 BOOST_FOREACH(
const FamilyToCapabilityMap::value_type &val,
1527 family_to_cap_map) {
1541 (
const uint8_t *)(&asn), 4);
1557 session->
Send(data, result, NULL);
1573 SandeshLevel::SYS_INFO;
1584 if (init_)
return skip_;
1586 skip_ = getenv(
"BGP_SKIP_UPDATE_SEND") != NULL;
1594 : origin_override(config.origin_override),
1595 origin(
BgpAttr::OriginFromString(config.origin)) {
1604 if (origin_override && origin != rhs.
origin) {
1616 const string *msg_str) {
1684 int code,
int subcode,
const string &data) {
1694 vector<BgpProto::OpenMessage::OptParam *>::const_iterator it;
1697 (*it)->capabilities.end());
1698 (*it)->capabilities.clear();
1703 vector<BgpProto::OpenMessage::Capability *>::iterator c_it;
1711 BgpPeerInfoData peer_info;
1715 vector<string> families;
1716 vector<BgpProto::OpenMessage::Capability *>::iterator cap_it;
1721 uint8_t *data = (*cap_it)->capability.data();
1731 peer_info.set_families(families);
1750 if (!
peer_close_->SetGRCapabilities(&peer_info)) {
1766 BgpPeerInfoData peer_info;
1768 vector<string> families = vector<string>();
1769 peer_info.set_families(families);
1771 peer_info.set_negotiated_families(negotiated_families);
1772 peer_info.set_graceful_restart_families(vector<string>());
1777 vector<BgpProto::OpenMessage::Capability *>::iterator it;
1781 uint8_t *data = (*it)->capability.data();
1783 uint8_t safi_value =
get_value(data + 3, 1);
1784 if (afi == af_value && safi == safi_value) {
1795 template <
typename TableT,
typename PrefixT>
1801 for (vector<BgpProtoPrefix *>::const_iterator it = nlri->
nlri.begin();
1802 it != nlri->
nlri.end(); ++it) {
1806 uint32_t l3_label = 0;
1807 int result = PrefixT::FromProtoPrefix(
server_, **it,
1809 family, &prefix, &new_attr, &label, &l3_label);
1813 "MP NLRI parse error for " <<
1821 req.
data.reset(
new typename TableT::RequestData(
1822 new_attr, flags, label, l3_label, 0));
1824 req.
key.reset(
new typename TableT::RequestKey(prefix,
this));
1825 table->Enqueue(&req);
1876 return numeric_limits<uint32_t>::max() - med;
1900 uint32_t reach_count = 0, unreach_count = 0;
1907 "Cannot find inet table");
1912 for (vector<BgpProtoPrefix *>::const_iterator it =
1920 "Withdrawn route parse error for inet route");
1926 req.
data.reset(NULL);
1932 reach_count += msg->
nlri.size();
1933 for (vector<BgpProtoPrefix *>::const_iterator it = msg->
nlri.begin();
1934 it != msg->
nlri.end(); ++it) {
1940 "NLRI parse error for inet route");
1952 for (vector<BgpAttribute *>::const_iterator ait =
1967 reach_count += nlri->
nlri.size();
1969 unreach_count += nlri->
nlri.size();
1976 "AFI "<< nlri->
afi <<
" SAFI " << (
int) nlri->
safi <<
1986 "EndOfRib marker family " <<
1988 " size " << msgsize);
2002 ProcessNlri<InetTable, Ip4Prefix>(
2003 family, oper, nlri, attr, flags);
2006 ProcessNlri<InetVpnTable, InetVpnPrefix>(
2007 family, oper, nlri, attr, flags);
2010 ProcessNlri<Inet6Table, Inet6Prefix>(
2011 family, oper, nlri, attr, flags);
2014 ProcessNlri<Inet6VpnTable, Inet6VpnPrefix>(
2015 family, oper, nlri, attr, flags);
2018 ProcessNlri<EvpnTable, EvpnPrefix>(
2019 family, oper, nlri, attr, flags);
2022 ProcessNlri<ErmVpnTable, ErmVpnPrefix>(
2023 family, oper, nlri, attr, flags);
2026 ProcessNlri<MvpnTable, MvpnPrefix>(
2027 family, oper, nlri, attr, flags);
2030 ProcessNlri<RTargetTable, RTargetPrefix>(
2031 family, oper, nlri, attr, flags);
2043 "Update size " << msgsize <<
2044 " reach " << reach_count <<
" unreach " << unreach_count);
2050 return std::vector<std::string>();
2059 bool tunnel_encap_found =
false;
2060 if (ext_community) {
2061 for (ExtCommunity::ExtCommunityList::const_iterator iter =
2066 tunnel_encap_found =
true;
2072 if (!ext_community || !tunnel_encap_found) {
2074 BOOST_FOREACH(
const string &encap_string,
2081 ext_community ? ext_community.get() : NULL, encap_list);
2119 string error_message) {
2121 "Timer error: " << error_name <<
" " << error_message);
2125 string error_message) {
2127 "Timer error: " << error_name <<
" " << error_message);
2138 vector<Address::Family> vpn_family_list = list_of
2146 table,
"Register peer with the table");
2156 "EndOfRib Receive Timer scheduled for family " <<
2158 " to fire after " << timeout <<
" second(s)");
2165 string error_message) {
2167 "Timer error: " << error_name <<
" " << error_message);
2192 int keepalive_time_msecs =
state_machine_->keepalive_time_msecs();
2193 if (keepalive_time_msecs <= 0)
2249 for (
size_t i = 0; i < size; i ++) {
2250 if (!(i % 32)) out <<
"\n";
2251 if (!(i % 4)) out <<
" 0x";
2252 snprintf(buf,
sizeof(buf),
"%02X", msg[i]);
2267 if (minfo == NULL) {
2271 "Error while parsing message at " << ec.
type_name);
2290 bool update_nh =
false;
2296 Ip4Address::bytes_type bt = { { 0 } };
2298 nlri->
nexthop.begin() +
sizeof(bt), bt.begin());
2302 Ip4Address::bytes_type bt = { { 0 } };
2304 copy(nlri->
nexthop.begin() + rdsize,
2305 nlri->
nexthop.begin() + rdsize +
sizeof(bt), bt.begin());
2311 Ip4Address::bytes_type bt = { { 0 } };
2313 nlri->
nexthop.begin() +
sizeof(bt), bt.begin());
2325 for (
int idx = 0; idx < 2; ++idx) {
2326 Ip6Address::bytes_type bt = { { 0 } };
2327 if ((idx + 1) *
sizeof(bt) > nlri->
nexthop.size())
2329 copy(nlri->
nexthop.begin() + idx *
sizeof(bt),
2330 nlri->
nexthop.begin() + (idx + 1) *
sizeof(bt), bt.begin());
2332 if (v6_addr.is_v4_mapped()) {
2337 if (!v6_addr.is_link_local()) {
2344 Ip6Address::bytes_type bt = { { 0 } };
2346 copy(nlri->
nexthop.begin() + rdsize,
2347 nlri->
nexthop.begin() + rdsize +
sizeof(bt), bt.begin());
2349 if (v6_addr.is_v4_mapped()) {
2398 PeerProtoStats *proto_stats) {
2399 proto_stats->set_open(stats.
open);
2400 proto_stats->set_keepalive(stats.
keepalive);
2401 proto_stats->set_close(stats.
close);
2402 proto_stats->set_update(stats.
update);
2409 PeerUpdateStats *rt_stats) {
2410 rt_stats->set_reach(stats.
reach);
2411 rt_stats->set_unreach(stats.
unreach);
2417 PeerSocketStats *peer_socket_stats) {
2418 peer_socket_stats->set_calls(socket_stats.
calls);
2419 peer_socket_stats->set_bytes(socket_stats.
bytes);
2420 if (socket_stats.
calls) {
2421 peer_socket_stats->set_average_bytes(
2424 peer_socket_stats->set_blocked_count(socket_stats.
blocked_count);
2427 peer_socket_stats->set_blocked_duration(os.str());
2430 os << boost::posix_time::microseconds(
2432 peer_socket_stats->set_average_blocked_duration(os.str());
2442 bnr->set_last_state(peer_stats->
last_state());
2443 bnr->set_last_event(peer_stats->
last_event());
2444 bnr->set_last_error(peer_stats->
last_error());
2446 bnr->set_flap_count(peer_stats->
num_flaps());
2447 bnr->set_flap_time(peer_stats->
last_flap());
2450 PeerProtoStats proto_stats;
2453 bnr->set_rx_proto_stats(proto_stats);
2457 bnr->set_tx_proto_stats(proto_stats);
2460 PeerUpdateStats rt_stats;
2463 bnr->set_rx_update_stats(rt_stats);
2467 bnr->set_tx_update_stats(rt_stats);
2470 PeerSocketStats peer_socket_stats;
2474 bnr->set_rx_socket_stats(peer_socket_stats);
2478 bnr->set_tx_socket_stats(peer_socket_stats);
2482 vector<ShowBgpNeighborFamily> show_family_attributes_list;
2486 ShowBgpNeighborFamily show_family_attributes;
2487 show_family_attributes.set_family(
2489 show_family_attributes.set_loop_count(
2491 show_family_attributes.set_prefix_limit(
2493 show_family_attributes.set_idle_timeout(
2496 show_family_attributes.set_gateway_address(
2499 show_family_attributes_list.push_back(show_family_attributes);
2501 nbr->set_family_attributes_list(show_family_attributes_list);
2505 BgpNeighborResp *bnr,
bool summary)
const {
2517 bnr->set_route_origin(
"-");
2525 bnr->set_encoding(
"BGP");
2554 bnr->set_configured_hold_time(
state_machine_->GetConfiguredHoldTime());
2559 bnr->set_routing_instances(vector<BgpNeighborRoutingInstance>());
2732 BgpPeerInfoData peer_info;
2734 PeerFlapInfo flap_info;
2737 peer_info.set_flap_info(flap_info);
2740 PeerFlapData peer_flap_data;
2741 peer_flap_data.set_name(
ToUVEKey());
2742 peer_flap_data.set_flap_info(flap_info);
2743 assert(!peer_flap_data.get_name().empty());
2751 BgpPeerInfoData peer_info;
2753 PeerFlapInfo flap_info;
2754 peer_info.set_flap_info(flap_info);
2757 PeerFlapData peer_flap_data;
2758 peer_flap_data.set_name(
ToUVEKey());
2759 peer_flap_data.set_flap_info(flap_info);
2760 assert(!peer_flap_data.get_name().empty());
2772 if ((
session_ != NULL) && (dscp_value != 0xFF)) {
OriginOverride origin_override_
tbb::atomic< uint64_t > unreach
virtual void GetRxSocketStats(SocketStats *stats) const =0
virtual bool IsInGRTimerWaitState() const
void increment_deleting_count()
void inc_tx_notification()
bool FlushUpdateUnlocked()
virtual const std::string ToString() const
virtual bool ProcessSession() const
const std::string & LastStateName() const
std::vector< std::string > negotiated_families_
void PrefixLimitIdleTimerErrorHandler(std::string error_name, std::string error_message)
static int FromProtoPrefix(const BgpProtoPrefix &proto_prefix, Ip4Prefix *prefix)
virtual std::string last_event() const =0
virtual void GetRxRouteStats(RxRouteStats *stats) const
void AddRTargets(as_t as)
boost::asio::ip::tcp::endpoint Endpoint
static bool end_of_rib_computed()
size_t GetBufferCapacity() const
const OriginOverrideConfig & origin_override() const
static void UpdateStats(FlowEvent *event, FlowStats *stats)
const RouteTargetList & GetImportList() const
void DecrementUpBgpaasPeerCount()
virtual bool ReceiveMsg(BgpSession *session, const u_int8_t *msg, size_t size)
const ClusterListSpec & cluster_list() const
std::vector< BgpProtoPrefix * > nlri
static void FillProtoStats(const IPeerDebugStats::ProtoStats &stats, PeerProtoStats *proto_stats)
uint64_t flap_count() const
void STLDeleteValues(Container *container)
BgpTable * GetTable(Address::Family fmly)
void FillBgpNeighborFamilyAttributes(BgpNeighborResp *nbr) const
const std::string last_notification_in_error() const
tbb::atomic< int > primary_path_count_
int RegisterInstanceOpCallback(RoutingInstanceCb cb)
The TaskScheduler keeps track of what tasks are currently schedulable. When a task is enqueued it is ...
TypePtr Locate(Type *attr)
PeerManager * peer_manager()
bool KeepaliveTimerExpired()
static void FillRouteUpdateStats(const IPeerDebugStats::UpdateStats &stats, PeerUpdateStats *rt_stats)
PeerCloseManager * close_manager()
uint64_t get_open_error() const
const AsPathSpec & path() const
#define BGP_LOG_PEER_TABLE(peer, level, flags, tbl, arg)
bool ProcessAuthKeyChainConfig(const BgpNeighborConfig *config)
uint8_t control_dscp() const
bool AcceptSession(BgpSession *session)
BgpAttrPtr GetMpNlriNexthop(BgpMpNlri *nlri, BgpAttrPtr attr)
uint32_t GetLocalPrefFromMed(uint32_t med) const
bool IsServerStartingUp() const
AuthenticationKeyChain::const_iterator const_iterator
bool set_synchronize(const SetType *set1, const SetType *set2, AddFunctor add_fn, DelFunctor del_fn)
virtual void UpdateTxReachRoute(uint64_t count)
void StopKeepaliveTimerUnlocked()
std::string peer_basename_
std::vector< std::string > configured_families_
virtual uint32_t local_bgp_identifier() const
void StopPrefixLimitIdleTimer()
boost::scoped_ptr< DeleteActor > deleter_
void UnregisterASNUpdateCallback(int listener)
boost::scoped_ptr< StateMachine > state_machine_
OriginOverride(const BgpNeighborConfig::OriginOverrideConfig &config)
#define BGP_LOG_PEER_NOTICE(type, peer, flags, dir, arg)
std::vector< BgpPeerFamilyAttributes * > FamilyAttributesList
static const size_t kMinBufferCapacity
void inc_rx_notification()
std::vector< BgpProtoPrefix * > nlri
virtual const std::vector< std::string > GetDefaultTunnelEncap(const Address::Family family) const
std::string KeyTypeToString() const
virtual void GetTxRouteUpdateStats(UpdateStats *stats) const =0
void EndOfRibTimerErrorHandler(std::string error_name, std::string error_message)
static const char * kMasterInstance
uint64_t get_rx_route_reach() const
uint16_t peer_port() const
static Family FamilyFromString(const std::string &family)
boost::asio::ip::address IpAddress
static Address::Family AfiSafiToFamily(uint16_t afi, uint8_t safi)
virtual uint64_t num_flaps() const
void BGPPeerInfoSend(const BgpPeerInfoData &peer_info) const
bool LookupFamily(Address::Family family)
virtual int GetPrimaryPathCount() const
boost::scoped_ptr< BgpPeerClose > peer_close_
DeleteActor(BgpPeer *peer)
RibExportPolicy BuildRibExportPolicy(Address::Family family) const
void SetListenSocketAuthKey(const AuthenticationKey &auth_key, KeyType key_type)
std::map< Address::Family, const uint8_t * > FamilyToCapabilityMap
uint64_t get_rx_update() const
#define BGP_LOG_PEER_WARNING(type, peer, flags, dir, arg)
BgpGlobalQosConfig * global_qos()
void inc_connect_timer_expired()
uint64_t get_socket_reads() const
std::unique_ptr< DBRequestData > data
BgpAttrPtr ReplaceNexthopAndLocate(const BgpAttr *attr, const IpAddress &addr)
BgpAttrOrigin::OriginType origin
virtual uint32_t bgp_identifier() const
RoutingInstanceMgr * routing_instance_mgr()
virtual bool IsXmppPeer() const
ProtoStats proto_stats_[2]
virtual void UpdateCloseRouteStats(Address::Family family, const BgpPath *old_path, uint32_t path_flags) const
#define BGP_UVE_SEND(type, object)
bool Enqueue(DBRequest *req)
time_t GetRTargetTableLastUpdatedTimeStamp() const
static SandeshLevel::type LoggingLevel()
std::vector< BgpAttribute * > BgpAttrSpec
tbb::atomic< uint64_t > blocked_count
bool IsRouterTypeBGPaaS() const
const std::string & name() const
void LocatePathResolver()
virtual bool CanUseMembershipManager() const
virtual IPeerClose * peer_close()
std::string GetInuseAuthKeyValue() const
virtual bool Is4ByteAsSupported() const
RoutingInstance * GetDefaultRoutingInstance()
virtual void SetDataCollectionKey(BgpPeerInfo *peer_info) const
virtual string last_state_change_at() const
virtual void Register(IPeer *peer, BgpTable *table, const RibExportPolicy &policy, int instance_id=-1)
const Ip4Address & originator_id() const
void ProcessEndpointConfig(const BgpNeighborConfig *config)
void SetRemovePrivatePolicy(bool all, bool replace, bool peer_loop_check)
const FamilyAttributesList & family_attributes_list() const
RoutingInstance * rtinstance_
void set_peer(BgpPeer *peer)
virtual BgpProto::BgpPeerType PeerType() const
uint64_t get_tx_update() const
int GetTaskInstance() const
virtual bool send_ready() const
virtual time_t GetEorSendTimerElapsedTime() const
void IncrementUpPeerCount()
AuthenticationKey inuse_auth_key_
std::string router_type() const
virtual TcpSession * CreateSession()
virtual bool MembershipPathCallback(DBTablePartBase *tpart, BgpRoute *route, BgpPath *path)
void FillPeerMembershipInfo(const IPeer *peer, BgpNeighborResp *resp) const
uint64_t get_rx_notification() const
int RegisterDSCPUpdateCallback(DSCPUpdateCb cb)
virtual Address::Family family() const =0
virtual bool Send(const uint8_t *data, size_t size, size_t *sent)
std::string private_as_action() const
static uint64_t get_value(const uint8_t *data, int size)
boost::asio::ip::tcp::endpoint endpoint
uint8_t loop_count() const
tbb::atomic< uint64_t > close
virtual const std::string & ToString() const
bool KeepaliveTimerRunning()
const BgpNeighborConfig * config_
const std::string & last_event() const
static const int kMinMessageSize
virtual std::string last_error() const =0
virtual void TriggerPrefixLimitCheck() const
static const int kEndOfRibSendRetryTime
virtual bool MayDelete() const
int GetTaskId(const std::string &name)
IpAddress gateway_address
virtual string last_error() const
std::vector< std::string > KeysToStringDetail() const
TaskTrigger prefix_limit_trigger_
#define BGP_LOG_STR(obj, level, flags, arg)
void StartEndOfRibReceiveTimer(Address::Family family)
void SendOpen(TcpSession *session)
int IsAsPathLoop(as_t asn, uint8_t max_loop_count=0) const
uint64_t get_tx_keepalive() const
void inc_rx_route_unreach(uint64_t count)
virtual void SetAdminState(bool down, int subcode=BgpProto::Notification::AdminShutdown)
void ConfigUpdate(const BgpNeighborConfig *config)
std::vector< OptParam * > opt_params
as_t local_autonomous_system() const
uint64_t get_rx_route_unreach() const
BgpPeer(BgpServer *server, RoutingInstance *instance, const BgpNeighborConfig *config)
void set_observer(EventObserver observer)
void DecrementUpPeerCount()
static const size_t kSize
virtual BgpServer * server()
tbb::atomic< uint64_t > primary_path_count
void KeepaliveTimerErrorHandler(std::string error_name, std::string error_message)
bool IsCloseInProgress() const
#define BGP_LOG_PEER_CRITICAL(type, peer, flags, dir, arg)
virtual uint64_t num_flaps() const =0
StateMachine * state_machine()
bool EndOfRibReceiveTimerExpired(Address::Family family)
boost::intrusive_ptr< const BgpAttr > BgpAttrPtr
uint16_t source_port() const
Timer * eor_send_timer_[Address::NUM_FAMILIES]
uint32_t GetEndOfRibReceiveTime() const
virtual void UpdateTxUnreachRoute(uint64_t count)
static BgpMessage * Decode(const uint8_t *data, size_t size, ParseErrorContext *ec=NULL, bool as4=false)
void SetSessionSocketAuthKey(TcpSession *session)
const std::string last_state_change_at() const
virtual void GetRxSocketStats(IPeerDebugStats::SocketStats *stats) const
std::vector< std::string > default_tunnel_encap_list
bool IsCloseGraceful() const
void ProcessUpdate(const BgpProto::Update *msg, size_t msgsize=0)
static Safi FamilyToSafi(Address::Family family)
#define BGP_LOG_FLAG_SYSLOG
std::vector< BgpProtoPrefix * > withdrawn_routes
static const std::string integerToString(const NumberType &num)
static bool SkipUpdateSend()
void inc_rx_route_reach(uint64_t count)
const AsPath4Byte * aspath_4byte() const
uint64_t get_rx_end_of_rib() const
void RoutingInstanceCallback(const std::string &vrf_name, int op)
void Register(BgpTable *table, const RibExportPolicy &policy)
static int Encode(const BgpMessage *msg, uint8_t *data, size_t size, EncodeOffsets *offsets=NULL, bool as4=false)
BgpTable * GetRTargetTable()
void SendNotification(BgpSession *, int code, int subcode=0, const std::string &data=std::string())
const std::vector< std::string > & negotiated_families() const
void increment_deleting_bgpaas_count()
const ClusterList * cluster_list() const
tbb::atomic< uint64_t > notification
static std::string OriginToString(BgpAttrOrigin::OriginType origin)
void SetInuseAuthKeyInfo(const AuthenticationKey &key, KeyType type)
virtual bool FlushUpdate()
static TaskScheduler * GetInstance()
const std::string & peer_name() const
virtual time_t GetRTargetTableLastUpdatedTimeStamp() const
BgpSession * CreateSession()
bool AsLeftMostMatch(as2_t as) const
bool SetCapabilities(const BgpProto::OpenMessage *msg)
virtual void GetTxSocketStats(SocketStats *stats) const =0
virtual IPeerDebugStats * peer_stats()
boost::asio::ip::address_v6 Ip6Address
BgpAttrPtr ReplaceSubProtocolAndLocate(const BgpAttr *attr, const std::string &sbp)
std::string last_flap_at() const
void RegisterRibIn(IPeer *peer, BgpTable *table)
std::unique_ptr< DBRequestKey > key
KeyType inuse_authkey_type_
virtual string ToString() const
uint64_t get_tx_route_total() const
int RegisterASNUpdateCallback(ASNUpdateCb callback)
Timer * eor_receive_timer_[Address::NUM_FAMILIES]
tbb::atomic< uint64_t > reach
BgpAttrPtr ReplaceLocalPreferenceAndLocate(const BgpAttr *attr, uint32_t local_pref)
void LogInstallAuthKeys(const std::string &socket_name, const std::string &oper, const AuthenticationKey &auth_key, KeyType key_type)
std::string BytesToHexString(const u_int8_t *msg, size_t size)
#define CHECK_CONCURRENCY(...)
static boost::posix_time::ptime UTCUsecToPTime(uint64_t tusec)
virtual string last_flap() const
virtual void StartKeepaliveTimerUnlocked()
const string MatchProtocolToString(MatchProtocol::MatchProtocolType protocol)
virtual const std::string GetStateName() const
void ResetInuseAuthKeyInfo()
RoutingInstance * GetRoutingInstance()
FamilyAttributesList family_attributes_list_
void set_session(BgpSession *session)
virtual bool MpNlriAllowed(uint16_t afi, uint8_t safi)
BgpSessionManager * session_manager()
boost::scoped_ptr< PeerStats > peer_stats_
boost::scoped_ptr< PeerCloseManager > close_manager_
void SetSessionSocketOptionDscp(TcpSession *session)
const AuthenticationData & auth_data() const
static std::string ToString(uint16_t afi, uint8_t safi)
uint64_t get_tx_route_unreach() const
bool PrefixLimitIdleTimerRunning() const
std::string gateway_address_string(Address::Family family) const
virtual uint32_t GetOutputQueueDepth(Address::Family family) const
tbb::spin_mutex spin_mutex_
uint32_t PeerAddress() const
void NotifyEstablished(bool established)
void decrement_deleting_count()
#define BGP_LOG_WARNING_STR(obj, flags, arg)
uint32_t local_as() const
BgpAttrPtr GetRouteTargetRouteAttr() const
virtual void GetTxProtoStats(ProtoStats *stats) const
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)
tbb::atomic< uint64_t > total_path_count
std::string router_type() const
virtual void GetRxProtoStats(ProtoStats *stats) const
BgpAttrPtr ReplaceOriginAndLocate(const BgpAttr *attr, BgpAttrOrigin::OriginType origin)
virtual const std::string & ToUVEKey() const
bool AsLeftMostMatch(as_t as) const
tbb::atomic< uint64_t > end_of_rib
boost::asio::ip::address_v4 Ip4Address
static std::pair< uint16_t, uint8_t > FamilyToAfiSafi(Address::Family family)
const AsPath * as_path() const
uint32_t cluster_id() const
int SetListenSocketMd5Option(uint32_t peer_ip, const std::string &md5_password)
virtual void SendEndOfRIB(Address::Family family)
int STLSortedCompare(InputIterator first1, InputIterator last1, InputIterator first2, InputIterator last2, CompareOp op)
AddressFamilyList GetAddressFamilies() const
bool PrefixLimitIdleTimerExpired()
Timer * prefix_limit_idle_timer_
virtual string last_state() const
void UnregisterDSCPUpdateCallback(int listener)
std::vector< std::string > default_tunnel_encap_list
static Afi FamilyToAfi(Address::Family family)
virtual bool SendUpdate(const uint8_t *msg, size_t msgsize, const std::string *msg_str)
static std::string FamilyToString(Family fmly)
boost::asio::io_context * ioservice()
uint32_t GetEndOfRibReceiveTime(Address::Family family) const
void Close(bool graceful)
void FillNeighborInfo(const BgpSandeshContext *bsc, BgpNeighborResp *bnr, bool summary) const
virtual void UpdateRouteStats(Address::Family family, const BgpPath *old_path, uint32_t path_flags) const =0
#define BGP_UVE_SEND2(type, object, arg)
StateMachine::State GetState() const
const std::string peer_address_string() const
uint32_t bgp_identifier() const
const io::SocketStats & GetSocketStats() const
void BGPaaSAddRTarget(as_t as, BgpTable *table, BgpAttrPtr attr, RouteTargetList::const_iterator it)
uint64_t get_hold_timer_expired() const
uint32_t GetEndOfRibSendTime() const
void RegisterToVpnTables()
const ExtCommunity * ext_community() const
uint64_t get_rx_route_total() const
uint64_t get_rx_keepalive() const
time_t eor_send_timer_start_time_
static time_t UTCTimestamp()
const IpAddress & gateway_address(Address::Family family) const
#define BGP_TRACE_PEER_PACKET(peer, msg, size, level)
const AsPath4ByteSpec & path() const
#define BGP_LOG_FLAG_TRACE
virtual std::string last_flap() const =0
bool peer_is_control_node_
static uint64_t UTCTimestampUsec()
std::vector< tbb::atomic< uint32_t > > family_primary_path_count_
static void FillSocketStats(const IPeerDebugStats::SocketStats &socket_stats, PeerSocketStats *peer_socket_stats)
void StartKeepaliveTimer()
void UnregisterPeer(BgpPeer *peer)
bool GetBestAuthKey(AuthenticationKey *auth_key, KeyType *key_type) const
void ClearListenSocketAuthKey()
UpdateStats update_stats_[2]
std::vector< uint8_t > buffer_
const bytes_type & GetExtCommunity() const
static const size_t kMaxBufferCapacity
virtual bool IsServerStartingUp() const
virtual void GetRxRouteUpdateStats(UpdateStats *stats) const
virtual void SendEndOfRIBActual(Address::Family family)
void inc_hold_timer_expired()
bool Start(int time, Handler handler, ErrorHandler error_handler=NULL)
virtual int GetTotalPathCount() const
std::vector< Capability * > capabilities
int SetDscpSocketOption(uint8_t value)
void StartPrefixLimitIdleTimer(uint32_t plim_idle_time_msecs)
uint64_t get_connect_error() const
Endpoint remote_endpoint() const
virtual bool IsReady() const
void BGPaaSDeleteRTarget(as_t as, BgpTable *table, RouteTargetList::const_iterator it)
uint64_t get_connect_timer_expired() const
void FillCloseInfo(BgpNeighborResp *resp) const
void MembershipRequestCallback(BgpTable *table)
bool ProcessFamilyAttributesConfig(const BgpNeighborConfig *config)
virtual void GetRxProtoStats(ProtoStats *stats) const =0
tbb::atomic< uint64_t > open
tbb::atomic< uint64_t > keepalive
void IncrementUpBgpaasPeerCount()
tbb::atomic< uint64_t > update
void ProcessNlri(Address::Family family, DBRequest::DBOperation oper, const BgpMpNlri *nlri, BgpAttrPtr attr, uint32_t flags)
virtual void GetTxRouteUpdateStats(UpdateStats *stats) const
bool enable_4byte_as() const
virtual string last_event() const
static const std::vector< Address::Family > supported_families_
virtual std::string last_state() const =0
void ReceiveEndOfRIB(Address::Family family, size_t msgsize)
static const int kDefaultPort
virtual void BindLocalEndpoint(BgpSession *session)
BgpMembershipManager * membership_mgr()
bool EndOfRibSendTimerExpired(Address::Family family)
TcpSession::Endpoint endpoint_
virtual std::string ToString() const
tbb::atomic< int > total_path_count_
static void FillBgpNeighborDebugState(BgpNeighborResp *bnr, const IPeerDebugStats *peer)
void set_ext_community(ExtCommunityPtr extcomm)
RouteTargetList rtargets_
bool AttemptGRHelperMode(int code, int subcode) const
bool IsFamilyNegotiated(Address::Family family)
virtual void GetTxProtoStats(ProtoStats *stats) const =0
AuthenticationData auth_data_
uint64_t total_flap_count_
uint64_t get_tx_route_reach() const
BgpProto::BgpPeerType peer_type_
std::string transport_address_string() const
bool ClusterListLoop(uint32_t cluster_id) const
std::vector< uint8_t > nexthop
uint32_t cluster_id() const
uint32_t local_identifier() const
bool Reschedule(int time)
const BgpNeighborConfig * config() const
void SendNotification(int code, int subcode, const std::string &data=std::string())
tbb::atomic< uint64_t > calls
virtual std::string last_state_change_at() const =0
std::string bgp_identifier_string() const
std::vector< BgpProto::OpenMessage::Capability * > capabilities_
void DeleteRTargets(as_t as)
static SandeshLevel::type LoggingUtLevel()
void decrement_deleting_bgpaas_count()
static Ip4Address V4FromV4MappedV6(const Ip6Address &v6_address)
virtual Socket * socket() const
virtual bool notification() const
uint64_t get_socket_writes() const
virtual void ProcessPathTunnelEncapsulation(const BgpPath *path, BgpAttr *attr, ExtCommunityDB *extcomm_db, const BgpTable *table) const
tbb::atomic< int > membership_req_pending_
int SetMd5SocketOption(uint32_t peer_ip, const std::string &md5_password)
void ASNUpdateCallback(as_t old_asn, as_t old_local_asn)
void DSCPUpdateCallback(uint8_t dscp_value)
TcpSession::Endpoint endpoint() const
virtual bool CheckSplitHorizon(uint32_t cluster_id=0, uint32_t ribout_cid=0) const
uint64_t get_tx_end_of_rib() const
virtual void DestroyIPeer(IPeer *ipeer)
uint64_t get_update_error() const
tbb::atomic< uint64_t > blocked_duration_usecs
uint32_t GetRibOutQueueDepth(const IPeer *peer, const BgpTable *table) const
LifetimeActor * deleter()
virtual void GetRxErrorStats(RxErrorStats *stats) const
string private_as_action_
uint32_t GetPathFlags(Address::Family family, const BgpAttr *attr) const
BgpPeerFamilyAttributes(const BgpNeighborConfig *config, const BgpFamilyAttributesConfig &family_config)
bool vpn_tables_registered_
int HardwareThreadCount()
tbb::atomic< uint64_t > bytes
std::vector< BgpAttribute * > path_attributes
void increment_flap_count()
virtual void GetRxRouteUpdateStats(UpdateStats *stats) const =0
int membership_req_pending() const
static bool DeleteTimer(Timer *Timer)
virtual void UpdatePrimaryPathCount(int count, Address::Family family) const
#define BGP_LOG_PEER(type, peer, level, flags, dir, arg)
void SendKeepalive(bool from_timer)
static const int kRouteTargetEndOfRibTimeSecs
std::string local_bgp_identifier_string() const
bool operator!=(const OriginOverride &rhs) const
const std::string & localname() const
static std::string UTCUsecToString(uint64_t tstamp)
virtual void GetTxSocketStats(IPeerDebugStats::SocketStats *stats) const