4 #include <bgp_schema_types.h>
22 #define LOGICAL_ROUTER_NAME "logical-router"
23 #define VIRTUAL_PORT_GROUP_CONFIG_NAME "virtual-port-group"
25 #define VMI_NETWORK_ROUTER_INTERFACE "network:router_interface"
28 using namespace boost::uuids;
29 using namespace autogen;
44 false, src_port_map, dst_port_map,
true));
57 VirtualNetwork *cfg =
static_cast<VirtualNetwork *
>(vn_node->
GetObject());
59 autogen::IdPermsType id_perms = cfg->id_perms();
61 CfgUuidSet(id_perms.uuid.uuid_mslong, id_perms.uuid.uuid_lslong, vn_uuid);
68 vn_iter != vn_node->
end(vn_graph); ++vn_iter) {
77 if(!(ri->is_default())) {
80 FloatingIp *fip =
static_cast<FloatingIp *
>(node->
GetObject());
83 boost::system::error_code ec;
84 IpAddress addr = IpAddress::from_string(fip->address(), ec);
85 if (ec.value() != 0) {
86 LOG(ERROR,
"Error decoding Floating IP address " << fip->address());
88 "Error decoding Floating IP address " +
92 IpAddress::from_string(fip->fixed_ip_address(), ec);
93 if (ec.value() != 0) {
96 if (!fixed_ip_addr.is_unspecified()) {
97 if ((addr.is_v4() && !fixed_ip_addr.is_v4()) ||
98 (addr.is_v6() && !fixed_ip_addr.is_v6())) {
99 string msg =
"Invalid fixed-ip " + fip->fixed_ip_address() +
100 " for FloatingIP " + fip->address();
108 if (ri->fabric_snat()) {
115 if (boost::iequals(fip->traffic_direction(),
"ingress"))
117 else if (boost::iequals(fip->traffic_direction(),
"egress"))
123 for (PortMappings::const_iterator it = fip->port_mappings().begin();
124 it != fip->port_mappings().end(); it++) {
128 dst_port_map.insert(std::make_pair(dst, it->dst_port));
131 src_port_map.insert(std::make_pair(src, it->src_port));
136 fip->port_mappings_enable(),
138 dst_port_map,
false));
169 fip_iter != node->
end(fip_graph); ++fip_iter) {
184 node1->
begin(pool_graph);
185 node1_iter != node1->
end(pool_graph); ++node1_iter) {
188 static_cast<IFMapNode *
>(node1_iter.operator->());
216 aip_iter != node->
end(aip_graph); ++aip_iter) {
228 pool_node->
begin(pool_graph);
229 pool_iter != pool_node->
end(pool_graph); ++pool_iter) {
232 static_cast<IFMapNode *
>(pool_iter.operator->());
238 VirtualNetwork *cfg = static_cast <VirtualNetwork *>
241 autogen::IdPermsType id_perms = cfg->id_perms();
243 CfgUuidSet(id_perms.uuid.uuid_mslong, id_perms.uuid.uuid_lslong,
252 vn_node->
begin(vn_graph);
253 vn_iter != vn_node->
end(vn_graph); ++vn_iter) {
256 static_cast<IFMapNode *
>(vn_iter.operator->());
264 if(!(ri->is_default())) {
267 AliasIp *aip =
static_cast<AliasIp *
>(node->
GetObject());
270 boost::system::error_code ec;
271 IpAddress addr = IpAddress::from_string(aip->address(), ec);
272 if (ec.value() != 0) {
274 "Error decoding Alias IP address " +
296 InterfaceRouteTable *entry =
297 static_cast<InterfaceRouteTable*
>(node->
GetObject());
300 for (std::vector<RouteType>::const_iterator it = entry->routes().begin();
301 it != entry->routes().end(); it++) {
303 boost::system::error_code ec;
309 if (ec.value() == 0) {
315 if (ec.value() == 0) {
319 LOG(DEBUG,
"Error decoding v4/v6 Static Route address " <<
324 IpAddress gw = IpAddress::from_string(it->next_hop, ec);
326 gw = IpAddress::from_string(
"0.0.0.0", ec);
333 it->community_attributes.community_attribute));
343 boost::system::error_code ec;
344 ip = Ip4Address::from_string(entry->ip_prefix().ip_prefix, ec);
345 if (ec.value() == 0) {
354 if (cfg->IsPropertySet(VirtualMachineInterface::PROPERTIES) ==
false)
357 if (cfg->properties().sub_interface_vlan_tag == 0)
366 uint16_t *rx_vlan_id,
367 uint16_t *tx_vlan_id,
371 if (*li_node == NULL) {
375 if (*phy_interface == NULL) {
377 FindAdjacentIFMapNode(node,
"physical-interface");
379 if (*phy_interface) {
383 if (!(*phy_interface)) {
389 if (*phy_device == NULL) {
392 FindAdjacentIFMapNode(*phy_interface,
"physical-router");
394 if (!(*phy_device)) {
400 autogen::LogicalInterface *port =
401 static_cast <autogen::LogicalInterface *>(node->
GetObject());
402 if (port->IsPropertySet(autogen::LogicalInterface::VLAN_TAG)) {
403 *rx_vlan_id = port->vlan_tag();
404 *tx_vlan_id = port->vlan_tag();
413 if (*vpg_node == NULL) {
418 FindAdjacentIFMapNode(node,
"virtual-port-group-physical-interface");
419 if (vpg_pi_node == NULL) {
423 if (*phy_interface == NULL) {
425 FindAdjacentIFMapNode(vpg_pi_node,
"physical-interface");
427 if (*phy_interface) {
431 if (*phy_interface == NULL) {
435 if (*phy_device == NULL) {
438 FindAdjacentIFMapNode(*phy_interface,
"physical-router");
440 if (*phy_device == NULL) {
447 for (std::vector<AllowedAddressPair>::const_iterator it =
448 cfg->allowed_address_pairs().begin();
449 it != cfg->allowed_address_pairs().end(); ++it) {
450 boost::system::error_code ec;
451 int plen = it->ip.ip_prefix_len;
452 IpAddress ip = Ip4Address::from_string(it->ip.ip_prefix, ec);
453 if (ec.value() != 0) {
454 ip = Ip6Address::from_string(it->ip.ip_prefix, ec);
456 if (ec.value() != 0) {
461 if (ec.value() != 0) {
470 if (it->address_mode ==
"active-active") {
485 VirtualMachineInterfaceRoutingInstance *entry =
486 static_cast<VirtualMachineInterfaceRoutingInstance*
>(node->
GetObject());
490 const PolicyBasedForwardingRuleType &rule = entry->data();
491 if (rule.direction ==
"" && !agent->
isMockMode()) {
502 iter != node->
end(graph); ++iter) {
509 if (rule.vlan_tag == 0 && rule.protocol ==
"" &&
510 rule.service_chain_address ==
"") {
512 const autogen::RoutingInstance *ri =
513 static_cast<autogen::RoutingInstance *
>(vrf_node->
GetObject());
514 if (ri->fabric_snat()) {
518 if (!rule.service_chain_address.size() &&
519 !rule.ipv6_service_chain_address.size()) {
520 LOG(DEBUG,
"Service VLAN IP address not specified for "
524 boost::system::error_code ec;
526 bool ip_set =
true, ip6_set =
true;
527 if (rule.service_chain_address.size()) {
528 addr = Ip4Address::from_string(rule.service_chain_address, ec);
529 if (ec.value() != 0) {
531 LOG(DEBUG,
"Error decoding Service VLAN IP address " <<
532 rule.service_chain_address);
536 if (rule.ipv6_service_chain_address.size()) {
537 addr6 = Ip6Address::from_string(rule.ipv6_service_chain_address,
539 if (ec.value() != 0) {
541 LOG(DEBUG,
"Error decoding Service VLAN IP address " <<
542 rule.ipv6_service_chain_address);
545 if (!ip_set && !ip6_set) {
549 if (rule.vlan_tag > 4093) {
550 LOG(DEBUG,
"Invalid VLAN Tag " << rule.vlan_tag);
554 LOG(DEBUG,
"Add Service VLAN entry <" << rule.vlan_tag <<
" : " <<
555 rule.service_chain_address <<
" : " << vrf_node->
name());
588 VirtualMachineInterface *cfg) {
589 if (cfg->vrf_assign_table().size() == 0)
593 if (cfg->properties().service_interface_type !=
"left" &&
594 cfg->properties().service_interface_type !=
"right") {
603 if (pt->source_prefix.ip_prefix.length() > 0) {
604 if (pt->source_prefix.ip_prefix_len < 8) {
605 LOG(ERROR,
"FatFlowCfg validation failed for VMI uuid:" << u
606 <<
" Protocol:" << pt->protocol <<
" Port:" << pt->port
607 <<
" Plen:" << pt->source_prefix.ip_prefix_len
608 <<
" src mask cannot be < 8\n");
611 if (pt->source_aggregate_prefix_length < pt->source_prefix.ip_prefix_len) {
612 LOG(ERROR,
"FatFlowCfg validation failed for VMI uuid:" << u
613 <<
" Protocol:" << pt->protocol <<
" Port:" << pt->port
614 <<
" src aggr plen is less than src mask\n");
618 if (pt->destination_prefix.ip_prefix.length() > 0) {
619 if (pt->destination_prefix.ip_prefix_len < 8) {
620 LOG(ERROR,
"FatFlowCfg validation failed for VMI uuid:" << u
621 <<
" Protocol:" << pt->protocol <<
" Port:" << pt->port
622 <<
" Plen:" << pt->destination_prefix.ip_prefix_len
623 <<
" dst mask cannot be < 8\n");
626 if (pt->destination_aggregate_prefix_length <
627 pt->destination_prefix.ip_prefix_len) {
628 LOG(ERROR,
"FatFlowCfg validation failed for VMI uuid:" << u
629 <<
" Protocol:" << pt->protocol <<
" Port:" << pt->port
630 <<
" dst aggr plen is less than dst mask\n");
634 if ((pt->source_prefix.ip_prefix.length() > 0) &&
635 (pt->destination_prefix.ip_prefix.length() > 0)) {
636 IpAddress ip_src = IpAddress::from_string(pt->source_prefix.ip_prefix);
637 IpAddress ip_dst = IpAddress::from_string(pt->destination_prefix.ip_prefix);
638 if ((ip_src.is_v4() && ip_dst.is_v6()) ||
639 (ip_src.is_v6() && ip_dst.is_v4())) {
640 LOG(ERROR,
"FatFlowCfg validation failed for VMI uuid:" << u <<
" Protocol:" << pt->protocol
641 <<
" Port:" << pt->port <<
" src and dst addr family mismatch\n");
650 VirtualMachineInterface *cfg = static_cast <VirtualMachineInterface *>
653 for (FatFlowProtocols::const_iterator it = cfg->fat_flow_protocols().begin();
654 it != cfg->fat_flow_protocols().end(); it++) {
659 it->protocol, it->port,
661 it->source_prefix.ip_prefix,
662 it->source_prefix.ip_prefix_len,
663 it->source_aggregate_prefix_length,
664 it->destination_prefix.ip_prefix,
665 it->destination_prefix.ip_prefix_len,
666 it->destination_aggregate_prefix_length);
673 InstanceIp *ip =
static_cast<InstanceIp *
>(node->
GetObject());
674 boost::system::error_code err;
675 IpAddress addr = IpAddress::from_string(ip->address(), err);
676 bool is_primary =
false;
678 if (err.value() != 0) {
682 if (ip->secondary() !=
true && ip->service_instance_ip() !=
true &&
683 ip->service_health_check_ip() !=
true) {
691 data->
addr_ > addr.to_v4()) {
692 data->
addr_ = addr.to_v4();
693 if (ip->mode() ==
"active-active") {
699 }
else if (addr.is_v6()) {
707 if (ip->mode() ==
"active-active") {
715 if (ip->service_instance_ip()) {
719 if (ip->mode() ==
"active-active") {
722 }
else if (addr.is_v6()) {
725 if (ip->mode() ==
"active-active") {
732 if (ip->mode() ==
"active-active") {
737 if (ip->secondary() || ip->service_instance_ip()) {
738 tracking_ip = IpAddress::from_string(
739 ip->secondary_ip_tracking_ip().ip_prefix, err);
740 if (err.value() != 0) {
744 if (tracking_ip == addr) {
749 if (ip->service_health_check_ip()) {
763 is_primary, ip->service_instance_ip(),
764 ip->service_health_check_ip(),
765 ip->local_ip(), tracking_ip));
769 is_primary, ip->service_instance_ip(),
770 ip->service_health_check_ip(),
771 ip->local_ip(), tracking_ip));
780 uuid tag_uuid = nil_uuid();
781 autogen::IdPermsType id_perms = tag_cfg->id_perms();
782 CfgUuidSet(id_perms.uuid.uuid_mslong, id_perms.uuid.uuid_lslong,
793 autogen::IdPermsType id_perms = sg_cfg->id_perms();
794 uint32_t sg_id = sg_cfg->id();
796 uuid sg_uuid = nil_uuid();
797 CfgUuidSet(id_perms.uuid.uuid_mslong, id_perms.uuid.uuid_lslong,
812 iter != vn_node->
end(graph); ++iter) {
822 if(ri->is_default()) {
840 bridge_domain_node->
begin(graph);
841 iter != bridge_domain_node->
end(graph); ++iter) {
865 iter != node->
end(graph); ++iter) {
874 ServiceTemplate *entry =
static_cast<ServiceTemplate*
>(adj_node->
GetObject());
878 ServiceTemplateType svc_template_props = entry->
properties();
879 string service_mode = svc_template_props.service_mode;
881 if (service_mode ==
"in-network") {
883 }
else if (service_mode ==
"transparent") {
885 }
else if (service_mode ==
"in-network-nat") {
896 PortTuple *entry =
static_cast<PortTuple*
>(node->
GetObject());
903 iter != node->
end(graph); ++iter) {
915 VirtualMachineInterface *vmi =
916 static_cast<autogen::VirtualMachineInterface *
>
918 if (!vmi->IsPropertySet(VirtualMachineInterface::DEVICE_OWNER)) {
928 IFMapNode *node,
const string &s_intf_type) {
929 PortTuple *entry =
static_cast<PortTuple*
>(node->
GetObject());
936 iter != node->
end(graph); ++iter) {
945 VirtualMachineInterface *cfg = static_cast <VirtualMachineInterface *>
947 if (!cfg->IsPropertySet(VirtualMachineInterface::PROPERTIES)) {
951 string interface_to_find =
"right";
952 if (s_intf_type ==
"right") {
953 interface_to_find =
"left";
955 const string &cfg_intf_type = cfg->properties().service_interface_type;
956 if (cfg_intf_type != interface_to_find) {
960 data->
is_left_si_ = (interface_to_find ==
"right") ?
true :
false;
962 autogen::IdPermsType id_perms = cfg->id_perms();
963 CfgUuidSet(id_perms.uuid.uuid_mslong, id_perms.uuid.uuid_lslong,
976 VirtualMachineInterfaceBridgeDomain *entry =
977 static_cast<VirtualMachineInterfaceBridgeDomain*
>(node->
GetObject());
980 const BridgeDomainMembershipType &vlan = entry->data();
985 iter != node->
end(graph); ++iter) {
988 static_cast<IFMapNode *
>(iter.operator->());
999 autogen::BridgeDomain *bd_cfg =
static_cast<autogen::BridgeDomain *
>
1001 if (bd_cfg->isid() == 0) {
1004 autogen::IdPermsType id_perms = bd_cfg->id_perms();
1005 uuid bd_uuid = nil_uuid();
1006 CfgUuidSet(id_perms.uuid.uuid_mslong, id_perms.uuid.uuid_lslong,
1011 if (bd_cfg->mac_learning_enabled()) {
1028 "Virtual-network UUID mismatch for interface:",
1030 "configuration VN uuid",
1038 "Virtual-machine UUID mismatch for interface:",
1040 "configuration VM UUID is",
1042 "compute VM uuid is",
1052 VirtualNetwork *vn =
1053 static_cast<VirtualNetwork *
>(node->
GetObject());
1055 autogen::IdPermsType id_perms = vn->id_perms();
1057 id_perms.uuid.uuid_lslong, data->
vn_uuid_);
1064 for (FatFlowProtocols::const_iterator it = vn->fat_flow_protocols().begin();
1065 it != vn->fat_flow_protocols().end(); it++) {
1071 it->protocol, it->port,
1073 it->source_prefix.ip_prefix,
1074 it->source_prefix.ip_prefix_len,
1075 it->source_aggregate_prefix_length,
1076 it->destination_prefix.ip_prefix,
1077 it->destination_prefix.ip_prefix_len,
1078 it->destination_aggregate_prefix_length);
1109 if (vn_node == NULL) {
1118 iter != vn_node->
end(graph); ++iter) {
1119 if (iter->IsDeleted()) {
1125 "host-based-service-virtual-network") == 0) {
1126 autogen::HostBasedServiceVirtualNetwork *hbsvn =
1127 static_cast<HostBasedServiceVirtualNetwork *
>(adj_node->
GetObject());
1128 ServiceVirtualNetworkType
type = hbsvn->data();
1129 if (strcmp(type.virtual_network_type.c_str(),
1132 }
else if (strcmp(type.virtual_network_type.c_str(),
1135 }
else if (strcmp(type.virtual_network_type.c_str(),
1136 "management") == 0) {
1148 Project *pr =
static_cast<Project *
>(node->
GetObject());
1164 if (link->
metadata() !=
"project-tag") {
1177 autogen::QosConfig *qc =
1178 static_cast<autogen::QosConfig *
>(node->
GetObject());
1180 autogen::IdPermsType id_perms = qc->id_perms();
1190 VirtualMachine *vm =
static_cast<VirtualMachine *
>(node->
GetObject());
1193 autogen::IdPermsType id_perms = vm->id_perms();
1195 id_perms.uuid.uuid_lslong, data->
vm_uuid_);
1221 VirtualMachineInterface *cfg,
1226 MirrorActionType mirror_to = cfg->properties().interface_mirror.mirror_to;
1227 if (mirror_to.analyzer_name.empty())
1230 if (!mirror_to.nic_assisted_mirroring) {
1231 boost::system::error_code ec;
1232 IpAddress dip = IpAddress::from_string(mirror_to.analyzer_ip_address,
1234 if (ec.value() != 0) {
1238 if (mirror_to.udp_port) {
1239 dport = mirror_to.udp_port;
1245 mirror_to.juniper_header);
1250 (mirror_to.analyzer_name, std::string(),
1253 }
else if (mirror_flag ==
1259 }
else if (mirror_flag ==
1261 IpAddress vtep_dip = IpAddress::from_string
1262 (mirror_to.static_nh_header.vtep_dst_ip_address, ec);
1263 if (ec.value() != 0) {
1269 mirror_to.static_nh_header.vni, mirror_flag,
1271 (mirror_to.static_nh_header.vtep_dst_mac_address));
1274 LOG(ERROR,
"Mirror nh mode not supported");
1278 mirror_to.analyzer_name,
1279 mirror_to.nic_assisted_mirroring_vlan);
1282 string traffic_direction =
1283 cfg->properties().interface_mirror.traffic_direction;
1284 if (traffic_direction.compare(
"egress") == 0) {
1286 }
else if (traffic_direction.compare(
"ingress") == 0) {
1296 for (std::vector<VrfAssignRuleType>::const_iterator iter =
1297 cfg->vrf_assign_table().begin(); iter != cfg->vrf_assign_table().end();
1300 iter->routing_instance,
1307 const std::string &node_type) {
1325 (ipam_node =
FindTarget(table, adj_node,
"network-ipam"))) {
1326 VirtualNetworkNetworkIpam *ipam =
1327 static_cast<VirtualNetworkNetworkIpam *
>(adj_node->
GetObject());
1329 const VnSubnetsType &subnets = ipam->data();
1330 boost::system::error_code ec;
1331 for (
unsigned int i = 0; i < subnets.ipam_subnets.size(); ++i) {
1333 Ip4Address::from_string(
1334 subnets.ipam_subnets[i].subnet.ip_prefix, ec),
1335 subnets.ipam_subnets[i].subnet.ip_prefix_len) && data->
addr_ !=
Ip4Address(0)) {
1336 data->
dhcp_enable_ = subnets.ipam_subnets[i].enable_dhcp;
1339 (Ip6Address::from_string(
1340 subnets.ipam_subnets[i].subnet.ip_prefix, ec)),
1341 subnets.ipam_subnets[i].subnet.ip_prefix_len)) {
1360 VirtualMachineInterface *cfg,
1369 if (*phy_interface) {
1374 if ((*phy_device) == NULL) {
1377 return static_cast<PhysicalRouter *
>((*phy_device)->GetObject());
1381 if (*phy_interface) {
1385 data->
rx_vlan_id_ = cfg->properties().sub_interface_vlan_tag;
1386 data->
tx_vlan_id_ = cfg->properties().sub_interface_vlan_tag;
1388 if ((*phy_device) == NULL) {
1391 return static_cast<PhysicalRouter *
>((*phy_device)->GetObject());
1399 if (!parent_vmi_node)
1403 VirtualMachineInterface *parent_cfg =
1404 static_cast <VirtualMachineInterface *> (parent_vmi_node->
GetObject());
1409 autogen::IdPermsType id_perms = parent_cfg->id_perms();
1410 CfgUuidSet(id_perms.uuid.uuid_mslong, id_perms.uuid.uuid_lslong,
1412 data->
rx_vlan_id_ = cfg->properties().sub_interface_vlan_tag;
1413 data->
tx_vlan_id_ = cfg->properties().sub_interface_vlan_tag;
1421 if (cfg->IsPropertySet
1422 (VirtualMachineInterface::ECMP_HASHING_INCLUDE_FIELDS) &&
1423 (cfg->ecmp_hashing_include_fields().hashing_configured)) {
1425 ecmp_hashing_include_fields());
1433 VirtualNetwork *vn_cfg =
1434 static_cast <VirtualNetwork *> (vn_node->
GetObject());
1435 if ((vn_cfg->IsPropertySet
1436 (VirtualNetwork::ECMP_HASHING_INCLUDE_FIELDS) ==
false) ||
1437 (vn_cfg->ecmp_hashing_include_fields().hashing_configured ==
false)) {
1443 ecmp_hashing_include_fields());
1450 const VirtualMachineInterface *cfg,
1453 const VirtualNetwork *vn = NULL;
1454 bool igmp_enabled =
false;
1457 vn =
static_cast<const VirtualNetwork *
>(vn_node->
GetObject());
1460 if (cfg) igmp_enabled = cfg->igmp_enable();
1462 if (vn && !igmp_enabled) igmp_enabled = vn->igmp_enable();
1464 if (!igmp_enabled) {
1477 const VirtualMachineInterface *cfg,
1480 const VirtualNetwork *vn = NULL;
1482 vn =
static_cast<const VirtualNetwork *
>(vn_node->
GetObject());
1485 if (cfg->IsPropertySet(VirtualMachineInterface::PROPERTIES)) {
1486 data->
max_flows_ = cfg->properties().max_flows;
1489 autogen::VirtualNetworkType properties = vn->properties();
1496 VirtualMachineInterface *cfg,
1499 if (cfg->IsPropertySet(VirtualMachineInterface::PROPERTIES)) {
1515 if (cfg->mac_addresses().size()) {
1516 data->
vm_mac_ = cfg->mac_addresses().at(0);
1539 PhysicalRouter *prouter,
1542 if (entry != NULL) {
1550 VirtualMachineInterface *cfg = static_cast <VirtualMachineInterface *>
1552 const std::vector<KeyValuePair> &bindings = cfg->bindings();
1553 bool vnic_type_direct =
false;
1554 bool vif_type_hw_veb =
false;
1555 for (std::vector<KeyValuePair>::const_iterator it = bindings.begin();
1556 it != bindings.end(); ++it) {
1557 KeyValuePair kvp = *it;
1558 if ((kvp.key ==
"vnic_type") && (kvp.value ==
"direct")) {
1559 vnic_type_direct =
true;
1560 }
else if ((kvp.key ==
"vif_type") && (kvp.value ==
"hw_veb")) {
1561 vif_type_hw_veb =
true;
1565 if (vnic_type_direct && vif_type_hw_veb) {
1576 if (prouter == NULL) {
1587 if (prouter->display_name() == agent->
agent_name()) {
1598 autogen::LogicalInterface *port =
1599 static_cast <autogen::LogicalInterface *>
1622 if (logical_router) {
1628 autogen::LogicalRouter *lr_obj =
1629 static_cast <autogen::LogicalRouter *>
1631 if (lr_obj->type() ==
"vxlan-routing") {
1643 bool dont_copy_label = *label_added;
1645 VmInterface::TagEntrySet::iterator tag_it;
1646 for (tag_it = tag_list.
list_.begin(); tag_it != tag_list.
list_.end();
1649 *label_added =
true;
1650 if (dont_copy_label) {
1663 bool label_added =
false;
1678 VirtualMachineInterface *cfg = static_cast <VirtualMachineInterface *>
1688 assert(!u.is_nil());
1711 string service_intf_type =
"";
1713 if (cfg->IsPropertySet(VirtualMachineInterface::PROPERTIES)) {
1714 service_intf_type = cfg->properties().service_interface_type;
1717 if (service_intf_type !=
"left" && service_intf_type !=
"right") {
1718 service_intf_type =
"";
1723 std::list<IFMapNode *> bgp_as_a_service_node_list;
1724 std::list<IFMapNode *> bgp_router_node_list;
1734 if (agent_->config_manager()->SkipNode(adj_node)) {
1741 if (adj_node->
table() == agent_->cfg()->cfg_sg_table()) {
1745 if (adj_node->
table() == agent_->cfg()->cfg_tag_table()) {
1749 if (adj_node->
table() == agent()->cfg()->cfg_slo_table()) {
1750 uuid slo_uuid = nil_uuid();
1751 autogen::SecurityLoggingObject *slo =
1752 static_cast<autogen::SecurityLoggingObject *
>(adj_node->
1754 autogen::IdPermsType id_perms = slo->id_perms();
1755 CfgUuidSet(id_perms.uuid.uuid_mslong, id_perms.uuid.uuid_lslong,
1760 if (adj_node->
table() == agent_->cfg()->cfg_vn_table()) {
1762 BuildVn(data, adj_node, u, &vn_list);
1765 if (adj_node->
table() == agent_->cfg()->cfg_qos_table()) {
1769 if (adj_node->
table() == agent_->cfg()->cfg_vm_table()) {
1770 BuildVm(data, adj_node, u, &vm_list);
1773 if (adj_node->
table() == agent_->cfg()->cfg_project_table()) {
1777 if (adj_node->
table() == agent_->cfg()->cfg_instanceip_table()) {
1781 if (adj_node->
table() == agent_->cfg()->cfg_floatingip_table()) {
1785 if (adj_node->
table() == agent_->cfg()->cfg_aliasip_table()) {
1789 if (adj_node->
table() == agent_->cfg()->cfg_vm_port_vrf_table()) {
1793 if (adj_node->
table() == agent_->cfg()->cfg_route_table()) {
1797 if (adj_node->
table() == agent_->cfg()->cfg_subnet_table()) {
1801 if (adj_node->
table() == agent_->cfg()->cfg_logical_port_table()) {
1803 &rx_vlan_id, &tx_vlan_id,
1804 &li_node, &phy_interface,
1808 if (adj_node->
table() == agent_->cfg()->cfg_vm_interface_table()) {
1809 parent_vmi_node = adj_node;
1813 bgp_as_a_service_node_list.push_back(adj_node);
1817 bgp_router_node_list.push_back(adj_node);
1820 if (adj_node->
table() == agent_->cfg()->cfg_vm_port_bridge_domain_table()) {
1824 if (adj_node->
table() == agent_->cfg()->cfg_port_tuple_table()) {
1825 if (!service_intf_type.empty()) {
1855 if (parent_vmi_node && data->
vm_uuid_ == nil_uuid()) {
1857 (parent_vmi_node->
table());
1861 vmi_iter != parent_vmi_node->
end(vmi_graph); ++vmi_iter) {
1864 if (agent_->config_manager()->SkipNode(vm_node, agent_->cfg()->cfg_vm_table())) {
1867 BuildVm(data, vm_node, u, &vm_list);
1873 agent_->oper_db()->bgp_as_a_service()->ProcessConfig
1874 (data->
vrf_name_, bgp_router_node_list, bgp_as_a_service_node_list, u);
1879 if ((vn_node && data->
addr_.to_ulong()) || (vn_node && !(data->
ip6_addr_.is_unspecified()))) {
1884 PhysicalRouter *prouter = NULL;
1887 data, parent_vmi_node, &phy_interface,
1905 if (cfg->display_name() == agent_->vhost_interface_name()) {
1907 agent_->set_vhost_disable_policy(cfg->disable_policy());
1908 vmi_uuid = nil_uuid();
1912 if (cfg->display_name() == agent_->vhost_interface_name()) {
1919 cfg->display_name());
1926 CopyTag(data, vmi_list, vm_list, vn_list, project_list);
1932 req.
data.reset(data);
1938 req.
data.reset(data);
1943 req.
data.reset(data);
1947 autogen::IdPermsType id_perms = prouter->id_perms();
1948 CfgUuidSet(id_perms.uuid.uuid_mslong, id_perms.uuid.uuid_lslong, dev);
1950 UpdatePhysicalDeviceVnEntry(u, dev, data->
vn_uuid_, vn_node);
1951 vmi_ifnode_to_req_++;
1980 agent_->oper_db()->bgp_as_a_service()->DeleteVmInterface(u);
1981 DelPhysicalDeviceVnEntry(u);
1997 if (state->
uuid().is_nil())
2000 agent()->config_manager()->AddVmiNode(node);
2006 VirtualMachineInterface *cfg = static_cast <VirtualMachineInterface *>
2008 autogen::IdPermsType id_perms = cfg->id_perms();
2009 CfgUuidSet(id_perms.uuid.uuid_mslong, id_perms.uuid.uuid_lslong, u);
PortSubscribeTable * port_subscribe_table() const
boost::uuids::uuid uuid()
static const MacAddress & ZeroMac()
VmInterface::FloatingIpList floating_ip_list_
static const uint32_t kInvalidSgId
static void UpdateVmiSiMode(Agent *agent, VmInterfaceConfigData *data, IFMapNode *node)
VmInterface::StaticRouteList static_route_list_
BridgeDomainEntrySet list_
void CopyTagList(VmInterfaceConfigData *data, VmInterface::TagEntryList &tag_list, bool *label_added)
static IFMapNode * FindTarget(IFMapAgentTable *table, IFMapNode *node, const std::string &node_type)
static void BuildBridgeDomainTable(Agent *agent, VmInterfaceConfigData *data, IFMapNode *node)
boost::uuids::uuid parent_vmi_
IpAddress GetMirrorSourceIp(const IpAddress &dest)
VmInterface::VrfAssignRuleList vrf_assign_rule_list_
static bool BuildBridgeDomainVrfTable(Agent *agent, IFMapNode *vn_node)
boost::uuids::uuid qos_config_uuid_
static PhysicalRouter * BuildParentInfo(Agent *agent, VirtualMachineInterface *cfg, IFMapNode *node, IFMapNode *logical_node, IFMapNode *vpg_node, VmInterfaceConfigData *data, IFMapNode *parent_vmi_node, IFMapNode **phy_interface, IFMapNode **phy_device)
static const uint8_t kMaxV6PrefixLen
static void CfgUuidSet(uint64_t ms_long, uint64_t ls_long, boost::uuids::uuid &u)
const std::string & metadata() const
boost::system::error_code Ip4PrefixParse(const string &str, Ip4Address *addr, int *plen)
Interface::MirrorDirection mirror_direction_
bool tor_agent_enabled() const
bool UpdateFields(const autogen::EcmpHashingIncludeFields &ecmp_hashing_fields)
boost::uuids::uuid vmi_cfg_uuid_
VmInterface::VmiType vmi_type_
static void BuildProxyArpFlags(Agent *agent, VmInterfaceConfigData *data, VirtualMachineInterface *cfg)
static uint32_t GetTypeVal(const std::string &str, const std::string &val)
bool VmiIFNodeToReq(IFMapNode *node, DBRequest &req, const boost::uuids::uuid &u)
IFMapNodeState * IFMapNodeGet(IFMapNode *node)
bool IsIp4SubnetMember(const Ip4Address &ip, const Ip4Address &prefix_ip, uint16_t plen)
static bool BuildFloatingIpVnVrf(Agent *agent, VmInterfaceConfigData *data, IFMapNode *node, IFMapNode *vn_node)
void set_uuid(const boost::uuids::uuid &u)
ConfigManager * config_manager() const
virtual const boost::uuids::uuid & vm_uuid() const =0
static bool IsVlanSubInterface(VirtualMachineInterface *cfg)
boost::asio::ip::address IpAddress
static const MacAddress & vrrp_mac()
VmInterface::InstanceIpList instance_ipv4_list_
static const MacAddress kZeroMac
bool pbb_gateway_mode() const
VmInterface::InstanceIpList instance_ipv6_list_
std::unique_ptr< DBRequestData > data
void SetIFMapNode(IFMapNode *node)
virtual const char * Typename() const =0
static void BuildQosConfig(VmInterfaceConfigData *data, IFMapNode *node)
static void BuildResolveRoute(VmInterfaceConfigData *data, IFMapNode *node)
static bool BuildBridgeDomainVnTable(Agent *agent, IFMapNode *bridge_domain_node)
InterfaceTable * interface_table() const
bool Enqueue(DBRequest *req)
static void BuildVn(VmInterfaceConfigData *data, IFMapNode *node, const boost::uuids::uuid &u, VmInterface::TagEntryList *tag_list)
void DelVmiToVmiType(const boost::uuids::uuid &u)
bool CanUseNode(IFMapNode *node)
bool VmiIFNodeToUuid(IFMapNode *node, boost::uuids::uuid &u)
static const uint8_t kMaxV4PrefixLen
virtual const boost::uuids::uuid & vn_uuid() const =0
VmInterface::ProxyArpMode proxy_arp_mode_
adjacency_iterator end(DBGraph *graph)
virtual bool MatchVn(const boost::uuids::uuid &u) const =0
static std::string UuidToString(const boost::uuids::uuid &id)
boost::uuids::uuid vm_uuid_
static void BuildAttributes(Agent *agent, IFMapNode *node, VirtualMachineInterface *cfg, VmInterfaceConfigData *data)
IFMapAgentTable * cfg_service_template_table() const
VmInterface::BridgeDomainList bridge_domain_list_
static void ComputeTypeInfo(Agent *agent, VmInterfaceConfigData *data, const PortSubscribeEntry *entry, PhysicalRouter *prouter, IFMapNode *node, IFMapNode *logical_node, IFMapNode *logical_router)
MirrorTable * mirror_table() const
std::string ToString() const
static void BuildVm(VmInterfaceConfigData *data, IFMapNode *node, const boost::uuids::uuid &u, VmInterface::TagEntryList *tag_list)
bool server_gateway_mode() const
static FatFlowEntry MakeFatFlowEntry(const std::string &protocol, const int &port, const std::string &ignore_addr_str, const std::string &src_prefix_str, const int &src_prefix_mask, const int &src_aggregate_plen, const std::string &dst_prefix_str, const int &dst_prefix_mask, const int &dst_aggregate_plen)
const DBGraph * GetGraph() const
const std::string & fabric_vrf_name() const
static void CompareVnVm(const uuid &vmi_uuid, VmInterfaceConfigData *data, const PortSubscribeEntry *entry)
static void ReadDhcpEnable(Agent *agent, VmInterfaceConfigData *data, IFMapNode *node)
void CopyTag(VmInterfaceConfigData *data, VmInterface::TagEntryList &vmi_list, VmInterface::TagEntryList &vm_list, VmInterface::TagEntryList &vn_list, VmInterface::TagEntryList &project_list)
IFMapAgentTable * cfg_vm_interface_table() const
#define IFMAP_ERROR(obj,...)
static void BuildProject(VmInterfaceConfigData *data, IFMapNode *node, const boost::uuids::uuid &u, VmInterface::TagEntryList *tag_list)
#define BGP_AS_SERVICE_CONFIG_NAME
static void BuildVmiSiMode(Agent *agent, VmInterfaceConfigData *data, IFMapNode *node)
static const uint32_t kInvalidVlanId
static void BuildAllowedAddressPairRouteList(VirtualMachineInterface *cfg, VmInterfaceConfigData *data)
static void BuildInterfaceConfigurationDataFromVpg(Agent *agent, IFMapNode *node, IFMapNode **vpg_node, IFMapNode **phy_interface, IFMapNode **phy_device)
bool cfg_igmp_enable() const
static void ReadIgmpConfig(Agent *agent, const IFMapNode *vn_node, const VirtualMachineInterface *cfg, VmInterfaceConfigData *data)
static const uint16_t AnalyzerUdpPort()
boost::asio::ip::address_v6 Ip6Address
Ip4Address router_id() const
std::unique_ptr< DBRequestKey > key
IFMapAgentTable * cfg_tag_table() const
AllowedAddressPairSet list_
IFMapAgentTable * cfg_vn_network_ipam_table() const
std::string service_intf_type_
VmInterface::SecurityGroupEntryList sg_list_
VmInterface::AliasIpList alias_ip_list_
VmInterface::AllowedAddressPairList allowed_address_pair_list_
boost::uuids::uuid si_other_end_vmi_
static const std::string & NullString()
PortSubscribeEntryPtr Get(const boost::uuids::uuid &vmi_uuid, const boost::uuids::uuid &vm_uuid, const boost::uuids::uuid &vn_uuid) const
#define LOGICAL_ROUTER_NAME
OperDhcpOptions oper_dhcp_options_
IpAddress service_health_check_ip_
void set_use_global_vrouter(bool use_global_vrouter)
#define OPER_TRACE_ENTRY(obj, table,...)
static void BuildInterfaceConfigurationData(Agent *agent, IFMapNode *node, uint16_t *rx_vlan_id, uint16_t *tx_vlan_id, IFMapNode **li_node, IFMapNode **phy_interface, IFMapNode **phy_device)
static void FillHbsInfo(VmInterfaceConfigData *data, IFMapNode *vn_node)
boost::shared_ptr< PortSubscribeEntry > PortSubscribeEntryPtr
std::vector< Ip4Address > AddressList
static MirrorEntryData::MirrorEntryFlags DecodeMirrorFlag(const std::string &nh_mode, bool juniper_header)
boost::uuids::uuid logical_interface_
const std::string & agent_name() const
static void BuildFloatingIpList(Agent *agent, VmInterfaceConfigData *data, IFMapNode *node)
const std::string & name() const
static void BuildTagList(VmInterface::TagEntryList *tag_list, IFMapNode *node)
virtual bool MatchVm(const boost::uuids::uuid &u) const =0
int GetVmiToVmiType(const boost::uuids::uuid &u)
const boost::uuids::uuid & fabric_vn_uuid() const
static void BuildFatFlowTable(Agent *agent, const boost::uuids::uuid &u, VmInterfaceConfigData *data, IFMapNode *node)
void CopyVhostData(const Agent *agent)
bool mac_ip_learning_enable_
boost::asio::ip::address_v4 Ip4Address
IFMapNodePtr SetState(IFMapNode *node)
const Properties & properties() const
static void BuildSiOtherVmi(Agent *agent, VmInterfaceConfigData *data, IFMapNode *node, const string &s_intf_type)
static void AddMirrorEntry(const std::string &analyzer_name, const std::string &vrf_name, const IpAddress &sip, uint16_t sport, const IpAddress &dip, uint16_t dport)
std::map< PortMapKey, uint16_t, PortMapKey > PortMap
std::string physical_interface_
VmInterface::HbsIntfType hbs_intf_type_
IFMapObject * GetObject()
void set_host_routes(const HostOptionsList &host_routes)
VmInterface::TagEntryList tag_list_
const Agent * agent() const
IFMapAgentTable * cfg_floatingip_pool_table() const
boost::intrusive_ptr< IFMapNodeState > IFMapNodePtr
VmInterface::FatFlowList fat_flow_list_
boost::system::error_code Inet6PrefixParse(const string &str, Ip6Address *addr, int *plen)
static void ReadDhcpOptions(VirtualMachineInterface *cfg, VmInterfaceConfigData &data)
void HandleVmiIfnodeDelete(const boost::uuids::uuid &vmi_uuid)
void HandleVmiIfnodeAdd(const boost::uuids::uuid &vmi_uuid, const VmInterfaceConfigData *data)
static void UpdateAttributes(Agent *agent, VmInterfaceConfigData *data)
static const std::string & BcastMac()
#define VIRTUAL_PORT_GROUP_CONFIG_NAME
IFMapAgentTable * cfg_bridge_domain_table() const
SecurityGroupEntrySet list_
#define LOG(_Level, _Msg)
static void ReadMaxFlowsConfig(const IFMapNode *vn_node, const VirtualMachineInterface *cfg, VmInterfaceConfigData *data)
edge_iterator edge_list_end(DBGraph *graph)
IFMapAgentTable * cfg_vrf_table() const
IFMapAgentTable * cfg_instanceip_table() const
const std::string & linklocal_vrf_name()
static bool DeleteVmi(InterfaceTable *table, const uuid &u, DBRequest *req)
IFMapAgentTable * cfg_vn_table() const
static bool BuildLogicalRouterData(Agent *agent, VmInterfaceConfigData *data, IFMapNode *node)
IFMapAgentTable * cfg_aliasip_pool_table() const
static void AddFabricFloatingIp(Agent *agent, VmInterfaceConfigData *data, IpAddress src_ip)
VmiEcmpLoadBalance ecmp_load_balance_
uint32_t local_preference_
AgentConfig * cfg() const
static void BuildStaticRouteList(VmInterfaceConfigData *data, IFMapNode *node)
VmInterface::DeviceType device_type_
const std::string & fabric_vn_name() const
bool SkipNode(IFMapNode *node)
static void BuildAliasIpList(InterfaceTable *intf_table, VmInterfaceConfigData *data, IFMapNode *node)
static bool ValidateFatFlowCfg(const boost::uuids::uuid &u, const ProtocolType *pt)
std::string analyzer_name_
static MacAddress FromString(const std::string &str, boost::system::error_code *error=NULL)
void Insert(const FatFlowEntry *rhs)
#define VMI_NETWORK_ROUTER_INTERFACE
static void ReadAnalyzerNameAndCreate(Agent *agent, VirtualMachineInterface *cfg, VmInterfaceConfigData &data)
adjacency_iterator begin(DBGraph *graph)
GlobalSystemConfig * global_system_config() const
bool IsIp6SubnetMember(const Ip6Address &ip, const Ip6Address &subnet, uint8_t plen)
IFMapAgentTable * cfg_service_instance_table() const
VmInterface::ServiceVlanList service_vlan_list_
static uint16_t ProtocolStringToInt(const std::string &str)
#define BGP_ROUTER_CONFIG_NAME
bool VmiProcessConfig(IFMapNode *node, DBRequest &req, const boost::uuids::uuid &u)
static void BuildVrfAssignRule(VirtualMachineInterface *cfg, VmInterfaceConfigData *data)
static void BuildInstanceIp(Agent *agent, VmInterfaceConfigData *data, IFMapNode *node)
static void BuildVrfAndServiceVlanInfo(Agent *agent, VmInterfaceConfigData *data, IFMapNode *node)
boost::uuids::uuid vn_uuid_
uint16_t mirror_port() const
static void BuildSgList(VmInterfaceConfigData *data, IFMapNode *node)
static void BuildEcmpHashingIncludeFields(VirtualMachineInterface *cfg, IFMapNode *vn_node, VmInterfaceConfigData *data)
void set_options(const DhcpOptionsList &options)
edge_iterator edge_list_begin(DBGraph *graph)
const std::string & fabric_policy_vrf_name() const