Search in sources :

Example 11 with PiCriterion

use of org.onosproject.net.flow.criteria.PiCriterion in project onos by opennetworkinglab.

the class FilteringObjectiveTranslator method mplsFwdClassifierRules.

private Collection<FlowRule> mplsFwdClassifierRules(PortNumber inPort, MacAddress dstMac, FilteringObjective obj) throws FabricPipelinerException {
    // Forwarding classifier for MPLS is composed of 2 rules
    // with higher priority wrt standard forwarding classifier rules,
    // this is due to overlap on ternary matching.
    TrafficTreatment treatment = fwdClassifierTreatment(FWD_MPLS);
    final PiCriterion ethTypeMplsIpv4 = PiCriterion.builder().matchTernary(FabricConstants.HDR_ETH_TYPE, Ethernet.MPLS_UNICAST, ETH_TYPE_EXACT_MASK).matchExact(FabricConstants.HDR_IP_ETH_TYPE, Ethernet.TYPE_IPV4).build();
    final TrafficSelector selectorMplsIpv4 = DefaultTrafficSelector.builder().matchInPort(inPort).matchPi(ethTypeMplsIpv4).matchEthDstMasked(dstMac, MacAddress.EXACT_MASK).build();
    final PiCriterion ethTypeMplsIpv6 = PiCriterion.builder().matchTernary(FabricConstants.HDR_ETH_TYPE, Ethernet.MPLS_UNICAST, ETH_TYPE_EXACT_MASK).matchExact(FabricConstants.HDR_IP_ETH_TYPE, Ethernet.TYPE_IPV6).build();
    final TrafficSelector selectorMplsIpv6 = DefaultTrafficSelector.builder().matchInPort(inPort).matchPi(ethTypeMplsIpv6).matchEthDstMasked(dstMac, MacAddress.EXACT_MASK).build();
    return List.of(flowRule(obj, FabricConstants.FABRIC_INGRESS_FILTERING_FWD_CLASSIFIER, selectorMplsIpv4, treatment, obj.priority() + 1), flowRule(obj, FabricConstants.FABRIC_INGRESS_FILTERING_FWD_CLASSIFIER, selectorMplsIpv6, treatment, obj.priority() + 1));
}
Also used : PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) 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 12 with PiCriterion

use of org.onosproject.net.flow.criteria.PiCriterion in project onos by opennetworkinglab.

the class FilteringObjectiveTranslator method fwdClassifierRule.

private FlowRule fwdClassifierRule(PortNumber inPort, short ethType, MacAddress dstMac, MacAddress dstMacMask, TrafficTreatment treatment, FilteringObjective obj) throws FabricPipelinerException {
    // Match on ip_eth_type that is the eth_type of the L3 protocol.
    // i.e., if the packet has an IP header, ip_eth_type should
    // contain the corresponding eth_type (for IPv4 or IPv6)
    final PiCriterion ethTypeCriterion = PiCriterion.builder().matchExact(FabricConstants.HDR_IP_ETH_TYPE, ethType).build();
    final TrafficSelector selector = DefaultTrafficSelector.builder().matchInPort(inPort).matchPi(ethTypeCriterion).matchEthDstMasked(dstMac, dstMacMask == null ? MacAddress.EXACT_MASK : dstMacMask).build();
    return flowRule(obj, FabricConstants.FABRIC_INGRESS_FILTERING_FWD_CLASSIFIER, selector, treatment);
}
Also used : PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector)

Example 13 with PiCriterion

use of org.onosproject.net.flow.criteria.PiCriterion 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 14 with PiCriterion

use of org.onosproject.net.flow.criteria.PiCriterion in project onos by opennetworkinglab.

the class NextObjectiveTranslator method egressVlan.

private void egressVlan(PortNumber outPort, NextObjective obj, Instruction popVlanInst, ObjectiveTranslation.Builder resultBuilder) throws FabricPipelinerException {
    final VlanIdCriterion vlanIdCriterion = (VlanIdCriterion) criterion(obj.meta(), Criterion.Type.VLAN_VID);
    final PiCriterion egressVlanTableMatch = PiCriterion.builder().matchExact(FabricConstants.HDR_EG_PORT, outPort.toLong()).build();
    final TrafficSelector selector = DefaultTrafficSelector.builder().matchPi(egressVlanTableMatch).matchVlanId(vlanIdCriterion.vlanId()).build();
    final TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
    if (popVlanInst == null) {
        treatmentBuilder.pushVlan();
    } else {
        treatmentBuilder.popVlan();
    }
    resultBuilder.addFlowRule(flowRule(obj, FabricConstants.FABRIC_EGRESS_EGRESS_NEXT_EGRESS_VLAN, selector, treatmentBuilder.build()));
}
Also used : PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion)

Example 15 with PiCriterion

use of org.onosproject.net.flow.criteria.PiCriterion in project onos by opennetworkinglab.

the class NextObjectiveTranslatorTest method testSimple.

private void testSimple(TrafficTreatment treatment, PiAction piAction) throws FabricPipelinerException {
    NextObjective nextObjective = DefaultNextObjective.builder().withId(NEXT_ID_1).withPriority(PRIORITY).withMeta(VLAN_META).addTreatment(treatment).withType(NextObjective.Type.SIMPLE).makePermanent().fromApp(APP_ID).add();
    ObjectiveTranslation actualTranslation = translatorSimple.translate(nextObjective);
    // Simple table
    PiCriterion nextIdCriterion = PiCriterion.builder().matchExact(FabricConstants.HDR_NEXT_ID, NEXT_ID_1).build();
    TrafficSelector nextIdSelector = DefaultTrafficSelector.builder().matchPi(nextIdCriterion).build();
    FlowRule expectedFlowRule = DefaultFlowRule.builder().forDevice(DEVICE_ID).fromApp(APP_ID).makePermanent().withPriority(0).forTable(FabricConstants.FABRIC_INGRESS_NEXT_SIMPLE).withSelector(nextIdSelector).withTreatment(DefaultTrafficTreatment.builder().piTableAction(piAction).build()).build();
    // Expected egress VLAN_PUSH flow rule.
    final PortNumber outPort = outputPort(treatment);
    PiCriterion egressVlanTableMatch = PiCriterion.builder().matchExact(FabricConstants.HDR_EG_PORT, outPort.toLong()).build();
    TrafficSelector selectorForEgressVlan = DefaultTrafficSelector.builder().matchPi(egressVlanTableMatch).matchVlanId(VLAN_100).build();
    PiAction piActionForEgressVlan = PiAction.builder().withId(FabricConstants.FABRIC_EGRESS_EGRESS_NEXT_PUSH_VLAN).build();
    TrafficTreatment treatmentForEgressVlan = DefaultTrafficTreatment.builder().piTableAction(piActionForEgressVlan).build();
    FlowRule expectedEgressVlanPushRule = DefaultFlowRule.builder().withSelector(selectorForEgressVlan).withTreatment(treatmentForEgressVlan).forTable(FabricConstants.FABRIC_EGRESS_EGRESS_NEXT_EGRESS_VLAN).makePermanent().withPriority(nextObjective.priority()).forDevice(DEVICE_ID).fromApp(APP_ID).build();
    ObjectiveTranslation expectedTranslation = ObjectiveTranslation.builder().addFlowRule(vlanMetaFlowRule).addFlowRule(expectedFlowRule).addFlowRule(expectedEgressVlanPushRule).build();
    assertEquals(expectedTranslation, actualTranslation);
}
Also used : DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) PortNumber(org.onosproject.net.PortNumber) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PiAction(org.onosproject.net.pi.runtime.PiAction)

Aggregations

PiCriterion (org.onosproject.net.flow.criteria.PiCriterion)69 PiAction (org.onosproject.net.pi.runtime.PiAction)45 PiActionParam (org.onosproject.net.pi.runtime.PiActionParam)31 TrafficSelector (org.onosproject.net.flow.TrafficSelector)29 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)28 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)27 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)26 FlowRule (org.onosproject.net.flow.FlowRule)25 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)16 PiTableAction (org.onosproject.net.pi.runtime.PiTableAction)13 Test (org.junit.Test)8 UpfProgrammableException (org.onosproject.net.behaviour.upf.UpfProgrammableException)8 DefaultNextObjective (org.onosproject.net.flowobjective.DefaultNextObjective)8 NextObjective (org.onosproject.net.flowobjective.NextObjective)8 PiActionId (org.onosproject.net.pi.model.PiActionId)7 DefaultGroupBucket (org.onosproject.net.group.DefaultGroupBucket)6 DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)6 GroupBucket (org.onosproject.net.group.GroupBucket)6 GroupBuckets (org.onosproject.net.group.GroupBuckets)6 GroupDescription (org.onosproject.net.group.GroupDescription)6