Search in sources :

Example 26 with ExtensionTreatment

use of org.onosproject.net.flow.instructions.ExtensionTreatment in project onos by opennetworkinglab.

the class OpenstackSecurityGroupHandler method initializeAclTable.

private void initializeAclTable(DeviceId deviceId, boolean install) {
    ExtensionTreatment ctTreatment = niciraConnTrackTreatmentBuilder(driverService, deviceId).commit(true).build();
    TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder();
    sBuilder.matchEthType(Ethernet.TYPE_IPV4);
    TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
    tBuilder.extension(ctTreatment, deviceId).transition(JUMP_TABLE);
    osFlowRuleService.setRule(appId, deviceId, sBuilder.build(), tBuilder.build(), PRIORITY_ACL_INGRESS_RULE, ACL_RECIRC_TABLE, install);
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ExtensionTreatment(org.onosproject.net.flow.instructions.ExtensionTreatment)

Example 27 with ExtensionTreatment

use of org.onosproject.net.flow.instructions.ExtensionTreatment in project onos by opennetworkinglab.

the class OpenstackVtapManager method setOutputTableForTunnel.

private void setOutputTableForTunnel(DeviceId deviceId, int tableId, PortNumber outPort, IpAddress serverIp, boolean install) {
    log.debug("setOutputTableForTunnel[{}]: deviceId={}, tableId={}, outPort={}, serverIp={}", install ? "add" : "remove", deviceId, tableId, outPort, serverIp);
    TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder().setOutput(outPort);
    if (tunnelNicira) {
        ExtensionTreatment extensionTreatment = buildTunnelExtension(deviceId, serverIp);
        if (extensionTreatment == null) {
            return;
        }
        treatment.extension(extensionTreatment, deviceId);
    }
    FlowRule flowRule = DefaultFlowRule.builder().forDevice(deviceId).withSelector(selector.build()).withTreatment(treatment.build()).withPriority(PRIORITY_VTAP_OUTPUT_RULE).makePermanent().forTable(tableId).fromApp(appId).build();
    log.debug("setOutputTableForTunnel flowRule={}, install={}", flowRule, install);
    applyFlowRule(flowRule, install);
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ExtensionTreatment(org.onosproject.net.flow.instructions.ExtensionTreatment)

Example 28 with ExtensionTreatment

use of org.onosproject.net.flow.instructions.ExtensionTreatment in project onos by opennetworkinglab.

the class OpenstackVtapManager method buildResubmitExtension.

private ExtensionTreatment buildResubmitExtension(DeviceId deviceId, int tableId) {
    Device device = deviceService.getDevice(deviceId);
    if (device == null || !device.is(ExtensionTreatmentResolver.class)) {
        log.warn("Nicira extension treatment is not supported");
        return null;
    }
    ExtensionTreatmentResolver resolver = device.as(ExtensionTreatmentResolver.class);
    ExtensionTreatment treatment = resolver.getExtensionInstruction(NICIRA_RESUBMIT_TABLE.type());
    try {
        treatment.setPropertyValue(TABLE_EXTENSION, ((short) tableId));
        return treatment;
    } catch (ExtensionPropertyException e) {
        log.error("Failed to set nicira resubmit extension treatment for {}", deviceId);
        return null;
    }
}
Also used : Device(org.onosproject.net.Device) ExtensionTreatmentResolver(org.onosproject.net.behaviour.ExtensionTreatmentResolver) ExtensionTreatment(org.onosproject.net.flow.instructions.ExtensionTreatment) ExtensionPropertyException(org.onosproject.net.flow.instructions.ExtensionPropertyException)

Example 29 with ExtensionTreatment

use of org.onosproject.net.flow.instructions.ExtensionTreatment in project onos by opennetworkinglab.

the class K8sRoutingSnatHandler method setExtSnatUpstreamRule.

private void setExtSnatUpstreamRule(K8sNode k8sNode, boolean install) {
    K8sNetwork net = k8sNetworkService.network(k8sNode.hostname());
    if (net == null) {
        return;
    }
    TrafficSelector selector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchInPort(k8sNode.extToIntgPatchPortNum()).matchEthDst(DEFAULT_GATEWAY_MAC).build();
    TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
    if (install) {
        ExtensionTreatment natTreatment = RulePopulatorUtil.niciraConnTrackTreatmentBuilder(driverService, k8sNode.extBridge()).commit(true).natFlag(CT_NAT_SRC_FLAG).natAction(true).natIp(k8sNode.extBridgeIp()).natPortMin(TpPort.tpPort(TP_PORT_MINIMUM_NUM)).natPortMax(TpPort.tpPort(TP_PORT_MAXIMUM_NUM)).build();
        tBuilder.extension(natTreatment, k8sNode.extBridge()).setEthSrc(k8sNode.extBridgeMac()).setEthDst(k8sNode.extGatewayMac());
        if (k8sNode.mode() == PASSTHROUGH) {
            tBuilder.setOutput(k8sNode.extToRouterPortNum());
        } else {
            if (MacAddress.valueOf(DEFAULT_EXTERNAL_GATEWAY_MAC).equals(k8sNode.extGatewayMac())) {
                tBuilder.setOutput(k8sNode.extIntfPortNum());
            } else {
                tBuilder.setOutput(k8sNode.extBridgePortNum());
            }
        }
    }
    k8sFlowRuleService.setRule(appId, k8sNode.extBridge(), selector, tBuilder.build(), PRIORITY_STATEFUL_SNAT_RULE, EXT_ENTRY_TABLE, install);
}
Also used : K8sNetwork(org.onosproject.k8snetworking.api.K8sNetwork) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ExtensionTreatment(org.onosproject.net.flow.instructions.ExtensionTreatment)

Example 30 with ExtensionTreatment

use of org.onosproject.net.flow.instructions.ExtensionTreatment in project onos by opennetworkinglab.

the class K8sRoutingSnatHandler method setExtSnatDownstreamRule.

private void setExtSnatDownstreamRule(K8sNode k8sNode, boolean install) {
    DeviceId deviceId = k8sNode.extBridge();
    TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPDst(IpPrefix.valueOf(k8sNode.extBridgeIp(), HOST_PREFIX));
    ExtensionTreatment natTreatment = RulePopulatorUtil.niciraConnTrackTreatmentBuilder(driverService, deviceId).commit(false).natAction(true).table((short) POD_RESOLUTION_TABLE).build();
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().setEthSrc(DEFAULT_GATEWAY_MAC).extension(natTreatment, deviceId).build();
    k8sFlowRuleService.setRule(appId, deviceId, sBuilder.build(), treatment, PRIORITY_STATEFUL_SNAT_RULE, EXT_ENTRY_TABLE, install);
}
Also used : DeviceId(org.onosproject.net.DeviceId) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ExtensionTreatment(org.onosproject.net.flow.instructions.ExtensionTreatment)

Aggregations

ExtensionTreatment (org.onosproject.net.flow.instructions.ExtensionTreatment)35 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)17 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)17 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)16 TrafficSelector (org.onosproject.net.flow.TrafficSelector)16 ExtensionTreatmentResolver (org.onosproject.net.behaviour.ExtensionTreatmentResolver)12 ExtensionPropertyException (org.onosproject.net.flow.instructions.ExtensionPropertyException)11 DeviceId (org.onosproject.net.DeviceId)8 Device (org.onosproject.net.Device)7 MacAddress (org.onlab.packet.MacAddress)3 DriverHandler (org.onosproject.net.driver.DriverHandler)3 Pod (io.fabric8.kubernetes.api.model.Pod)2 IpAddress (org.onlab.packet.IpAddress)2 TpPort (org.onlab.packet.TpPort)2 KubevirtNetworkingUtil.getRouterMacAddress (org.onosproject.kubevirtnetworking.util.KubevirtNetworkingUtil.getRouterMacAddress)2 ExtensionTreatmentType (org.onosproject.net.flow.instructions.ExtensionTreatmentType)2 OFAction (org.projectfloodlight.openflow.protocol.action.OFAction)2 OFActionNiciraCt (org.projectfloodlight.openflow.protocol.action.OFActionNiciraCt)2 OFActionNiciraLoad (org.projectfloodlight.openflow.protocol.action.OFActionNiciraLoad)2 OFActionNiciraMove (org.projectfloodlight.openflow.protocol.action.OFActionNiciraMove)2