30 #include <pugixml/pugixml.hpp>
33 #include "controller/controller_types.h"
36 #include <xmpp_enet_types.h>
37 #include <xmpp_unicast_types.h>
38 #include <xmpp_multicast_types.h>
39 #include <xmpp_mvpn_types.h>
42 using namespace boost::asio;
45 using std::unique_ptr;
46 using std::stringstream;
48 using process::ConnectionType;
49 using process::ConnectionStatus;
56 bool is_type5 = mac.
IsZero();
57 size_t pos = str.find(
'/');
58 if (pos == string::npos) {
63 boost::system::error_code ec;
64 string plen_str = str.substr(pos + 1);
67 string addrstr = str.substr(0, pos);
68 boost::system::error_code ec1;
69 *addr = IpAddress::from_string(addrstr, ec1);
72 return atoi(plen_str.c_str());
74 if (plen_str ==
"32") {
77 if (ec || plen != 32) {
81 }
else if (plen_str ==
"128") {
84 if (ec || plen != 128) {
96 const std::string &xmpp_server,
97 const std::string &label_range,
99 : channel_(NULL), channel_str_(),
100 xmpp_server_(xmpp_server), label_range_(label_range),
101 xs_idx_(xs_idx), route_published_time_(0), agent_(agent) {
125 (
const std::string &vrf_name,
const IpAddress &prefix_addr) {
128 if (prefix_addr.is_v4()) {
130 }
else if (prefix_addr.is_v6()) {
133 if (rt_table == NULL) {
135 "Unable to fetch route table for prefix " +
136 prefix_addr.to_string());
142 (
const std::string &vrf_name,
const IpAddress &prefix_addr) {
145 if (prefix_addr.is_v4()) {
148 if (rt_table == NULL) {
150 "Unable to fetch route table for prefix " +
151 prefix_addr.to_string());
168 return "No BGP peer";
178 boost::system::error_code ec;
181 assert(ec.value() == 0);
186 const int prefix_len,
187 std::string vrf_name,
188 const Peer* bgp_peer) {
191 ip_address, prefix_len,
205 pugi::xml_node node =
pugi->FindNode(
"items");
206 pugi::xml_attribute attr = node.attribute(
"node");
209 strtok_r(
const_cast<char *
>(attr.value()),
"/", &saveptr);
210 strtok_r(NULL,
"/", &saveptr);
211 char *vrf_name = strtok_r(NULL,
"", &saveptr);
212 const std::string vrf(vrf_name);
216 if (rt_table == NULL) {
218 "Invalid VRF. Ignoring route retract" +
219 string(attr.value()));
223 pugi::xml_node node_check =
pugi->FindNode(
"retract");
224 if (!
pugi->IsNull(node_check)) {
225 for (node = node.first_child(); node; node = node.next_sibling()) {
226 if (strcmp(node.name(),
"retract") == 0) {
227 std::string
id = node.first_attribute().value();
229 "EVPN Delete Node id:" +
id);
231 boost::scoped_array<char> buff(
new char[
id.length() + 1]);
232 strcpy(buff.get(),
id.c_str());
245 uint32_t ethernet_tag = 0;
250 char *token = strtok_r(buff.get() + offset,
"-", &saveptr);
251 if ((strlen(saveptr) != 0) && token) {
252 ethernet_tag = atoi(token);
253 offset += strlen(token) + 1;
257 token = strtok_r(buff.get() + offset,
",", &saveptr);
258 if ((strlen(saveptr) == 0) || (token == NULL)) {
260 "Error parsing MAC from retract-id: " +
id);
264 boost::system::error_code ec;
268 "Error decoding MAC from retract-id: "+
id);
272 offset += strlen(token) + 1;
275 string str = buff.get() + offset;
276 size_t pos = str.find(
',');
277 if (pos != string::npos) {
278 string group_str = str.substr(pos + 1);
279 pos = group_str.find(
',');
280 if (pos == string::npos) {
283 string addrstr = group_str.substr(0, pos);
284 group = IpAddress::from_string(group_str, ec);
289 string source_str = str.substr(pos + 1);
290 source = IpAddress::from_string(source_str, ec);
300 "Error decoding IP address from "
309 group.to_v4(), source.to_v4(),
337 rt_table->
DeleteReq(bgp_peer, vrf_name, mac,
338 ip_addr, plen, ethernet_tag,
346 plen, vrf_name, bgp_peer);
356 if (EnetItemsType::XmlParseProperty(node, &xparser) ==
false) {
358 "Xml Parsing for evpn Failed");
362 EnetItemsType *items;
365 items = (
static_cast<EnetItemsType *
>(xparser.get()));
366 std::vector<EnetItemType>::iterator iter;
367 for (vector<EnetItemType>::iterator iter =items->item.begin();
368 iter != items->item.end(); iter++) {
371 boost::system::error_code ec;
374 group = IpAddress::from_string(item->entry.nlri.group, ec);
375 source = IpAddress::from_string(item->entry.nlri.source, ec);
381 "Error parsing address : " + item->entry.nlri.address);
392 if (
IsEcmp(item->entry.next_hops.next_hop)) {
394 vn_list.insert(item->entry.virtual_network);
397 AddEvpnRoute(vrf_name, item->entry.nlri.mac, ip_addr, plen, item);
404 pugi::xml_node node =
pugi->FindNode(
"items");
405 pugi::xml_attribute attr = node.attribute(
"node");
408 strtok_r(
const_cast<char *
>(attr.value()),
"/", &saveptr);
409 strtok_r(NULL,
"/", &saveptr);
410 char *vrf_name = strtok_r(NULL,
"", &saveptr);
411 const std::string vrf(vrf_name);
413 pugi::xml_node node_check =
pugi->FindNode(
"retract");
414 if (!
pugi->IsNull(node_check)) {
415 pugi->ReadNode(
"retract");
416 std::string retract_id =
pugi->ReadAttrib(
"id");
420 "Ignore retract request from non multicast tree "
421 "builder peer; Multicast Delete Node id:" + retract_id);
425 for (node = node.first_child(); node; node = node.next_sibling()) {
426 if (strcmp(node.name(),
"retract") == 0) {
427 std::string
id = node.first_attribute().value();
429 "Multicast Delete Node id:" +
id);
433 strtok_r(
const_cast<char *
>(
id.c_str()),
":", &saveptr);
434 strtok_r(NULL,
":", &saveptr);
435 char *group = strtok_r(NULL,
",", &saveptr);
436 char *source = strtok_r(NULL,
"", &saveptr);
437 if (group == NULL || source == NULL) {
439 "Error parsing multicast group address from retract id");
443 boost::system::error_code ec;
444 IpAddress g_address = IpAddress::from_string(group, ec);
445 if (ec.value() != 0) {
447 "Error parsing multicast group address");
451 IpAddress s_address = IpAddress::from_string(source, ec);
452 if (ec.value() != 0) {
454 "Error parsing multicast source address");
462 vrf, g_address.to_v4(),
463 s_address.to_v4(), 0, olist,
470 pugi::xml_node items_node =
pugi->FindNode(
"item");
471 if (!
pugi->IsNull(items_node)) {
472 pugi->ReadNode(
"item");
473 std::string item_id =
pugi->ReadAttrib(
"id");
477 "Ignore request from non multicast tree "
478 "builder peer; Multicast Delete Node:" + item_id);
485 if (McastItemsType::XmlParseProperty(node, &xparser) ==
false) {
487 "Xml Parsing for Multicast Message Failed");
491 McastItemsType *items;
494 items = (
static_cast<McastItemsType *
>(xparser.get()));
495 std::vector<McastItemType>::iterator items_iter;
496 boost::system::error_code ec;
497 for (items_iter = items->item.begin(); items_iter != items->item.end();
502 IpAddress g_address = IpAddress::from_string(item->entry.nlri.group, ec);
503 if (ec.value() != 0) {
505 "Error parsing multicast group address");
509 IpAddress s_address = IpAddress::from_string(item->entry.nlri.source, ec);
510 if (ec.value() != 0) {
512 "Error parsing multicast source address");
517 std::vector<McastNextHopType>::iterator iter;
518 for (iter = item->entry.olist.next_hop.begin();
519 iter != item->entry.olist.next_hop.end(); iter++) {
521 McastNextHopType nh = *iter;
522 IpAddress addr = IpAddress::from_string(nh.address, ec);
523 if (ec.value() != 0) {
525 "Error parsing next-hop address");
530 stringstream nh_label(nh.label);
533 GetTypeBitmap(nh.tunnel_encapsulation_list);
535 addr.to_v4(), encap));
539 IpAddress::from_string(item->entry.nlri.source_address, ec);
542 source_address.to_v4(),
548 vrf, g_address.to_v4(), s_address.to_v4(),
549 item->entry.nlri.source_label, olist,
556 pugi::xml_node node =
pugi->FindNode(
"items");
557 pugi::xml_attribute attr = node.attribute(
"node");
560 strtok_r(
const_cast<char *
>(attr.value()),
"/", &saveptr);
561 strtok_r(NULL,
"/", &saveptr);
562 char *vrf_name = strtok_r(NULL,
"", &saveptr);
563 const std::string vrf(vrf_name);
565 pugi::xml_node node_check =
pugi->FindNode(
"retract");
566 if (!
pugi->IsNull(node_check)) {
567 pugi->ReadNode(
"retract");
568 std::string retract_id =
pugi->ReadAttrib(
"id");
570 for (node = node.first_child(); node; node = node.next_sibling()) {
571 if (strcmp(node.name(),
"retract") == 0) {
572 std::string
id = node.first_attribute().value();
574 "Multicast Delete Node id:" +
id);
578 strtok_r(
const_cast<char *
>(
id.c_str()),
":", &saveptr);
579 strtok_r(NULL,
":", &saveptr);
580 char *group = strtok_r(NULL,
",", &saveptr);
581 char *source = strtok_r(NULL,
"", &saveptr);
582 if (group == NULL || source == NULL) {
584 "Error parsing multicast group address from retract id");
588 boost::system::error_code ec;
589 IpAddress g_address = IpAddress::from_string(group, ec);
590 if (ec.value() != 0) {
592 "Error parsing multicast group address");
596 IpAddress s_address = IpAddress::from_string(source, ec);
597 if (ec.value() != 0) {
599 "Error parsing multicast source address");
613 pugi::xml_node items_node =
pugi->FindNode(
"item");
614 if (!
pugi->IsNull(items_node)) {
615 pugi->ReadNode(
"item");
616 std::string item_id =
pugi->ReadAttrib(
"id");
620 "Ignore request from non multicast tree "
621 "builder peer; Multicast Delete Node:" + item_id);
628 if (MvpnItemsType::XmlParseProperty(node, &xparser) ==
false) {
630 "Xml Parsing for Multicast Message Failed");
634 MvpnItemsType *items;
637 items = (
static_cast<MvpnItemsType *
>(xparser.get()));
638 std::vector<MvpnItemType>::iterator items_iter;
639 boost::system::error_code ec;
640 for (items_iter = items->item.begin(); items_iter != items->item.end();
645 IpAddress g_address = IpAddress::from_string(item->entry.nlri.group, ec);
646 if (ec.value() != 0) {
648 "Error parsing multicast group address");
652 IpAddress s_address = IpAddress::from_string(item->entry.nlri.source, ec);
653 if (ec.value() != 0) {
655 "Error parsing multicast source address");
659 int route_type = item->entry.nlri.route_type;
660 if (route_type != 7) {
668 multicast_sequence_number());
674 pugi::xml_node node =
pugi->FindNode(
"items");
675 pugi::xml_attribute attr = node.attribute(
"node");
677 const char *af = NULL;
679 af = strtok_r(
const_cast<char *
>(attr.value()),
"/", &saveptr);
680 strtok_r(NULL,
"/", &saveptr);
681 char *vrf_name = strtok_r(NULL,
"", &saveptr);
686 FindActiveEntry(&vrf_key));
706 if (!
pugi->IsNull(node)) {
707 pugi::xml_node node_check =
pugi->FindNode(
"retract");
708 if (!
pugi->IsNull(node_check)) {
709 for (node = node.first_child(); node; node = node.next_sibling()) {
710 if (strcmp(node.name(),
"retract") == 0) {
711 std::string
id = node.first_attribute().value();
713 "Delete Node id:" +
id);
715 boost::system::error_code ec;
725 if (ec.value() != 0) {
727 "Error parsing v4 prefix for delete");
731 prefix_addr, prefix_len,
737 if (ec.value() != 0) {
739 "Error parsing v6 prefix for delete");
743 prefix_addr, prefix_len,
753 if (ItemsType::XmlParseProperty(node, &xparser) ==
false) {
755 "Xml Parsing Failed");
761 items = (
static_cast<ItemsType *
>(xparser.get()));
762 for (vector<ItemType>::iterator iter =items->item.begin();
763 iter != items->item.end();
766 boost::system::error_code ec;
773 if (ec.value() != 0) {
775 "Error parsing v4 route address");
778 AddRoute(vrf_name, prefix_addr, prefix_len, item);
783 if (ec.value() != 0) {
785 "Error parsing v6 route address");
788 AddRoute(vrf_name, prefix_addr, prefix_len, item);
791 "Error updating route, Unknown IP family");
800 pugi::xml_node node =
pugi->FindNode(
"items");
801 pugi::xml_attribute attr = node.attribute(
"node");
803 const char *af = NULL;
805 af = strtok_r(
const_cast<char *
>(attr.value()),
"/", &saveptr);
806 strtok_r(NULL,
"/", &saveptr);
807 char *vrf_name = strtok_r(NULL,
"", &saveptr);
812 FindActiveEntry(&vrf_key));
826 "Route Table not found");
830 if (!
pugi->IsNull(node)) {
832 pugi::xml_node node_check =
pugi->FindNode(
"retract");
833 if (!
pugi->IsNull(node_check)) {
834 for (node = node.first_child(); node; node = node.next_sibling()) {
835 if (strcmp(node.name(),
"retract") == 0) {
836 std::string
id = node.first_attribute().value();
838 "Delete Node id:" +
id);
840 boost::system::error_code ec;
845 if (ec.value() != 0) {
847 "Error parsing v4 prefix for delete");
852 prefix_addr, prefix_len,
863 if (ItemsType::XmlParseProperty(node, &xparser) ==
false) {
865 "Xml Parsing Failed");
871 items = (
static_cast<ItemsType *
>(xparser.get()));
872 for (vector<ItemType>::iterator iter =items->item.begin();
873 iter != items->item.end();
876 boost::system::error_code ec;
883 if (ec.value() != 0) {
885 "Error parsing v4 route address");
891 "Error updating route, Unknown IP family");
897 template <
typename TYPE>
901 if (item->entry.load_balance.load_balance_decision.empty() ||
902 item->entry.load_balance.load_balance_decision !=
904 ecmp_load_balance.
SetAll();
906 uint8_t field_list_size = item->entry.
907 load_balance.load_balance_fields.load_balance_field_list.size();
908 if (field_list_size == 0)
909 ecmp_load_balance.
SetAll();
911 for (uint32_t i = 0; i < field_list_size; i++) {
912 std::string field_type = item->entry.
913 load_balance.load_balance_fields.load_balance_field_list[i];
928 uint32_t prefix_len, ItemType *item,
937 if (rt_table == NULL) {
941 std::stringstream str;
942 str << prefix_addr.to_string();
949 rt_table, str.str());
954 prefix_addr, prefix_len,
960 prefix_addr, prefix_len, data);
973 FindActiveEntry(&vrf_key));
984 if (rt_table == NULL || rt_table->
vrf_entry() == NULL) {
988 std::stringstream str;
989 str << item->entry.nlri.ethernet_tag;
993 str << prefix_addr.to_string();
996 rt_table, str.str());
1002 item->entry.nlri.ethernet_tag,
1008 plen, item->entry.nlri.ethernet_tag, data);
1011 template <
typename TYPE>
1016 const std::string &prefix_str) {
1021 vn_list, ecmp_load_balance, tag_list,
1022 item, rt_table, prefix_str);
1027 EnetOlistType &olist,
1029 for (uint32_t i = 0; i < olist.next_hop.size(); i++) {
1030 boost::system::error_code ec;
1032 IpAddress::from_string(olist.next_hop[i].address,
1034 if (ec.value() != 0) {
1038 int label = olist.next_hop[i].label;
1040 GetTypeBitmap(olist.next_hop[i].tunnel_encapsulation_list);
1042 addr.to_v4(), encap));
1050 EnetItemType *item) {
1059 "add leaf evpn multicast route");
1062 "Error parsing next-hop address");
1066 "add evpn multicast route");
1069 "Error parsing next-hop address");
1074 ModifyEvpnMembers(
bgp_peer_id(), vrf_name, group.to_v4(),
1075 source.to_v4(), leaf_olist,
1076 item->entry.nlri.ethernet_tag,
1078 multicast_sequence_number());
1083 EnetItemType *item) {
1091 "add leaf evpn multicast route");
1094 "Error parsing next-hop address");
1098 "add evpn multicast route");
1101 "Error parsing next-hop address");
1106 ModifyTorMembers(
bgp_peer_id(), vrf_name, leaf_olist,
1107 item->entry.nlri.ethernet_tag,
1109 multicast_sequence_number());
1113 item->entry.nlri.ethernet_tag,
1115 multicast_sequence_number());
1119 uint32_t prefix_len,
1136 prefix_addr, prefix_len, data);
1147 if (prefix_addr == addr && prefix_len == 32 &&
1161 prefix_addr, prefix_len, nh,
1163 sg_list, tag_list, cl,
true);
1167 std::string mac_str,
1170 EnetItemType *item) {
1172 VrfKey vrf_key(vrf_name);
1175 FindActiveEntry(&vrf_key));
1178 "VRF not found, ignoring request");
1186 if (rt_table == NULL || rt_table->
vrf_entry() == NULL) {
1188 "Invalid VRF. Ignoring route");
1192 boost::system::error_code ec;
1199 string nexthop_addr = item->entry.next_hops.next_hop[0].address;
1200 IpAddress nh_ip = IpAddress::from_string(nexthop_addr, ec);
1201 uint32_t label = item->entry.next_hops.next_hop[0].label;
1203 (item->entry.next_hops.next_hop[0].tunnel_encapsulation_list);
1206 if (item->entry.local_preference != 0) {
1207 preference = item->entry.local_preference;
1209 PathPreference path_preference(item->entry.sequence_number, preference,
1216 mac.
ToString(), 0, nexthop_addr, label,
"");
1223 si_ref_vn == NULL) {
1227 vn_list.insert(item->entry.virtual_network);
1228 std::vector<std::string> peer_sources;
1229 for (
const auto &peer_addr : item->entry.peers.peer) {
1230 peer_sources.push_back(peer_addr);
1238 MacAddress(item->entry.next_hops.next_hop[0].mac),
1240 item->entry.security_group_list.security_group,
1253 "add remote evpn route");
1255 vn_list.insert(item->entry.virtual_network);
1262 vrf_name, nh_ip.to_v4(),
1264 MacAddress(item->entry.next_hops.next_hop[0].mac),
1266 item->entry.security_group_list.security_group,
1269 (item->entry.next_hops.next_hop.size() > 1),
1271 item->entry.etree_leaf);
1273 plen, item->entry.nlri.ethernet_tag, data);
1295 assert(routing_vrf != vrf);
1302 "Not a Routing VRF. Ignoring route");
1310 if (evpn_rt_table == NULL || evpn_rt_table->
vrf_entry() == NULL) {
1312 "Invalid Routing VRF. Ignoring route");
1321 if (evpn_rt == NULL) {
1323 "Local EVPN route not found, ignoring request");
1329 vn_list.insert(item->entry.virtual_network);
1336 item->entry.security_group_list.security_group,
1363 ip_addr, plen, item->entry.nlri.ethernet_tag);
1366 if (route == NULL) {
1368 "route not found, ignoring request");
1376 "nexthop not found, ignoring request");
1385 label, mac, ip_addr,
1386 item->entry.nlri.ethernet_tag,
1387 item->entry.virtual_network,
1396 "Invalid nexthop in evpn route");
1405 vn_list.insert(item->entry.virtual_network);
1412 label,
false, vn_list,
1415 Ip4Address(0), ecmp_load_balance,
false,
false,
1426 Ip4Address(0), ecmp_load_balance,
false,
false,
1431 ip_addr, item->entry.nlri.ethernet_tag,
1436 uint32_t prefix_len, ItemType *item,
1441 if (rt_table == NULL) {
1445 boost::system::error_code ec;
1446 string nexthop_addr = item->entry.next_hops.next_hop[0].address;
1447 uint32_t label = item->entry.next_hops.next_hop[0].label;
1448 IpAddress addr = IpAddress::from_string(nexthop_addr, ec);
1450 (item->entry.next_hops.next_hop[0].tunnel_encapsulation_list);
1451 if (ec.value() != 0) {
1453 "Error parsing nexthop ip address");
1459 if (item->entry.local_preference != 0) {
1460 preference = item->entry.local_preference;
1462 PathPreference path_preference(item->entry.sequence_number, preference,
1468 std::string vn_string;
1469 for (VnListType::const_iterator vnit = vn_list.begin();
1470 vnit != vn_list.end(); ++vnit) {
1471 vn_string += *vnit +
" ";
1474 prefix_addr.to_string(), prefix_len,
1475 addr.to_v4().to_string(), label, vn_string);
1477 if (item->entry.next_hops.next_hop[0].label ==
1482 item->entry.security_group_list.security_group,
1492 if (prefix_addr.to_v4() ==
Ip4Address(0) && prefix_len == 0) {
1521 vrf_name, addr.to_v4(), encap, label,
1523 item->entry.security_group_list.security_group,
1525 path_preference,
false, ecmp_load_balance,
1532 bool native_encap =
false;
1534 native_encap =
true;
1541 if ((mpls == NULL) || (mpls->
nexthop()
1544 gres_parameters().IsEnabled()) {
1548 (rt_table->
FindLPM(local_vm_route_key));
1556 LOG(DEBUG,
"Mpls lablel picked from interface nh for local vm route, received label: " << label);
1569 item->entry.security_group_list.security_group,
1574 ecmp_load_balance,
false,
false,
1577 prefix_addr, prefix_len,
1590 if (intrface == NULL) {
1605 item->entry.security_group_list.security_group,
1610 ecmp_load_balance,
false,
false,
1613 prefix_addr, prefix_len,
1617 if (!prefix_addr.is_v4()) {
1619 "MPLS label inet interface type not supported for non IPv4");
1629 prefix_addr.to_v4(), prefix_len,
1630 inet_interface_route);
1634 "MPLS label points to invalid interface type");
1642 const VlanNH *vlan_nh =
static_cast<const VlanNH *
>(nh);
1649 item->entry.security_group_list.security_group,
1670 if (!prefix_addr.is_v4()) {
1672 "VRF nexthop is not supported for non IPv4");
1678 item->entry.security_group_list.security_group,
1682 prefix_addr.to_v4(),
1689 "MPLS label points to invalid NH");
1694 uint32_t prefix_len, ItemType *item,
1699 if (rt_table == NULL) {
1707 boost::system::error_code ec;
1708 string nexthop_addr = item->entry.next_hops.next_hop[0].address;
1709 uint32_t label = item->entry.next_hops.next_hop[0].label;
1710 IpAddress addr = IpAddress::from_string(nexthop_addr, ec);
1712 if (ec.value() != 0) {
1714 "Error parsing nexthop ip address");
1720 if (item->entry.local_preference != 0) {
1721 preference = item->entry.local_preference;
1723 PathPreference path_preference(item->entry.sequence_number, preference,
1729 std::string vn_string;
1730 for (VnListType::const_iterator vnit = vn_list.begin();
1731 vnit != vn_list.end(); ++vnit) {
1732 vn_string += *vnit +
" ";
1735 prefix_addr.to_string(), prefix_len,
1736 addr.to_v4().to_string(), label, vn_string);
1744 vrf_name, addr.to_v4(),
1747 item->entry.security_group_list.security_group,
1749 path_preference,
false, ecmp_load_balance,
1756 template <
typename TYPE>
1758 if (nexthops.size() == 0)
1761 std::string address = nexthops[0].address;
1762 uint32_t label = nexthops[0].label;
1763 for (uint32_t index = 1; index < nexthops.size(); index++) {
1764 if (nexthops[index].address != address ||
1765 (uint32_t)nexthops[index].label != label) {
1773 template <
typename TYPE>
1775 for (uint32_t index = 0; index < nexthops.size(); index++) {
1776 vn_list->insert(nexthops[index].virtual_network);
1781 uint32_t prefix_len, ItemType *item) {
1782 if ((item->entry.next_hops.next_hop[0].label ==
1789 GetVnList(item->entry.next_hops.next_hop, &vn_list);
1790 if (
IsEcmp(item->entry.next_hops.next_hop)) {
1793 AddRemoteRoute(vrf_name, prefix_addr, prefix_len, item, vn_list);
1798 uint32_t prefix_len, ItemType *item,
1804 if (rt_table == NULL) {
1808 std::stringstream str;
1809 str << prefix_addr.to_string();
1816 rt_table, str.str());
1819 prefix_addr, prefix_len, data);
1822 uint32_t prefix_len, ItemType *item) {
1825 GetVnList(item->entry.next_hops.next_hop, &vn_list);
1826 if (
IsEcmp(item->entry.next_hops.next_hop)) {
1837 pugi->LoadXmlDoc(msg_pugi->
doc());
1852 pugi::xml_node node =
pugi->FindNode(
"items");
1859 pugi->ReadNode(
"items");
1860 std::string nodename =
pugi->ReadAttrib(
"node");
1862 const char *af = NULL, *safi = NULL, *vrf_name;
1863 char *str =
const_cast<char *
>(nodename.c_str());
1865 af = strtok_r(str,
"/", &saveptr);
1866 safi = strtok_r(NULL,
"/", &saveptr);
1872 "BGP peer not present, agentxmppchannel is inactive");
1903 "Error Route update, Unknown Address Family or safi");
1918 assert(agent_xmpp_channel);
1924 StartConfigCleanupTimer();
1930 bool xmpp_channel_found =
false;
1936 xmpp_channel_found =
true;
1940 return xmpp_channel_found;
1979 end_of_config_timer()->Start(peer);
2000 std::unique_ptr<XmlBase> dummy_dom;
2004 std::move(dummy_dom),
2034 "NULL",
"BGP peer ready.");
2046 "NULL",
"BGP peer set as config server.");
2057 if (agent_mcast_builder == NULL) {
2089 "NULL",
"BGP peer decommissioned for xmpp channel.");
2102 bool peer_is_config_server = (
agent_->
2104 bool peer_is_agent_mcast_builder = (agent_mcast_builder ==
this);
2107 if (peer_is_config_server) {
2120 "NOT_READY",
"NULL",
"BGP peer selected as"
2121 "config peer on decommission of old config "
2127 if (peer_is_agent_mcast_builder) {
2138 bool evaluate_new_mcast_builder =
2141 if (!evaluate_new_mcast_builder) {
2142 new_mcast_builder = NULL;
2144 "NULL",
"No elected Multicast Tree Builder");
2147 if (evaluate_new_mcast_builder) {
2154 "Peer elected Multicast Tree Builder");
2175 "NULL",
"Connection to Xmpp Server, Timed out");
2177 bool update_list =
false;
2180 for (; iter != end; iter++) {
2181 std::vector<string> server;
2182 boost::split(server, *iter, boost::is_any_of(
":"));
2185 if (iter+1 == end)
break;
2186 std::rotate(iter, iter+1, end);
2232 boost::scoped_ptr<XmlWriter> xml_writer(
new XmlWriter(&repr));
2242 pugi->AddNode(
"iq",
"");
2243 pugi->AddAttribute(
"type",
"set");
2248 pugi->AddAttribute(
"to", to);
2250 pugi->AddChildNode(
"pubsub",
"");
2251 pugi->AddAttribute(
"xmlns",
"http://jabber.org/protocol/pubsub");
2252 if (subscribe ==
true) {
2253 pugi->AddChildNode(
"subscribe",
"");
2255 pugi->AddChildNode(
"unsubscribe",
"");
2257 std::string vm(
"virtual-machine:");
2261 pugi->AddAttribute(
"node", vm);
2263 pugi->doc().print(*xml_writer,
"", pugi::format_default,
2264 pugi::encoding_utf8);
2268 if (peer->
SendUpdate(
reinterpret_cast<const uint8_t *
>(repr.c_str()),
2269 repr.length()) ==
false) {
2271 "VM subscribe Send Update deferred", vm,
"");
2280 boost::scoped_ptr<XmlWriter> xml_writer(
new XmlWriter(&repr));
2290 pugi->AddNode(
"iq",
"");
2291 pugi->AddAttribute(
"type",
"set");
2296 pugi->AddAttribute(
"to", to);
2298 pugi->AddChildNode(
"pubsub",
"");
2299 pugi->AddAttribute(
"xmlns",
"http://jabber.org/protocol/pubsub");
2300 pugi->AddChildNode(
"subscribe",
"");
2301 string node(
"virtual-router:");
2303 pugi->AddAttribute(
"node", node);
2305 pugi->doc().print(*xml_writer,
"", pugi::format_default,
2306 pugi::encoding_utf8);
2310 if (peer->
SendUpdate(
reinterpret_cast<const uint8_t *
>(repr.c_str()),
2311 repr.length()) ==
false) {
2313 "Config subscribe Send Update deferred", node,
"");
2321 static int req_id = 0;
2323 boost::scoped_ptr<XmlWriter> xml_writer(
new XmlWriter(&repr));
2329 subscribe ?
"Subscribe" :
"Unsubscribe");
2334 pugi->AddNode(
"iq",
"");
2335 pugi->AddAttribute(
"type",
"set");
2340 pugi->AddAttribute(
"to", to);
2342 stringstream request_id;
2343 request_id <<
"subscribe" << req_id++;
2344 pugi->AddAttribute(
"id", request_id.str());
2345 pugi->AddChildNode(
"pubsub",
"");
2346 pugi->AddAttribute(
"xmlns",
"http://jabber.org/protocol/pubsub");
2348 pugi->AddChildNode(
"subscribe",
"");
2350 pugi->AddChildNode(
"unsubscribe",
"");
2353 pugi->AddChildNode(
"options",
"" );
2354 stringstream vrf_id;
2355 vrf_id << vrf->
rd();
2356 pugi->AddChildNode(
"instance-id", vrf_id.str());
2358 pugi->doc().print(*xml_writer,
"", pugi::format_default,
2359 pugi::encoding_utf8);
2361 if (peer->
SendUpdate(
reinterpret_cast<const uint8_t *
>(repr.c_str()),
2362 repr.length()) ==
false) {
2364 "Vrf subscribe Send Update deferred", vrf_id.str(),
"");
2373 if (ecmp_load_balance.
AllSet())
2377 item.entry.load_balance.load_balance_fields.load_balance_field_list);
2385 uint32_t mpls_label,
2391 uint32_t native_vrf_id) {
2393 const std::string vrf_name = route->
vrf()->
GetName();
2403 boost::scoped_ptr<XmlWriter> xml_writer(
new XmlWriter(&repr));
2423 item.entry.nlri.address = rstr.str();
2428 autogen::NextHopType nh;
2431 nh.label = mpls_label;
2438 nh.tunnel_encapsulation_list.tunnel_encapsulation.push_back(
"gre");
2441 nh.tunnel_encapsulation_list.tunnel_encapsulation.push_back(
"udp");
2444 nh.tunnel_encapsulation_list.tunnel_encapsulation.push_back(
"vxlan");
2451 nh.tunnel_encapsulation_list.tunnel_encapsulation.push_back(
"native");
2454 if (tag_list && tag_list->size()) {
2455 nh.tag_list.tag = *tag_list;
2456 nh.is_new_tags_list =
true;
2458 const InterfaceNH *interface_nh = loc_vm_path !=
nullptr ?
2461 const VmInterface *vm_interface = interface_nh !=
nullptr ?
2464 if (vm_interface !=
nullptr &&
2466 nh.is_new_tags_list =
false;
2467 for (
auto &tag : nh.tag_list.tag) {
2468 tag = (0x00000000FFFF & tag) |
2469 ((0xFFFF00000000 & tag) >> 16);
2475 nh.local_sequence_number = path_preference.
loc_sequence();
2478 for (VnListType::const_iterator vnit = vn_list.begin();
2479 vnit != vn_list.end(); ++vnit) {
2480 nh.virtual_network = *vnit;
2481 item.entry.next_hops.next_hop.push_back(nh);
2484 if (sg_list && sg_list->size()) {
2485 item.entry.security_group_list.security_group = *sg_list;
2488 if (communities && !communities->empty()) {
2489 item.entry.community_tag_list.community_tag = *communities;
2493 item.entry.version = 1;
2497 item.entry.sequence_number = path_preference.
sequence();
2498 item.entry.local_preference = path_preference.
preference();
2500 pugi->AddNode(
"iq",
"");
2501 pugi->AddAttribute(
"type",
"set");
2507 pugi->AddAttribute(
"to", to);
2509 stringstream pubsub_id;
2510 pubsub_id <<
"pubsub" << id;
2511 pugi->AddAttribute(
"id", pubsub_id.str());
2513 pugi->AddChildNode(
"pubsub",
"");
2514 pugi->AddAttribute(
"xmlns",
"http://jabber.org/protocol/pubsub");
2515 pugi->AddChildNode(
"publish",
"");
2518 stringstream ss_node;
2519 ss_node << item.entry.nlri.af <<
"/"
2520 << item.entry.nlri.safi <<
"/"
2524 ss_node <<
"/" << native_vrf_id;
2526 std::string node_id(ss_node.str());
2527 pugi->AddAttribute(
"node", node_id);
2528 pugi->AddChildNode(
"item",
"");
2530 pugi::xml_node node =
pugi->FindNode(
"item");
2535 pugi->doc().print(*xml_writer,
"", pugi::format_default,
2536 pugi::encoding_utf8);
2538 SendUpdate(
reinterpret_cast<const uint8_t *
>(repr.c_str()), repr.length());
2541 pugi->DeleteNode(
"pubsub");
2542 pugi->ReadNode(
"iq");
2544 stringstream collection_id;
2545 collection_id <<
"collection" <<
id++;
2546 pugi->ModifyAttribute(
"id", collection_id.str());
2547 pugi->AddChildNode(
"pubsub",
"");
2548 pugi->AddAttribute(
"xmlns",
"http://jabber.org/protocol/pubsub");
2549 pugi->AddChildNode(
"collection",
"");
2553 pugi->AddChildNode(
"associate",
"");
2555 pugi->AddChildNode(
"dissociate",
"");
2557 pugi->AddAttribute(
"node", node_id);
2559 pugi->doc().print(*xml_writer,
"", pugi::format_default,
2560 pugi::encoding_utf8);
2562 SendUpdate(
reinterpret_cast<const uint8_t *
>(repr.c_str()), repr.length());
2568 stringstream &node_id,
2571 const std::string &vn,
2576 uint32_t tunnel_bmap,
2577 const std::string &destination,
2578 const std::string &source,
2585 if ((path == NULL) && (associate)) {
2588 "OVS path not found for ff:ff:ff:ff:ff:ff, skip send");
2593 item.entry.sequence_number = 0;
2594 item.entry.replicator_address = source;
2599 item.entry.nlri.mac = rstr.str();
2600 item.entry.assisted_replication_supported =
false;
2601 item.entry.edge_replication_not_supported =
false;
2606 rstr << destination;
2608 item.entry.nlri.ethernet_tag = 0;
2609 if (associate ==
false)
2610 item.entry.nlri.ethernet_tag = label;
2612 item.entry.nlri.address = rstr.str();
2613 assert(item.entry.nlri.address !=
"0.0.0.0");
2615 autogen::EnetNextHopType nh;
2617 nh.address = destination;
2620 node_id << item.entry.nlri.af <<
"/" << item.entry.nlri.safi <<
"/"
2621 << route->
ToString() <<
"," << item.entry.nlri.address;
2630 nh.tunnel_encapsulation_list.tunnel_encapsulation.push_back(
"gre");
2633 nh.tunnel_encapsulation_list.tunnel_encapsulation.push_back(
"udp");
2638 item.entry.nlri.ethernet_tag = nh.label;
2642 nh.tunnel_encapsulation_list.tunnel_encapsulation.push_back(
"vxlan");
2645 if (sg_list && sg_list->size()) {
2646 item.entry.security_group_list.security_group = *sg_list;
2649 if (tag_list && tag_list->size()) {
2650 nh.tag_list.tag = *tag_list;
2654 item.entry.next_hops.next_hop.push_back(nh);
2663 stringstream &node_id,
2666 const std::string &vn,
2671 uint32_t tunnel_bmap,
2674 bool assisted_replication) {
2677 item.entry.sequence_number = 0;
2679 item.entry.edge_replication_not_supported =
true;
2681 item.entry.edge_replication_not_supported =
false;
2687 rstr <<
"0.0.0.0/32";
2688 item.entry.nlri.address = rstr.str();
2689 assert(item.entry.nlri.address !=
"0.0.0.0");
2692 if (assisted_replication) {
2694 item.entry.assisted_replication_supported =
true;
2695 node_id << item.entry.nlri.af <<
"/" << item.entry.nlri.safi <<
"/"
2696 << route->
ToString() <<
"," << item.entry.nlri.address
2701 item.entry.assisted_replication_supported =
false;
2702 node_id << item.entry.nlri.af <<
"/" << item.entry.nlri.safi <<
"/"
2716 item.entry.nlri.mac = mac.
ToString();
2719 item.entry.nlri.flags =
2725 item.entry.nlri.mac = route->
ToString();
2728 autogen::EnetNextHopType nh;
2730 nh.address = nh_ip->to_string();
2734 item.entry.nlri.ethernet_tag = route->
vrf()->
isid();
2735 if (associate ==
false) {
2739 item.entry.nlri.ethernet_tag = label;
2748 nh.tunnel_encapsulation_list.tunnel_encapsulation.push_back(
"gre");
2751 nh.tunnel_encapsulation_list.tunnel_encapsulation.push_back(
"udp");
2759 item.entry.nlri.ethernet_tag = nh.label;
2763 nh.tunnel_encapsulation_list.tunnel_encapsulation.push_back(
"vxlan");
2766 if (sg_list && sg_list->size()) {
2767 item.entry.security_group_list.security_group = *sg_list;
2771 item.entry.next_hops.next_hop.push_back(nh);
2779 stringstream &node_id,
2782 const std::string &vn,
2787 uint32_t tunnel_bmap,
2793 item.entry.local_preference = path_preference.
preference();
2794 item.entry.sequence_number = path_preference.
sequence();
2795 item.entry.assisted_replication_supported =
false;
2796 item.entry.edge_replication_not_supported =
false;
2802 item.entry.nlri.mac = rstr.str();
2810 item.entry.nlri.ethernet_tag = evpn_route->
ethernet_tag();
2812 item.entry.nlri.address = rstr.str();
2813 assert(item.entry.nlri.address !=
"0.0.0.0");
2815 item.entry.etree_leaf =
true;
2817 item.entry.etree_leaf = active_path->
etree_leaf();
2820 autogen::EnetNextHopType nh;
2822 nh.address = nh_ip->to_string();
2834 nh.tunnel_encapsulation_list.tunnel_encapsulation.push_back(
"gre");
2837 nh.tunnel_encapsulation_list.tunnel_encapsulation.push_back(
"udp");
2841 nh.label = active_path->
vxlan_id();
2845 nh.tunnel_encapsulation_list.tunnel_encapsulation.push_back(
"vxlan");
2848 if (sg_list && sg_list->size()) {
2849 item.entry.security_group_list.security_group = *sg_list;
2852 if (tag_list && tag_list->size()) {
2853 nh.tag_list.tag = *tag_list;
2854 nh.is_new_tags_list =
true;
2855 const InterfaceNH *interface_nh = active_path !=
nullptr ?
2858 const VmInterface *vm_interface = interface_nh !=
nullptr ?
2862 if (vm_interface !=
nullptr &&
2864 nh.is_new_tags_list =
false;
2865 for (
auto &tag : nh.tag_list.tag) {
2866 tag = (0x00000000FFFF & tag) |
2867 ((0xFFFF00000000 & tag) >> 16);
2873 nh.local_sequence_number = path_preference.
loc_sequence();
2877 item.entry.next_hops.next_hop.push_back(nh);
2882 node_id << item.entry.nlri.af <<
"/" << item.entry.nlri.safi <<
"/"
2888 stringstream &ss_node,
2893 boost::scoped_ptr<XmlWriter> xml_writer(
new XmlWriter(&repr));
2899 pugi->AddNode(
"iq",
"");
2900 pugi->AddAttribute(
"type",
"set");
2906 pugi->AddAttribute(
"to", to);
2908 stringstream pubsub_id;
2909 pubsub_id <<
"pubsub_l2" << id;
2910 pugi->AddAttribute(
"id", pubsub_id.str());
2912 pugi->AddChildNode(
"pubsub",
"");
2913 pugi->AddAttribute(
"xmlns",
"http://jabber.org/protocol/pubsub");
2914 pugi->AddChildNode(
"publish",
"");
2916 std::string node_id(ss_node.str());
2917 pugi->AddAttribute(
"node", node_id);
2918 pugi->AddChildNode(
"item",
"");
2920 pugi::xml_node node =
pugi->FindNode(
"item");
2925 pugi->doc().print(*xml_writer,
"", pugi::format_default,
2926 pugi::encoding_utf8);
2928 SendUpdate(
reinterpret_cast<const uint8_t *
>(repr.c_str()), repr.length());
2931 pugi->DeleteNode(
"pubsub");
2932 pugi->ReadNode(
"iq");
2934 stringstream collection_id;
2935 collection_id <<
"collection_l2" <<
id++;
2936 pugi->ModifyAttribute(
"id", collection_id.str());
2937 pugi->AddChildNode(
"pubsub",
"");
2938 pugi->AddAttribute(
"xmlns",
"http://jabber.org/protocol/pubsub");
2939 pugi->AddChildNode(
"collection",
"");
2943 pugi->AddChildNode(
"associate",
"");
2945 pugi->AddChildNode(
"dissociate",
"");
2947 pugi->AddAttribute(
"node", node_id);
2949 pugi->doc().print(*xml_writer,
"", pugi::format_default,
2950 pugi::encoding_utf8);
2952 SendUpdate(
reinterpret_cast<const uint8_t *
>(repr.c_str()), repr.length());
2964 uint32_t tunnel_bmap,
2965 const std::string &destination,
2966 const std::string &source,
2971 stringstream ss_node;
2982 sg_list, tag_list, communities,
2983 label, tunnel_bmap, associate,
2992 sg_list, tag_list, communities, label,
2993 tunnel_bmap, destination, source,
2994 associate) ==
false)
3009 sg_list, tag_list, communities, label,
3010 tunnel_bmap, associate,
3018 tag_list, communities, label, tunnel_bmap,
3019 path_preference, associate) ==
false)
3029 autogen::McastItemType item;
3031 boost::scoped_ptr<XmlWriter> xml_writer(
new XmlWriter(&repr));
3036 "Peer not elected Multicast Tree Builder");
3053 autogen::McastNextHopType item_nexthop;
3056 item_nexthop.address = rtr;
3058 item_nexthop.tunnel_encapsulation_list.tunnel_encapsulation.push_back(
"gre");
3059 item_nexthop.tunnel_encapsulation_list.tunnel_encapsulation.push_back(
"udp");
3060 item.entry.next_hops.next_hop.push_back(item_nexthop);
3063 pugi->AddNode(
"iq",
"");
3064 pugi->AddAttribute(
"type",
"set");
3069 pugi->AddAttribute(
"to", to);
3071 std::string pubsub_id(
"pubsub_b");
3072 stringstream str_id;
3074 pubsub_id += str_id.str();
3075 pugi->AddAttribute(
"id", pubsub_id);
3077 pugi->AddChildNode(
"pubsub",
"");
3078 pugi->AddAttribute(
"xmlns",
"http://jabber.org/protocol/pubsub");
3079 pugi->AddChildNode(
"publish",
"");
3080 stringstream ss_node;
3081 ss_node << item.entry.nlri.af <<
"/"
3082 << item.entry.nlri.safi <<
"/"
3085 std::string node_id(ss_node.str());
3086 pugi->AddAttribute(
"node", node_id);
3087 pugi->AddChildNode(
"item",
"");
3089 pugi::xml_node node =
pugi->FindNode(
"item");
3094 pugi->doc().print(*xml_writer,
"", pugi::format_default,
3095 pugi::encoding_utf8);
3097 SendUpdate(
reinterpret_cast<const uint8_t *
>(repr.c_str()), repr.length());
3100 pugi->DeleteNode(
"pubsub");
3101 pugi->ReadNode(
"iq");
3103 stringstream collection_id;
3104 collection_id <<
"collection" <<
id++;
3105 pugi->ModifyAttribute(
"id", collection_id.str());
3106 pugi->AddChildNode(
"pubsub",
"");
3107 pugi->AddAttribute(
"xmlns",
"http://jabber.org/protocol/pubsub");
3108 pugi->AddChildNode(
"collection",
"");
3112 pugi->AddChildNode(
"associate",
"");
3114 pugi->AddChildNode(
"dissociate",
"");
3116 pugi->AddAttribute(
"node", node_id);
3118 pugi->doc().print(*xml_writer,
"", pugi::format_default,
3119 pugi::encoding_utf8);
3121 SendUpdate(
reinterpret_cast<const uint8_t *
>(repr.c_str()), repr.length());
3142 boost::scoped_ptr<XmlWriter> xml_writer(
new XmlWriter(&repr));
3156 item.entry.nlri.route_type = 7;
3160 item.entry.next_hop.address = rtr;
3161 item.entry.next_hop.label = 0;
3164 pugi->AddNode(
"iq",
"");
3165 pugi->AddAttribute(
"type",
"set");
3170 pugi->AddAttribute(
"to", to);
3172 std::string pubsub_id(
"pubsub_b");
3173 stringstream str_id;
3175 pubsub_id += str_id.str();
3176 pugi->AddAttribute(
"id", pubsub_id);
3178 pugi->AddChildNode(
"pubsub",
"");
3179 pugi->AddAttribute(
"xmlns",
"http://jabber.org/protocol/pubsub");
3180 pugi->AddChildNode(
"publish",
"");
3181 stringstream ss_node;
3182 ss_node << item.entry.nlri.af <<
"/"
3183 << item.entry.nlri.safi <<
"/"
3186 std::string node_id(ss_node.str());
3187 pugi->AddAttribute(
"node", node_id);
3188 pugi->AddChildNode(
"item",
"");
3190 pugi::xml_node node =
pugi->FindNode(
"item");
3195 pugi->doc().print(*xml_writer,
"", pugi::format_default,
3196 pugi::encoding_utf8);
3198 SendUpdate(
reinterpret_cast<const uint8_t *
>(repr.c_str()), repr.length());
3201 pugi->DeleteNode(
"pubsub");
3202 pugi->ReadNode(
"iq");
3204 stringstream collection_id;
3205 collection_id <<
"collection" <<
id++;
3206 pugi->ModifyAttribute(
"id", collection_id.str());
3207 pugi->AddChildNode(
"pubsub",
"");
3208 pugi->AddAttribute(
"xmlns",
"http://jabber.org/protocol/pubsub");
3209 pugi->AddChildNode(
"collection",
"");
3213 pugi->AddChildNode(
"associate",
"");
3215 pugi->AddChildNode(
"dissociate",
"");
3217 pugi->AddAttribute(
"node", node_id);
3219 pugi->doc().print(*xml_writer,
"", pugi::format_default,
3220 pugi::encoding_utf8);
3222 SendUpdate(
reinterpret_cast<const uint8_t *
>(repr.c_str()), repr.length());
3232 uint32_t tunnel_bmap,
3236 const std::string &destination,
3237 const std::string &source,
3240 if (!peer)
return false;
3263 const std::string &destination,
3264 const std::string &source,
3265 uint32_t tunnel_bmap) {
3266 if (!peer)
return false;
3298 uint32_t native_vrf_id)
3300 if (!peer)
return false;
3312 sg_list, tag_list, communities, label,
3313 bmap, path_preference,
true,
3314 type, ecmp_load_balance, native_vrf_id);
3319 vn = *vn_list.begin();
3321 sg_list, tag_list, communities, label,
3323 path_preference,
true);
3340 if (!peer)
return false;
3352 sg_list, tag_list, communities,
3365 vn = *vn_list.begin();
3367 vn, NULL, NULL, NULL,
3368 label, bmap,
"",
"",
3369 path_preference,
false);
3376 if (!peer)
return false;
3391 if (!peer)
return false;
3408 if (
agent()->mulitcast_builder() ==
this) {
3410 controller()->multicast_sequence_number());
3425 msg +=
"\n<message from=\"";
3432 msg +=
"\n\t<event xmlns=\"http://jabber.org/protocol/pubsub\">";
3435 msg +=
"\n\t</event>\n</message>\n";
3448 boost::asio::ip::tcp::endpoint ep;
3449 boost::system::error_code ec;
3450 string last_state_name;
3456 ep.address().to_string();
3463 ConnectionStatus::UP, ep,
3467 ConnectionStatus::DOWN, ep,
3485 template <
typename TYPE>
3488 bool new_tags = item->entry.next_hops.next_hop[0].is_new_tags_list;
3489 tag_list = item->entry.next_hops.next_hop[0].tag_list.tag;
3490 std::sort(tag_list.begin(), tag_list.end());
3494 for (
auto &tag : tag_list) {
3495 tag = (0x0000FFFF & tag) | ((0xFFFF0000 & tag) << 16);
boost::system::error_code Inet6PrefixParse(const string &str, Ip6Address *addr, int *plen)
boost::system::error_code Ip4PrefixParse(const string &str, Ip4Address *addr, int *plen)
boost::asio::ip::address_v6 Ip6Address
boost::asio::ip::address IpAddress
boost::asio::ip::address_v4 Ip4Address
IpAddress AddressFromString(const std::string &ip_address_str, boost::system::error_code *ec)
std::vector< uint64_t > TagList
std::vector< int > SecurityGroupList
std::vector< Ip4Address > AddressList
std::set< std::string > VnListType
std::vector< std::string > CommunityList
void NotifyAll(AgentXmppChannel *peer)
static uint64_t NewSeqNumber()
ConfigCleanupTimer * config_cleanup_timer()
EndOfConfigTimer * end_of_config_timer()
bool mvpn_ipv4_enable() const
TunnelType::Type tunnel_type() const
NextHop * nexthop() const
uint32_t GetActiveLabel() const
uint32_t vxlan_id() const
virtual const PrefixType & prefix_address() const
Returns the value of a stored prefix address (IPv4, IPv6 or MAC address)
Agent supports multiple route tables - Inet-unicast (IPv4/IPv6), Inet-multicast, bridge,...
VrfEntry * vrf_entry() const
AgentRoute * FindActiveEntry(const AgentRouteKey *key)
Base class for all Route entries in agent.
AgentPath * GetLocalVmPortPath() const
const AgentPath * FindIntfOrCompLocalVmPortPath() const
Finds path to an interface or a composite of interfaces and returns it. The priority is given to comp...
virtual const std::string GetSourceAddressString() const =0
virtual const std::string GetAddressString() const =0
virtual std::string ToString() const =0
bool is_multicast() const
virtual AgentPath * FindPath(const Peer *peer) const
const std::string & intf_route_type() const
virtual Agent::RouteTableType GetTableType() const =0
AgentPath * FindLocalVmPortPath() const
void incr_xmpp_in_msgs(uint8_t idx)
void incr_xmpp_reconnects(uint8_t idx)
void incr_xmpp_out_msgs(uint8_t idx)
static bool ControllerSendMcastRouteDelete(AgentXmppChannel *peer, AgentRoute *route)
void AddEvpnEcmpRoute(std::string vrf_name, const MacAddress &mac, const IpAddress &ip, uint32_t plen, autogen::EnetItemType *item, const VnListType &vn_list)
LlgrStaleTimer * llgr_stale_timer()
static bool ControllerSendEvpnRouteDelete(AgentXmppChannel *peer, AgentRoute *route, std::string vn, uint32_t mpls_label, const std::string &destination, const std::string &source, uint32_t tunnel_bmap)
ControllerEcmpRoute * BuildEcmpData(TYPE *item, const VnListType &vn_list, const EcmpLoadBalance &ecmp_load_balance, const AgentRouteTable *rt_table, const std::string &prefix_str)
virtual bool SendUpdate(const uint8_t *msg, size_t msgsize)
bool ControllerSendIPMcastRouteCommon(AgentRoute *route, bool associate)
virtual void ReceiveV4V6Update(XmlPugi *pugi)
void AddMulticastEvpnRoute(const std::string &vrf_name, const IpAddress &source, const IpAddress &group, autogen::EnetItemType *item)
bool ControllerSendMvpnRouteCommon(AgentRoute *route, bool associate)
void AddMplsRoute(std::string vrf_name, IpAddress ip, uint32_t plen, autogen::ItemType *item)
static bool ControllerSendCfgSubscribe(AgentXmppChannel *peer)
bool BuildTorMulticastMessage(autogen::EnetItemType &item, std::stringstream &node_id, AgentRoute *route, const Ip4Address *nh_ip, const std::string &vn, const SecurityGroupList *sg_list, const TagList *tag_list, const CommunityList *communities, uint32_t label, uint32_t tunnel_bmap, const std::string &destination, const std::string &source, bool associate)
void BuildTagList(const TYPE *item, TagList &tag_list)
uint8_t GetXmppServerIdx()
void StartEndOfRibTxWalker()
static void XmppClientChannelEvent(AgentXmppChannel *peer, xmps::PeerState state)
bool BuildEvpnMulticastMessage(autogen::EnetItemType &item, std::stringstream &node_id, AgentRoute *route, const Ip4Address *nh_ip, const std::string &vn, const SecurityGroupList *sg_list, const TagList *tag_list, const CommunityList *communities, uint32_t label, uint32_t tunnel_bmap, bool associate, const AgentPath *path, bool assisted_replication)
virtual void ReceiveMulticastUpdate(XmlPugi *pugi)
EndOfRibRxTimer * end_of_rib_rx_timer()
void AddRemoteMplsRoute(std::string vrf_name, IpAddress ip, uint32_t plen, autogen::ItemType *item, const VnListType &vn_list)
uint64_t sequence_number() const
virtual std::string ToString() const
void AddRemoteRoute(std::string vrf_name, IpAddress prefix_addr, uint32_t prefix_len, autogen::ItemType *item, const VnListType &vn_list)
XmppChannel * GetXmppChannel()
static bool SetConfigPeer(AgentXmppChannel *peer)
static bool IsBgpPeerActive(const Agent *agent, AgentXmppChannel *peer)
void AddInetMplsEcmpRoute(std::string vrf_name, IpAddress ip, uint32_t plen, autogen::ItemType *item, const VnListType &vn_list)
static void CleanConfigStale(AgentXmppChannel *agent_xmpp_channel)
bool BuildAndSendEvpnDom(autogen::EnetItemType &item, std::stringstream &ss_node, const AgentRoute *route, bool associate)
static bool ControllerSendRouteDelete(AgentXmppChannel *peer, AgentRoute *route, const VnListType &vn_list, uint32_t label, uint32_t tunnel_bmap, const SecurityGroupList *sg_list, const TagList *tag_list, const CommunityList *communities, Agent::RouteTableType type, const PathPreference &path_preference)
virtual void ReceiveUpdate(const XmppStanza::XmppMessage *msg)
void AddEvpnRoute(const std::string &vrf_name, std::string mac_addr, const IpAddress &ip, uint32_t plen, autogen::EnetItemType *item)
std::string GetMcastLabelRange()
static bool IsXmppChannelActive(const Agent *agent, AgentXmppChannel *peer)
void UpdateConnectionInfo(xmps::PeerState state)
static bool ControllerSendEvpnRouteAdd(AgentXmppChannel *peer, AgentRoute *route, const Ip4Address *nexthop_ip, std::string vn, uint32_t mpls_label, uint32_t tunnel_bmap, const SecurityGroupList *sg_list, const TagList *tag_list, const CommunityList *communities, const std::string &destination, const std::string &source, const PathPreference &path_preference)
void GetVnList(const TYPE &nexthops, VnListType *vn_list)
static bool ControllerSendMcastRouteAdd(AgentXmppChannel *peer, AgentRoute *route)
void ReceiveInternal(const XmppStanza::XmppMessage *msg)
virtual void WriteReadyCb(const boost::system::error_code &ec)
boost::scoped_ptr< EndOfRibRxTimer > end_of_rib_rx_timer_
AgentXmppChannel(Agent *agent, const std::string &xmpp_server, const std::string &label_range, uint8_t xs_idx)
static bool ControllerSendSubscribe(AgentXmppChannel *peer, VrfEntry *vrf, bool subscribe)
virtual void ReceiveMvpnUpdate(XmlPugi *pugi)
bool ControllerSendV4V6UnicastRouteCommon(AgentRoute *route, const VnListType &vn_list, const SecurityGroupList *sg_list, const TagList *tag_list, const CommunityList *communities, uint32_t mpls_label, uint32_t tunnel_bmap, const PathPreference &path_preference, bool associate, Agent::RouteTableType type, const EcmpLoadBalance &ecmp_load_balance, uint32_t native_vrf_id)
bool ControllerSendEvpnRouteCommon(AgentRoute *route, const Ip4Address *nexthop_ip, std::string vn, const SecurityGroupList *sg_list, const TagList *tag_list, const CommunityList *communities, uint32_t mpls_label, uint32_t tunnel_bmap, const std::string &destination, const std::string &source, const PathPreference &path_preference, bool associate)
static bool ControllerSendVmCfgSubscribe(AgentXmppChannel *peer, const boost::uuids::uuid &vm_id, bool subscribe)
std::string GetXmppServer()
virtual void ReceiveInet4MplsUpdate(XmlPugi *pugi)
bool ControllerSendMcastRouteCommon(AgentRoute *route, bool associate)
bool BuildEvpnUnicastMessage(autogen::EnetItemType &item, std::stringstream &node_id, AgentRoute *route, const Ip4Address *nh_ip, const std::string &vn, const SecurityGroupList *sg_list, const TagList *tag_list, const CommunityList *communities, uint32_t label, uint32_t tunnel_bmap, const PathPreference &path_prefernce, bool associate)
boost::scoped_ptr< EndOfRibTxTimer > end_of_rib_tx_timer_
EndOfRibTxTimer * end_of_rib_tx_timer()
void StopEndOfRibTxWalker()
boost::scoped_ptr< LlgrStaleTimer > llgr_stale_timer_
static bool ControllerSendRouteAdd(AgentXmppChannel *peer, AgentRoute *route, const Ip4Address *nexthop_ip, const VnListType &vn_list, uint32_t label, uint32_t tunnel_bmap, const SecurityGroupList *sg_list, const TagList *tag_list, const CommunityList *communities, Agent::RouteTableType type, const PathPreference &path_preference, const EcmpLoadBalance &ecmp_load_balance, uint32_t native_vrf_id)
InetUnicastAgentRouteTable * PrefixToRouteMplsTable(const std::string &vrf_name, const IpAddress &prefix_addr)
void RegisterXmppChannel(XmppChannel *channel)
void AddInetEcmpRoute(std::string vrf_name, IpAddress ip, uint32_t plen, autogen::ItemType *item, const VnListType &vn_list)
void ReceiveBgpMessage(std::unique_ptr< XmlBase > impl)
virtual ~AgentXmppChannel()
InetUnicastAgentRouteTable * PrefixToRouteTable(const std::string &vrf_name, const IpAddress &prefix_addr)
virtual void ReceiveEvpnUpdate(XmlPugi *pugi)
static void SetMulticastPeer(AgentXmppChannel *old_peer, AgentXmppChannel *new_peer)
void AddFabricVrfRoute(const Ip4Address &prefix_addr, uint32_t prefix_len, const Ip4Address &addr, const VnListType &vn_list, const SecurityGroupList &sg_list, const TagList &tag_list)
bool IsEcmp(const TYPE &nexthops)
static void HandleAgentXmppClientChannelEvent(AgentXmppChannel *peer, xmps::PeerState state)
std::string GetBgpPeerName() const
void AddRoute(std::string vrf_name, IpAddress ip, uint32_t plen, autogen::ItemType *item)
void set_ifmap_active_xmpp_server(const std::string &addr, uint8_t xs_idx)
AgentXmppChannel * mulitcast_builder()
AgentXmppChannel * controller_xmpp_channel(uint8_t idx) const
const std::string & ifmap_active_xmpp_server() const
std::vector< string > & GetControllerlist()
VNController * controller() const
AddressList vhost_default_gateway() const
Ip4Address vhost_prefix() const
AgentParam * params() const
const std::string & fabric_policy_vrf_name() const
VrfTable * vrf_table() const
const Peer * local_peer() const
const Peer * local_vm_export_peer() const
uint32_t vhost_prefix_len() const
bool simulate_evpn_tor() const
const Peer * local_vm_peer() const
IFMapAgentParser * ifmap_parser() const
const Peer * multicast_peer() const
const std::string & controller_ifmap_xmpp_server(uint8_t idx) const
const uint16_t controller_ifmap_xmpp_port(uint8_t idx) const
void set_controller_xmpp_channel_setup_time(uint64_t time, uint8_t idx)
VrfEntry * fabric_vrf() const
static const std::string & xmpp_control_node_prefix()
void set_cn_mcast_builder(AgentXmppChannel *peer)
bool tor_agent_enabled() const
const Interface * vhost_interface() const
AgentStats * stats() const
process::ConnectionState * connection_state() const
AgentIfMapXmppChannel * ifmap_xmpp_channel(uint8_t idx) const
void reset_ifmap_active_xmpp_server()
const std::string & fabric_vrf_name() const
Ip4Address router_id() const
const int8_t & ifmap_active_xmpp_server_index() const
const Peer * multicast_tree_builder_peer() const
MplsTable * mpls_table() const
void StopPeerNotifyRoutes()
void PeerNotifyRoutes(WalkDoneCb cb)
ClonedLocalPathList::iterator ClonedLocalPathListIter
ClonedLocalPathList & cloned_local_path_list()
static ControllerMplsRoute * MakeControllerMplsRoute(const BgpPeer *peer, const string &default_vrf, const Ip4Address &router_id, const string &vrf_name, const Ip4Address &tunnel_dest, TunnelType::TypeBmap bmap, uint32_t label, MacAddress rewrite_dmac, const VnListType &dest_vn_list, const SecurityGroupList &sg_list, const TagList &tag_list, const PathPreference &path_preference, bool ecmp_suppressed, const EcmpLoadBalance &ecmp_load_balance, bool etree_leaf)
static const uint64_t kInvalidPeerIdentifier
static ControllerVmRoute * MakeControllerVmRoute(const BgpPeer *peer, const string &default_vrf, const Ip4Address &router_id, const string &vrf_name, const Ip4Address &tunnel_dest, TunnelType::TypeBmap bmap, uint32_t label, MacAddress rewrite_dmac, const VnListType &dest_vn_list, const SecurityGroupList &sg_list, const TagList &tag_list, const PathPreference &path_preference, bool ecmp_suppressed, const EcmpLoadBalance &ecmp_load_balance, bool etree_leaf)
ListenerId Register(ChangeCallback callback, const std::string &name="unspecified")
const std::string & destination_port_str() const
const std::string & source_port_str() const
const std::string & ip_protocol_str() const
const std::string & source_ip_str() const
void set_destination_port()
const std::string & destination_ip_str() const
void GetStringVector(std::vector< std::string > &string_vector) const
void set_destination_ip()
void AddLocalVmRouteReq(const Peer *peer, const std::string &vrf_name, const MacAddress &mac, const IpAddress &ip_addr, uint32_t ethernet_tag, LocalVmRoute *data)
void AddClonedLocalPathReq(const Peer *peer, const string &vrf_name, const MacAddress &mac, const IpAddress &ip_addr, uint32_t ethernet_tag, ClonedLocalPath *data)
static void AddRemoteVmRouteReq(const Peer *peer, const std::string &vrf_name, const MacAddress &mac, const IpAddress &ip_addr, uint32_t plen, uint32_t ethernet_tag, AgentRouteData *data)
void AddType5Route(const Peer *peer, const std::string &vrf_name, const IpAddress &ip_addr, uint32_t ethernet_tag, EvpnRoutingData *data, uint8_t plen=0)
void AddControllerReceiveRouteReq(const Peer *peer, const std::string &vrf_name, uint32_t label, const MacAddress &mac, const IpAddress &ip_addr, uint32_t ethernet_tag, const std::string &vn_name, const PathPreference &pref, uint64_t sequence_number)
static void DeleteReq(const Peer *peer, const std::string &vrf_name, const MacAddress &mac, const IpAddress &ip_addr, uint32_t plen, uint32_t ethernet_tag, AgentRouteData *data)
uint32_t ethernet_tag() const
uint8_t prefix_length() const
!
const MacAddress & mac() const
const AgentPath * FindOvsPath() const
const Ip4Address & src_ip_addr() const
const Ip4Address & dest_ip_addr() const
InetUnicastRouteEntry * FindResolveRoute(const Ip4Address &ip)
static void AddMplsRouteReq(const Peer *peer, const string &vrf_name, const IpAddress &dst_addr, uint8_t plen, AgentRouteData *data)
static void AddRemoteVmRouteReq(const Peer *peer, const string &vm_vrf, const IpAddress &vm_addr, uint8_t plen, AgentRouteData *data)
InetUnicastRouteEntry * FindLPM(const IpAddress &ip)
void AddClonedLocalPathReq(const Peer *peer, const string &vm_vrf, const IpAddress &addr, uint8_t plen, ClonedLocalPath *data)
void AddInetInterfaceRouteReq(const Peer *peer, const string &vm_vrf, const Ip4Address &addr, uint8_t plen, InetInterfaceRoute *data)
void AddLocalVmRouteReq(const Peer *peer, const string &vm_vrf, const IpAddress &addr, uint8_t plen, LocalVmRoute *data)
static void DeleteReq(const Peer *peer, const string &vrf_name, const IpAddress &addr, uint8_t plen, AgentRouteData *data)
static void AddGatewayRoute(const Peer *peer, const string &vrf_name, const Ip4Address &dst_addr, uint8_t plen, const AddressList &gw_list, const VnListType &vn_name, uint32_t label, const SecurityGroupList &sg_list, const TagList &tag_list, const CommunityList &communities, bool native_encap)
static void DeleteMplsRouteReq(const Peer *peer, const string &vrf_name, const IpAddress &addr, uint8_t plen, AgentRouteData *data)
void AddVlanNHRouteReq(const Peer *peer, const string &vm_vrf, const IpAddress &addr, uint8_t plen, VlanNhRoute *data)
void AddVhostMplsRoute(const IpAddress &vhost_addr, const Peer *peer)
uint8_t prefix_length() const
!
const boost::uuids::uuid & GetIfUuid() const
const Interface * GetInterface() const
const MacAddress & mac() const
const std::string & name() const
std::string ToString() const
static const MacAddress & BroadcastMac()
const NextHop * nexthop() const
static const uint32_t kInvalidLabel
MplsLabel * FindMplsLabel(uint32_t label)
static const uint32_t kInvalidExportLabel
bool FlushPeerInfo(uint64_t peer_sequence)
void ModifyFabricMembers(const Peer *peer, const std::string &vrf_name, const Ip4Address &group, const Ip4Address &source, uint32_t source_label, const TunnelOlist &olist, uint64_t peer_identifier=0)
static void GetMulticastMacFromIp(const Ip4Address &ip, MacAddress &mac)
uint32_t GetEvpnMulticastSGFlags(const std::string &vrf_name, const Ip4Address &src_addr, const Ip4Address &grp_addr)
void ModifyMvpnVrfRegistration(const Peer *peer, const std::string &vrf_name, const Ip4Address &group, const Ip4Address &source, uint64_t peer_identifier)
static MulticastHandler * GetInstance()
VxlanRoutingManager * vxlan_routing_manager() const
MulticastHandler * multicast() const
GlobalSystemConfig * global_system_config() const
uint32_t loc_sequence() const
uint32_t preference() const
uint32_t sequence() const
void incr_sequence_number()
static TypeBmap MplsoMplsType()
static TypeBmap VxlanType()
static TypeBmap NativeType()
static TypeBmap UDPType()
static TypeBmap GREType()
static Type ComputeType(TypeBmap bmap)
static TypeBmap MplsType()
AgentIfMapVmExport * agent_ifmap_vm_export() const
void FlushTimedOutChannels(uint8_t index)
TunnelType::TypeBmap GetTypeBitmap(const autogen::EnetTunnelEncapsulationListType &encap)
void Enqueue(ControllerWorkQueueDataType data)
void ReConnectXmppServer()
uint64_t multicast_sequence_number()
void increment_multicast_sequence_number()
uint16_t GetVlanTag() const
const boost::uuids::uuid & GetIfUuid() const
const bool & contains_new_tags() const
VrfEntry * GetVrf() const
bool vxlan_routing_vn() const
const std::string & GetExportName()
const string & GetName() const
InetUnicastAgentRouteTable * GetInet4MplsUnicastRouteTable() const
InetUnicastAgentRouteTable * GetInet4UnicastRouteTable() const
static const uint32_t kInvalidIndex
InetUnicastAgentRouteTable * GetInet6UnicastRouteTable() const
uint32_t vxlan_id() const
VnEntry * si_vn_ref() const
static void Notify(const Agent *agent, AgentXmppChannel *, DBTablePartBase *partition, DBEntryBase *e)
VrfEntry * FindVrfFromName(const string &name)
InetUnicastAgentRouteTable * GetInet6UnicastRouteTable(const std::string &vrf_name)
AgentRouteTable * GetEvpnRouteTable(const std::string &vrf_name)
InetUnicastAgentRouteTable * GetInet4UnicastRouteTable(const std::string &vrf_name)
InetUnicastAgentRouteTable * GetInet4MplsUnicastRouteTable(const std::string &vrf_name)
static const uint32_t kInvalidvxlan_id
static bool IsVxlanAvailable(const Agent *agent)
Checks whether VxLAN routing manager is enabled or not.
void XmppAdvertiseEvpnRoute(const IpAddress &prefix_ip, const int prefix_len, uint32_t vxlan_id, const std::string vrf_name, const RouteParameters ¶ms, const Peer *bgp_peer, const std::vector< std::string > &peer_sources)
Advertises an EVPN route received using XMPP channel.
static const Peer * routing_vrf_vxlan_bgp_peer_
A pointer to the Peer where all BGP routes are stored.
static bool IsRoutingVrf(const VrfEntry *vrf)
Determines whether the pointer to the VRF instance is of routing type.
const pugi::xml_document & doc()
virtual void RegisterReceive(xmps::PeerId, ReceiveCb)=0
virtual void UnRegisterReceive(xmps::PeerId)=0
virtual const XmppConnection * connection() const =0
virtual const std::string & ToString() const =0
virtual xmps::PeerState GetPeerState() const =0
virtual std::string LastStateName() const =0
virtual const std::string & FromString() const =0
virtual void UnRegisterWriteReady(xmps::PeerId id)=0
virtual bool Send(const uint8_t *, size_t, xmps::PeerId, SendReadyCb)=0
bool Send(const uint8_t *data, size_t size, const std::string *msg_str=NULL)
static const char * kConfigPeer
static const char * kBgpPeer
static const char * kFqnPrependAgentNodeJID
static const char * kEndOfRibMarker
std::unique_ptr< XmlBase > dom
static XmlBase * AllocXmppXmlImpl(const char *doc=NULL)
#define CONTROLLER_TRACE(obj,...)
#define CONTROLLER_INFO_TRACE(obj,...)
#define CONTROLLER_TX_CONFIG_TRACE(obj, index,...)
static int ParseEvpnAddress(const string &str, IpAddress *addr, const MacAddress &mac)
void PopulateEcmpHashFieldsToUse(ItemType &item, const EcmpLoadBalance &ecmp_load_balance)
void InetRequestDelete(const IpAddress &ip_address, const int prefix_len, std::string vrf_name, const Peer *bgp_peer)
static bool FillEvpnOlist(Agent *agent, EnetOlistType &olist, TunnelOlist *tunnel_olist)
static void GetEcmpHashFieldsToUse(TYPE *item, EcmpLoadBalance &ecmp_load_balance)
static const std::string LoadBalanceDecision
#define LOG(_Level, _Msg)
std::vector< OlistTunnelEntry > TunnelOlist
static int compare(const Type &lhs, const Type &rhs)
std::unique_ptr< DBRequestKey > key
std::unique_ptr< DBRequestData > data
virtual void Start(AgentXmppChannel *agent_xmpp_channel)
uint64_t end_of_rib_rx_time_
uint64_t last_route_published_time_
uint64_t end_of_rib_tx_time_
virtual void Start(AgentXmppChannel *agent_xmpp_channel)
A structure to hold path parameters during the transfer (routes leaking) of data between VRF instance...
static XmppXmlImplFactory * Instance()
static uint64_t UTCTimestampUsec()