7 #include <boost/assign/list_of.hpp>
8 #include <boost/foreach.hpp>
40 #include "control-node/sandesh/control_node_types.h"
42 #include "schema/xmpp_multicast_types.h"
43 #include "schema/xmpp_enet_types.h"
44 #include "schema/xmpp_mvpn_types.h"
49 #include "xmpp/sandesh/xmpp_peer_info_types.h"
51 using autogen::EnetItemType;
52 using autogen::EnetNextHopListType;
53 using autogen::EnetSecurityGroupListType;
54 using autogen::EnetTunnelEncapsulationListType;
56 using autogen::McastItemType;
57 using autogen::McastNextHopsType;
58 using autogen::McastTunnelEncapsulationListType;
60 using autogen::MvpnItemType;
61 using autogen::MvpnNextHopType;
62 using autogen::MvpnTunnelEncapsulationListType;
64 using autogen::ItemType;
65 using autogen::NextHopListType;
66 using autogen::SecurityGroupListType;
67 using autogen::CommunityTagListType;
68 using autogen::TunnelEncapsulationListType;
69 using autogen::TagListType;
71 using boost::assign::list_of;
73 using boost::system::error_code;
78 using std::unique_ptr;
80 using std::numeric_limits;
81 using std::ostringstream;
95 if (local_pref == 100)
97 if (local_pref == 200)
99 return numeric_limits<uint32_t>::max() - local_pref;
107 ++inet6_rx_bad_prefix_count;
111 ++inet6_rx_bad_nexthop_count;
115 ++inet6_rx_bad_afi_safi_count;
119 return inet6_rx_bad_xml_token_count;
123 return inet6_rx_bad_prefix_count;
127 return inet6_rx_bad_nexthop_count;
131 return inet6_rx_bad_afi_safi_count;
147 return parent_->ToString();
152 return (parent_->channel_->LastStateName());
156 return (parent_->channel_->LastStateChangeAt());
166 return (parent_->channel_->LastEvent());
171 return (parent_->channel_->LastFlap());
176 return (parent_->channel_->FlapCount());
180 stats->
open = parent_->channel_->rx_open();
181 stats->
close = parent_->channel_->rx_close();
182 stats->
keepalive = parent_->channel_->rx_keepalive();
183 stats->
update = parent_->channel_->rx_update();
187 stats->
open = parent_->channel_->tx_open();
188 stats->
close = parent_->channel_->tx_close();
189 stats->
keepalive = parent_->channel_->tx_keepalive();
190 stats->
update = parent_->channel_->tx_update();
194 stats->
reach = parent_->stats_[
RX].reach;
195 stats->
unreach = parent_->stats_[
RX].unreach;
201 stats->
reach = parent_->stats_[
TX].reach;
202 stats->
unreach = parent_->stats_[
TX].unreach;
208 const XmppSession *session = parent_->GetSession();
211 stats->
calls = socket_stats.read_calls;
212 stats->
bytes = socket_stats.read_bytes;
217 const XmppSession *session = parent_->GetSession();
220 stats->
calls = socket_stats.write_calls;
221 stats->
bytes = socket_stats.write_bytes;
224 socket_stats.write_blocked_duration_usecs;
246 parent_->stats_[
TX].unreach += count;
250 parent_->stats_[
TX].reach += count;
265 total_path_count_ = 0;
266 primary_path_count_ = 0;
270 assert(GetTotalPathCount() == 0);
272 XmppPeerInfoData peer_info;
274 peer_info.set_deleted(
true);
275 parent_->XMPPPeerInfoSend(peer_info);
277 PeerStatsData peer_stats_data;
278 peer_stats_data.set_name(
ToUVEKey());
279 peer_stats_data.set_deleted(
true);
280 assert(!peer_stats_data.get_name().empty());
281 BGP_UVE_SEND2(PeerStatsUve, peer_stats_data,
"ObjectXmppPeerInfo");
286 if (parent_->close_manager_->IsMembershipInUse())
287 return parent_->close_manager_->MembershipPathCallback(tpart, rt,
294 virtual bool SendUpdate(
const uint8_t *msg,
size_t msgsize,
295 const std::string *msg_str);
296 virtual bool SendUpdate(
const uint8_t *msg,
size_t msgsize) {
297 return SendUpdate(msg, msgsize, NULL);
300 return parent_->ToString();
304 return parent_->GetMembershipRequestQueueSize() == 0;
310 return parent_->ToUVEKey();
316 return parent_->peer_close_.get();
319 return parent_->peer_close_.get();
323 uint32_t path_flags)
const {
324 peer_close()->UpdateRouteStats(family, old_path, path_flags);
328 return parent_->peer_stats_.get();
331 return parent_->peer_stats_.get();
335 return (parent_->channel_->GetPeerState() ==
xmps::READY);
338 switch (parent_->channel_->GetPeerState()) {
349 virtual void Close(
bool graceful);
365 if (remote.address().is_v4()) {
366 return remote.address().to_v4().to_ulong();
372 total_path_count_ += count;
375 return total_path_count_;
380 primary_path_count_ += count;
383 return primary_path_count_;
391 return std::vector<std::string>();
394 return parent_->close_manager_->IsInGRTimerWaitState();
398 parent_->MembershipRequestCallback(table);
406 if (!server_)
return;
414 parent_->ResetEndOfRibSendState();
429 static char *skip_env_ = getenv(
"XMPP_SKIP_UPDATE_SEND");
444 const string *msg_str) {
447 parent_->stats_[
TX].rt_updates++;
448 if (parent_->SkipUpdateSend())
450 send_ready_ = channel->
Send(msg, msgsize, msg_str,
xmps::BGP,
458 if (parent_->eor_send_timer_ && parent_->eor_send_timer_->running())
459 parent_->eor_send_timer_->Cancel();
469 parent_->set_peer_closed(
true);
479 parent_->ClearEndOfRibState();
481 parent_->peer_close_->Close(graceful);
508 TaskScheduler::GetInstance()->GetTaskId(
"xmpp::StateMachine"),
509 channel->GetTaskInstance(),
513 BgpStaticObjectFactory::Create<PeerCloseManager>(static_cast<IPeerClose*>(
peer_close_.get())));
517 "EndOfRib receive timer",
522 "EndOfRib send timer",
556 assert(!peer_info.get_name().empty());
597 assert(instance_mgr);
613 rt_instance, &sub_state->
targets);
635 *addrp = IpAddress::from_string(address, error);
639 return (zero_ok ?
true : !addrp->is_unspecified());
646 int *instance_id, uint64_t *subscription_gen_id,
RequestType *req_type) {
648 *subscription_gen_id = 0;
659 instance_id, subscription_gen_id);
685 const string &table_name) {
686 TableMembershipRequestMap::iterator loc =
697 const string &table_name)
const {
698 TableMembershipRequestMap::const_iterator loc =
724 InstanceMembershipRequestMap::const_iterator loc =
740 int *instance_id, uint64_t *subscription_gen_id,
bool *subscribe_pending,
743 *subscribe_pending =
false;
748 *table = rt_instance->
GetTable(family);
749 if (rt_instance != NULL && !rt_instance->
deleted()) {
752 subscription_gen_id, &req_type)) {
757 "Received route after unsubscribe");
760 *subscribe_pending =
true;
763 if (*instance_id < 0) {
766 "Received route without subscribe");
778 *subscribe_pending =
true;
779 }
else if (add_change || !rt_instance) {
790 const pugi::xml_node &node,
bool add_change) {
794 if (!item.XmlParse(node)) {
802 "Unsupported address family " << item.entry.nlri.af <<
803 " for multicast route");
810 item.entry.nlri.safi <<
" for multicast route");
815 IpAddress grp_address = IpAddress::from_string(
"0.0.0.0", error);
816 if (!item.entry.nlri.group.empty()) {
818 item.entry.nlri.group, &grp_address,
false)) {
820 "Bad group address " << item.entry.nlri.group);
825 IpAddress src_address = IpAddress::from_string(
"0.0.0.0", error);
826 if (!item.entry.nlri.source.empty()) {
828 item.entry.nlri.source, &src_address,
true)) {
830 "Bad source address " << item.entry.nlri.source);
835 bool subscribe_pending;
837 uint64_t subscription_gen_id;
840 &subscription_gen_id, &subscribe_pending, add_change)) {
846 uint16_t cluster_seed =
857 grp_address.to_v4(), src_address.to_v4());
865 string label_range(
"none");
869 vector<uint32_t> labels;
870 const McastNextHopsType &inh_list = item.entry.next_hops;
872 if (inh_list.next_hop.empty()) {
875 mc_prefix.ToString());
880 if (inh_list.next_hop.size() != 1) {
882 "More than one nexthop received for multicast route " <<
883 mc_prefix.ToString());
887 McastNextHopsType::const_iterator nit = inh_list.begin();
890 label_range = nit->label;
892 labels.size() != 2) {
894 "Bad label range " << label_range <<
895 " for multicast route " << mc_prefix.ToString());
899 if (!labels[0] || !labels[1] || labels[1] < labels[0]) {
902 " for multicast route " << mc_prefix.ToString());
910 attrs.push_back(&attr_label);
917 " for multicast route " << mc_prefix.ToString());
921 attrs.push_back(&nexthop);
924 bool no_tunnel_encap =
true;
925 bool no_valid_tunnel_encap =
true;
926 for (McastTunnelEncapsulationListType::const_iterator eit =
927 nit->tunnel_encapsulation_list.begin();
928 eit != nit->tunnel_encapsulation_list.end(); ++eit) {
929 no_tunnel_encap =
false;
933 no_valid_tunnel_encap =
false;
939 if (!no_tunnel_encap && no_valid_tunnel_encap) {
944 attrs.push_back(&ext);
948 attr, flags, 0, 0, subscription_gen_id));
956 if (subscribe_pending) {
958 request_entry->
Swap(&req);
962 make_pair(vrf_name, table_name), request_entry));
969 "Multicast group " << item.entry.nlri.group <<
970 " source " << item.entry.nlri.source <<
971 " and label range " << label_range <<
972 " enqueued for " << (add_change ?
"add/change" :
"delete"));
978 IpAddress src_address,
bool add_change, uint64_t subscription_gen_id,
979 int instance_id,
DBRequest& req,
const MvpnNextHopType &nexthop) {
982 grp_address.to_v4(), src_address.to_v4());
1000 attrs.push_back(&source_rd);
1003 attr, flags, 0, 0, subscription_gen_id));
1012 IpAddress src_address,
bool add_change, uint64_t subscription_gen_id,
1016 grp_address.to_v4(), src_address.to_v4());
1029 attrs.push_back(&nexthop);
1033 attr, flags, 0, 0, subscription_gen_id));
1042 const pugi::xml_node &node,
bool add_change) {
1046 if (!item.XmlParse(node)) {
1054 "Unsupported address family " << item.entry.nlri.af <<
1055 " for multicast route");
1062 item.entry.nlri.safi <<
" for multicast route");
1066 if (item.entry.nlri.group.empty()) {
1068 "Mandatory group address not specified");
1073 IpAddress grp_address = IpAddress::from_string(
"0.0.0.0", error);
1075 item.entry.nlri.group, &grp_address,
false)) {
1077 "Bad group address " << item.entry.nlri.group);
1081 if (item.entry.nlri.source.empty()) {
1083 "Mandatory source address not specified");
1087 IpAddress src_address = IpAddress::from_string(
"0.0.0.0", error);
1089 item.entry.nlri.source, &src_address,
true)) {
1091 "Bad source address " << item.entry.nlri.source);
1095 bool subscribe_pending;
1097 uint64_t subscription_gen_id;
1100 &subscription_gen_id, &subscribe_pending, add_change)) {
1105 int rt_type = item.entry.nlri.route_type;
1110 subscription_gen_id, req);
1113 subscription_gen_id, instance_id, req, item.entry.next_hop);
1116 "Unsupported route type " << item.entry.nlri.route_type);
1125 if (subscribe_pending) {
1127 request_entry->
Swap(&req);
1131 make_pair(vrf_name, table_name), request_entry));
1137 "Multicast group " << item.entry.nlri.group <<
1138 " source " << item.entry.nlri.source <<
1139 " enqueued for " << (add_change ?
"add/change" :
"delete"));
1145 const pugi::xml_node &node,
bool add_change,
int primary_instance_id) {
1149 if (!item.XmlParse(node)) {
1151 "Invalid inet route message received");
1157 "Unsupported address family " << item.entry.nlri.af <<
1158 " for inet route " << item.entry.nlri.address);
1165 "Unsupported subsequent address family " << item.entry.nlri.safi <<
1166 " for inet route " << item.entry.nlri.address);
1174 "Bad inet route " << item.entry.nlri.address);
1178 if (add_change && item.entry.next_hops.next_hop.empty()) {
1180 "Missing next-hops for inet route " << inet_prefix.
ToString());
1189 bool subscribe_pending;
1191 uint64_t subscription_gen_id;
1194 item.entry.nlri.safi);
1196 &subscription_gen_id, &subscribe_pending, add_change)) {
1214 const NextHopListType &inh_list = item.entry.next_hops;
1217 if (inh_list.next_hop.size() != 1) {
1220 "More than one nexthop received for inet route " <<
1225 NextHopListType::const_iterator nit = inh_list.begin();
1231 "Bad nexthop address " << nit->address <<
1232 " for inet route " << inet_prefix.
ToString());
1237 ((master && nit->label) &&
1241 "Bad label " << nit->label <<
1242 " for inet route " << inet_prefix.
ToString());
1249 "Bad label " << nit->label <<
1250 " for inet route in master instance(mpls)/non master instance" <<
1255 nh_address = nhop_address;
1259 bool no_tunnel_encap =
true;
1260 bool no_valid_tunnel_encap =
true;
1261 for (TunnelEncapsulationListType::const_iterator eit =
1262 nit->tunnel_encapsulation_list.begin();
1263 eit != nit->tunnel_encapsulation_list.end(); ++eit) {
1264 no_tunnel_encap =
false;
1268 no_valid_tunnel_encap =
false;
1274 if (!no_tunnel_encap && no_valid_tunnel_encap && !master) {
1279 if (!nit->mac.empty()) {
1285 "Bad next-hop mac address " << nit->mac);
1288 if (!mac_addr.
IsZero()) {
1295 uint16_t tag_index = 0;
1296 for (TagListType::const_iterator tit = nit->tag_list.begin();
1297 tit != nit->tag_list.end(); ++tit) {
1300 ext.
communities.push_back(tag.GetExtCommunityValue());
1302 Tag tag(tag_index, *tit);
1304 ext.
communities.push_back(tag4.GetExtCommunityValue());
1310 if (nit->local_sequence_number) {
1317 attrs.push_back(&local_pref);
1321 uint32_t med_value = item.entry.med;
1326 attrs.push_back(&med);
1329 const CommunityTagListType &ict_list = item.entry.community_tag_list;
1330 for (CommunityTagListType::const_iterator cit = ict_list.begin();
1331 cit != ict_list.end(); ++cit) {
1333 uint32_t rt_community =
1340 uint32_t addr = nh_address.to_v4().to_ulong();
1342 attrs.push_back(&nexthop);
1343 uint16_t cluster_seed =
1346 if (!master || primary_instance_id) {
1348 instance_id = primary_instance_id;
1356 attrs.push_back(&source_rd);
1360 uint16_t sg_index = 0;
1361 const SecurityGroupListType &isg_list = item.entry.security_group_list;
1362 for (SecurityGroupListType::const_iterator sit = isg_list.begin();
1363 sit != isg_list.end(); ++sit) {
1366 ext.
communities.push_back(sg.GetExtCommunityValue());
1371 ext.
communities.push_back(sg4.GetExtCommunityValue());
1376 if (item.entry.mobility.seqno) {
1378 item.entry.mobility.sticky);
1380 }
else if (item.entry.sequence_number) {
1386 LoadBalance load_balance(item.entry.load_balance);
1391 attrs.push_back(&comm);
1393 attrs.push_back(&ext);
1397 attrs.push_back(&sbp);
1401 attr, flags, label, 0, subscription_gen_id));
1407 if (subscribe_pending) {
1409 request_entry->
Swap(&req);
1413 make_pair(vrf_name, table_name), request_entry));
1420 "Inet route " << item.entry.nlri.address <<
1421 " with next-hop " << nh_address <<
" and label " << label <<
1422 " enqueued for " << (add_change ?
"add/change" :
"delete") <<
1423 " to table " << table->
name());
1436 const pugi::xml_node &node,
bool add_change) {
1440 if (!item.XmlParse(node)) {
1443 "Invalid inet6 route message received");
1450 "Unsupported address family " << item.entry.nlri.af <<
1451 " for inet6 route " << item.entry.nlri.address);
1458 "Unsupported subsequent address family " << item.entry.nlri.safi <<
1459 " for inet6 route " << item.entry.nlri.address);
1469 "Bad inet6 route " << item.entry.nlri.address);
1473 if (add_change && item.entry.next_hops.next_hop.empty()) {
1475 "Missing next-hops for inet6 route " << inet6_prefix.
ToString());
1488 bool subscribe_pending;
1490 uint64_t subscription_gen_id;
1493 &subscription_gen_id, &subscribe_pending, add_change)) {
1517 const NextHopListType &inh_list = item.entry.next_hops;
1520 if (inh_list.next_hop.size() != 1) {
1523 "More than one nexthop received for inet6 route " <<
1528 NextHopListType::const_iterator nit = inh_list.begin();
1535 "Bad nexthop address " << nit->address <<
1536 " for inet6 route " << inet6_prefix.
ToString());
1544 "Bad label " << nit->vni <<
1545 " for inet6 route " << inet6_prefix.
ToString());
1550 if (nit->mac.empty())
1558 "Bad next-hop mac address " << nit->mac);
1567 "Bad label " << nit->label <<
1568 " for inet6 route " << inet6_prefix.
ToString());
1571 if (!master && !nit->label)
1575 nh_address = nhop_address;
1583 bool no_tunnel_encap =
true;
1584 bool no_valid_tunnel_encap =
true;
1585 for (TunnelEncapsulationListType::const_iterator eit =
1586 nit->tunnel_encapsulation_list.begin();
1587 eit != nit->tunnel_encapsulation_list.end(); ++eit) {
1588 no_tunnel_encap =
false;
1592 no_valid_tunnel_encap =
false;
1598 if (!no_tunnel_encap && no_valid_tunnel_encap && !master) {
1603 if (!nit->mac.empty()) {
1609 "Bad next-hop mac address " << nit->mac);
1612 if (!mac_addr.
IsZero()) {
1619 uint16_t tag_index = 0;
1620 for (TagListType::const_iterator tit = nit->tag_list.begin();
1621 tit != nit->tag_list.end(); ++tit) {
1624 ext.
communities.push_back(tag.GetExtCommunityValue());
1626 Tag tag(tag_index, *tit);
1630 ext.
communities.push_back(tag4.GetExtCommunityValue());
1635 if (nit->local_sequence_number) {
1642 attrs.push_back(&local_pref);
1646 uint32_t med_value = item.entry.med;
1651 attrs.push_back(&med);
1654 const CommunityTagListType &ict_list =
1655 item.entry.community_tag_list;
1656 for (CommunityTagListType::const_iterator cit = ict_list.begin();
1657 cit != ict_list.end(); ++cit) {
1659 uint32_t rt_community =
1667 attrs.push_back(&nexthop);
1671 uint32_t addr = nh_address.to_v4().to_ulong();
1672 uint16_t cluster_seed =
1681 attrs.push_back(&source_rd);
1685 const SecurityGroupListType &isg_list =
1686 item.entry.security_group_list;
1687 uint16_t sg_index = 0;
1688 for (SecurityGroupListType::const_iterator sit = isg_list.begin();
1689 sit != isg_list.end(); ++sit) {
1692 ext.
communities.push_back(sg.GetExtCommunityValue());
1697 ext.
communities.push_back(sg4.GetExtCommunityValue());
1702 if (item.entry.mobility.seqno) {
1704 item.entry.mobility.sticky);
1706 }
else if (item.entry.sequence_number) {
1712 LoadBalance load_balance(item.entry.load_balance);
1718 attrs.push_back(&sbp);
1721 attrs.push_back(&comm);
1723 attrs.push_back(&ext);
1727 attr, flags, label, 0, subscription_gen_id));
1733 if (subscribe_pending) {
1735 request_entry->
Swap(&req);
1739 make_pair(vrf_name, table_name), request_entry));
1746 "Inet6 route " << item.entry.nlri.address <<
1747 " with next-hop " << nh_address <<
" and label " << label <<
1748 " enqueued for " << (add_change ?
"add/change" :
"delete") <<
1749 " to table " << table->
name());
1763 const pugi::xml_node &node,
bool add_change) {
1767 if (!item.XmlParse(node)) {
1769 "Invalid enet route message received");
1775 "Unsupported address family " << item.entry.nlri.af <<
1776 " for enet route " << item.entry.nlri.address);
1782 "Unsupported subsequent address family " << item.entry.nlri.safi <<
1783 " for enet route " << item.entry.nlri.mac);
1789 IpAddress group= IpAddress::from_string(
"0.0.0.0", error);
1790 if (!item.entry.nlri.group.empty()) {
1793 item.entry.nlri.group, &group,
false)) {
1795 "Bad group address " << item.entry.nlri.group);
1799 IpAddress source = IpAddress::from_string(
"0.0.0.0", error);
1801 item.entry.nlri.af, item.entry.nlri.source, &source,
true)) {
1803 "Bad source address " << item.entry.nlri.source);
1811 "Bad mac address " << item.entry.nlri.mac);
1815 bool type2 = type6 ?
false : !mac_addr.
IsZero();
1820 if (!item.entry.nlri.address.empty()) {
1821 size_t pos = item.entry.nlri.address.find(
'/');
1822 if (pos == string::npos) {
1824 "Missing / in address " << item.entry.nlri.address);
1828 bool ipv6 = item.entry.nlri.address.find(
':') != string::npos;
1835 "Cannot parse inet prefix string " <<
1836 item.entry.nlri.address);
1840 if (type2 && inet_prefix.
prefixlen() != 32 &&
1841 item.entry.nlri.address !=
"0.0.0.0/0") {
1844 "Bad inet address " << item.entry.nlri.address);
1857 "Cannot parse inet6 prefix string " <<
1858 item.entry.nlri.address);
1862 if (type2 && inet6_prefix.
prefixlen() != 128 &&
1863 item.entry.nlri.address !=
"::/0") {
1866 "Bad inet6 address " << item.entry.nlri.address);
1874 bool subscribe_pending;
1876 uint64_t subscription_gen_id;
1879 &subscription_gen_id, &subscribe_pending, add_change)) {
1894 uint32_t ethernet_tag = item.entry.nlri.ethernet_tag;
1898 type2 ? EvpnPrefix(rd, ethernet_tag, mac_addr, ip_addr) :
1899 EvpnPrefix(rd, ip_addr, prefix_len);
1907 uint32_t l3_label = 0;
1913 const EnetNextHopListType &inh_list = item.entry.next_hops;
1915 if (inh_list.next_hop.empty()) {
1923 if (inh_list.next_hop.size() != 1) {
1926 "More than one nexthop received for enet route " <<
1931 EnetNextHopListType::const_iterator nit = inh_list.begin();
1942 nh_address = nhop_address;
1944 l3_label = nit->l3_label;
1945 if (!nit->mac.empty()) {
1951 "Bad next-hop mac address " << nit->mac <<
1960 bool no_tunnel_encap =
true;
1961 bool no_valid_tunnel_encap =
true;
1962 for (EnetTunnelEncapsulationListType::const_iterator eit =
1963 nit->tunnel_encapsulation_list.begin();
1964 eit != nit->tunnel_encapsulation_list.end(); ++eit) {
1965 no_tunnel_encap =
false;
1969 no_valid_tunnel_encap =
false;
1979 if (!no_tunnel_encap && no_valid_tunnel_encap) {
1984 uint16_t tag_index = 0;
1985 for (TagListType::const_iterator tit = nit->tag_list.begin();
1986 tit != nit->tag_list.end(); ++tit) {
1989 ext.
communities.push_back(tag.GetExtCommunityValue());
1991 Tag tag(tag_index, *tit);
1994 ext.
communities.push_back(tag4.GetExtCommunityValue());
1999 if (nit->local_sequence_number) {
2006 attrs.push_back(&local_pref);
2011 uint32_t med_value = item.entry.med;
2016 attrs.push_back(&med);
2021 if (item.entry.replicator_address.empty() &&
2022 item.entry.edge_replication_not_supported) {
2024 flags &= ~
BgpPath::CheckGlobalErmVpnRoute;
2025 attrs.push_back(&nexthop);
2028 attrs.push_back(&nexthop);
2035 nh_address.to_v4().to_ulong(), instance_id));
2038 nh_address.to_v4().to_ulong(), instance_id));
2040 attrs.push_back(&source_rd);
2043 const EnetSecurityGroupListType &isg_list =
2044 item.entry.security_group_list;
2045 uint16_t sg_index = 0;
2046 for (EnetSecurityGroupListType::const_iterator sit = isg_list.begin();
2047 sit != isg_list.end(); ++sit) {
2050 ext.
communities.push_back(sg.GetExtCommunityValue());
2055 ext.
communities.push_back(sg4.GetExtCommunityValue());
2060 if (item.entry.mobility.seqno) {
2062 item.entry.mobility.sticky);
2064 }
else if (item.entry.sequence_number) {
2069 ETree etree(item.entry.etree_leaf);
2073 attrs.push_back(&ext);
2077 if (!item.entry.replicator_address.empty()) {
2080 item.entry.replicator_address, &replicator_address)) {
2083 "Bad replicator address " <<
2084 item.entry.replicator_address <<
2094 if (item.entry.assisted_replication_supported) {
2098 if (!item.entry.edge_replication_not_supported) {
2105 pmsi_spec.
SetLabel(label, &ext_comm);
2106 attrs.push_back(&pmsi_spec);
2112 attr, flags, label, l3_label, subscription_gen_id));
2120 if (subscribe_pending) {
2122 request_entry->
Swap(&req);
2126 make_pair(vrf_name, table_name), request_entry));
2134 " with next-hop " << nh_address <<
2135 " label " << label <<
" l3-label " << l3_label <<
2136 " enqueued for " << (add_change ?
"add/change" :
"delete"));
2143 unique_ptr<DBRequest> ptr(request);
2147 if (table == NULL || table->
IsDeleted()) {
2153 int instance_id = -1;
2154 uint64_t subscription_gen_id = 0;
2156 &instance_id, &subscription_gen_id);
2157 if (!is_registered) {
2160 "Not subscribed to table " << table->
name());
2165 ->set_subscription_gen_id(subscription_gen_id);
2190 "Subscribe to table " << table->
name() <<
2191 (tmr_state->
no_ribout ?
" (no ribout)" :
"") <<
2222 "Unsubscribe to table " << table->
name());
2227 #define RegisterTable(table, tmr_state) \
2228 RegisterTable(__LINE__, table, tmr_state)
2229 #define UnregisterTable(table) UnregisterTable(__LINE__, table)
2234 BOOST_FOREACH(TableMembershipRequestMap::value_type &entry,
2263 "Table not in subscribe/unsubscribe request queue");
2270 "Subscribe to table " << table_name <<
" completed");
2275 "Unsubscribe to table " << table_name <<
" completed");
2341 assert(
defer_q_.count(vrf_n_table) == 0);
2350 for (DeferQ::iterator it =
defer_q_.find(vrf_n_table);
2351 it !=
defer_q_.end() && it->first.second == table->
name(); ++it) {
2370 vector<BgpNeighborRoutingInstance> instance_list;
2371 BOOST_FOREACH(
const SubscribedRoutingInstanceList::value_type &entry,
2373 BgpNeighborRoutingInstance instance;
2374 instance.set_name(entry.first->name());
2375 if (entry.second.IsLlgrStale()) {
2376 instance.set_state(
"subscribed-llgr-stale");
2377 }
else if (entry.second.IsGrStale()) {
2378 instance.set_state(
"subscribed-gr-stale");
2380 instance.set_state(
"subscribed");
2382 instance.set_index(entry.second.index);
2384 instance_list.push_back(instance);
2386 BOOST_FOREACH(
const InstanceMembershipRequestMap::value_type &entry,
2389 BgpNeighborRoutingInstance instance;
2390 instance.set_name(entry.first);
2391 instance.set_state(
"pending");
2393 instance_list.push_back(instance);
2395 resp->set_routing_instances(instance_list);
2399 vector<BgpNeighborRoutingTable> old_table_list = resp->get_routing_tables();
2400 set<string> old_table_set;
2401 vector<BgpNeighborRoutingTable> new_table_list;
2403 BOOST_FOREACH(
const BgpNeighborRoutingTable &table, old_table_list) {
2404 old_table_set.insert(table.get_name());
2406 new_table_list.push_back(table);
2409 BOOST_FOREACH(
const TableMembershipRequestMap::value_type &entry,
2411 BgpNeighborRoutingTable table;
2412 table.set_name(entry.first);
2413 if (old_table_set.find(entry.first) != old_table_set.end())
2414 table.set_current_state(
"subscribed");
2417 table.set_current_request(
"subscribe");
2419 table.set_current_request(
"unsubscribe");
2422 table.set_pending_request(
"subscribe");
2424 table.set_pending_request(
"unsubscribe");
2426 new_table_list.push_back(table);
2428 resp->set_routing_tables(new_table_list);
2435 for (DeferQ::iterator it =
2436 defer_q_.find(make_pair(vrf_name, table_name)), itnext;
2437 (it !=
defer_q_.end() && it->first.second == table_name);
2450 for (DeferQ::iterator it =
2451 defer_q_.lower_bound(make_pair(vrf_name,
string())), itnext;
2452 (it !=
defer_q_.end() && it->first.first == vrf_name);
2465 BOOST_FOREACH(SubscribedRoutingInstanceList::value_type &entry,
2467 entry.second.SetGrStale();
2476 BOOST_FOREACH(SubscribedRoutingInstanceList::value_type &entry,
2478 assert(entry.second.IsGrStale());
2479 entry.second.SetLlgrStale();
2490 if (i->second.IsGrStale()) {
2491 string name = i->first->name();
2498 "Instance subscription " << name <<
2499 " is still stale and hence unsubscribed");
2515 "Instance subscription " << rt_instance->
name() <<
2516 " stale flag is cleared");
2524 pair<SubscribedRoutingInstanceList::iterator, bool> ret =
2526 rt_instance, state));
2543 SubscribedRoutingInstanceList::iterator loc =
2550 SubscribedRoutingInstanceList::const_iterator loc =
2561 for (RoutingInstance::RouteTableList::const_iterator it = rt_list.begin();
2562 it != rt_list.end(); ++it) {
2577 int instance_id = -1;
2578 bool no_ribout =
false;
2583 for (xml_node node = options.first_child(); node;
2584 node = node.next_sibling()) {
2585 if (strcmp(node.name(),
"instance-id") == 0) {
2586 instance_id = node.text().as_int();
2588 if (strcmp(node.name(),
"no-ribout") == 0) {
2589 no_ribout = node.text().as_bool();
2595 assert(instance_mgr);
2597 if (rt_instance == NULL) {
2600 "Routing instance " << vrf_name <<
2601 " not found when processing " <<
2602 (add_change ?
"subscribe" :
"unsubscribe"));
2607 "Duplicate subscribe for routing instance " <<
2608 vrf_name <<
", triggering close");
2622 "Spurious unsubscribe for routing instance " <<
2623 vrf_name <<
", triggering close");
2628 }
else if (rt_instance->
deleted()) {
2631 "Routing instance " << vrf_name <<
2632 " is being deleted when processing " <<
2633 (add_change ?
"subscribe" :
"unsubscribe"));
2638 "Duplicate subscribe for routing instance " <<
2639 vrf_name <<
", triggering close");
2644 "Duplicate subscribe for routing instance " <<
2645 vrf_name <<
", triggering close");
2665 "Spurious unsubscribe for routing instance " <<
2666 vrf_name <<
", triggering close");
2680 "Duplicate subscribe for routing instance " <<
2681 vrf_name <<
", triggering close");
2688 "Duplicate subscribe for routing instance " <<
2689 vrf_name <<
" under GR, triggering close");
2699 "Spurious unsubscribe for routing instance " <<
2700 vrf_name <<
", triggering close");
2716 for (RoutingInstance::RouteTableList::const_iterator it = rt_list.begin();
2717 it != rt_list.end(); ++it) {
2736 if (
defer_q_.count(make_pair(vrf_name, table->
name()))) {
2739 "Flush deferred route requests for table " <<
2740 table->
name() <<
" on unsubscribe");
2774 string error_message) {
2776 "Timer error: " << error_name <<
" " << error_message);
2780 if (!
peer_->IsReady())
2798 "EndOfRib Receive timer rescheduled to fire after " <<
2817 if (!
peer_->IsReady())
2832 "EndOfRib Send timer rescheduled to fire after " <<
2851 timeout <<
" second(s)");
2862 if (!
peer_->send_ready())
2889 msg +=
"\n<message from=\"";
2892 msg +=
peer_->ToString();
2896 msg +=
"\n\t<event xmlns=\"http://jabber.org/protocol/pubsub\">";
2899 msg +=
"\n\t</event>\n</message>\n";
2911 bool expect_prefix_len)
const {
2914 char *str =
const_cast<char *
>(s.c_str());
2915 char *saveptr, *token;
2916 token = strtok_r(str,
"/", &saveptr);
2917 if (!token || !saveptr)
2919 token = strtok_r(NULL,
"/", &saveptr);
2920 if (!token || !saveptr)
2922 token = strtok_r(NULL,
"/", &saveptr);
2923 if (!token || !saveptr)
2925 token = strtok_r(NULL,
"/", &saveptr);
2926 if (!token || !saveptr)
2928 if (expect_prefix_len) {
2929 token = strtok_r(NULL,
"/", &saveptr);
2930 if (!token || !saveptr)
2933 token = strtok_r(NULL,
"/", &saveptr);
2936 return strtoul(token, NULL, 0);
2954 if (iq->
iq_type.compare(
"set") == 0) {
2955 if (iq->
action.compare(
"subscribe") == 0) {
2957 }
else if (iq->
action.compare(
"unsubscribe") == 0) {
2959 }
else if (iq->
action.compare(
"publish") == 0) {
2963 xml_node item = pugi->
FindNode(
"item");
2969 "EndOfRib marker received");
2974 for (; item; item = item.next_sibling()) {
2975 if (strcmp(item.name(),
"item") != 0)
continue;
2977 string id(iq->
as_node.c_str());
2978 char *str =
const_cast<char *
>(
id.c_str());
2980 char *af = strtok_r(str,
"/", &saveptr);
2981 char *safi = strtok_r(NULL,
"/", &saveptr);
3018 : xmpp_server_(xmpp_server),
3019 bgp_server_(server),
3020 queue_(
TaskScheduler::GetInstance()->GetTaskId(
"bgp::Config"), 0,
3023 asn_listener_id_(-1),
3024 identifier_listener_id_(-1),
3025 dscp_listener_id_(-1) {
3093 as_t old_local_asn) {
3095 BOOST_FOREACH(XmppChannelMap::value_type &i,
channel_map_) {
3096 i.second->rtarget_manager()->ASNUpdateCallback(old_asn, old_local_asn);
3111 BOOST_FOREACH(XmppChannelMap::value_type &i,
channel_map_) {
3112 i.second->RoutingInstanceCallback(vrf_name, op);
3117 tbb::mutex::scoped_lock lock(
mutex_);
3118 BOOST_FOREACH(XmppChannelMap::value_type &i,
channel_map_) {
3125 tbb::mutex::scoped_lock lock(
mutex_);
3126 BOOST_FOREACH(
const XmppChannelMap::value_type &i,
channel_map_) {
3132 BOOST_FOREACH(XmppChannelMap::value_type &i,
channel_map_) {
3133 if (i.second->ToString() == client) {
3165 tbb::mutex::scoped_lock lock(
mutex_);
3167 XmppChannelMap::iterator it =
channel_map_.find(channel);
3172 channel_map_.insert(make_pair(channel, bgp_xmpp_channel));
3174 make_pair(channel->
ToString(), bgp_xmpp_channel));
3178 "Received XmppChannel up event");
3183 "No BGP configuration for self - closing channel");
3184 if (!getenv(
"CONTRAIL_CAT_FRAMEWORK"))
3191 "BGP is administratively down - closing channel");
3195 bgp_xmpp_channel = (*it).second;
3207 "Graceful Closure in progress - Closing channel");
3220 bgp_xmpp_channel = (*it).second;
3224 "Received XmppChannel down event");
3227 bgp_xmpp_channel->
Close();
3230 os <<
"Peer not found for " << channel->
ToString() <<
3231 " on channel down event";
3238 PeerStatsInfo stats;
3241 XmppPeerInfoData peer_info;
3243 peer_info.set_peer_stats_info(stats);
3244 assert(!peer_info.get_name().empty());
3247 PeerStatsData peer_stats_data;
3249 peer_stats_data.set_encoding(
"XMPP");
3252 assert(!peer_stats_data.get_name().empty());
3253 BGP_UVE_SEND2(PeerStatsUve, peer_stats_data,
"ObjectXmppPeerInfo");
3261 bool change =
false;
3262 uint32_t num_xmpp =
count();
3263 if (first || num_xmpp != state->get_num_xmpp_peer()) {
3264 state->set_num_xmpp_peer(num_xmpp);
3269 if (first || num_up_xmpp != state->get_num_up_xmpp_peer()) {
3270 state->set_num_up_xmpp_peer(num_up_xmpp);
3275 if (first || num_deleting_xmpp != state->get_num_deleting_xmpp_peer()) {
3276 state->set_num_deleting_xmpp_peer(num_deleting_xmpp);
3332 peer_->SetPeerClosed(flag);
3339 return peer_->IsDeleted();
3346 return peer_->closed_at();
3350 SubscribedRoutingInstanceList::const_iterator it =
3353 return it->second.IsGrStale();
3357 SubscribedRoutingInstanceList::const_iterator it =
3360 return it->second.IsLlgrStale();
3369 SubscribedRoutingInstanceList::const_iterator it =
3372 return it->second.targets;
tbb::atomic< uint64_t > unreach
const bool IsDefault() const
virtual const XmppConnection * connection() const =0
virtual const IPeerDebugStats * peer_stats() const
static uint32_t GetMedFromLocalPref(uint32_t local_pref)
pugi::xml_node FindNode(const std::string &name)
bool VerifyMembership(const std::string &vrf_name, Address::Family family, BgpTable **table, int *instance_id, uint64_t *subscribed_at, bool *subscribe_pending, bool add_change)
virtual int GetTotalPathCount() const
boost::asio::ip::tcp::endpoint Endpoint
void UnRegisterConnectionEvent(xmps::PeerId)
void SetEntryCallback(TaskEntryCallback on_entry)
const RouteTargetList & GetImportList() const
const uint64_t GetExtCommunityValue() const
RibExportPolicy bgp_policy_
tbb::atomic< uint64_t > instance_unsubscribe
std::string StateName() const
const uint64_t GetExtCommunityValue() const
uint32_t GetEndOfRibSendTime() const
time_t eor_send_timer_start_time_
BgpTable * GetTable(Address::Family fmly)
Endpoint local_endpoint() const
void UnregisterAdminDownCallback(int listener)
int RegisterInstanceOpCallback(RoutingInstanceCb cb)
The TaskScheduler keeps track of what tasks are currently schedulable. When a task is enqueued it is ...
static std::string GetTableName(std::string instance_name, Address::Family fmly)
TypePtr Locate(Type *attr)
virtual string last_state_change_at() const
RoutingInstance * GetRoutingInstance(const std::string &name)
void Shutdown(bool delete_entries=true)
#define BGP_LOG_PEER_TABLE(peer, level, flags, tbl, arg)
uint64_t get_subscription_gen_id()
bool IsServerStartingUp() const
virtual void RegisterReceive(xmps::PeerId, ReceiveCb)=0
uint64_t peer_closed_at() const
virtual bool DeleteChannel(BgpXmppChannel *channel)
void StartEndOfRibReceiveTimer()
uint32_t NumUpPeer() const
void UnregisterASNUpdateCallback(int listener)
bool EndOfRibReceiveTimerExpired()
LabelBlockManagerPtr lb_mgr_
uint64_t closed_at() const
boost::scoped_ptr< PeerCloseManager > close_manager_
void incr_inet6_rx_bad_afi_safi_count()
virtual bool IsVpnTable() const
virtual boost::asio::ip::tcp::endpoint endpoint() const
const uint64_t GetExtCommunityValue() const
RoutingInstance * routing_instance()
BgpXmppChannelManager(XmppServer *, BgpServer *)
const uint64_t GetExtCommunityValue() const
static const char * kMasterInstance
void ClearEndOfRibState()
virtual bool SendUpdate(const uint8_t *msg, size_t msgsize)
boost::asio::ip::address IpAddress
bool IsInGRTimerWaitState() const
static Address::Family AfiSafiToFamily(uint16_t afi, uint8_t safi)
bool IsReadyForDeletion()
void FillCloseInfo(BgpNeighborResp *resp) const
BgpGlobalSystemConfig * global_config()
void SetQueueDisable(bool disabled)
virtual bool SendUpdate(const uint8_t *msg, size_t msgsize, const std::string *msg_str)
void set_peer_closed(bool flag)
void RoutingInstanceCallback(std::string vrf_name, int op)
uint16_t rd_cluster_seed() const
uint64_t get_inet6_rx_bad_prefix_count() const
void FillInstanceMembershipInfo(BgpNeighborResp *resp) const
#define BGP_LOG_PEER_WARNING(type, peer, flags, dir, arg)
virtual IPeerDebugStats * peer_stats()=0
boost::intrusive_ptr< LabelBlock > LabelBlockPtr
std::unique_ptr< DBRequestData > data
virtual BgpServer * server() const
void XMPPPeerInfoSend(const XmppPeerInfoData &peer_info) const
void incr_inet6_rx_bad_xml_token_count()
RoutingInstanceMgr * routing_instance_mgr()
virtual void GetRxRouteUpdateStats(UpdateStats *stats) const
virtual BgpProto::BgpPeerType PeerType() const
tbb::atomic< uint64_t > reach
#define BGP_UVE_SEND(type, object)
std::string ToXmppIdString() const
bool IsSubscriptionEmpty() const
tbb::atomic< uint64_t > total
virtual const string & ToString() const
bool Enqueue(DBRequest *req)
std::vector< BgpAttribute * > BgpAttrSpec
tbb::atomic< uint64_t > blocked_count
XmppServer * xmpp_server()
const std::string & name() const
TableMembershipRequestState * GetTableMembershipState(const std::string &table_name)
void LocatePathResolver()
tbb::atomic< int > primary_path_count_
virtual void Register(IPeer *peer, BgpTable *table, const RibExportPolicy &policy, int instance_id=-1)
virtual string ToString() const
virtual IPeerClose * peer_close() const
const RoutingInstance::RouteTargetList & GetSubscribedRTargets(RoutingInstance *instance) const
void SetDscpValue(uint8_t value)
bool ProcessItem(std::string vrf_name, const pugi::xml_node &node, bool add_change, int primary_instance_id=0)
virtual bool GetMembershipInfo(BgpTable *table, int *instance_id, uint64_t *subscribed_at, RequestType *req_type)
std::pair< const std::string, const std::string > VrfTableName
tbb::atomic< uint64_t > inet6_rx_bad_xml_token_count
bool EndOfRibSendTimerExpired()
void DeleteSubscriptionState(RoutingInstance *rt_instance)
void SetPeerClosed(bool closed)
int RegisterDSCPUpdateCallback(DSCPUpdateCb cb)
virtual Address::Family family() const =0
static const int kEndOfRibTime
virtual bool CanUseMembershipManager() const
uint32_t GetEndOfRibReceiveTime() const
bool IsReadyForDeletion()
size_t GetMembershipRequestQueueSize() const
virtual xmps::PeerState GetPeerState() const =0
virtual IPeerDebugStats * peer_stats()
tbb::atomic< uint64_t > close
BgpXmppChannel * FindChannel(const XmppChannel *channel)
void ProcessDeferredSubscribeRequest(RoutingInstance *rt_instance, const InstanceMembershipRequestState &imr_state)
int identifier_listener_id_
void Swap(DBRequest *rhs)
void RemoveChannel(XmppChannel *channel)
virtual int GetTaskInstance() const =0
int admin_down_listener_id_
tbb::atomic< int > total_path_count_
bool GetRegistrationInfo(const IPeer *peer, const BgpTable *table, int *instance_id=NULL, uint64_t *subscription_gen_id=NULL) const
int GetTaskId(const std::string &name)
uint64_t get_inet6_rx_bad_xml_token_count() const
virtual bool IsReady() const
const std::string & ToUVEKey() const
size_t GetQueueSize() const
PeerStats(BgpXmppChannel *peer)
void incr_inet6_rx_bad_nexthop_count()
RouteTableList & GetTables()
virtual bool IsXmppPeer() const
static void FillPeerUpdateStats(const IPeerDebugStats *peer_stats, PeerStatsData *peer_stats_data)
static bool regex_match(const std::string &input, const regex ®ex)
tbb::atomic< uint64_t > primary_path_count
virtual BgpXmppChannel * CreateChannel(XmppChannel *channel)
#define BGP_LOG_PEER_CRITICAL(type, peer, flags, dir, arg)
size_t table_membership_requests() const
tbb::atomic< uint64_t > table_subscribe_complete
virtual void GetRxSocketStats(IPeerDebugStats::SocketStats *stats) const
const uint64_t GetExtCommunityValue() const
#define BGP_LOG_PEER_INSTANCE_CRITICAL(peer, instance, dir, flags, arg)
boost::intrusive_ptr< const BgpAttr > BgpAttrPtr
virtual uint32_t bgp_identifier() const
void UnregisterTable(int line, BgpTable *table)
Ip4Address ip4_addr() const
virtual bool Send(const uint8_t *, size_t, xmps::PeerId, SendReadyCb)=0
void ASNUpdateCallback(as_t old_asn, as_t old_local_asn)
#define BGP_LOG_PEER_INSTANCE(peer, instance, level, flags, arg)
boost::scoped_ptr< BgpXmppPeerClose > peer_close_
XmppPeer(BgpServer *server, BgpXmppChannel *channel)
bool Send(const uint8_t *data, size_t size, const std::string *msg_str=NULL)
int RegisterIdentifierUpdateCallback(IdentifierUpdateCb callback)
virtual void RegisterReferer(xmps::PeerId)
static Inet6Prefix FromString(const std::string &str, boost::system::error_code *errorp=NULL)
std::unique_ptr< XmlBase > dom
void AddSubscriptionState(RoutingInstance *rt_instance, int index)
const bool IsDeleted() const
virtual time_t GetEndOfRibSendTime() const
virtual bool LastReceived(time_t duration) const =0
ErrorStats & error_stats()
#define BGP_LOG_FLAG_SYSLOG
virtual void Close(bool graceful)
tbb::atomic< uint64_t > inet6_bad_nexthop_count
InstanceMembershipRequestMap instance_membership_request_map_
virtual void GetRxErrorStats(RxErrorStats *stats) const
virtual std::string StateName() const =0
static const char * kEndOfRibMarker
virtual bool IsRegistrationRequired() const
void incr_inet6_rx_bad_prefix_count()
tbb::atomic< int32_t > deleting_count_
ExtCommunityDB * extcomm_db()
static TaskScheduler * GetInstance()
bool MembershipResponseHandler(std::string table_name)
virtual void GetTxSocketStats(IPeerDebugStats::SocketStats *stats) const
int GetPrimaryInstanceID(const std::string &s, bool expect_prefix_len) const
virtual string last_error() const
virtual void UpdatePrimaryPathCount(int count, Address::Family family) const
BgpConfigManager * config_manager()
void RegisterRibIn(IPeer *peer, BgpTable *table)
std::unique_ptr< DBRequestKey > key
std::string ToString() const
void MembershipRequestCallback(BgpTable *table)
static Ip4Prefix FromString(const std::string &str, boost::system::error_code *errorp=NULL)
virtual bool send_ready() const
#define BGP_LOG_PEER_INSTANCE_WARNING(peer, instance, flags, arg)
bool ProcessMvpnItem(std::string vrf_name, const pugi::xml_node &item, bool add_change)
WorkQueue< std::string > membership_response_worker_
virtual const string GetStateName() const
ChannelStats channel_stats_
int RegisterASNUpdateCallback(ASNUpdateCb callback)
void AddTableMembershipState(const std::string &table_name, TableMembershipRequestState tmr_state)
void SetIdentifier(Ip4Address identifier)
void STLDeleteElements(Container *container)
tbb::atomic< uint64_t > reach
boost::scoped_ptr< XmppPeer > peer_
virtual uint64_t num_flaps() const
#define CHECK_CONCURRENCY(...)
TunnelEncapType::Encap tunnel_encap() const
virtual string last_flap() const
bool ProcessEnetItem(std::string vrf_name, const pugi::xml_node &item, bool add_change)
tbb::atomic< uint64_t > end_of_rib
virtual void Unregister(IPeer *peer, BgpTable *table)
void FlushDeferQ(std::string vrf_name)
uint64_t get_inet6_rx_bad_afi_safi_count() const
void UpdateCloseRouteStats(Address::Family family, const BgpPath *old_path, uint32_t path_flags) const
bool DeleteTableMembershipState(const std::string &table_name)
SubscriptionState * GetSubscriptionState(RoutingInstance *rt_instance)
TcpSession::Endpoint remote_endpoint() const
virtual string last_event() const
void ClearAllConnections()
virtual void GetRxRouteStats(RxRouteStats *stats) const
void WriteReadyCb(const boost::system::error_code &ec)
bool IsCloseInProgress() const
virtual const InstanceMembershipRequestState * GetInstanceMembershipState(const std::string &instance) const
virtual const std::string & ToString() const =0
const BgpXmppChannelManager * manager() const
void CreateType7MvpnRouteRequest(IpAddress grp_address, IpAddress src_address, bool add_change, uint64_t subscription_gen_id, DBRequest &req)
virtual void GetRxProtoStats(ProtoStats *stats) const
const std::string & name() const
static RouteDistinguisher kZeroRd
tbb::atomic< uint64_t > subscription_gen_id_
virtual void UnRegisterReceive(xmps::PeerId)=0
std::string ToString() const
void ProcessPendingSubscriptions()
bool IsActiveChannel() const
bool DeleteInstanceMembershipState(const std::string &instance)
virtual void UpdateTxReachRoute(uint64_t count)
boost::scoped_ptr< BgpXmppRTargetManager > rtarget_manager_
static bool regex_search(const std::string &input, const regex ®ex)
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)
void DSCPUpdateCallback(uint8_t value)
void SetRegistrationInfo(const IPeer *peer, const BgpTable *table, int instance_id, uint64_t subscription_gen_id)
virtual void GetTxProtoStats(ProtoStats *stats) const
tbb::atomic< uint64_t > total_path_count
virtual void UpdateTxUnreachRoute(uint64_t count)
Ip6Address ip6_addr() const
static const int32_t kMaxVniSigned
XmppServer * xmpp_server_
void SetLabel(uint32_t label, const ExtCommunity *ext)
tbb::atomic< uint64_t > end_of_rib
void UnregisterInstanceOpCallback(int id)
const std::string & ToString() const
boost::asio::ip::address_v4 Ip4Address
void ReceiveEndOfRIB(Address::Family family)
std::map< std::string, BgpTable * > RouteTableList
virtual void XmppHandleChannelEvent(XmppChannel *channel, xmps::PeerState state)
TcpSession::Endpoint local_endpoint() const
bool HasSelfConfiguration() const
void UnregisterDSCPUpdateCallback(int listener)
void set_disable(bool disabled)
virtual void UpdateTotalPathCount(int count) const
void ProcessSubscriptionRequest(std::string rt_instance, const XmppStanza::XmppMessageIq *iq, bool add_change)
static void FillPeerDebugStats(const IPeerDebugStats *peer_stats, PeerStatsInfo *stats)
boost::asio::io_context * ioservice()
bool peer_deleted() const
static const int kEndOfRibSendRetryTime
tbb::atomic< uint64_t > inet6_bad_prefix_count
#define BGP_UVE_SEND2(type, object, arg)
BgpXmppChannelManager * manager_
uint32_t bgp_identifier() const
const io::SocketStats & GetSocketStats() const
int RegisterAdminDownCallback(AdminDownCb callback)
virtual bool MembershipPathCallback(DBTablePartBase *tpart, BgpRoute *rt, BgpPath *path)
void set_deleted(bool deleted)
static time_t UTCTimestamp()
const uint64_t GetExtCommunityValue() const
virtual bool LastSent(time_t duration) const =0
#define BGP_LOG_FLAG_TRACE
bool ProcessMembershipResponse(std::string table_name, TableMembershipRequestState *tmr_state)
bool CollectStats(BgpRouterState *state, bool first) const
void EndOfRibTimerErrorHandler(std::string error_name, std::string error_message)
static uint64_t UTCTimestampUsec()
XmppChannelMap channel_map_
time_t eor_receive_timer_start_time_
const uint64_t GetExtCommunityValue() const
void CreateType5MvpnRouteRequest(IpAddress grp_address, IpAddress src_address, bool add_change, uint64_t subscription_gen_id, int instance_id, DBRequest &req, const autogen::MvpnNextHopType &nh)
void AddInstanceMembershipState(const std::string &instance, InstanceMembershipRequestState imr_state)
virtual const std::string & ToUVEKey() const =0
bool IsSubscriptionLlgrStale(RoutingInstance *instance) const
tbb::atomic< uint64_t > unreach
void FillPeerInfo(const BgpXmppChannel *channel) const
PeerCloseManager * close_manager()
WorkQueue< BgpXmppChannel * > queue_
bool Start(int time, Handler handler, ErrorHandler error_handler=NULL)
bool skip_update_send_cached_
virtual const std::vector< std::string > GetDefaultTunnelEncap(Address::Family family) const
Endpoint remote_endpoint() const
bool XmppDecodeAddress(int af, const std::string &address, IpAddress *addrp, bool zero_ok=false)
bool IsRibOutRegistered(const IPeer *peer, const BgpTable *table) const
void StaleCurrentSubscriptions()
tbb::atomic< uint64_t > table_unsubscribe
tbb::atomic< uint64_t > open
tbb::atomic< uint64_t > keepalive
tbb::atomic< uint64_t > rt_updates
tbb::atomic< uint64_t > update
virtual int GetPrimaryPathCount() const
bool ProcessMcastItem(std::string vrf_name, const pugi::xml_node &item, bool add_change)
boost::function< void(BgpXmppChannel *)> VisitorFn
bool IsSubscriptionGrStale(RoutingInstance *instance) const
static bool stringToIntegerList(std::string input, std::string seperator, std::vector< NumberType > &entries)
tbb::atomic< uint64_t > table_unsubscribe_complete
bool IsRouterTypeBGPaaS() const
BgpMembershipManager * membership_mgr()
virtual BgpServer * server()
virtual string last_state() const
TableMembershipRequestMap table_membership_request_map_
bool ProcessInet6Item(std::string vrf_name, const pugi::xml_node &node, bool add_change)
RoutingInstance::RouteTargetList targets
std::string transport_address_string() const
virtual void UnRegisterWriteReady(xmps::PeerId id)=0
const XmppSession * GetSession() const
void IdentifierUpdateCallback(Ip4Address old_identifier)
int32_t deleting_count() const
void MembershipRequestCallback(BgpTable *table)
BgpXmppChannel(XmppChannel *channel, BgpServer *bgp_server=NULL, BgpXmppChannelManager *manager=NULL)
void PeerSendReady(IPeerUpdate *peer)
void VisitChannels(BgpXmppChannelManager::VisitorFn)
void ResetEndOfRibSendState()
tbb::atomic< uint64_t > inet6_bad_afi_safi_count
virtual bool IsAs4Supported() const
bool Reschedule(int time)
virtual TcpSession::Endpoint endpoint() const
uint64_t get_inet6_rx_bad_nexthop_count() const
SubscribedRoutingInstanceList routing_instances_
#define BGP_LOG_NOTICE(obj, flags,...)
tbb::atomic< uint64_t > inet6_bad_xml_token_count
tbb::atomic< uint64_t > calls
virtual void UnRegisterReferer(xmps::PeerId)
void LlgrStaleCurrentSubscriptions()
static SandeshLevel::type LoggingUtLevel()
virtual const string & ToUVEKey() const
void FillTableMembershipInfo(BgpNeighborResp *resp) const
void ClearStaledSubscription(RoutingInstance *rt_instance, SubscriptionState *sub_state)
static MacAddress FromString(const std::string &str, boost::system::error_code *error=NULL)
tbb::atomic< uint64_t > table_subscribe
virtual void ReceiveUpdate(const XmppStanza::XmppMessage *msg)
virtual void ProcessPathTunnelEncapsulation(const BgpPath *path, BgpAttr *attr, ExtCommunityDB *extcomm_db, const BgpTable *table) const
const XmppSession * session() const
void DequeueRequest(const std::string &table_name, DBRequest *request)
bool Enqueue(QueueEntryT entry)
void RoutingInstanceCallback(std::string vrf_name, int op)
const uint64_t GetExtCommunityValue() const
as_t autonomous_system() const
virtual ~BgpXmppChannelManager()
virtual bool IsInGRTimerWaitState() const
const XmppChannel * channel() const
std::set< RouteTarget > RouteTargetList
bool DeletePath(DBTablePartBase *root, BgpRoute *rt, BgpPath *path)
const std::string & ToUVEKey() const
void SweepCurrentSubscriptions()
void RegisterConnectionEvent(xmps::PeerId, ConnectionEventCb)
static const char * kBgpPeer
tbb::atomic< uint64_t > instance_subscribe
tbb::atomic< uint64_t > blocked_duration_usecs
XmppChannelNameMap channel_name_map_
static const char * kControlNodeJID
tbb::atomic< uint64_t > bytes
virtual void GetTxRouteUpdateStats(UpdateStats *stats) const
DBTableBase * FindTable(const std::string &name)
Timer * eor_receive_timer_
boost::scoped_ptr< PeerStats > peer_stats_
void decrement_deleting_count()
void RegisterTable(int line, BgpTable *table, const TableMembershipRequestState *tmr_state)
static bool DeleteTimer(Timer *Timer)
virtual IPeerClose * peer_close()
#define BGP_LOG_PEER(type, peer, level, flags, dir, arg)
void CreateConfigUpdater(BgpConfigManager *config_manager)
virtual ~BgpXmppChannel()