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 peer_type_((config->peer_as() == config->local_as()) ?
519 instance_delete_ref_(this, instance ? instance->
deleter() : NULL),
521 total_flap_count_(0),
523 dscp_listener_id_(-1),
525 asn_listener_id_(-1),
598 BgpPeerInfoData peer_info;
605 peer_info.set_route_origin(
608 peer_info.set_route_origin(
"-");
612 peer_info.set_peer_type(
630 BgpPeerInfoData peer_info;
632 peer_info.set_deleted(
true);
635 PeerStatsData peer_stats_data;
636 peer_stats_data.set_name(
ToUVEKey());
637 peer_stats_data.set_deleted(
true);
638 assert(!peer_stats_data.get_name().empty());
639 BGP_UVE_SEND2(PeerStatsUve, peer_stats_data,
"ObjectBgpPeer");
641 PeerFlapData peer_flap_data;
642 peer_flap_data.set_name(
ToUVEKey());
643 peer_flap_data.set_deleted(
true);
644 assert(!peer_flap_data.get_name().empty());
658 char *buffer_capacity_str = getenv(
"BGP_PEER_BUFFER_SIZE");
659 if (buffer_capacity_str) {
660 size_t env_buffer_capacity = strtoul(buffer_capacity_str, NULL, 0);
665 return env_buffer_capacity;
677 uint32_t ribout_cid)
const {
680 if (!server_cluster_id)
return true;
685 if (ribout_cid && ribout_cid != server_cluster_id) {
706 attrs.push_back(&nexthop);
708 attrs.push_back(&origin);
714 RouteTargetList::const_iterator it) {
734 for (RouteTargetList::const_iterator it =
rtargets_.begin();
742 RouteTargetList::const_iterator it) {
760 for (RouteTargetList::const_iterator it =
rtargets_.begin();
908 if (dscp_value != 0xFF) {
920 string logstr = socket_name +
" socket kernel " + oper +
" of key id "
940 if (!family_attributes || family_attributes->
prefix_limit == 0)
966 family_attributes_list[family] = family_attributes;
970 family_attributes_list.begin(), family_attributes_list.end(),
1003 bool admin_down_changed =
false;
1004 BgpPeerInfoData peer_info;
1010 admin_down_changed =
true;
1038 peer_info.set_route_origin(
"-");
1081 "Updated Local Autonomous System from " <<
1093 "Updated Hold Time from " <<
1105 "Updated Peer Autonomous System from " <<
1114 boost::system::error_code ec;
1125 peer_info.set_peer_type(
1150 "Session cleared due to configuration change");
1293 const BgpPath *old_path, uint32_t path_flags)
const {
1396 membership_mgr->
Register(
this, table, policy);
1437 vector<Address::Family> family_list = list_of
1444 table,
"Register peer with the table");
1453 if (mgr !=
nullptr) {
1456 if (vxlan_ri !=
nullptr) {
1459 table,
"Register ribin for peer with the table");
1474 table,
"Register peer with the table");
1477 vector<Address::Family> vpn_family_list = list_of
1485 table,
"Register ribin for peer with the table");
1509 static const uint8_t cap_mp[][4] = {
1542 BOOST_FOREACH(
const FamilyToCapabilityMap::value_type &val,
1543 family_to_cap_map) {
1557 (
const uint8_t *)(&asn), 4);
1589 SandeshLevel::SYS_INFO;
1600 if (init_)
return skip_;
1602 skip_ = getenv(
"BGP_SKIP_UPDATE_SEND") != NULL;
1610 : origin_override(config.origin_override),
1611 origin(
BgpAttr::OriginFromString(config.origin)) {
1620 if (origin_override && origin != rhs.
origin) {
1632 const string *msg_str) {
1700 int code,
int subcode,
const string &data) {
1710 vector<BgpProto::OpenMessage::OptParam *>::const_iterator it;
1711 for (it = msg->
opt_params.begin(); it < msg->opt_params.end(); ++it) {
1713 (*it)->capabilities.end());
1714 (*it)->capabilities.clear();
1719 vector<BgpProto::OpenMessage::Capability *>::iterator c_it;
1727 BgpPeerInfoData peer_info;
1731 vector<string> families;
1732 vector<BgpProto::OpenMessage::Capability *>::iterator cap_it;
1737 uint8_t *data = (*cap_it)->capability.data();
1747 peer_info.set_families(families);
1766 if (!
peer_close_->SetGRCapabilities(&peer_info)) {
1782 BgpPeerInfoData peer_info;
1784 vector<string> families = vector<string>();
1785 peer_info.set_families(families);
1788 peer_info.set_graceful_restart_families(vector<string>());
1793 vector<BgpProto::OpenMessage::Capability *>::iterator it;
1797 uint8_t *data = (*it)->capability.data();
1799 uint8_t safi_value =
get_value(data + 3, 1);
1800 if (afi == af_value && safi == safi_value) {
1811 template <
typename TableT,
typename PrefixT>
1817 for (vector<BgpProtoPrefix *>::const_iterator it = nlri->
nlri.begin();
1818 it != nlri->
nlri.end(); ++it) {
1822 uint32_t l3_label = 0;
1823 int result = PrefixT::FromProtoPrefix(
server_, **it,
1825 family, &prefix, &new_attr, &label, &l3_label);
1829 "MP NLRI parse error for " <<
1837 req.
data.reset(
new typename TableT::RequestData(
1838 new_attr, flags, label, l3_label, 0));
1840 req.
key.reset(
new typename TableT::RequestKey(prefix,
this));
1841 table->Enqueue(&req);
1845 template <
typename PrefixT>
1849 for (vector<BgpProtoPrefix *>::const_iterator it = nlri->
nlri.begin();
1850 it != nlri->
nlri.end(); ++it) {
1854 uint32_t l3_label = 0;
1855 int result = PrefixT::FromProtoPrefix(
server_, **it,
1857 family, &prefix, &new_attr, &label, &l3_label);
1861 "MP NLRI parse error for " <<
1866 ProcessBgpaas(oper, prefix.addr(), prefix.prefixlen(), new_attr, flags);
1877 if (mgr ==
nullptr) {
1882 if (vxlan_ri ==
nullptr) {
1894 req.
data.reset(NULL);
1947 return numeric_limits<uint32_t>::max() - med;
1971 uint32_t reach_count = 0, unreach_count = 0;
1978 "Cannot find inet table");
1983 for (vector<BgpProtoPrefix *>::const_iterator it =
1991 "Withdrawn route parse error for inet route");
2003 req.
data.reset(NULL);
2009 reach_count += msg->
nlri.size();
2010 for (vector<BgpProtoPrefix *>::const_iterator it = msg->
nlri.begin();
2011 it != msg->
nlri.end(); ++it) {
2017 "NLRI parse error for inet route");
2035 for (vector<BgpAttribute *>::const_iterator ait =
2050 reach_count += nlri->
nlri.size();
2052 unreach_count += nlri->
nlri.size();
2059 "AFI "<< nlri->
afi <<
" SAFI " << (
int) nlri->
safi <<
2069 "EndOfRib marker family " <<
2071 " size " << msgsize);
2085 ProcessNlri<InetTable, Ip4Prefix>(
2086 family, oper, nlri, attr, flags);
2089 ProcessNlriBgpaas<Ip4Prefix>(
2090 family, oper, nlri, attr, flags);
2094 ProcessNlri<InetVpnTable, InetVpnPrefix>(
2095 family, oper, nlri, attr, flags);
2098 ProcessNlri<Inet6Table, Inet6Prefix>(
2099 family, oper, nlri, attr, flags);
2102 ProcessNlriBgpaas<Inet6Prefix>(
2103 family, oper, nlri, attr, flags);
2107 ProcessNlri<Inet6VpnTable, Inet6VpnPrefix>(
2108 family, oper, nlri, attr, flags);
2111 ProcessNlri<EvpnTable, EvpnPrefix>(
2112 family, oper, nlri, attr, flags);
2115 ProcessNlri<ErmVpnTable, ErmVpnPrefix>(
2116 family, oper, nlri, attr, flags);
2119 ProcessNlri<MvpnTable, MvpnPrefix>(
2120 family, oper, nlri, attr, flags);
2123 ProcessNlri<RTargetTable, RTargetPrefix>(
2124 family, oper, nlri, attr, flags);
2136 "Update size " << msgsize <<
2137 " reach " << reach_count <<
" unreach " << unreach_count);
2143 return std::vector<std::string>();
2152 bool tunnel_encap_found =
false;
2153 if (ext_community) {
2154 for (ExtCommunity::ExtCommunityList::const_iterator iter =
2159 tunnel_encap_found =
true;
2165 if (!ext_community || !tunnel_encap_found) {
2167 BOOST_FOREACH(
const string &encap_string,
2174 ext_community ? ext_community.get() : NULL, encap_list);
2212 string error_message) {
2214 "Timer error: " << error_name <<
" " << error_message);
2218 string error_message) {
2220 "Timer error: " << error_name <<
" " << error_message);
2231 vector<Address::Family> vpn_family_list = list_of
2239 table,
"Register peer with the table");
2249 "EndOfRib Receive Timer scheduled for family " <<
2251 " to fire after " << timeout <<
" second(s)");
2258 string error_message) {
2260 "Timer error: " << error_name <<
" " << error_message);
2285 int keepalive_time_msecs =
state_machine_->keepalive_time_msecs();
2286 if (keepalive_time_msecs <= 0)
2342 for (
size_t i = 0; i < size; i ++) {
2343 if (!(i % 32)) out <<
"\n";
2344 if (!(i % 4)) out <<
" 0x";
2345 snprintf(buf,
sizeof(buf),
"%02X", msg[i]);
2360 if (minfo == NULL) {
2364 "Error while parsing message at " << ec.
type_name);
2383 bool update_nh =
false;
2389 Ip4Address::bytes_type bt = { { 0 } };
2391 nlri->
nexthop.begin() +
sizeof(bt), bt.begin());
2395 Ip4Address::bytes_type bt = { { 0 } };
2397 copy(nlri->
nexthop.begin() + rdsize,
2398 nlri->
nexthop.begin() + rdsize +
sizeof(bt), bt.begin());
2404 Ip4Address::bytes_type bt = { { 0 } };
2406 nlri->
nexthop.begin() +
sizeof(bt), bt.begin());
2418 for (
int idx = 0; idx < 2; ++idx) {
2419 Ip6Address::bytes_type bt = { { 0 } };
2420 if ((idx + 1) *
sizeof(bt) > nlri->
nexthop.size())
2422 copy(nlri->
nexthop.begin() + idx *
sizeof(bt),
2423 nlri->
nexthop.begin() + (idx + 1) *
sizeof(bt), bt.begin());
2425 if (v6_addr.is_v4_mapped()) {
2430 if (!v6_addr.is_link_local()) {
2437 Ip6Address::bytes_type bt = { { 0 } };
2439 copy(nlri->
nexthop.begin() + rdsize,
2440 nlri->
nexthop.begin() + rdsize +
sizeof(bt), bt.begin());
2442 if (v6_addr.is_v4_mapped()) {
2491 PeerProtoStats *proto_stats) {
2492 proto_stats->set_open(stats.
open);
2493 proto_stats->set_keepalive(stats.
keepalive);
2494 proto_stats->set_close(stats.
close);
2495 proto_stats->set_update(stats.
update);
2502 PeerUpdateStats *rt_stats) {
2503 rt_stats->set_reach(stats.
reach);
2504 rt_stats->set_unreach(stats.
unreach);
2510 PeerSocketStats *peer_socket_stats) {
2511 peer_socket_stats->set_calls(socket_stats.
calls);
2512 peer_socket_stats->set_bytes(socket_stats.
bytes);
2513 if (socket_stats.
calls) {
2514 peer_socket_stats->set_average_bytes(
2517 peer_socket_stats->set_blocked_count(socket_stats.
blocked_count);
2520 peer_socket_stats->set_blocked_duration(os.str());
2523 os << boost::posix_time::microseconds(
2525 peer_socket_stats->set_average_blocked_duration(os.str());
2543 PeerProtoStats proto_stats;
2546 bnr->set_rx_proto_stats(proto_stats);
2550 bnr->set_tx_proto_stats(proto_stats);
2553 PeerUpdateStats rt_stats;
2556 bnr->set_rx_update_stats(rt_stats);
2560 bnr->set_tx_update_stats(rt_stats);
2563 PeerSocketStats peer_socket_stats;
2567 bnr->set_rx_socket_stats(peer_socket_stats);
2571 bnr->set_tx_socket_stats(peer_socket_stats);
2575 vector<ShowBgpNeighborFamily> show_family_attributes_list;
2579 ShowBgpNeighborFamily show_family_attributes;
2580 show_family_attributes.set_family(
2582 show_family_attributes.set_loop_count(
2584 show_family_attributes.set_prefix_limit(
2586 show_family_attributes.set_idle_timeout(
2589 show_family_attributes.set_gateway_address(
2592 show_family_attributes_list.push_back(show_family_attributes);
2594 nbr->set_family_attributes_list(show_family_attributes_list);
2598 BgpNeighborResp *bnr,
bool summary)
const {
2610 bnr->set_route_origin(
"-");
2618 bnr->set_encoding(
"BGP");
2647 bnr->set_configured_hold_time(
state_machine_->GetConfiguredHoldTime());
2652 bnr->set_routing_instances(vector<BgpNeighborRoutingInstance>());
2825 BgpPeerInfoData peer_info;
2827 PeerFlapInfo flap_info;
2830 peer_info.set_flap_info(flap_info);
2833 PeerFlapData peer_flap_data;
2834 peer_flap_data.set_name(
ToUVEKey());
2835 peer_flap_data.set_flap_info(flap_info);
2836 assert(!peer_flap_data.get_name().empty());
2844 BgpPeerInfoData peer_info;
2846 PeerFlapInfo flap_info;
2847 peer_info.set_flap_info(flap_info);
2850 PeerFlapData peer_flap_data;
2851 peer_flap_data.set_name(
ToUVEKey());
2852 peer_flap_data.set_flap_info(flap_info);
2853 assert(!peer_flap_data.get_name().empty());
2865 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_
std::atomic< int > membership_req_pending_
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
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)
std::atomic< int > primary_path_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
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()
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())
std::atomic< int > total_path_count_
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
std::atomic< uint32_t > family_primary_path_count_[Address::NUM_FAMILIES]
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
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
uint64_t primary_path_count
uint64_t total_path_count
uint64_t blocked_duration_usecs
void SetRemovePrivatePolicy(bool all, bool replace, bool peer_loop_check)
std::atomic< uint64_t > write_calls
std::atomic< uint64_t > write_blocked_duration_usecs
std::atomic< uint64_t > read_bytes
std::atomic< uint64_t > write_blocked
std::atomic< uint64_t > read_calls
std::atomic< uint64_t > write_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)