Search in sources :

Example 1 with PiInterpreterException

use of org.onosproject.net.pi.model.PiPipelineInterpreter.PiInterpreterException in project onos by opennetworkinglab.

the class FilteringObjectiveTranslator method ingressPortVlanRule.

private void ingressPortVlanRule(FilteringObjective obj, Criterion inPortCriterion, VlanIdCriterion outerVlanCriterion, VlanIdCriterion innerVlanCriterion, ObjectiveTranslation.Builder resultBuilder) throws FabricPipelinerException {
    final boolean outerVlanValid = outerVlanCriterion != null && !outerVlanCriterion.vlanId().equals(VlanId.NONE);
    final boolean innerVlanValid = innerVlanCriterion != null && !innerVlanCriterion.vlanId().equals(VlanId.NONE);
    if (innerVlanValid && !capabilities.supportDoubleVlanTerm()) {
        throw new FabricPipelinerException("Found 2 VLAN IDs, but the pipeline does not support double VLAN termination", ObjectiveError.UNSUPPORTED);
    }
    final PiCriterion piCriterion = PiCriterion.builder().matchExact(FabricConstants.HDR_VLAN_IS_VALID, outerVlanValid ? ONE : ZERO).build();
    final TrafficSelector.Builder selector = DefaultTrafficSelector.builder().add(inPortCriterion).add(piCriterion);
    if (outerVlanValid) {
        selector.add(outerVlanCriterion);
    }
    if (innerVlanValid) {
        selector.add(innerVlanCriterion);
    }
    final TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
    if (obj.type().equals(FilteringObjective.Type.DENY)) {
        treatmentBuilder.piTableAction(DENY);
    } else {
        // FIXME SDFAB-52 to complete the work on metadata
        Byte portType = portType(obj);
        if (portType == null) {
            throw new FabricPipelinerException(format("Unsupported port_type configuration: metadata=%s", obj.meta()), ObjectiveError.BADPARAMS);
        }
        try {
            treatmentBuilder.piTableAction(mapFilteringTreatment(obj.meta(), FabricConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN, portType));
        } catch (PiInterpreterException ex) {
            throw new FabricPipelinerException(format("Unable to map treatment for table '%s': %s", FabricConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN, ex.getMessage()), ObjectiveError.UNSUPPORTED);
        }
    }
    resultBuilder.addFlowRule(flowRule(obj, FabricConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN, selector.build(), treatmentBuilder.build()));
}
Also used : PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) PiInterpreterException(org.onosproject.net.pi.model.PiPipelineInterpreter.PiInterpreterException) 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 PiInterpreterException

use of org.onosproject.net.pi.model.PiPipelineInterpreter.PiInterpreterException in project fabric-tna by stratum.

the class FilteringObjectiveTranslator method ingressPortVlanRule.

private void ingressPortVlanRule(FilteringObjective obj, PortCriterion inPortCriterion, VlanIdCriterion outerVlanCriterion, VlanIdCriterion innerVlanCriterion, ObjectiveTranslation.Builder resultBuilder) throws FabricPipelinerException {
    final boolean outerVlanValid = outerVlanCriterion != null && !outerVlanCriterion.vlanId().equals(VlanId.NONE);
    final boolean innerVlanValid = innerVlanCriterion != null && !innerVlanCriterion.vlanId().equals(VlanId.NONE);
    if (innerVlanValid && !capabilities.supportDoubleVlanTerm()) {
        throw new FabricPipelinerException("Found 2 VLAN IDs, but the pipeline does not support double VLAN termination", ObjectiveError.UNSUPPORTED);
    }
    final PiCriterion piCriterion = PiCriterion.builder().matchExact(P4InfoConstants.HDR_VLAN_IS_VALID, outerVlanValid ? ONE : ZERO).build();
    final TrafficSelector.Builder selector = DefaultTrafficSelector.builder().add(inPortCriterion).add(piCriterion);
    if (outerVlanValid) {
        selector.add(outerVlanCriterion);
    }
    if (innerVlanValid) {
        selector.add(innerVlanCriterion);
    }
    final TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
    if (obj.type().equals(FilteringObjective.Type.DENY)) {
        treatmentBuilder.piTableAction(DENY);
    } else {
        // FIXME SDFAB-52 to complete the work on metadata
        Byte portType = portType(obj);
        if (portType == null) {
            throw new FabricPipelinerException(format("Unsupported port_type configuration: metadata=%s", obj.meta()), ObjectiveError.BADPARAMS);
        }
        try {
            treatmentBuilder.piTableAction(mapFilteringTreatment(obj.meta(), P4InfoConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN, portType));
        } catch (PiInterpreterException ex) {
            throw new FabricPipelinerException(format("Unable to map treatment for table '%s': %s", P4InfoConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN, ex.getMessage()), ObjectiveError.UNSUPPORTED);
        }
        // the EgressDscpRewriter table.
        if (portType == PORT_TYPE_EDGE) {
            // We need to make sure that traffic exiting an edge port doesn't
            // carry the SD-Fabric DSCP field.
            resultBuilder.addFlowRule(buildEgressDscpRewriter(obj, inPortCriterion, true));
        } else if (portType == PORT_TYPE_INFRA) {
            // We need to make sure that traffic exiting an infra port carry
            // SD-Fabric DSCP field.
            resultBuilder.addFlowRule(buildEgressDscpRewriter(obj, inPortCriterion, false));
            resultBuilder.addFlowRule(buildTrustDscpEntry(obj, inPortCriterion));
        }
    }
    resultBuilder.addFlowRule(flowRule(obj, P4InfoConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN, selector.build(), treatmentBuilder.build()));
}
Also used : PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) PiInterpreterException(org.onosproject.net.pi.model.PiPipelineInterpreter.PiInterpreterException) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Aggregations

DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)2 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)2 TrafficSelector (org.onosproject.net.flow.TrafficSelector)2 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)2 PiCriterion (org.onosproject.net.flow.criteria.PiCriterion)2 PiInterpreterException (org.onosproject.net.pi.model.PiPipelineInterpreter.PiInterpreterException)2