Search in sources :

Example 71 with OpenstackNode

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

the class OpenstackSwitchingArpHandler method setArpReplyRuleForGeneve.

/**
 * Installs flow rules to match ARP reply packets only for GENEVE.
 *
 * @param port      instance port
 * @param install   installation flag
 */
private void setArpReplyRuleForGeneve(InstancePort port, boolean install) {
    OpenstackNode localNode = osNodeService.node(port.deviceId());
    TrafficSelector selector = getArpReplySelectorForGeneve(port);
    setLocalArpReplyTreatmentForGeneve(selector, port, install);
    setRemoteArpTreatmentForTunnel(selector, port, localNode, install);
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode)

Example 72 with OpenstackNode

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

the class OpenstackSwitchingArpHandler method setRemoteArpTreatmentForTunnel.

// a helper method
private void setRemoteArpTreatmentForTunnel(TrafficSelector selector, InstancePort port, OpenstackNode localNode, boolean install) {
    for (OpenstackNode remoteNode : osNodeService.completeNodes(COMPUTE)) {
        if (!remoteNode.intgBridge().equals(port.deviceId())) {
            PortNumber portNum = tunnelPortNumByNetId(port.networkId(), osNetworkService, remoteNode);
            TrafficTreatment treatmentToRemote = DefaultTrafficTreatment.builder().extension(buildExtension(deviceService, remoteNode.intgBridge(), localNode.dataIp().getIp4Address()), remoteNode.intgBridge()).setOutput(portNum).build();
            osFlowRuleService.setRule(appId, remoteNode.intgBridge(), selector, treatmentToRemote, PRIORITY_ARP_REQUEST_RULE, ARP_TABLE, install);
        }
    }
}
Also used : OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) PortNumber(org.onosproject.net.PortNumber) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 73 with OpenstackNode

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

the class OpenstackSwitchingHandler method setForwardingRulesForTunnel.

/**
 * Configures the flow rules which are used for L2 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 setForwardingRulesForTunnel(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()).matchTunnelId(getVni(instPort)).build();
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().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
    OpenstackNode localNode = osNodeService.node(instPort.deviceId());
    if (localNode == null) {
        final String error = String.format("Cannot find openstack node for %s", instPort.deviceId());
        throw new IllegalStateException(error);
    }
    osNodeService.completeNodes(COMPUTE).stream().filter(remoteNode -> !remoteNode.intgBridge().equals(localNode.intgBridge())).forEach(remoteNode -> {
        PortNumber portNum = tunnelPortNumByNetId(instPort.networkId(), osNetworkService, remoteNode);
        TrafficTreatment treatmentToRemote = DefaultTrafficTreatment.builder().extension(buildExtension(deviceService, remoteNode.intgBridge(), localNode.dataIp().getIp4Address()), remoteNode.intgBridge()).setOutput(portNum).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) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PortNumber(org.onosproject.net.PortNumber)

Example 74 with OpenstackNode

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

the class OpenstackK8sIntegrationManager method setNodePortEgressRules.

private void setNodePortEgressRules(IpAddress k8sNodeIp, String osK8sExtPortName, boolean install) {
    InstancePort instPort = instPortByNodeIp(k8sNodeIp);
    if (instPort == null) {
        return;
    }
    OpenstackNode osNode = osNodeByNodeIp(k8sNodeIp);
    if (osNode == null) {
        return;
    }
    PortNumber osK8sExtPortNum = portNumberByNodeIpAndPortName(k8sNodeIp, osK8sExtPortName);
    Port phyPort = phyPortByInstPort(instPort);
    if (phyPort == null) {
        log.warn("No phys interface found for instance port {}", instPort);
        return;
    }
    TrafficSelector selector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchInPort(osK8sExtPortNum).build();
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().setEthSrc(instPort.macAddress()).setOutput(phyPort.number()).build();
    osFlowRuleService.setRule(appId, osNode.intgBridge(), selector, treatment, PRIORITY_CNI_PT_NODE_PORT_IP_RULE, PRE_FLAT_TABLE, install);
    setJumpRules(osK8sExtPortNum, osNode, install);
}
Also used : InstancePort(org.onosproject.openstacknetworking.api.InstancePort) InstancePort(org.onosproject.openstacknetworking.api.InstancePort) Port(org.onosproject.net.Port) TpPort(org.onlab.packet.TpPort) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) PortNumber(org.onosproject.net.PortNumber) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 75 with OpenstackNode

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

the class OpenstackK8sIntegrationManager method setNodeToPodIpRules.

private void setNodeToPodIpRules(IpAddress k8sNodeIp, IpPrefix podCidr, IpPrefix serviceCidr, IpAddress gatewayIp, String osK8sIntPortName, MacAddress k8sIntOsPortMac, boolean install) {
    OpenstackNode osNode = osNodeByNodeIp(k8sNodeIp);
    if (osNode == null) {
        return;
    }
    PortNumber osK8sIntPortNum = osNode.portNumByName(osK8sIntPortName);
    if (osK8sIntPortNum == null) {
        return;
    }
    TrafficSelector originalPodSelector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPSrc(IpPrefix.valueOf(k8sNodeIp, 32)).matchIPDst(podCidr).build();
    TrafficSelector transformedPodSelector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPSrc(IpPrefix.valueOf(k8sNodeIp, 32)).matchIPDst(IpPrefix.valueOf(shiftIpDomain(podCidr.toString(), SHIFTED_IP_PREFIX))).build();
    TrafficSelector serviceSelector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPSrc(IpPrefix.valueOf(k8sNodeIp, 32)).matchIPDst(serviceCidr).build();
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().setIpSrc(gatewayIp).setEthSrc(k8sIntOsPortMac).setOutput(osK8sIntPortNum).build();
    osFlowRuleService.setRule(appId, osNode.intgBridge(), originalPodSelector, treatment, PRIORITY_CNI_PT_IP_RULE, FLAT_TABLE, install);
    osFlowRuleService.setRule(appId, osNode.intgBridge(), transformedPodSelector, treatment, PRIORITY_CNI_PT_IP_RULE, FLAT_TABLE, install);
    osFlowRuleService.setRule(appId, osNode.intgBridge(), serviceSelector, treatment, PRIORITY_CNI_PT_IP_RULE, FLAT_TABLE, install);
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) PortNumber(org.onosproject.net.PortNumber) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Aggregations

OpenstackNode (org.onosproject.openstacknode.api.OpenstackNode)76 OpenstackNodeService (org.onosproject.openstacknode.api.OpenstackNodeService)22 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)19 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)19 TrafficSelector (org.onosproject.net.flow.TrafficSelector)19 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)19 PortNumber (org.onosproject.net.PortNumber)14 DefaultOpenstackNode (org.onosproject.openstacknode.api.DefaultOpenstackNode)14 DeviceService (org.onosproject.net.device.DeviceService)13 Set (java.util.Set)12 Test (org.junit.Test)12 IpAddress (org.onlab.packet.IpAddress)12 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)9 Objects (java.util.Objects)9 Optional (java.util.Optional)9 ExecutorService (java.util.concurrent.ExecutorService)9 Collectors (java.util.stream.Collectors)9 ComponentConfigService (org.onosproject.cfg.ComponentConfigService)9 Produces (javax.ws.rs.Produces)8 InstancePort (org.onosproject.openstacknetworking.api.InstancePort)7