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>
43 using namespace boost::asio;
44 using namespace autogen;
46 using std::unique_ptr;
47 using std::stringstream;
49 using process::ConnectionType;
50 using process::ConnectionStatus;
57 bool is_type5 = mac.
IsZero();
58 size_t pos = str.find(
'/');
59 if (pos == string::npos) {
64 boost::system::error_code ec;
65 string plen_str = str.substr(pos + 1);
68 string addrstr = str.substr(0, pos);
69 boost::system::error_code ec1;
70 *addr = IpAddress::from_string(addrstr, ec1);
73 return atoi(plen_str.c_str());
75 if (plen_str ==
"32") {
78 if (ec || plen != 32) {
82 }
else if (plen_str ==
"128") {
85 if (ec || plen != 128) {
97 const std::string &xmpp_server,
98 const std::string &label_range,
100 : channel_(NULL), channel_str_(),
101 xmpp_server_(xmpp_server), label_range_(label_range),
102 xs_idx_(xs_idx), route_published_time_(0), agent_(agent) {
126 (
const std::string &vrf_name,
const IpAddress &prefix_addr) {
129 if (prefix_addr.is_v4()) {
130 rt_table = agent_->vrf_table()->GetInet4UnicastRouteTable(vrf_name);
131 }
else if (prefix_addr.is_v6()) {
132 rt_table = agent_->vrf_table()->GetInet6UnicastRouteTable(vrf_name);
134 if (rt_table == NULL) {
136 "Unable to fetch route table for prefix " +
137 prefix_addr.to_string());
143 (
const std::string &vrf_name,
const IpAddress &prefix_addr) {
146 if (prefix_addr.is_v4()) {
147 rt_table = agent_->vrf_table()->GetInet4MplsUnicastRouteTable(vrf_name);
149 if (rt_table == NULL) {
151 "Unable to fetch route table for prefix " +
152 prefix_addr.to_string());
169 return "No BGP peer";
179 boost::system::error_code ec;
182 assert(ec.value() == 0);
187 const int prefix_len,
188 std::string vrf_name,
189 const Peer* bgp_peer) {
192 ip_address, prefix_len,
206 pugi::xml_node node = pugi->
FindNode(
"items");
207 pugi::xml_attribute attr = node.attribute(
"node");
210 strtok_r(const_cast<char *>(attr.value()),
"/", &saveptr);
211 strtok_r(NULL,
"/", &saveptr);
212 char *vrf_name = strtok_r(NULL,
"", &saveptr);
213 const std::string vrf(vrf_name);
217 if (rt_table == NULL) {
219 "Invalid VRF. Ignoring route retract" +
220 string(attr.value()));
224 pugi::xml_node node_check = pugi->
FindNode(
"retract");
225 if (!pugi->
IsNull(node_check)) {
226 for (node = node.first_child(); node; node = node.next_sibling()) {
227 if (strcmp(node.name(),
"retract") == 0) {
228 std::string
id = node.first_attribute().value();
230 "EVPN Delete Node id:" +
id);
232 boost::scoped_array<char> buff(
new char[
id.length() + 1]);
233 strcpy(buff.get(),
id.c_str());
246 uint32_t ethernet_tag = 0;
251 char *token = strtok_r(buff.get() + offset,
"-", &saveptr);
252 if ((strlen(saveptr) != 0) && token) {
253 ethernet_tag = atoi(token);
254 offset += strlen(token) + 1;
258 token = strtok_r(buff.get() + offset,
",", &saveptr);
259 if ((strlen(saveptr) == 0) || (token == NULL)) {
261 "Error parsing MAC from retract-id: " +
id);
265 boost::system::error_code ec;
269 "Error decoding MAC from retract-id: "+
id);
273 offset += strlen(token) + 1;
276 string str = buff.get() + offset;
277 size_t pos = str.find(
',');
278 if (pos != string::npos) {
279 string group_str = str.substr(pos + 1);
280 pos = group_str.find(
',');
281 if (pos == string::npos) {
284 string addrstr = group_str.substr(0, pos);
285 group = IpAddress::from_string(group_str, ec);
290 string source_str = str.substr(pos + 1);
291 source = IpAddress::from_string(source_str, ec);
301 "Error decoding IP address from "
310 group.to_v4(), source.to_v4(),
338 rt_table->
DeleteReq(bgp_peer, vrf_name, mac,
339 ip_addr, plen, ethernet_tag,
347 plen, vrf_name, bgp_peer);
357 if (EnetItemsType::XmlParseProperty(node, &xparser) ==
false) {
359 "Xml Parsing for evpn Failed");
363 EnetItemsType *items;
366 items = (
static_cast<EnetItemsType *
>(xparser.get()));
367 std::vector<EnetItemType>::iterator iter;
368 for (vector<EnetItemType>::iterator iter =items->item.begin();
369 iter != items->item.end(); iter++) {
372 boost::system::error_code ec;
375 group = IpAddress::from_string(item->entry.nlri.group, ec);
376 source = IpAddress::from_string(item->entry.nlri.source, ec);
382 "Error parsing address : " + item->entry.nlri.address);
393 if (
IsEcmp(item->entry.next_hops.next_hop)) {
395 vn_list.insert(item->entry.virtual_network);
398 AddEvpnRoute(vrf_name, item->entry.nlri.mac, ip_addr, plen, item);
405 pugi::xml_node node = pugi->
FindNode(
"items");
406 pugi::xml_attribute attr = node.attribute(
"node");
409 strtok_r(const_cast<char *>(attr.value()),
"/", &saveptr);
410 strtok_r(NULL,
"/", &saveptr);
411 char *vrf_name = strtok_r(NULL,
"", &saveptr);
412 const std::string vrf(vrf_name);
414 pugi::xml_node node_check = pugi->
FindNode(
"retract");
415 if (!pugi->
IsNull(node_check)) {
417 std::string retract_id = pugi->
ReadAttrib(
"id");
421 "Ignore retract request from non multicast tree "
422 "builder peer; Multicast Delete Node id:" + retract_id);
426 for (node = node.first_child(); node; node = node.next_sibling()) {
427 if (strcmp(node.name(),
"retract") == 0) {
428 std::string
id = node.first_attribute().value();
430 "Multicast Delete Node id:" +
id);
434 strtok_r(const_cast<char *>(
id.c_str()),
":", &saveptr);
435 strtok_r(NULL,
":", &saveptr);
436 char *group = strtok_r(NULL,
",", &saveptr);
437 char *source = strtok_r(NULL,
"", &saveptr);
438 if (group == NULL || source == NULL) {
440 "Error parsing multicast group address from retract id");
444 boost::system::error_code ec;
445 IpAddress g_address = IpAddress::from_string(group, ec);
446 if (ec.value() != 0) {
448 "Error parsing multicast group address");
452 IpAddress s_address = IpAddress::from_string(source, ec);
453 if (ec.value() != 0) {
455 "Error parsing multicast source address");
463 vrf, g_address.to_v4(),
464 s_address.to_v4(), 0, olist,
471 pugi::xml_node items_node = pugi->
FindNode(
"item");
472 if (!pugi->
IsNull(items_node)) {
478 "Ignore request from non multicast tree "
479 "builder peer; Multicast Delete Node:" + item_id);
486 if (McastItemsType::XmlParseProperty(node, &xparser) ==
false) {
488 "Xml Parsing for Multicast Message Failed");
492 McastItemsType *items;
495 items = (
static_cast<McastItemsType *
>(xparser.get()));
496 std::vector<McastItemType>::iterator items_iter;
497 boost::system::error_code ec;
498 for (items_iter = items->item.begin(); items_iter != items->item.end();
503 IpAddress g_address = IpAddress::from_string(item->entry.nlri.group, ec);
504 if (ec.value() != 0) {
506 "Error parsing multicast group address");
510 IpAddress s_address = IpAddress::from_string(item->entry.nlri.source, ec);
511 if (ec.value() != 0) {
513 "Error parsing multicast source address");
518 std::vector<McastNextHopType>::iterator iter;
519 for (iter = item->entry.olist.next_hop.begin();
520 iter != item->entry.olist.next_hop.end(); iter++) {
522 McastNextHopType nh = *iter;
523 IpAddress addr = IpAddress::from_string(nh.address, ec);
524 if (ec.value() != 0) {
526 "Error parsing next-hop address");
531 stringstream nh_label(nh.label);
534 GetTypeBitmap(nh.tunnel_encapsulation_list);
536 addr.to_v4(), encap));
540 IpAddress::from_string(item->entry.nlri.source_address, ec);
543 source_address.to_v4(),
549 vrf, g_address.to_v4(), s_address.to_v4(),
550 item->entry.nlri.source_label, olist,
557 pugi::xml_node node = pugi->
FindNode(
"items");
558 pugi::xml_attribute attr = node.attribute(
"node");
561 strtok_r(const_cast<char *>(attr.value()),
"/", &saveptr);
562 strtok_r(NULL,
"/", &saveptr);
563 char *vrf_name = strtok_r(NULL,
"", &saveptr);
564 const std::string vrf(vrf_name);
566 pugi::xml_node node_check = pugi->
FindNode(
"retract");
567 if (!pugi->
IsNull(node_check)) {
569 std::string retract_id = pugi->
ReadAttrib(
"id");
571 for (node = node.first_child(); node; node = node.next_sibling()) {
572 if (strcmp(node.name(),
"retract") == 0) {
573 std::string
id = node.first_attribute().value();
575 "Multicast Delete Node id:" +
id);
579 strtok_r(const_cast<char *>(
id.c_str()),
":", &saveptr);
580 strtok_r(NULL,
":", &saveptr);
581 char *group = strtok_r(NULL,
",", &saveptr);
582 char *source = strtok_r(NULL,
"", &saveptr);
583 if (group == NULL || source == NULL) {
585 "Error parsing multicast group address from retract id");
589 boost::system::error_code ec;
590 IpAddress g_address = IpAddress::from_string(group, ec);
591 if (ec.value() != 0) {
593 "Error parsing multicast group address");
597 IpAddress s_address = IpAddress::from_string(source, ec);
598 if (ec.value() != 0) {
600 "Error parsing multicast source address");
614 pugi::xml_node items_node = pugi->
FindNode(
"item");
615 if (!pugi->
IsNull(items_node)) {
621 "Ignore request from non multicast tree "
622 "builder peer; Multicast Delete Node:" + item_id);
629 if (MvpnItemsType::XmlParseProperty(node, &xparser) ==
false) {
631 "Xml Parsing for Multicast Message Failed");
635 MvpnItemsType *items;
638 items = (
static_cast<MvpnItemsType *
>(xparser.get()));
639 std::vector<MvpnItemType>::iterator items_iter;
640 boost::system::error_code ec;
641 for (items_iter = items->item.begin(); items_iter != items->item.end();
646 IpAddress g_address = IpAddress::from_string(item->entry.nlri.group, ec);
647 if (ec.value() != 0) {
649 "Error parsing multicast group address");
653 IpAddress s_address = IpAddress::from_string(item->entry.nlri.source, ec);
654 if (ec.value() != 0) {
656 "Error parsing multicast source address");
660 int route_type = item->entry.nlri.route_type;
661 if (route_type != 7) {
669 multicast_sequence_number());
675 pugi::xml_node node = pugi->
FindNode(
"items");
676 pugi::xml_attribute attr = node.attribute(
"node");
678 const char *af = NULL;
680 af = strtok_r(const_cast<char *>(attr.value()),
"/", &saveptr);
681 strtok_r(NULL,
"/", &saveptr);
682 char *vrf_name = strtok_r(NULL,
"", &saveptr);
687 FindActiveEntry(&vrf_key));
707 if (!pugi->
IsNull(node)) {
708 pugi::xml_node node_check = pugi->
FindNode(
"retract");
709 if (!pugi->
IsNull(node_check)) {
710 for (node = node.first_child(); node; node = node.next_sibling()) {
711 if (strcmp(node.name(),
"retract") == 0) {
712 std::string
id = node.first_attribute().value();
714 "Delete Node id:" +
id);
716 boost::system::error_code ec;
726 if (ec.value() != 0) {
728 "Error parsing v4 prefix for delete");
732 prefix_addr, prefix_len,
738 if (ec.value() != 0) {
740 "Error parsing v6 prefix for delete");
744 prefix_addr, prefix_len,
754 if (ItemsType::XmlParseProperty(node, &xparser) ==
false) {
756 "Xml Parsing Failed");
762 items = (
static_cast<ItemsType *
>(xparser.get()));
763 for (vector<ItemType>::iterator iter =items->item.begin();
764 iter != items->item.end();
767 boost::system::error_code ec;
774 if (ec.value() != 0) {
776 "Error parsing v4 route address");
779 AddRoute(vrf_name, prefix_addr, prefix_len, item);
784 if (ec.value() != 0) {
786 "Error parsing v6 route address");
789 AddRoute(vrf_name, prefix_addr, prefix_len, item);
792 "Error updating route, Unknown IP family");
801 pugi::xml_node node = pugi->
FindNode(
"items");
802 pugi::xml_attribute attr = node.attribute(
"node");
804 const char *af = NULL;
806 af = strtok_r(const_cast<char *>(attr.value()),
"/", &saveptr);
807 strtok_r(NULL,
"/", &saveptr);
808 char *vrf_name = strtok_r(NULL,
"", &saveptr);
813 FindActiveEntry(&vrf_key));
827 "Route Table not found");
831 if (!pugi->
IsNull(node)) {
833 pugi::xml_node node_check = pugi->
FindNode(
"retract");
834 if (!pugi->
IsNull(node_check)) {
835 for (node = node.first_child(); node; node = node.next_sibling()) {
836 if (strcmp(node.name(),
"retract") == 0) {
837 std::string
id = node.first_attribute().value();
839 "Delete Node id:" +
id);
841 boost::system::error_code ec;
846 if (ec.value() != 0) {
848 "Error parsing v4 prefix for delete");
853 prefix_addr, prefix_len,
864 if (ItemsType::XmlParseProperty(node, &xparser) ==
false) {
866 "Xml Parsing Failed");
872 items = (
static_cast<ItemsType *
>(xparser.get()));
873 for (vector<ItemType>::iterator iter =items->item.begin();
874 iter != items->item.end();
877 boost::system::error_code ec;
884 if (ec.value() != 0) {
886 "Error parsing v4 route address");
892 "Error updating route, Unknown IP family");
898 template <
typename TYPE>
902 if (item->entry.load_balance.load_balance_decision.empty() ||
903 item->entry.load_balance.load_balance_decision !=
905 ecmp_load_balance.
SetAll();
907 uint8_t field_list_size = item->entry.
908 load_balance.load_balance_fields.load_balance_field_list.size();
909 if (field_list_size == 0)
910 ecmp_load_balance.
SetAll();
912 for (uint32_t i = 0; i < field_list_size; i++) {
913 std::string field_type = item->entry.
914 load_balance.load_balance_fields.load_balance_field_list[i];
929 uint32_t prefix_len, ItemType *item,
938 if (rt_table == NULL) {
942 std::stringstream str;
943 str << prefix_addr.to_string();
950 rt_table, str.str());
955 prefix_addr, prefix_len,
961 prefix_addr, prefix_len, data);
974 FindActiveEntry(&vrf_key));
985 if (rt_table == NULL || rt_table->
vrf_entry() == NULL) {
989 std::stringstream str;
990 str << item->entry.nlri.ethernet_tag;
994 str << prefix_addr.to_string();
997 rt_table, str.str());
1003 item->entry.nlri.ethernet_tag,
1009 plen, item->entry.nlri.ethernet_tag, data);
1012 template <
typename TYPE>
1017 const std::string &prefix_str) {
1022 vn_list, ecmp_load_balance, tag_list,
1023 item, rt_table, prefix_str);
1028 EnetOlistType &olist,
1030 for (uint32_t i = 0; i < olist.next_hop.size(); i++) {
1031 boost::system::error_code ec;
1033 IpAddress::from_string(olist.next_hop[i].address,
1035 if (ec.value() != 0) {
1039 int label = olist.next_hop[i].label;
1041 GetTypeBitmap(olist.next_hop[i].tunnel_encapsulation_list);
1043 addr.to_v4(), encap));
1051 EnetItemType *item) {
1060 "add leaf evpn multicast route");
1063 "Error parsing next-hop address");
1067 "add evpn multicast route");
1070 "Error parsing next-hop address");
1075 ModifyEvpnMembers(
bgp_peer_id(), vrf_name, group.to_v4(),
1076 source.to_v4(), leaf_olist,
1077 item->entry.nlri.ethernet_tag,
1079 multicast_sequence_number());
1084 EnetItemType *item) {
1092 "add leaf evpn multicast route");
1095 "Error parsing next-hop address");
1099 "add evpn multicast route");
1102 "Error parsing next-hop address");
1107 ModifyTorMembers(
bgp_peer_id(), vrf_name, leaf_olist,
1108 item->entry.nlri.ethernet_tag,
1110 multicast_sequence_number());
1114 item->entry.nlri.ethernet_tag,
1116 multicast_sequence_number());
1120 uint32_t prefix_len,
1137 prefix_addr, prefix_len, data);
1148 if (prefix_addr == addr && prefix_len == 32 &&
1162 prefix_addr, prefix_len, nh,
1164 sg_list, tag_list, cl,
true);
1168 std::string mac_str,
1171 EnetItemType *item) {
1173 VrfKey vrf_key(vrf_name);
1176 FindActiveEntry(&vrf_key));
1179 "VRF not found, ignoring request");
1187 if (rt_table == NULL || rt_table->
vrf_entry() == NULL) {
1189 "Invalid VRF. Ignoring route");
1193 boost::system::error_code ec;
1200 string nexthop_addr = item->entry.next_hops.next_hop[0].address;
1201 IpAddress nh_ip = IpAddress::from_string(nexthop_addr, ec);
1202 uint32_t label = item->entry.next_hops.next_hop[0].label;
1204 (item->entry.next_hops.next_hop[0].tunnel_encapsulation_list);
1207 if (item->entry.local_preference != 0) {
1208 preference = item->entry.local_preference;
1210 PathPreference path_preference(item->entry.sequence_number, preference,
1217 mac.
ToString(), 0, nexthop_addr, label,
"");
1224 si_ref_vn == NULL) {
1228 vn_list.insert(item->entry.virtual_network);
1235 MacAddress(item->entry.next_hops.next_hop[0].mac),
1237 item->entry.security_group_list.security_group,
1249 "add remote evpn route");
1251 vn_list.insert(item->entry.virtual_network);
1258 vrf_name, nh_ip.to_v4(),
1260 MacAddress(item->entry.next_hops.next_hop[0].mac),
1262 item->entry.security_group_list.security_group,
1265 (item->entry.next_hops.next_hop.size() > 1),
1267 item->entry.etree_leaf);
1269 plen, item->entry.nlri.ethernet_tag, data);
1283 if (si_ref_vn && (si_ref_vn->vxlan_routing_vn() ==
true)) {
1290 VrfEntry *routing_vrf = si_ref_vn->GetVrf();
1291 assert(routing_vrf != vrf);
1298 "Not a Routing VRF. Ignoring route");
1306 if (evpn_rt_table == NULL || evpn_rt_table->
vrf_entry() == NULL) {
1308 "Invalid Routing VRF. Ignoring route");
1317 if (evpn_rt == NULL) {
1319 "Local EVPN route not found, ignoring request");
1325 vn_list.insert(item->entry.virtual_network);
1332 item->entry.security_group_list.security_group,
1359 ip_addr, plen, item->entry.nlri.ethernet_tag);
1362 if (route == NULL) {
1364 "route not found, ignoring request");
1368 AgentPath *local_path = route->FindLocalVmPortPath();
1372 "nexthop not found, ignoring request");
1381 label, mac, ip_addr,
1382 item->entry.nlri.ethernet_tag,
1383 item->entry.virtual_network,
1392 "Invalid nexthop in evpn route");
1401 vn_list.insert(item->entry.virtual_network);
1408 label,
false, vn_list,
1411 Ip4Address(0), ecmp_load_balance,
false,
false,
1422 Ip4Address(0), ecmp_load_balance,
false,
false,
1427 ip_addr, item->entry.nlri.ethernet_tag,
1428 static_cast<LocalVmRoute *>(local_vm_route));
1432 uint32_t prefix_len, ItemType *item,
1437 if (rt_table == NULL) {
1441 boost::system::error_code ec;
1442 string nexthop_addr = item->entry.next_hops.next_hop[0].address;
1443 uint32_t label = item->entry.next_hops.next_hop[0].label;
1444 IpAddress addr = IpAddress::from_string(nexthop_addr, ec);
1446 (item->entry.next_hops.next_hop[0].tunnel_encapsulation_list);
1447 if (ec.value() != 0) {
1449 "Error parsing nexthop ip address");
1455 if (item->entry.local_preference != 0) {
1456 preference = item->entry.local_preference;
1458 PathPreference path_preference(item->entry.sequence_number, preference,
1464 std::string vn_string;
1465 for (VnListType::const_iterator vnit = vn_list.begin();
1466 vnit != vn_list.end(); ++vnit) {
1467 vn_string += *vnit +
" ";
1470 prefix_addr.to_string(), prefix_len,
1471 addr.to_v4().to_string(), label, vn_string);
1473 if (item->entry.next_hops.next_hop[0].label ==
1478 item->entry.security_group_list.security_group,
1488 if (prefix_addr.to_v4() ==
Ip4Address(0) && prefix_len == 0) {
1517 vrf_name, addr.to_v4(), encap, label,
1519 item->entry.security_group_list.security_group,
1521 path_preference,
false, ecmp_load_balance,
1528 bool native_encap =
false;
1530 native_encap =
true;
1537 if ((mpls == NULL) || (mpls->
nexthop()
1540 gres_parameters().IsEnabled()) {
1544 (rt_table->
FindLPM(local_vm_route_key));
1552 LOG(DEBUG,
"Mpls lablel picked from interface nh for local vm route, received label: " << label);
1565 item->entry.security_group_list.security_group,
1570 ecmp_load_balance,
false,
false,
1573 prefix_addr, prefix_len,
1574 static_cast<LocalVmRoute *>(local_vm_rt_update));
1586 if (intrface == NULL) {
1601 item->entry.security_group_list.security_group,
1606 ecmp_load_balance,
false,
false,
1609 prefix_addr, prefix_len,
1610 static_cast<LocalVmRoute *>(local_vm_route));
1613 if (!prefix_addr.is_v4()) {
1615 "MPLS label inet interface type not supported for non IPv4");
1625 prefix_addr.to_v4(), prefix_len,
1626 inet_interface_route);
1630 "MPLS label points to invalid interface type");
1638 const VlanNH *vlan_nh =
static_cast<const VlanNH *
>(nh);
1645 item->entry.security_group_list.security_group,
1666 if (!prefix_addr.is_v4()) {
1668 "VRF nexthop is not supported for non IPv4");
1674 item->entry.security_group_list.security_group,
1678 prefix_addr.to_v4(),
1685 "MPLS label points to invalid NH");
1690 uint32_t prefix_len, ItemType *item,
1695 if (rt_table == NULL) {
1703 boost::system::error_code ec;
1704 string nexthop_addr = item->entry.next_hops.next_hop[0].address;
1705 uint32_t label = item->entry.next_hops.next_hop[0].label;
1706 IpAddress addr = IpAddress::from_string(nexthop_addr, ec);
1708 if (ec.value() != 0) {
1710 "Error parsing nexthop ip address");
1716 if (item->entry.local_preference != 0) {
1717 preference = item->entry.local_preference;
1719 PathPreference path_preference(item->entry.sequence_number, preference,
1725 std::string vn_string;
1726 for (VnListType::const_iterator vnit = vn_list.begin();
1727 vnit != vn_list.end(); ++vnit) {
1728 vn_string += *vnit +
" ";
1731 prefix_addr.to_string(), prefix_len,
1732 addr.to_v4().to_string(), label, vn_string);
1740 vrf_name, addr.to_v4(),
1743 item->entry.security_group_list.security_group,
1745 path_preference,
false, ecmp_load_balance,
1752 template <
typename TYPE>
1754 if (nexthops.size() == 0)
1757 std::string address = nexthops[0].address;
1758 uint32_t label = nexthops[0].label;
1759 for (uint32_t index = 1; index < nexthops.size(); index++) {
1760 if (nexthops[index].address != address ||
1761 (uint32_t)nexthops[index].label != label) {
1769 template <
typename TYPE>
1771 for (uint32_t index = 0; index < nexthops.size(); index++) {
1772 vn_list->insert(nexthops[index].virtual_network);
1777 uint32_t prefix_len, ItemType *item) {
1778 if ((item->entry.next_hops.next_hop[0].label ==
1785 GetVnList(item->entry.next_hops.next_hop, &vn_list);
1786 if (
IsEcmp(item->entry.next_hops.next_hop)) {
1789 AddRemoteRoute(vrf_name, prefix_addr, prefix_len, item, vn_list);
1794 uint32_t prefix_len, ItemType *item,
1800 if (rt_table == NULL) {
1804 std::stringstream str;
1805 str << prefix_addr.to_string();
1812 rt_table, str.str());
1815 prefix_addr, prefix_len, data);
1818 uint32_t prefix_len, ItemType *item) {
1821 GetVnList(item->entry.next_hops.next_hop, &vn_list);
1822 if (
IsEcmp(item->entry.next_hops.next_hop)) {
1848 pugi::xml_node node = pugi->
FindNode(
"items");
1856 std::string nodename = pugi->
ReadAttrib(
"node");
1858 const char *af = NULL, *safi = NULL, *vrf_name;
1859 char *str =
const_cast<char *
>(nodename.c_str());
1861 af = strtok_r(str,
"/", &saveptr);
1862 safi = strtok_r(NULL,
"/", &saveptr);
1868 "BGP peer not present, agentxmppchannel is inactive");
1899 "Error Route update, Unknown Address Family or safi");
1914 assert(agent_xmpp_channel);
1920 StartConfigCleanupTimer();
1926 bool xmpp_channel_found =
false;
1932 xmpp_channel_found =
true;
1936 return xmpp_channel_found;
1975 end_of_config_timer()->Start(peer);
1996 std::unique_ptr<XmlBase> dummy_dom;
2000 std::move(dummy_dom),
2006 return (static_cast<BgpPeer *>(
bgp_peer_id_.get()))->sequence_number();
2030 "NULL",
"BGP peer ready.");
2042 "NULL",
"BGP peer set as config server.");
2053 if (agent_mcast_builder == NULL) {
2085 "NULL",
"BGP peer decommissioned for xmpp channel.");
2098 bool peer_is_config_server = (
agent_->
2100 bool peer_is_agent_mcast_builder = (agent_mcast_builder ==
this);
2103 if (peer_is_config_server) {
2116 "NOT_READY",
"NULL",
"BGP peer selected as"
2117 "config peer on decommission of old config "
2123 if (peer_is_agent_mcast_builder) {
2134 bool evaluate_new_mcast_builder =
2137 if (!evaluate_new_mcast_builder) {
2138 new_mcast_builder = NULL;
2140 "NULL",
"No elected Multicast Tree Builder");
2143 if (evaluate_new_mcast_builder) {
2150 "Peer elected Multicast Tree Builder");
2171 "NULL",
"Connection to Xmpp Server, Timed out");
2173 bool update_list =
false;
2176 for (; iter != end; iter++) {
2177 std::vector<string> server;
2178 boost::split(server, *iter, boost::is_any_of(
":"));
2181 if (iter+1 == end)
break;
2182 std::rotate(iter, iter+1, end);
2228 boost::scoped_ptr<XmlWriter> xml_writer(
new XmlWriter(&repr));
2247 pugi->
AddAttribute(
"xmlns",
"http://jabber.org/protocol/pubsub");
2248 if (subscribe ==
true) {
2253 std::string vm(
"virtual-machine:");
2259 pugi->
doc().print(*xml_writer,
"", pugi::format_default,
2260 pugi::encoding_utf8);
2264 if (peer->
SendUpdate(reinterpret_cast<const uint8_t *>(repr.c_str()),
2265 repr.length()) ==
false) {
2267 "VM subscribe Send Update deferred", vm,
"");
2276 boost::scoped_ptr<XmlWriter> xml_writer(
new XmlWriter(&repr));
2295 pugi->
AddAttribute(
"xmlns",
"http://jabber.org/protocol/pubsub");
2297 string node(
"virtual-router:");
2301 pugi->
doc().print(*xml_writer,
"", pugi::format_default,
2302 pugi::encoding_utf8);
2306 if (peer->
SendUpdate(reinterpret_cast<const uint8_t *>(repr.c_str()),
2307 repr.length()) ==
false) {
2309 "Config subscribe Send Update deferred", node,
"");
2317 static int req_id = 0;
2319 boost::scoped_ptr<XmlWriter> xml_writer(
new XmlWriter(&repr));
2325 subscribe ?
"Subscribe" :
"Unsubscribe");
2338 stringstream request_id;
2339 request_id <<
"subscribe" << req_id++;
2342 pugi->
AddAttribute(
"xmlns",
"http://jabber.org/protocol/pubsub");
2350 stringstream vrf_id;
2351 vrf_id << vrf->
rd();
2354 pugi->
doc().print(*xml_writer,
"", pugi::format_default,
2355 pugi::encoding_utf8);
2357 if (peer->
SendUpdate(reinterpret_cast<const uint8_t *>(repr.c_str()),
2358 repr.length()) ==
false) {
2360 "Vrf subscribe Send Update deferred", vrf_id.str(),
"");
2369 if (ecmp_load_balance.
AllSet())
2373 item.entry.load_balance.load_balance_fields.load_balance_field_list);
2381 uint32_t mpls_label,
2387 uint32_t native_vrf_id) {
2389 const std::string vrf_name = route->
vrf()->
GetName();
2399 boost::scoped_ptr<XmlWriter> xml_writer(
new XmlWriter(&repr));
2419 item.entry.nlri.address = rstr.str();
2424 autogen::NextHopType nh;
2427 nh.label = mpls_label;
2434 nh.tunnel_encapsulation_list.tunnel_encapsulation.push_back(
"gre");
2437 nh.tunnel_encapsulation_list.tunnel_encapsulation.push_back(
"udp");
2440 nh.tunnel_encapsulation_list.tunnel_encapsulation.push_back(
"vxlan");
2447 nh.tunnel_encapsulation_list.tunnel_encapsulation.push_back(
"native");
2450 if (tag_list && tag_list->size()) {
2451 nh.tag_list.tag = *tag_list;
2455 nh.local_sequence_number = path_preference.
loc_sequence();
2458 for (VnListType::const_iterator vnit = vn_list.begin();
2459 vnit != vn_list.end(); ++vnit) {
2460 nh.virtual_network = *vnit;
2461 item.entry.next_hops.next_hop.push_back(nh);
2464 if (sg_list && sg_list->size()) {
2465 item.entry.security_group_list.security_group = *sg_list;
2468 if (communities && !communities->empty()) {
2469 item.entry.community_tag_list.community_tag = *communities;
2473 item.entry.version = 1;
2477 item.entry.sequence_number = path_preference.
sequence();
2478 item.entry.local_preference = path_preference.
preference();
2489 stringstream pubsub_id;
2490 pubsub_id <<
"pubsub" << id;
2494 pugi->
AddAttribute(
"xmlns",
"http://jabber.org/protocol/pubsub");
2498 stringstream ss_node;
2499 ss_node << item.entry.nlri.af <<
"/"
2500 << item.entry.nlri.safi <<
"/"
2504 ss_node <<
"/" << native_vrf_id;
2506 std::string node_id(ss_node.str());
2510 pugi::xml_node node = pugi->
FindNode(
"item");
2515 pugi->
doc().print(*xml_writer,
"", pugi::format_default,
2516 pugi::encoding_utf8);
2518 SendUpdate(reinterpret_cast<const uint8_t *>(repr.c_str()), repr.length());
2524 stringstream collection_id;
2525 collection_id <<
"collection" <<
id++;
2528 pugi->
AddAttribute(
"xmlns",
"http://jabber.org/protocol/pubsub");
2539 pugi->
doc().print(*xml_writer,
"", pugi::format_default,
2540 pugi::encoding_utf8);
2542 SendUpdate(reinterpret_cast<const uint8_t *>(repr.c_str()), repr.length());
2548 stringstream &node_id,
2551 const std::string &vn,
2556 uint32_t tunnel_bmap,
2557 const std::string &destination,
2558 const std::string &source,
2565 if ((path == NULL) && (associate)) {
2568 "OVS path not found for ff:ff:ff:ff:ff:ff, skip send");
2573 item.entry.sequence_number = 0;
2574 item.entry.replicator_address = source;
2579 item.entry.nlri.mac = rstr.str();
2580 item.entry.assisted_replication_supported =
false;
2581 item.entry.edge_replication_not_supported =
false;
2586 rstr << destination;
2588 item.entry.nlri.ethernet_tag = 0;
2589 if (associate ==
false)
2590 item.entry.nlri.ethernet_tag = label;
2592 item.entry.nlri.address = rstr.str();
2593 assert(item.entry.nlri.address !=
"0.0.0.0");
2595 autogen::EnetNextHopType nh;
2597 nh.address = destination;
2600 node_id << item.entry.nlri.af <<
"/" << item.entry.nlri.safi <<
"/"
2601 << route->
ToString() <<
"," << item.entry.nlri.address;
2605 tunnel_type = path->tunnel_type();
2610 nh.tunnel_encapsulation_list.tunnel_encapsulation.push_back(
"gre");
2613 nh.tunnel_encapsulation_list.tunnel_encapsulation.push_back(
"udp");
2617 nh.label = path->vxlan_id();
2618 item.entry.nlri.ethernet_tag = nh.label;
2622 nh.tunnel_encapsulation_list.tunnel_encapsulation.push_back(
"vxlan");
2625 if (sg_list && sg_list->size()) {
2626 item.entry.security_group_list.security_group = *sg_list;
2629 if (tag_list && tag_list->size()) {
2630 nh.tag_list.tag = *tag_list;
2634 item.entry.next_hops.next_hop.push_back(nh);
2643 stringstream &node_id,
2646 const std::string &vn,
2651 uint32_t tunnel_bmap,
2654 bool assisted_replication) {
2657 item.entry.sequence_number = 0;
2659 item.entry.edge_replication_not_supported =
true;
2661 item.entry.edge_replication_not_supported =
false;
2667 rstr <<
"0.0.0.0/32";
2668 item.entry.nlri.address = rstr.str();
2669 assert(item.entry.nlri.address !=
"0.0.0.0");
2672 if (assisted_replication) {
2674 item.entry.assisted_replication_supported =
true;
2675 node_id << item.entry.nlri.af <<
"/" << item.entry.nlri.safi <<
"/"
2676 << route->
ToString() <<
"," << item.entry.nlri.address
2681 item.entry.assisted_replication_supported =
false;
2682 node_id << item.entry.nlri.af <<
"/" << item.entry.nlri.safi <<
"/"
2696 item.entry.nlri.mac = mac.
ToString();
2699 item.entry.nlri.flags =
2705 item.entry.nlri.mac = route->
ToString();
2708 autogen::EnetNextHopType nh;
2710 nh.address = nh_ip->to_string();
2714 item.entry.nlri.ethernet_tag = route->
vrf()->
isid();
2715 if (associate ==
false) {
2719 item.entry.nlri.ethernet_tag = label;
2728 nh.tunnel_encapsulation_list.tunnel_encapsulation.push_back(
"gre");
2731 nh.tunnel_encapsulation_list.tunnel_encapsulation.push_back(
"udp");
2739 item.entry.nlri.ethernet_tag = nh.label;
2743 nh.tunnel_encapsulation_list.tunnel_encapsulation.push_back(
"vxlan");
2746 if (sg_list && sg_list->size()) {
2747 item.entry.security_group_list.security_group = *sg_list;
2751 item.entry.next_hops.next_hop.push_back(nh);
2759 stringstream &node_id,
2762 const std::string &vn,
2767 uint32_t tunnel_bmap,
2773 item.entry.local_preference = path_preference.
preference();
2774 item.entry.sequence_number = path_preference.
sequence();
2775 item.entry.assisted_replication_supported =
false;
2776 item.entry.edge_replication_not_supported =
false;
2782 item.entry.nlri.mac = rstr.str();
2790 item.entry.nlri.ethernet_tag = evpn_route->
ethernet_tag();
2792 item.entry.nlri.address = rstr.str();
2793 assert(item.entry.nlri.address !=
"0.0.0.0");
2795 item.entry.etree_leaf =
true;
2797 item.entry.etree_leaf = active_path->
etree_leaf();
2800 autogen::EnetNextHopType nh;
2802 nh.address = nh_ip->to_string();
2814 nh.tunnel_encapsulation_list.tunnel_encapsulation.push_back(
"gre");
2817 nh.tunnel_encapsulation_list.tunnel_encapsulation.push_back(
"udp");
2821 nh.label = active_path->
vxlan_id();
2825 nh.tunnel_encapsulation_list.tunnel_encapsulation.push_back(
"vxlan");
2828 if (sg_list && sg_list->size()) {
2829 item.entry.security_group_list.security_group = *sg_list;
2832 if (tag_list && tag_list->size()) {
2833 nh.tag_list.tag = *tag_list;
2837 nh.local_sequence_number = path_preference.
loc_sequence();
2841 item.entry.next_hops.next_hop.push_back(nh);
2846 node_id << item.entry.nlri.af <<
"/" << item.entry.nlri.safi <<
"/"
2852 stringstream &ss_node,
2857 boost::scoped_ptr<XmlWriter> xml_writer(
new XmlWriter(&repr));
2872 stringstream pubsub_id;
2873 pubsub_id <<
"pubsub_l2" << id;
2877 pugi->
AddAttribute(
"xmlns",
"http://jabber.org/protocol/pubsub");
2880 std::string node_id(ss_node.str());
2884 pugi::xml_node node = pugi->
FindNode(
"item");
2889 pugi->
doc().print(*xml_writer,
"", pugi::format_default,
2890 pugi::encoding_utf8);
2892 SendUpdate(reinterpret_cast<const uint8_t *>(repr.c_str()), repr.length());
2898 stringstream collection_id;
2899 collection_id <<
"collection_l2" <<
id++;
2902 pugi->
AddAttribute(
"xmlns",
"http://jabber.org/protocol/pubsub");
2913 pugi->
doc().print(*xml_writer,
"", pugi::format_default,
2914 pugi::encoding_utf8);
2916 SendUpdate(reinterpret_cast<const uint8_t *>(repr.c_str()), repr.length());
2928 uint32_t tunnel_bmap,
2929 const std::string &destination,
2930 const std::string &source,
2935 stringstream ss_node;
2946 sg_list, tag_list, communities,
2947 label, tunnel_bmap, associate,
2956 sg_list, tag_list, communities, label,
2957 tunnel_bmap, destination, source,
2958 associate) ==
false)
2973 sg_list, tag_list, communities, label,
2974 tunnel_bmap, associate,
2982 tag_list, communities, label, tunnel_bmap,
2983 path_preference, associate) ==
false)
2993 autogen::McastItemType item;
2995 boost::scoped_ptr<XmlWriter> xml_writer(
new XmlWriter(&repr));
3000 "Peer not elected Multicast Tree Builder");
3017 autogen::McastNextHopType item_nexthop;
3020 item_nexthop.address = rtr;
3022 item_nexthop.tunnel_encapsulation_list.tunnel_encapsulation.push_back(
"gre");
3023 item_nexthop.tunnel_encapsulation_list.tunnel_encapsulation.push_back(
"udp");
3024 item.entry.next_hops.next_hop.push_back(item_nexthop);
3035 std::string pubsub_id(
"pubsub_b");
3036 stringstream str_id;
3038 pubsub_id += str_id.str();
3042 pugi->
AddAttribute(
"xmlns",
"http://jabber.org/protocol/pubsub");
3044 stringstream ss_node;
3045 ss_node << item.entry.nlri.af <<
"/"
3046 << item.entry.nlri.safi <<
"/"
3049 std::string node_id(ss_node.str());
3053 pugi::xml_node node = pugi->
FindNode(
"item");
3058 pugi->
doc().print(*xml_writer,
"", pugi::format_default,
3059 pugi::encoding_utf8);
3061 SendUpdate(reinterpret_cast<const uint8_t *>(repr.c_str()), repr.length());
3067 stringstream collection_id;
3068 collection_id <<
"collection" <<
id++;
3071 pugi->
AddAttribute(
"xmlns",
"http://jabber.org/protocol/pubsub");
3082 pugi->
doc().print(*xml_writer,
"", pugi::format_default,
3083 pugi::encoding_utf8);
3085 SendUpdate(reinterpret_cast<const uint8_t *>(repr.c_str()), repr.length());
3106 boost::scoped_ptr<XmlWriter> xml_writer(
new XmlWriter(&repr));
3120 item.entry.nlri.route_type = 7;
3124 item.entry.next_hop.address = rtr;
3125 item.entry.next_hop.label = 0;
3136 std::string pubsub_id(
"pubsub_b");
3137 stringstream str_id;
3139 pubsub_id += str_id.str();
3143 pugi->
AddAttribute(
"xmlns",
"http://jabber.org/protocol/pubsub");
3145 stringstream ss_node;
3146 ss_node << item.entry.nlri.af <<
"/"
3147 << item.entry.nlri.safi <<
"/"
3150 std::string node_id(ss_node.str());
3154 pugi::xml_node node = pugi->
FindNode(
"item");
3159 pugi->
doc().print(*xml_writer,
"", pugi::format_default,
3160 pugi::encoding_utf8);
3162 SendUpdate(reinterpret_cast<const uint8_t *>(repr.c_str()), repr.length());
3168 stringstream collection_id;
3169 collection_id <<
"collection" <<
id++;
3172 pugi->
AddAttribute(
"xmlns",
"http://jabber.org/protocol/pubsub");
3183 pugi->
doc().print(*xml_writer,
"", pugi::format_default,
3184 pugi::encoding_utf8);
3186 SendUpdate(reinterpret_cast<const uint8_t *>(repr.c_str()), repr.length());
3196 uint32_t tunnel_bmap,
3200 const std::string &destination,
3201 const std::string &source,
3204 if (!peer)
return false;
3227 const std::string &destination,
3228 const std::string &source,
3229 uint32_t tunnel_bmap) {
3230 if (!peer)
return false;
3262 uint32_t native_vrf_id)
3264 if (!peer)
return false;
3276 sg_list, tag_list, communities, label,
3277 bmap, path_preference,
true,
3278 type, ecmp_load_balance, native_vrf_id);
3283 vn = *vn_list.begin();
3285 sg_list, tag_list, communities, label,
3287 path_preference,
true);
3304 if (!peer)
return false;
3316 sg_list, tag_list, communities,
3329 vn = *vn_list.begin();
3331 vn, NULL, NULL, NULL,
3332 label, bmap,
"",
"",
3333 path_preference,
false);
3340 if (!peer)
return false;
3355 if (!peer)
return false;
3372 if (
agent()->mulitcast_builder() ==
this) {
3374 controller()->multicast_sequence_number());
3389 msg +=
"\n<message from=\"";
3396 msg +=
"\n\t<event xmlns=\"http://jabber.org/protocol/pubsub\">";
3399 msg +=
"\n\t</event>\n</message>\n";
3412 boost::asio::ip::tcp::endpoint ep;
3413 boost::system::error_code ec;
3414 string last_state_name;
3420 ep.address().to_string();
3427 ConnectionStatus::UP, ep,
3431 ConnectionStatus::DOWN, ep,
3449 template <
typename TYPE>
3452 *tag_list = item->entry.next_hops.next_hop[0].tag_list.tag;
3453 std::sort(tag_list->begin(), tag_list->end());
MulticastHandler * multicast() const
AgentIfMapVmExport * agent_ifmap_vm_export() const
IFMapAgentParser * ifmap_parser() const
void AddType5Route(const Peer *peer, const std::string &vrf_name, const IpAddress &ip_addr, uint32_t ethernet_tag, EvpnRoutingData *data, uint8_t plen=0)
uint8_t prefix_length() const
!
virtual const XmppConnection * connection() const =0
AgentPath * FindLocalVmPortPath() const
pugi::xml_node FindNode(const std::string &name)
const Interface * GetInterface() const
static void DeleteMplsRouteReq(const Peer *peer, const string &vrf_name, const IpAddress &addr, uint8_t plen, AgentRouteData *data)
void ModifyMvpnVrfRegistration(const Peer *peer, const std::string &vrf_name, const Ip4Address &group, const Ip4Address &source, uint64_t peer_identifier)
XmppChannel * GetXmppChannel()
bool BuildAndSendEvpnDom(autogen::EnetItemType &item, std::stringstream &ss_node, const AgentRoute *route, bool associate)
virtual std::string ToString() const
const Peer * local_vm_export_peer() const
void AddRoute(std::string vrf_name, IpAddress ip, uint32_t plen, autogen::ItemType *item)
uint64_t end_of_rib_tx_time_
void incr_xmpp_reconnects(uint8_t idx)
boost::system::error_code Ip4PrefixParse(const string &str, Ip4Address *addr, int *plen)
InetUnicastRouteEntry * FindLPM(const IpAddress &ip)
const uint16_t controller_ifmap_xmpp_port(uint8_t idx) const
void AddLocalVmRouteReq(const Peer *peer, const string &vm_vrf, const IpAddress &addr, uint8_t plen, LocalVmRoute *data)
VrfEntry * fabric_vrf() const
const std::string & source_ip_str() const
bool tor_agent_enabled() const
uint64_t last_route_published_time_
virtual void RegisterReceive(xmps::PeerId, ReceiveCb)=0
virtual const std::string GetAddressString() const =0
AgentXmppChannel * mulitcast_builder()
VrfEntry * FindVrfFromName(const string &name)
std::string GetMcastLabelRange()
AgentRouteTable * GetEvpnRouteTable(const std::string &vrf_name)
virtual void Start(AgentXmppChannel *agent_xmpp_channel)
bool FlushPeerInfo(uint64_t peer_sequence)
TunnelType::Type tunnel_type() const
Agent supports multiple route tables - Inet-unicast (IPv4/IPv6), Inet-multicast, bridge, EVPN (Type2/Type5). This base class contains common code for all types of route tables.
virtual void ReceiveInet4MplsUpdate(XmlPugi *pugi)
void AddClonedLocalPathReq(const Peer *peer, const string &vrf_name, const MacAddress &mac, const IpAddress &ip_addr, uint32_t ethernet_tag, ClonedLocalPath *data)
const Ip4Address & dest_ip_addr() const
uint32_t preference() const
static XmlBase * AllocXmppXmlImpl(const char *doc=NULL)
const Interface * vhost_interface() const
const std::string & intf_route_type() const
void GetVnList(const TYPE &nexthops, VnListType *vn_list)
uint32_t vhost_prefix_len() const
bool IsEcmp(const TYPE &nexthops)
static void GetEcmpHashFieldsToUse(TYPE *item, EcmpLoadBalance &ecmp_load_balance)
const NextHop * nexthop() const
bool simulate_evpn_tor() const
void ReceiveInternal(const XmppStanza::XmppMessage *msg)
static int ParseEvpnAddress(const string &str, IpAddress *addr, const MacAddress &mac)
boost::asio::ip::address IpAddress
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)
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)
EndOfRibTxTimer * end_of_rib_tx_timer()
InetUnicastAgentRouteTable * PrefixToRouteMplsTable(const std::string &vrf_name, const IpAddress &prefix_addr)
void AddMplsRoute(std::string vrf_name, IpAddress ip, uint32_t plen, autogen::ItemType *item)
std::vector< int > SecurityGroupList
EndOfRibRxTimer * end_of_rib_rx_timer()
AgentStats * stats() const
static const uint32_t kInvalidExportLabel
bool is_multicast() const
std::unique_ptr< DBRequestData > data
void AddRemoteMplsRoute(std::string vrf_name, IpAddress ip, uint32_t plen, autogen::ItemType *item, const VnListType &vn_list)
void set_ifmap_active_xmpp_server(const std::string &addr, uint8_t xs_idx)
void set_controller_xmpp_channel_setup_time(uint64_t time, uint8_t idx)
void StartEndOfRibTxWalker()
InetUnicastAgentRouteTable * GetInet4UnicastRouteTable() const
static const uint64_t kInvalidPeerIdentifier
static TypeBmap MplsType()
InetUnicastAgentRouteTable * GetInet4MplsUnicastRouteTable() const
const pugi::xml_document & doc()
void UpdateConnectionInfo(xmps::PeerState state)
const std::string & GetExportName()
boost::scoped_ptr< EndOfRibRxTimer > end_of_rib_rx_timer_
bool ControllerSendMvpnRouteCommon(AgentRoute *route, bool associate)
InetUnicastAgentRouteTable * GetInet6UnicastRouteTable() const
const string & GetName() const
static void GetMulticastMacFromIp(const Ip4Address &ip, MacAddress &mac)
const MacAddress & mac() const
boost::scoped_ptr< LlgrStaleTimer > llgr_stale_timer_
AddressList vhost_default_gateway() const
static bool ControllerSendVmCfgSubscribe(AgentXmppChannel *peer, const boost::uuids::uuid &vm_id, bool subscribe)
uint16_t GetVlanTag() const
A structure to hold path parameters during the transfer (routes leaking) of data between VRF instance...
AgentXmppChannel * controller_xmpp_channel(uint8_t idx) const
MplsTable * mpls_table() const
static void SetMulticastPeer(AgentXmppChannel *old_peer, AgentXmppChannel *new_peer)
VxlanRoutingManager * vxlan_routing_manager() const
void Enqueue(ControllerWorkQueueDataType data)
uint64_t multicast_sequence_number()
Base class for all Route entries in agent.
static bool ControllerSendMcastRouteAdd(AgentXmppChannel *peer, AgentRoute *route)
static void HandleAgentXmppClientChannelEvent(AgentXmppChannel *peer, xmps::PeerState state)
virtual xmps::PeerState GetPeerState() const =0
Ip4Address vhost_prefix() const
void StopEndOfRibTxWalker()
static const char * kFqnPrependAgentNodeJID
virtual const std::string GetSourceAddressString() const =0
std::string ToString() const
uint32_t ethernet_tag() const
static TypeBmap MplsoMplsType()
AgentIfMapXmppChannel * ifmap_xmpp_channel(uint8_t idx) const
EndOfConfigTimer * end_of_config_timer()
virtual int AddAttribute(const std::string &key, const std::string &value)
void InetRequestDelete(const IpAddress &ip_address, const int prefix_len, std::string vrf_name, const Peer *bgp_peer)
AgentRoute * FindActiveEntry(const AgentRouteKey *key)
ListenerId Register(ChangeCallback callback, const std::string &name="unspecified")
void GetStringVector(std::vector< std::string > &string_vector) const
const AgentPath * FindOvsPath() const
const std::string & fabric_vrf_name() const
void ReceiveBgpMessage(std::unique_ptr< XmlBase > impl)
void AddClonedLocalPathReq(const Peer *peer, const string &vm_vrf, const IpAddress &addr, uint8_t plen, ClonedLocalPath *data)
NextHop * nexthop() const
bool mvpn_ipv4_enable() const
ControllerEcmpRoute * BuildEcmpData(TYPE *item, const VnListType &vn_list, const EcmpLoadBalance &ecmp_load_balance, const AgentRouteTable *rt_table, const std::string &prefix_str)
virtual Agent::RouteTableType GetTableType() const =0
virtual void ReceiveV4V6Update(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)
void StopPeerNotifyRoutes()
virtual int AddChildNode(const std::string &key, const std::string &value)
virtual bool Send(const uint8_t *, size_t, xmps::PeerId, SendReadyCb)=0
VrfEntry * vrf_entry() const
bool Send(const uint8_t *data, size_t size, const std::string *msg_str=NULL)
static bool FillEvpnOlist(Agent *agent, EnetOlistType &olist, TunnelOlist *tunnel_olist)
static bool IsRoutingVrf(const VrfEntry *vrf)
Determines whether the pointer to the VRF instance is of routing type.
std::unique_ptr< XmlBase > dom
bool IsNull(pugi::xml_node &node)
static const uint32_t kInvalidvxlan_id
void AddInetEcmpRoute(std::string vrf_name, IpAddress ip, uint32_t plen, autogen::ItemType *item, const VnListType &vn_list)
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)
void AddVhostMplsRoute(const IpAddress &vhost_addr, const Peer *peer)
TunnelType::TypeBmap GetTypeBitmap(const autogen::EnetTunnelEncapsulationListType &encap)
const std::string & source_port_str() const
static const char * kEndOfRibMarker
static bool IsXmppChannelActive(const Agent *agent, AgentXmppChannel *peer)
void NotifyAll(AgentXmppChannel *peer)
LlgrStaleTimer * llgr_stale_timer()
void PeerNotifyRoutes(WalkDoneCb cb)
uint64_t sequence_number() const
boost::asio::ip::address_v6 Ip6Address
Ip4Address router_id() const
VNController * controller() const
std::unique_ptr< DBRequestKey > key
void AddLocalVmRouteReq(const Peer *peer, const std::string &vrf_name, const MacAddress &mac, const IpAddress &ip_addr, uint32_t ethernet_tag, LocalVmRoute *data)
bool vxlan_routing_vn() const
static void AddMplsRouteReq(const Peer *peer, const string &vrf_name, const IpAddress &dst_addr, uint8_t plen, AgentRouteData *data)
uint32_t loc_sequence() const
bool ControllerSendMcastRouteCommon(AgentRoute *route, bool associate)
void LoadXmlDoc(const pugi::xml_document &doc)
const Peer * multicast_peer() const
virtual int ModifyAttribute(const std::string &key, const std::string &value)
void set_destination_ip()
const Peer * local_peer() const
virtual void ReceiveMvpnUpdate(XmlPugi *pugi)
AgentXmppChannel(Agent *agent, const std::string &xmpp_server, const std::string &label_range, uint8_t xs_idx)
ClonedLocalPathList & cloned_local_path_list()
static const MacAddress & BroadcastMac()
static void CleanConfigStale(AgentXmppChannel *agent_xmpp_channel)
virtual const std::string & ToString() const =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)
std::vector< std::string > CommunityList
virtual void UnRegisterReceive(xmps::PeerId)=0
uint8_t GetXmppServerIdx()
std::vector< Ip4Address > AddressList
static void XmppClientChannelEvent(AgentXmppChannel *peer, xmps::PeerState state)
InetUnicastAgentRouteTable * PrefixToRouteTable(const std::string &vrf_name, const IpAddress &prefix_addr)
virtual std::string LastStateName() const =0
AgentParam * params() const
void incr_sequence_number()
bool ControllerSendIPMcastRouteCommon(AgentRoute *route, bool associate)
virtual const char * ReadAttrib(const std::string &str)
const std::string & controller_ifmap_xmpp_server(uint8_t idx) const
std::vector< string > & GetControllerlist()
static bool ControllerSendCfgSubscribe(AgentXmppChannel *peer)
virtual const char * ReadNode(const std::string &name)
std::set< std::string > VnListType
static void DeleteReq(const Peer *peer, const string &vrf_name, const IpAddress &addr, uint8_t plen, AgentRouteData *data)
virtual const std::string & FromString() const =0
static TypeBmap NativeType()
static const std::string LoadBalanceDecision
const MacAddress & mac() const
static Type ComputeType(TypeBmap bmap)
static TypeBmap UDPType()
#define CONTROLLER_TX_CONFIG_TRACE(obj, index,...)
virtual void ReceiveUpdate(const XmppStanza::XmppMessage *msg)
virtual const PrefixType & prefix_address() const
Returns the value of a stored prefix address (IPv4, IPv6 or MAC address)
virtual int AddNode(const std::string &key, const std::string &value)
boost::asio::ip::address_v4 Ip4Address
virtual void Start(AgentXmppChannel *agent_xmpp_channel)
uint32_t GetActiveLabel() const
static const uint32_t kInvalidLabel
const AgentPath * FindIntfOrCompLocalVmPortPath() const
Finds path to an interface or a composite of interfaces and returns it. The priority is given to comp...
VrfTable * vrf_table() const
AgentPath * GetLocalVmPortPath() const
std::string GetXmppServer()
const std::string & destination_port_str() const
virtual ~AgentXmppChannel()
void AddVlanNHRouteReq(const Peer *peer, const string &vm_vrf, const IpAddress &addr, uint8_t plen, VlanNhRoute *data)
uint32_t GetEvpnMulticastSGFlags(const std::string &vrf_name, const Ip4Address &src_addr, const Ip4Address &grp_addr)
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)
void AddEvpnRoute(const std::string &vrf_name, std::string mac_addr, const IpAddress &ip, uint32_t plen, autogen::EnetItemType *item)
const std::string & destination_ip_str() const
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)
IpAddress AddressFromString(const std::string &ip_address_str, boost::system::error_code *ec)
boost::scoped_ptr< EndOfRibTxTimer > end_of_rib_tx_timer_
const std::string & ip_protocol_str() const
uint8_t prefix_length() const
!
const Peer * multicast_tree_builder_peer() const
virtual std::string ToString() const =0
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)
void FlushTimedOutChannels(uint8_t index)
static uint64_t UTCTimestampUsec()
uint32_t vxlan_id() const
ClonedLocalPathList::iterator ClonedLocalPathListIter
static TypeBmap GREType()
void AddEvpnEcmpRoute(std::string vrf_name, const MacAddress &mac, const IpAddress &ip, uint32_t plen, autogen::EnetItemType *item, const VnListType &vn_list)
void set_cn_mcast_builder(AgentXmppChannel *peer)
uint64_t end_of_rib_rx_time_
boost::system::error_code Inet6PrefixParse(const string &str, Ip6Address *addr, int *plen)
void AddMulticastEvpnRoute(const std::string &vrf_name, const IpAddress &source, const IpAddress &group, autogen::EnetItemType *item)
static int compare(const Type &lhs, const Type &rhs)
virtual int DeleteNode(const std::string &key)
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)
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)
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)
void RegisterXmppChannel(XmppChannel *channel)
void BuildTagList(const TYPE *item, TagList *tag_list)
static bool IsVxlanAvailable(const Agent *agent)
Checks whether VxLAN routing manager is enabled or not.
static const std::string & xmpp_control_node_prefix()
const boost::uuids::uuid & GetIfUuid() const
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)
Advertises an EVPN route received using XMPP channel.
void AddInetInterfaceRouteReq(const Peer *peer, const string &vm_vrf, const Ip4Address &addr, uint8_t plen, InetInterfaceRoute *data)
static const uint32_t kInvalidIndex
#define LOG(_Level, _Msg)
MplsLabel * FindMplsLabel(uint32_t label)
static const char * kConfigPeer
const std::string & name() const
const Peer * local_vm_peer() const
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)
virtual void UnRegisterWriteReady(xmps::PeerId id)=0
static bool ControllerSendMcastRouteDelete(AgentXmppChannel *peer, AgentRoute *route)
virtual void ReceiveMulticastUpdate(XmlPugi *pugi)
#define CONTROLLER_INFO_TRACE(obj,...)
static bool SetConfigPeer(AgentXmppChannel *peer)
static MulticastHandler * GetInstance()
void incr_xmpp_in_msgs(uint8_t idx)
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)
static void Notify(const Agent *agent, AgentXmppChannel *, DBTablePartBase *partition, DBEntryBase *e)
static XmppXmlImplFactory * Instance()
virtual AgentPath * FindPath(const Peer *peer) const
VnEntry * si_vn_ref() const
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)
std::vector< OlistTunnelEntry > TunnelOlist
virtual void ReceiveEvpnUpdate(XmlPugi *pugi)
static void AddRemoteVmRouteReq(const Peer *peer, const string &vm_vrf, const IpAddress &vm_addr, uint8_t plen, AgentRouteData *data)
void increment_multicast_sequence_number()
void AddInetMplsEcmpRoute(std::string vrf_name, IpAddress ip, uint32_t plen, autogen::ItemType *item, const VnListType &vn_list)
virtual void WriteReadyCb(const boost::system::error_code &ec)
process::ConnectionState * connection_state() const
GlobalSystemConfig * global_system_config() const
static const Peer * routing_vrf_vxlan_bgp_peer_
A pointer to the Peer where all BGP routes are stored.
InetUnicastRouteEntry * FindResolveRoute(const Ip4Address &ip)
uint32_t sequence() const
static uint64_t NewSeqNumber()
static TypeBmap VxlanType()
static const char * kBgpPeer
#define CONTROLLER_TRACE(obj,...)
uint32_t vxlan_id() const
void ReConnectXmppServer()
static bool ControllerSendSubscribe(AgentXmppChannel *peer, VrfEntry *vrf, bool subscribe)
virtual bool SendUpdate(const uint8_t *msg, size_t msgsize)
void set_destination_port()
const int8_t & ifmap_active_xmpp_server_index() const
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)
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)
void reset_ifmap_active_xmpp_server()
const boost::uuids::uuid & GetIfUuid() const
const std::string & ifmap_active_xmpp_server() const
static bool IsBgpPeerActive(const Agent *agent, AgentXmppChannel *peer)
std::vector< int > TagList
ConfigCleanupTimer * config_cleanup_timer()
std::string GetBgpPeerName() const
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 PopulateEcmpHashFieldsToUse(ItemType &item, const EcmpLoadBalance &ecmp_load_balance)
void incr_xmpp_out_msgs(uint8_t idx)
const std::string & fabric_policy_vrf_name() const
const Ip4Address & src_ip_addr() const
void AddRemoteRoute(std::string vrf_name, IpAddress prefix_addr, uint32_t prefix_len, autogen::ItemType *item, const VnListType &vn_list)