Search in sources :

Example 1 with COMPUTE

use of org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE in project onos by opennetworkinglab.

the class OpenstackSwitchingArpHandler method setFakeGatewayArpRule.

/**
 * Installs flow rules which convert ARP request packet into ARP reply
 * by adding a fake gateway MAC address as Source Hardware Address.
 *
 * @param osSubnet  openstack subnet
 * @param network   openstack network
 * @param install   flag which indicates whether to install rule or remove rule
 * @param osNode    openstack node
 */
private void setFakeGatewayArpRule(Subnet osSubnet, Network network, boolean install, OpenstackNode osNode) {
    if (ARP_BROADCAST_MODE.equals(getArpMode())) {
        Type netType = osNetworkService.networkType(network.getId());
        String gateway = osSubnet.getGateway();
        if (gateway == null) {
            return;
        }
        TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder();
        if (netType == VLAN) {
            sBuilder.matchVlanId(VlanId.vlanId(network.getProviderSegID()));
        } else if (netType == VXLAN || netType == GRE || netType == GENEVE) {
            // different networks
            if (!install) {
                long numOfDupGws = osNetworkService.subnets().stream().filter(s -> !s.getId().equals(osSubnet.getId())).filter(s -> s.getGateway() != null).filter(s -> s.getGateway().equals(osSubnet.getGateway())).count();
                if (numOfDupGws > 0) {
                    return;
                }
            }
        }
        sBuilder.matchEthType(EthType.EtherType.ARP.ethType().toShort()).matchArpOp(ARP.OP_REQUEST).matchArpTpa(Ip4Address.valueOf(gateway));
        if (osNode == null) {
            osNodeService.completeNodes(COMPUTE).forEach(n -> {
                Device device = deviceService.getDevice(n.intgBridge());
                TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
                if (netType == VLAN) {
                    tBuilder.popVlan();
                }
                tBuilder.extension(buildMoveEthSrcToDstExtension(device), device.id()).extension(buildMoveArpShaToThaExtension(device), device.id()).extension(buildMoveArpSpaToTpaExtension(device), device.id()).setArpOp(ARP.OP_REPLY).setArpSha(MacAddress.valueOf(gatewayMac)).setArpSpa(Ip4Address.valueOf(gateway)).setEthSrc(MacAddress.valueOf(gatewayMac)).setOutput(PortNumber.IN_PORT);
                osFlowRuleService.setRule(appId, n.intgBridge(), sBuilder.build(), tBuilder.build(), PRIORITY_ARP_GATEWAY_RULE, ARP_TABLE, install);
            });
        } else {
            Device device = deviceService.getDevice(osNode.intgBridge());
            TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
            if (netType == VLAN) {
                tBuilder.popVlan();
            }
            tBuilder.extension(buildMoveEthSrcToDstExtension(device), device.id()).extension(buildMoveArpShaToThaExtension(device), device.id()).extension(buildMoveArpSpaToTpaExtension(device), device.id()).setArpOp(ARP.OP_REPLY).setArpSha(MacAddress.valueOf(gatewayMac)).setArpSpa(Ip4Address.valueOf(gateway)).setOutput(PortNumber.IN_PORT);
            osFlowRuleService.setRule(appId, osNode.intgBridge(), sBuilder.build(), tBuilder.build(), PRIORITY_ARP_GATEWAY_RULE, ARP_TABLE, install);
        }
    }
}
Also used : OpenstackGroupRuleService(org.onosproject.openstacknetworking.api.OpenstackGroupRuleService) CoreService(org.onosproject.core.CoreService) InstancePort(org.onosproject.openstacknetworking.api.InstancePort) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) LoggerFactory(org.slf4j.LoggerFactory) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) ARP(org.onlab.packet.ARP) OpenstackNetworkListener(org.onosproject.openstacknetworking.api.OpenstackNetworkListener) PRIORITY_ARP_REQUEST_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_ARP_REQUEST_RULE) InstancePortEvent(org.onosproject.openstacknetworking.api.InstancePortEvent) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ByteBuffer(java.nio.ByteBuffer) PRIORITY_ARP_REPLY_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_ARP_REPLY_RULE) Ethernet(org.onlab.packet.Ethernet) OpenstackNodeListener(org.onosproject.openstacknode.api.OpenstackNodeListener) VLAN(org.onosproject.openstacknetworking.api.OpenstackNetwork.Type.VLAN) Type(org.onosproject.openstacknetworking.api.OpenstackNetwork.Type) ApplicationId(org.onosproject.core.ApplicationId) RulePopulatorUtil.buildMoveEthSrcToDstExtension(org.onosproject.openstacknetworking.util.RulePopulatorUtil.buildMoveEthSrcToDstExtension) RulePopulatorUtil.buildMoveArpShaToThaExtension(org.onosproject.openstacknetworking.util.RulePopulatorUtil.buildMoveArpShaToThaExtension) OpenstackNetworkEvent(org.onosproject.openstacknetworking.api.OpenstackNetworkEvent) MastershipService(org.onosproject.mastership.MastershipService) ALL(org.onosproject.net.group.GroupDescription.Type.ALL) GRE(org.onosproject.openstacknetworking.api.OpenstackNetwork.Type.GRE) NodeId(org.onosproject.cluster.NodeId) OpenstackNodeService(org.onosproject.openstacknode.api.OpenstackNodeService) Ip4Address(org.onlab.packet.Ip4Address) Device(org.onosproject.net.Device) OpenstackFlowRuleService(org.onosproject.openstacknetworking.api.OpenstackFlowRuleService) ARP_PROXY_MODE(org.onosproject.openstacknetworking.api.Constants.ARP_PROXY_MODE) Deactivate(org.osgi.service.component.annotations.Deactivate) PRIORITY_ARP_GROUP_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_ARP_GROUP_RULE) PacketProcessor(org.onosproject.net.packet.PacketProcessor) Set(java.util.Set) PacketService(org.onosproject.net.packet.PacketService) Executors.newSingleThreadExecutor(java.util.concurrent.Executors.newSingleThreadExecutor) Collectors(java.util.stream.Collectors) InstancePortListener(org.onosproject.openstacknetworking.api.InstancePortListener) NetworkType(org.openstack4j.model.network.NetworkType) Objects(java.util.Objects) EthType(org.onlab.packet.EthType) List(java.util.List) OPENSTACK_NETWORKING_APP_ID(org.onosproject.openstacknetworking.api.Constants.OPENSTACK_NETWORKING_APP_ID) FLAT(org.onosproject.openstacknetworking.api.OpenstackNetwork.Type.FLAT) PacketContext(org.onosproject.net.packet.PacketContext) OpenstackNetworkingUtil.swapStaleLocation(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.swapStaleLocation) ClusterService(org.onosproject.cluster.ClusterService) ARP_MODE_DEFAULT(org.onosproject.openstacknetworking.impl.OsgiPropertyConstants.ARP_MODE_DEFAULT) OpenstackNetworkingUtil.tunnelPortNumByNetId(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.tunnelPortNumByNetId) Dictionary(java.util.Dictionary) IdEntity(org.openstack4j.model.common.IdEntity) Tools(org.onlab.util.Tools) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) Network(org.openstack4j.model.network.Network) COMPUTE(org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE) GATEWAY_MAC_DEFAULT(org.onosproject.openstacknetworking.impl.OsgiPropertyConstants.GATEWAY_MAC_DEFAULT) ComponentContext(org.osgi.service.component.ComponentContext) RulePopulatorUtil.buildExtension(org.onosproject.openstacknetworking.util.RulePopulatorUtil.buildExtension) GroupBucket(org.onosproject.net.group.GroupBucket) RulePopulatorUtil.buildMoveArpSpaToTpaExtension(org.onosproject.openstacknetworking.util.RulePopulatorUtil.buildMoveArpSpaToTpaExtension) OpenstackNetworkService(org.onosproject.openstacknetworking.api.OpenstackNetworkService) Component(org.osgi.service.component.annotations.Component) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) Activate(org.osgi.service.component.annotations.Activate) GATEWAY_MAC(org.onosproject.openstacknetworking.impl.OsgiPropertyConstants.GATEWAY_MAC) ARP_TABLE(org.onosproject.openstacknetworking.api.Constants.ARP_TABLE) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ARP_MODE(org.onosproject.openstacknetworking.impl.OsgiPropertyConstants.ARP_MODE) ExecutorService(java.util.concurrent.ExecutorService) IpAddress(org.onlab.packet.IpAddress) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Logger(org.slf4j.Logger) ACTIVE(org.onosproject.openstacknetworking.api.InstancePort.State.ACTIVE) VlanId(org.onlab.packet.VlanId) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) GENEVE(org.onosproject.openstacknetworking.api.OpenstackNetwork.Type.GENEVE) Subnet(org.openstack4j.model.network.Subnet) PRIORITY_ARP_GATEWAY_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_ARP_GATEWAY_RULE) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) OpenstackNodeEvent(org.onosproject.openstacknode.api.OpenstackNodeEvent) OpenstackNetworkingUtil.getPropertyValue(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getPropertyValue) GroupId(org.onosproject.core.GroupId) ConfigProperty(org.onosproject.cfg.ConfigProperty) Modified(org.osgi.service.component.annotations.Modified) MacAddress(org.onlab.packet.MacAddress) VXLAN(org.onosproject.openstacknetworking.api.OpenstackNetwork.Type.VXLAN) Reference(org.osgi.service.component.annotations.Reference) PRIORITY_ARP_CONTROL_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_ARP_CONTROL_RULE) LeadershipService(org.onosproject.cluster.LeadershipService) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) InstancePortService(org.onosproject.openstacknetworking.api.InstancePortService) ARP_BROADCAST_MODE(org.onosproject.openstacknetworking.api.Constants.ARP_BROADCAST_MODE) RulePopulatorUtil.buildGroupBucket(org.onosproject.openstacknetworking.util.RulePopulatorUtil.buildGroupBucket) Type(org.onosproject.openstacknetworking.api.OpenstackNetwork.Type) NetworkType(org.openstack4j.model.network.NetworkType) EthType(org.onlab.packet.EthType) Device(org.onosproject.net.Device) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 2 with COMPUTE

use of org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE in project onos by opennetworkinglab.

the class OpenstackSwitchingHandler method setForwardingRulesForVlan.

/**
 * Configures the flow rules which are used for L2 VLAN packet switching.
 * Note that these rules will be inserted in switching table (table 5).
 *
 * @param instPort instance port object
 * @param install install flag, add the rule if true, remove it otherwise
 */
private void setForwardingRulesForVlan(InstancePort instPort, boolean install) {
    // switching rules for the instPorts in the same node
    TrafficSelector selector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPDst(instPort.ipAddress().toIpPrefix()).matchVlanId(getVlanId(instPort)).build();
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().popVlan().setEthDst(instPort.macAddress()).setOutput(instPort.portNumber()).build();
    osFlowRuleService.setRule(appId, instPort.deviceId(), selector, treatment, PRIORITY_SWITCHING_RULE, FORWARDING_TABLE, install);
    // switching rules for the instPorts in the remote node
    osNodeService.completeNodes(COMPUTE).stream().filter(remoteNode -> !remoteNode.intgBridge().equals(instPort.deviceId()) && remoteNode.vlanIntf() != null).forEach(remoteNode -> {
        TrafficTreatment treatmentToRemote = DefaultTrafficTreatment.builder().setEthDst(instPort.macAddress()).setOutput(remoteNode.vlanPortNum()).build();
        osFlowRuleService.setRule(appId, remoteNode.intgBridge(), selector, treatmentToRemote, PRIORITY_SWITCHING_RULE, FORWARDING_TABLE, install);
    });
}
Also used : CoreService(org.onosproject.core.CoreService) InstancePort(org.onosproject.openstacknetworking.api.InstancePort) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) OpenstackNetworkListener(org.onosproject.openstacknetworking.api.OpenstackNetworkListener) InstancePortEvent(org.onosproject.openstacknetworking.api.InstancePortEvent) OPENSTACK_INSTANCE_MIGRATION_STARTED(org.onosproject.openstacknetworking.api.InstancePortEvent.Type.OPENSTACK_INSTANCE_MIGRATION_STARTED) DriverService(org.onosproject.net.driver.DriverService) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) Ethernet(org.onlab.packet.Ethernet) PRIORITY_TUNNEL_TAG_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_TUNNEL_TAG_RULE) Type(org.onosproject.openstacknetworking.api.OpenstackNetwork.Type) ApplicationId(org.onosproject.core.ApplicationId) OpenstackNetworkEvent(org.onosproject.openstacknetworking.api.OpenstackNetworkEvent) MastershipService(org.onosproject.mastership.MastershipService) ACL_EGRESS_TABLE(org.onosproject.openstacknetworking.api.Constants.ACL_EGRESS_TABLE) NodeId(org.onosproject.cluster.NodeId) OpenstackNodeService(org.onosproject.openstacknode.api.OpenstackNodeService) OpenstackFlowRuleService(org.onosproject.openstacknetworking.api.OpenstackFlowRuleService) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) PRIORITY_ADMIN_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_ADMIN_RULE) Executors.newSingleThreadExecutor(java.util.concurrent.Executors.newSingleThreadExecutor) InstancePortListener(org.onosproject.openstacknetworking.api.InstancePortListener) Objects(java.util.Objects) OPENSTACK_NETWORKING_APP_ID(org.onosproject.openstacknetworking.api.Constants.OPENSTACK_NETWORKING_APP_ID) OpenstackNetworkingUtil.swapStaleLocation(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.swapStaleLocation) ClusterService(org.onosproject.cluster.ClusterService) OpenstackNetworkingUtil.tunnelPortNumByNetId(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.tunnelPortNumByNetId) PRE_FLAT_TABLE(org.onosproject.openstacknetworking.api.Constants.PRE_FLAT_TABLE) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) Network(org.openstack4j.model.network.Network) COMPUTE(org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE) RulePopulatorUtil.buildExtension(org.onosproject.openstacknetworking.util.RulePopulatorUtil.buildExtension) Strings(com.google.common.base.Strings) OpenstackNetworkService(org.onosproject.openstacknetworking.api.OpenstackNetworkService) Component(org.osgi.service.component.annotations.Component) TrafficSelector(org.onosproject.net.flow.TrafficSelector) Activate(org.osgi.service.component.annotations.Activate) ARP_TABLE(org.onosproject.openstacknetworking.api.Constants.ARP_TABLE) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ExecutorService(java.util.concurrent.ExecutorService) Port(org.openstack4j.model.network.Port) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) FORWARDING_TABLE(org.onosproject.openstacknetworking.api.Constants.FORWARDING_TABLE) Logger(org.slf4j.Logger) VlanId(org.onlab.packet.VlanId) PRIORITY_SWITCHING_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_SWITCHING_RULE) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) OpenstackNetworkingUtil.getPropertyValue(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getPropertyValue) ConfigProperty(org.onosproject.cfg.ConfigProperty) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) OpenstackNetworkingUtil.deriveResourceName(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.deriveResourceName) Reference(org.osgi.service.component.annotations.Reference) LeadershipService(org.onosproject.cluster.LeadershipService) VTAG_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAG_TABLE) InstancePortService(org.onosproject.openstacknetworking.api.InstancePortService) ARP_BROADCAST_MODE(org.onosproject.openstacknetworking.api.Constants.ARP_BROADCAST_MODE) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 3 with COMPUTE

use of org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE in project onos by opennetworkinglab.

the class OpenstackRoutingHandler method setGatewayRules.

private void setGatewayRules(Subnet osSubnet, Router osRouter, boolean install) {
    OpenstackNode srcNatGw = osNodeService.completeNodes(GATEWAY).stream().findFirst().orElse(null);
    if (srcNatGw == null) {
        return;
    }
    if (Strings.isNullOrEmpty(osSubnet.getGateway())) {
        // do nothing if no gateway is set
        return;
    }
    Network net = osNetworkAdminService.network(osSubnet.getNetworkId());
    Type netType = osNetworkAdminService.networkType(osSubnet.getNetworkId());
    Set<Subnet> routableSubnets = routableSubnets(osRouter, osSubnet.getId());
    // install rules to each compute node for routing IP packets to gateways
    osNodeService.completeNodes(COMPUTE).stream().filter(cNode -> cNode.dataIp() != null).forEach(cNode -> setRulesToGatewayWithRoutableSubnets(cNode, srcNatGw, net.getProviderSegID(), osSubnet, routableSubnets, netType, install));
    // install rules to punt ICMP packets to controller at gateway node
    // this rule is only valid for stateless ICMP SNAT case
    osNodeService.completeNodes(GATEWAY).forEach(gNode -> setReactiveGatewayIcmpRule(IpAddress.valueOf(osSubnet.getGateway()), gNode.intgBridge(), install));
    final String updateStr = install ? MSG_ENABLED : MSG_DISABLED;
    log.debug(updateStr + "IP to {}", osSubnet.getGateway());
}
Also used : OpenstackRouterService(org.onosproject.openstacknetworking.api.OpenstackRouterService) CoreService(org.onosproject.core.CoreService) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) LoggerFactory(org.slf4j.LoggerFactory) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) Constants(org.onosproject.openstacknetworking.api.Constants) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) STAT_OUTBOUND_TABLE(org.onosproject.openstacknetworking.api.Constants.STAT_OUTBOUND_TABLE) Ethernet(org.onlab.packet.Ethernet) OpenstackNodeListener(org.onosproject.openstacknode.api.OpenstackNodeListener) Executors.newSingleThreadScheduledExecutor(java.util.concurrent.Executors.newSingleThreadScheduledExecutor) PRIORITY_INTERNAL_ROUTING_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_INTERNAL_ROUTING_RULE) Type(org.onosproject.openstacknetworking.api.OpenstackNetwork.Type) ApplicationId(org.onosproject.core.ApplicationId) NodeId(org.onosproject.cluster.NodeId) PRIORITY_ICMP_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_ICMP_RULE) OpenstackNodeService(org.onosproject.openstacknode.api.OpenstackNodeService) ImmutableSet(com.google.common.collect.ImmutableSet) OpenstackFlowRuleService(org.onosproject.openstacknetworking.api.OpenstackFlowRuleService) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) PRIORITY_ADMIN_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_ADMIN_RULE) ICMP(org.onlab.packet.ICMP) USE_STATEFUL_SNAT(org.onosproject.openstacknetworking.impl.OsgiPropertyConstants.USE_STATEFUL_SNAT) Collectors(java.util.stream.Collectors) OpenstackNetworkingUtil.getPropertyValueAsBoolean(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getPropertyValueAsBoolean) Objects(java.util.Objects) OPENSTACK_NETWORKING_APP_ID(org.onosproject.openstacknetworking.api.Constants.OPENSTACK_NETWORKING_APP_ID) ClusterService(org.onosproject.cluster.ClusterService) DeviceId(org.onosproject.net.DeviceId) ROUTING_TABLE(org.onosproject.openstacknetworking.api.Constants.ROUTING_TABLE) IpPrefix(org.onlab.packet.IpPrefix) GATEWAY(org.onosproject.openstacknode.api.OpenstackNode.NodeType.GATEWAY) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) Network(org.openstack4j.model.network.Network) COMPUTE(org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE) RulePopulatorUtil.buildExtension(org.onosproject.openstacknetworking.util.RulePopulatorUtil.buildExtension) RouterInterface(org.openstack4j.model.network.RouterInterface) OpenstackRouterEvent(org.onosproject.openstacknetworking.api.OpenstackRouterEvent) Strings(com.google.common.base.Strings) Component(org.osgi.service.component.annotations.Component) OpenstackNetworkingUtil.tunnelPortNumByNetType(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.tunnelPortNumByNetType) TrafficSelector(org.onosproject.net.flow.TrafficSelector) OpenstackNetworkAdminService(org.onosproject.openstacknetworking.api.OpenstackNetworkAdminService) Router(org.openstack4j.model.network.Router) Activate(org.osgi.service.component.annotations.Activate) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ARP_MODE(org.onosproject.openstacknetworking.impl.OsgiPropertyConstants.ARP_MODE) ExecutorService(java.util.concurrent.ExecutorService) IpAddress(org.onlab.packet.IpAddress) PRIORITY_ICMP_REQUEST_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_ICMP_REQUEST_RULE) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Logger(org.slf4j.Logger) VlanId(org.onlab.packet.VlanId) Subnet(org.openstack4j.model.network.Subnet) PRIORITY_SWITCHING_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_SWITCHING_RULE) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) IPv4(org.onlab.packet.IPv4) OpenstackRouterListener(org.onosproject.openstacknetworking.api.OpenstackRouterListener) OpenstackNodeEvent(org.onosproject.openstacknode.api.OpenstackNodeEvent) OpenstackNetworkingUtil.getPropertyValue(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getPropertyValue) ConfigProperty(org.onosproject.cfg.ConfigProperty) OpenstackNetworkingUtil.deriveResourceName(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.deriveResourceName) Reference(org.osgi.service.component.annotations.Reference) LeadershipService(org.onosproject.cluster.LeadershipService) InstancePortService(org.onosproject.openstacknetworking.api.InstancePortService) ARP_BROADCAST_MODE(org.onosproject.openstacknetworking.api.Constants.ARP_BROADCAST_MODE) Type(org.onosproject.openstacknetworking.api.OpenstackNetwork.Type) OpenstackNetworkingUtil.tunnelPortNumByNetType(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.tunnelPortNumByNetType) Network(org.openstack4j.model.network.Network) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) Subnet(org.openstack4j.model.network.Subnet)

Example 4 with COMPUTE

use of org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE in project onos by opennetworkinglab.

the class OpenstackRoutingHandler method setRouterAdminRules.

private void setRouterAdminRules(String segmentId, Type networkType, boolean install) {
    TrafficTreatment treatment;
    TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4);
    switch(networkType) {
        case VXLAN:
        case GRE:
        case GENEVE:
            sBuilder.matchTunnelId(Long.parseLong(segmentId));
            break;
        case VLAN:
            sBuilder.matchVlanId(VlanId.vlanId(segmentId));
            break;
        default:
            final String error = String.format("%s %s", ERR_UNSUPPORTED_NET_TYPE, networkType.toString());
            throw new IllegalStateException(error);
    }
    treatment = DefaultTrafficTreatment.builder().drop().build();
    osNodeService.completeNodes().stream().filter(osNode -> osNode.type() == COMPUTE).forEach(osNode -> {
        osFlowRuleService.setRule(appId, osNode.intgBridge(), sBuilder.build(), treatment, PRIORITY_ADMIN_RULE, ROUTING_TABLE, install);
    });
}
Also used : OpenstackRouterService(org.onosproject.openstacknetworking.api.OpenstackRouterService) CoreService(org.onosproject.core.CoreService) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) LoggerFactory(org.slf4j.LoggerFactory) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) Constants(org.onosproject.openstacknetworking.api.Constants) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) STAT_OUTBOUND_TABLE(org.onosproject.openstacknetworking.api.Constants.STAT_OUTBOUND_TABLE) Ethernet(org.onlab.packet.Ethernet) OpenstackNodeListener(org.onosproject.openstacknode.api.OpenstackNodeListener) Executors.newSingleThreadScheduledExecutor(java.util.concurrent.Executors.newSingleThreadScheduledExecutor) PRIORITY_INTERNAL_ROUTING_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_INTERNAL_ROUTING_RULE) Type(org.onosproject.openstacknetworking.api.OpenstackNetwork.Type) ApplicationId(org.onosproject.core.ApplicationId) NodeId(org.onosproject.cluster.NodeId) PRIORITY_ICMP_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_ICMP_RULE) OpenstackNodeService(org.onosproject.openstacknode.api.OpenstackNodeService) ImmutableSet(com.google.common.collect.ImmutableSet) OpenstackFlowRuleService(org.onosproject.openstacknetworking.api.OpenstackFlowRuleService) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) PRIORITY_ADMIN_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_ADMIN_RULE) ICMP(org.onlab.packet.ICMP) USE_STATEFUL_SNAT(org.onosproject.openstacknetworking.impl.OsgiPropertyConstants.USE_STATEFUL_SNAT) Collectors(java.util.stream.Collectors) OpenstackNetworkingUtil.getPropertyValueAsBoolean(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getPropertyValueAsBoolean) Objects(java.util.Objects) OPENSTACK_NETWORKING_APP_ID(org.onosproject.openstacknetworking.api.Constants.OPENSTACK_NETWORKING_APP_ID) ClusterService(org.onosproject.cluster.ClusterService) DeviceId(org.onosproject.net.DeviceId) ROUTING_TABLE(org.onosproject.openstacknetworking.api.Constants.ROUTING_TABLE) IpPrefix(org.onlab.packet.IpPrefix) GATEWAY(org.onosproject.openstacknode.api.OpenstackNode.NodeType.GATEWAY) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) Network(org.openstack4j.model.network.Network) COMPUTE(org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE) RulePopulatorUtil.buildExtension(org.onosproject.openstacknetworking.util.RulePopulatorUtil.buildExtension) RouterInterface(org.openstack4j.model.network.RouterInterface) OpenstackRouterEvent(org.onosproject.openstacknetworking.api.OpenstackRouterEvent) Strings(com.google.common.base.Strings) Component(org.osgi.service.component.annotations.Component) OpenstackNetworkingUtil.tunnelPortNumByNetType(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.tunnelPortNumByNetType) TrafficSelector(org.onosproject.net.flow.TrafficSelector) OpenstackNetworkAdminService(org.onosproject.openstacknetworking.api.OpenstackNetworkAdminService) Router(org.openstack4j.model.network.Router) Activate(org.osgi.service.component.annotations.Activate) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ARP_MODE(org.onosproject.openstacknetworking.impl.OsgiPropertyConstants.ARP_MODE) ExecutorService(java.util.concurrent.ExecutorService) IpAddress(org.onlab.packet.IpAddress) PRIORITY_ICMP_REQUEST_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_ICMP_REQUEST_RULE) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Logger(org.slf4j.Logger) VlanId(org.onlab.packet.VlanId) Subnet(org.openstack4j.model.network.Subnet) PRIORITY_SWITCHING_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_SWITCHING_RULE) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) IPv4(org.onlab.packet.IPv4) OpenstackRouterListener(org.onosproject.openstacknetworking.api.OpenstackRouterListener) OpenstackNodeEvent(org.onosproject.openstacknode.api.OpenstackNodeEvent) OpenstackNetworkingUtil.getPropertyValue(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getPropertyValue) ConfigProperty(org.onosproject.cfg.ConfigProperty) OpenstackNetworkingUtil.deriveResourceName(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.deriveResourceName) Reference(org.osgi.service.component.annotations.Reference) LeadershipService(org.onosproject.cluster.LeadershipService) InstancePortService(org.onosproject.openstacknetworking.api.InstancePortService) ARP_BROADCAST_MODE(org.onosproject.openstacknetworking.api.Constants.ARP_BROADCAST_MODE) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 5 with COMPUTE

use of org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE in project onos by opennetworkinglab.

the class StatsFlowRuleManager method getOverlayDstPortBasedFlowInfos.

/**
 * Gets a set of flow infos by referring to overlay destination VM port.
 *
 * @return flow infos
 */
private Set<FlowInfo> getOverlayDstPortBasedFlowInfos() {
    Set<FlowInfo> flowInfos = Sets.newConcurrentHashSet();
    Set<PortNumber> instPortNums = instPortService.instancePorts().stream().map(InstancePort::portNumber).collect(Collectors.toSet());
    Set<DeviceId> deviceIds = osNodeService.completeNodes(COMPUTE).stream().map(OpenstackNode::intgBridge).collect(Collectors.toSet());
    deviceIds.forEach(d -> {
        List<PortStatistics> stats = deviceService.getPortStatistics(d).stream().filter(s -> instPortNums.contains(s.portNumber())).collect(Collectors.toList());
        stats.forEach(s -> {
            InstancePort instPort = getInstancePort(d, s.portNumber());
            if (instPort != null) {
                flowInfos.add(buildTxFlowInfoFromInstancePort(instPort, s));
                flowInfos.add(buildRxFlowInfoFromInstancePort(instPort, s));
            }
        });
    });
    return flowInfos;
}
Also used : FlowInfo(org.onosproject.openstacktelemetry.api.FlowInfo) DefaultFlowInfo(org.onosproject.openstacktelemetry.api.DefaultFlowInfo) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) InstancePort(org.onosproject.openstacknetworking.api.InstancePort) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) FlowEntry(org.onosproject.net.flow.FlowEntry) DriverService(org.onosproject.net.driver.DriverService) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) PROP_MONITOR_OVERLAY_DEFAULT(org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_MONITOR_OVERLAY_DEFAULT) FlowRuleService(org.onosproject.net.flow.FlowRuleService) Map(java.util.Map) ApplicationId(org.onosproject.core.ApplicationId) PROTOCOL_UDP(org.onlab.packet.IPv4.PROTOCOL_UDP) MastershipService(org.onosproject.mastership.MastershipService) OpenstackTelemetryService(org.onosproject.openstacktelemetry.api.OpenstackTelemetryService) PROP_EGRESS_STATS_DEFAULT(org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_EGRESS_STATS_DEFAULT) OpenstackTelemetryUtil.getBooleanProperty(org.onosproject.openstacktelemetry.util.OpenstackTelemetryUtil.getBooleanProperty) OpenstackNodeService(org.onosproject.openstacknode.api.OpenstackNodeService) StatsInfo(org.onosproject.openstacktelemetry.api.StatsInfo) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) DEFAULT_DATA_POINT_SIZE(org.onosproject.openstacktelemetry.api.Constants.DEFAULT_DATA_POINT_SIZE) DeviceId(org.onosproject.net.DeviceId) IPV4_DST(org.onosproject.net.flow.criteria.Criterion.Type.IPV4_DST) Dictionary(java.util.Dictionary) FlowRuleOperationsContext(org.onosproject.net.flow.FlowRuleOperationsContext) IPV4_SRC(org.onosproject.net.flow.criteria.Criterion.Type.IPV4_SRC) Host(org.onosproject.net.Host) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) DefaultStatsFlowRule(org.onosproject.openstacktelemetry.api.DefaultStatsFlowRule) ComponentContext(org.osgi.service.component.ComponentContext) STAT_FLAT_OUTBOUND_TABLE(org.onosproject.openstacknetworking.api.Constants.STAT_FLAT_OUTBOUND_TABLE) HostService(org.onosproject.net.host.HostService) ArrayList(java.util.ArrayList) VTAP_INBOUND_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAP_INBOUND_TABLE) Component(org.osgi.service.component.annotations.Component) TrafficSelector(org.onosproject.net.flow.TrafficSelector) VXLAN(org.onosproject.openstacktelemetry.api.Constants.VXLAN) PROP_MONITOR_OVERLAY(org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_MONITOR_OVERLAY) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Criterion(org.onosproject.net.flow.criteria.Criterion) TCP_SRC(org.onosproject.net.flow.criteria.Criterion.Type.TCP_SRC) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) FlowRuleOperations(org.onosproject.net.flow.FlowRuleOperations) PROP_REVERSE_PATH_STATS(org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_REVERSE_PATH_STATS) PROP_MONITOR_UNDERLAY(org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_MONITOR_UNDERLAY) UdpPortCriterion(org.onosproject.net.flow.criteria.UdpPortCriterion) VlanId(org.onlab.packet.VlanId) FlowInfo(org.onosproject.openstacktelemetry.api.FlowInfo) MacAddress(org.onlab.packet.MacAddress) TCP_DST(org.onosproject.net.flow.criteria.Criterion.Type.TCP_DST) ScheduledFuture(java.util.concurrent.ScheduledFuture) CoreService(org.onosproject.core.CoreService) PROP_MONITOR_UNDERLAY_DEFAULT(org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_MONITOR_UNDERLAY_DEFAULT) LoggerFactory(org.slf4j.LoggerFactory) IPProtocolCriterion(org.onosproject.net.flow.criteria.IPProtocolCriterion) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) StatsFlowRuleAdminService(org.onosproject.openstacktelemetry.api.StatsFlowRuleAdminService) SharedScheduledExecutors(org.onlab.util.SharedScheduledExecutors) STAT_OUTBOUND_TABLE(org.onosproject.openstacknetworking.api.Constants.STAT_OUTBOUND_TABLE) SWITCH(org.onosproject.net.Device.Type.SWITCH) IP_PROTO(org.onosproject.net.flow.criteria.Criterion.Type.IP_PROTO) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) UDP_SRC(org.onosproject.net.flow.criteria.Criterion.Type.UDP_SRC) Driver(org.onosproject.net.driver.Driver) TYPE_IPV4(org.onlab.packet.Ethernet.TYPE_IPV4) PROP_EGRESS_STATS(org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_EGRESS_STATS) Device(org.onosproject.net.Device) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) VTAP_OUTBOUND_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAP_OUTBOUND_TABLE) List(java.util.List) FlowRule(org.onosproject.net.flow.FlowRule) Optional(java.util.Optional) Queue(java.util.Queue) OPENSTACK_TELEMETRY_APP_ID(org.onosproject.openstacktelemetry.api.Constants.OPENSTACK_TELEMETRY_APP_ID) IpPrefix(org.onlab.packet.IpPrefix) DefaultStatsInfo(org.onosproject.openstacktelemetry.api.DefaultStatsInfo) COMPUTE(org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE) PortStatistics(org.onosproject.net.device.PortStatistics) VTAP_FLAT_OUTBOUND_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAP_FLAT_OUTBOUND_TABLE) VLAN(org.onosproject.openstacktelemetry.api.Constants.VLAN) CONTROLLER(org.onosproject.openstacknode.api.OpenstackNode.NodeType.CONTROLLER) OpenstackNetworkService(org.onosproject.openstacknetworking.api.OpenstackNetworkService) TcpPortCriterion(org.onosproject.net.flow.criteria.TcpPortCriterion) Activate(org.osgi.service.component.annotations.Activate) LinkedList(java.util.LinkedList) PROP_PORT_STATS(org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_PORT_STATS) FLAT(org.onosproject.openstacktelemetry.api.Constants.FLAT) IpAddress(org.onlab.packet.IpAddress) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) STAT_INBOUND_TABLE(org.onosproject.openstacknetworking.api.Constants.STAT_INBOUND_TABLE) Logger(org.slf4j.Logger) DefaultFlowInfo(org.onosproject.openstacktelemetry.api.DefaultFlowInfo) PROP_PORT_STATS_DEFAULT(org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_PORT_STATS_DEFAULT) Maps(com.google.common.collect.Maps) PROP_REVERSE_PATH_STATS_DEFAULT(org.onosproject.openstacktelemetry.impl.OsgiPropertyConstants.PROP_REVERSE_PATH_STATS_DEFAULT) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) TimeUnit(java.util.concurrent.TimeUnit) StatsFlowRule(org.onosproject.openstacktelemetry.api.StatsFlowRule) Modified(org.osgi.service.component.annotations.Modified) PROTOCOL_TCP(org.onlab.packet.IPv4.PROTOCOL_TCP) UDP_DST(org.onosproject.net.flow.criteria.Criterion.Type.UDP_DST) Reference(org.osgi.service.component.annotations.Reference) InstancePortService(org.onosproject.openstacknetworking.api.InstancePortService) DeviceId(org.onosproject.net.DeviceId) InstancePort(org.onosproject.openstacknetworking.api.InstancePort) PortNumber(org.onosproject.net.PortNumber) PortStatistics(org.onosproject.net.device.PortStatistics)

Aggregations

OpenstackNode (org.onosproject.openstacknode.api.OpenstackNode)10 COMPUTE (org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE)10 OpenstackNodeService (org.onosproject.openstacknode.api.OpenstackNodeService)10 Set (java.util.Set)9 DeviceService (org.onosproject.net.device.DeviceService)9 Tools.groupedThreads (org.onlab.util.Tools.groupedThreads)8 ComponentConfigService (org.onosproject.cfg.ComponentConfigService)8 ClusterService (org.onosproject.cluster.ClusterService)8 NodeId (org.onosproject.cluster.NodeId)8 ApplicationId (org.onosproject.core.ApplicationId)8 CoreService (org.onosproject.core.CoreService)8 PortNumber (org.onosproject.net.PortNumber)8 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)8 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)8 TrafficSelector (org.onosproject.net.flow.TrafficSelector)8 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)8 Activate (org.osgi.service.component.annotations.Activate)8 Component (org.osgi.service.component.annotations.Component)8 Deactivate (org.osgi.service.component.annotations.Deactivate)8 Reference (org.osgi.service.component.annotations.Reference)8