Search in sources :

Example 6 with ExtensionTreatment

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

the class OpenstackVtapManager method buildTunnelExtension.

/**
 * Returns tunnel destination extension treatment object.
 *
 * @param deviceId device id to apply this treatment
 * @param remoteIp tunnel destination ip address
 * @return extension treatment
 */
private ExtensionTreatment buildTunnelExtension(DeviceId deviceId, IpAddress remoteIp) {
    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_SET_TUNNEL_DST.type());
    try {
        treatment.setPropertyValue(TUNNEL_DST_EXTENSION, remoteIp.getIp4Address());
        return treatment;
    } catch (ExtensionPropertyException e) {
        log.error("Failed to set nicira tunnelDst 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 7 with ExtensionTreatment

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

the class OpenstackTroubleshootUtil method buildExtension.

/**
 * Returns tunnel destination extension treatment object.
 *
 * @param deviceService driver service
 * @param deviceId device id to apply this treatment
 * @param remoteIp tunnel destination ip address
 * @return extension treatment
 */
public static ExtensionTreatment buildExtension(DeviceService deviceService, DeviceId deviceId, Ip4Address remoteIp) {
    Device device = deviceService.getDevice(deviceId);
    if (device != null && !device.is(ExtensionTreatmentResolver.class)) {
        log.error("The extension treatment is not supported");
        return null;
    }
    if (device == null) {
        return null;
    }
    ExtensionTreatmentResolver resolver = device.as(ExtensionTreatmentResolver.class);
    ExtensionTreatment treatment = resolver.getExtensionInstruction(NICIRA_SET_TUNNEL_DST.type());
    try {
        treatment.setPropertyValue(TUNNEL_DST, remoteIp);
        return treatment;
    } catch (ExtensionPropertyException e) {
        log.warn("Failed to get tunnelDst 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 8 with ExtensionTreatment

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

the class SelectGroupHandler method buildNiciraExtenstion.

/**
 * Builds Nicira extension for tagging remoteIp of vxlan.
 *
 * @param id device id of vxlan source device
 * @param hostIp remote ip of vxlan destination device
 * @return NiciraExtension Treatment
 */
private ExtensionTreatment buildNiciraExtenstion(DeviceId id, Ip4Address hostIp) {
    Driver driver = driverService.getDriver(id);
    DriverHandler driverHandler = new DefaultDriverHandler(new DefaultDriverData(driver, id));
    ExtensionTreatmentResolver resolver = driverHandler.behaviour(ExtensionTreatmentResolver.class);
    ExtensionTreatment extensionInstruction = resolver.getExtensionInstruction(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_TUNNEL_DST.type());
    try {
        extensionInstruction.setPropertyValue(TUNNEL_DESTINATION, hostIp);
    } catch (ExtensionPropertyException e) {
        log.error("Error setting Nicira extension setting {}", e);
    }
    return extensionInstruction;
}
Also used : DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) DriverHandler(org.onosproject.net.driver.DriverHandler) Driver(org.onosproject.net.driver.Driver) ExtensionTreatmentResolver(org.onosproject.net.behaviour.ExtensionTreatmentResolver) ExtensionTreatment(org.onosproject.net.flow.instructions.ExtensionTreatment) ExtensionPropertyException(org.onosproject.net.flow.instructions.ExtensionPropertyException) DefaultDriverData(org.onosproject.net.driver.DefaultDriverData)

Example 9 with ExtensionTreatment

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

the class KubevirtSecurityGroupHandler method populateSecurityGroupRule.

private void populateSecurityGroupRule(KubevirtSecurityGroupRule sgRule, KubevirtPort port, IpPrefix remoteIp, boolean install) {
    if (!checkProtocol(sgRule.protocol())) {
        return;
    }
    DeviceId deviceId = port.isTenant() ? port.tenantDeviceId() : port.deviceId();
    Set<TrafficSelector> ctSelectors = buildSelectors(sgRule, Ip4Address.valueOf(port.ipAddress().toInetAddress()), port.macAddress(), remoteIp, port.networkId());
    if (ctSelectors == null || ctSelectors.isEmpty()) {
        return;
    }
    // if the device is not available we do not perform any action
    if (deviceId == null || !deviceService.isAvailable(deviceId)) {
        return;
    }
    // XXX All egress traffic needs to go through connection tracking module,
    // which might hurt its performance.
    ExtensionTreatment ctTreatment = niciraConnTrackTreatmentBuilder(driverService, deviceId).commit(true).build();
    TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
    KubevirtNetwork net = networkService.network(port.networkId());
    int aclTable;
    if (sgRule.direction().equalsIgnoreCase(EGRESS)) {
        if (net.type() == FLAT || net.type() == VLAN) {
            aclTable = ACL_EGRESS_TABLE;
        } else {
            aclTable = TENANT_ACL_EGRESS_TABLE;
        }
        tBuilder.transition(TENANT_ACL_RECIRC_TABLE);
    } else {
        if (net.type() == FLAT || net.type() == VLAN) {
            aclTable = ACL_INGRESS_TABLE;
        } else {
            aclTable = TENANT_ACL_INGRESS_TABLE;
        }
        tBuilder.extension(ctTreatment, deviceId).transition(TENANT_FORWARDING_TABLE);
    }
    int finalAclTable = aclTable;
    ctSelectors.forEach(selector -> {
        flowRuleService.setRule(appId, deviceId, selector, tBuilder.build(), PRIORITY_ACL_RULE, finalAclTable, install);
    });
    TrafficSelector tSelector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchEthDst(port.macAddress()).matchIPDst(IpPrefix.valueOf(port.ipAddress(), 32)).build();
    TrafficTreatment tTreatment = DefaultTrafficTreatment.builder().transition(TENANT_ACL_INGRESS_TABLE).build();
    flowRuleService.setRule(appId, deviceId, tSelector, tTreatment, PRIORITY_ACL_RULE, TENANT_ACL_RECIRC_TABLE, install);
}
Also used : KubevirtNetwork(org.onosproject.kubevirtnetworking.api.KubevirtNetwork) 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)

Example 10 with ExtensionTreatment

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

the class KubevirtSecurityGroupHandler method initializeAclTable.

private void initializeAclTable(DeviceId deviceId, int recircTable, PortNumber outport, 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).setOutput(outport);
    flowRuleService.setRule(appId, deviceId, sBuilder.build(), tBuilder.build(), PRIORITY_ACL_INGRESS_RULE, recircTable, 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)

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