Search in sources :

Example 16 with PiActionParam

use of org.onosproject.net.pi.runtime.PiActionParam in project onos by opennetworkinglab.

the class ForwardingObjectiveTranslatorTest method testMpls.

@Test
public void testMpls() throws FabricPipelinerException {
    TrafficSelector selector = DefaultTrafficSelector.builder().matchEthType(Ethernet.MPLS_UNICAST).matchMplsLabel(MPLS_10).matchMplsBos(true).build();
    TrafficSelector expectedSelector = DefaultTrafficSelector.builder().matchMplsLabel(MPLS_10).build();
    PiActionParam nextIdParam = new PiActionParam(FabricConstants.NEXT_ID, NEXT_ID_1);
    PiAction setNextIdAction = PiAction.builder().withId(FabricConstants.FABRIC_INGRESS_FORWARDING_POP_MPLS_AND_NEXT).withParameter(nextIdParam).build();
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().piTableAction(setNextIdAction).build();
    testSpecificForward(FabricConstants.FABRIC_INGRESS_FORWARDING_MPLS, expectedSelector, selector, NEXT_ID_1, treatment);
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PiAction(org.onosproject.net.pi.runtime.PiAction) Test(org.junit.Test)

Example 17 with PiActionParam

use of org.onosproject.net.pi.runtime.PiActionParam in project onos by opennetworkinglab.

the class ForwardingObjectiveTranslatorTest method testSpecificForward.

private void testSpecificForward(PiTableId expectedTableId, TrafficSelector expectedSelector, TrafficSelector selector, Integer nextId) throws FabricPipelinerException {
    TrafficTreatment setNextIdTreatment;
    if (nextId == null) {
        // Ref: RoutingRulePopulator.java->revokeIpRuleForRouter
        setNextIdTreatment = DefaultTrafficTreatment.builder().piTableAction(PiAction.builder().withId(FabricConstants.FABRIC_INGRESS_FORWARDING_NOP_ROUTING_V4).build()).build();
    } else {
        PiActionParam nextIdParam = new PiActionParam(FabricConstants.NEXT_ID, nextId);
        PiAction.Builder setNextIdAction = PiAction.builder().withParameter(nextIdParam);
        if (expectedTableId.equals(FabricConstants.FABRIC_INGRESS_FORWARDING_BRIDGING)) {
            setNextIdAction.withId(FabricConstants.FABRIC_INGRESS_FORWARDING_SET_NEXT_ID_BRIDGING);
        } else if (expectedTableId.equals(FabricConstants.FABRIC_INGRESS_FORWARDING_ROUTING_V4)) {
            setNextIdAction.withId(FabricConstants.FABRIC_INGRESS_FORWARDING_SET_NEXT_ID_ROUTING_V4);
        } else if (expectedTableId.equals(FabricConstants.FABRIC_INGRESS_FORWARDING_ROUTING_V6)) {
            setNextIdAction.withId(FabricConstants.FABRIC_INGRESS_FORWARDING_SET_NEXT_ID_ROUTING_V6);
        }
        setNextIdTreatment = DefaultTrafficTreatment.builder().piTableAction(setNextIdAction.build()).build();
    }
    testSpecificForward(expectedTableId, expectedSelector, selector, nextId, setNextIdTreatment);
}
Also used : DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) PiAction(org.onosproject.net.pi.runtime.PiAction)

Example 18 with PiActionParam

use of org.onosproject.net.pi.runtime.PiActionParam in project onos by opennetworkinglab.

the class ForwardingObjectiveTranslatorTest method testAclNext.

/**
 * Test versatile flag of forwarding objective with next step.
 */
@Test
public void testAclNext() {
    // ACL 8-tuples
    TrafficSelector selector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPDst(IPV4_UNICAST_ADDR).build();
    ForwardingObjective fwd = DefaultForwardingObjective.builder().withSelector(selector).withPriority(PRIORITY).fromApp(APP_ID).makePermanent().withFlag(ForwardingObjective.Flag.VERSATILE).nextStep(NEXT_ID_1).add();
    ObjectiveTranslation result = translator.translate(fwd);
    List<FlowRule> flowRulesInstalled = (List<FlowRule>) result.flowRules();
    List<GroupDescription> groupsInstalled = (List<GroupDescription>) result.groups();
    assertEquals(1, flowRulesInstalled.size());
    assertTrue(groupsInstalled.isEmpty());
    FlowRule actualFlowRule = flowRulesInstalled.get(0);
    PiAction piAction = PiAction.builder().withId(FabricConstants.FABRIC_INGRESS_ACL_SET_NEXT_ID_ACL).withParameter(new PiActionParam(FabricConstants.NEXT_ID, NEXT_ID_1)).build();
    FlowRule expectedFlowRule = DefaultFlowRule.builder().forDevice(DEVICE_ID).forTable(FabricConstants.FABRIC_INGRESS_ACL_ACL).withPriority(PRIORITY).makePermanent().withSelector(selector).withTreatment(DefaultTrafficTreatment.builder().piTableAction(piAction).build()).fromApp(APP_ID).build();
    assertTrue(expectedFlowRule.exactMatch(actualFlowRule));
}
Also used : DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) PiAction(org.onosproject.net.pi.runtime.PiAction) Test(org.junit.Test)

Example 19 with PiActionParam

use of org.onosproject.net.pi.runtime.PiActionParam in project onos by opennetworkinglab.

the class ForwardingObjectiveTranslator method aclRule.

private void aclRule(ForwardingObjective obj, ObjectiveTranslation.Builder resultBuilder) throws FabricPipelinerException {
    if (obj.nextId() == null && obj.treatment() != null) {
        final TrafficTreatment treatment = obj.treatment();
        final PortNumber outPort = outputPort(treatment);
        if (outPort != null && outPort.equals(PortNumber.CONTROLLER) && treatment.allInstructions().size() == 1) {
            final PiAction aclAction;
            if (treatment.clearedDeferred()) {
                aclAction = PiAction.builder().withId(FabricConstants.FABRIC_INGRESS_ACL_PUNT_TO_CPU).build();
            } else {
                // Action is SET_CLONE_SESSION_ID
                if (obj.op() == Objective.Operation.ADD) {
                    // Action is ADD, create clone group
                    final DefaultGroupDescription cloneGroup = createCloneGroup(obj.appId(), CLONE_TO_CPU_ID, outPort);
                    resultBuilder.addGroup(cloneGroup);
                }
                aclAction = PiAction.builder().withId(FabricConstants.FABRIC_INGRESS_ACL_SET_CLONE_SESSION_ID).withParameter(new PiActionParam(FabricConstants.CLONE_ID, CLONE_TO_CPU_ID)).build();
            }
            final TrafficTreatment piTreatment = DefaultTrafficTreatment.builder().piTableAction(aclAction).build();
            resultBuilder.addFlowRule(flowRule(obj, FabricConstants.FABRIC_INGRESS_ACL_ACL, obj.selector(), piTreatment));
            return;
        }
    }
    TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder(obj.selector());
    // Meta are used to signal the port type which can be edge or infra
    Byte portType = portType(obj);
    if (portType != null && !isSrMetadataSet(obj, PAIR_PORT)) {
        if (portType == PORT_TYPE_EDGE || portType == PORT_TYPE_INFRA) {
            selectorBuilder.matchPi(PiCriterion.builder().matchTernary(FabricConstants.HDR_PORT_TYPE, (long) portType, PORT_TYPE_MASK).build());
        } else {
            throw new FabricPipelinerException(format("Port type '%s' is not allowed for table '%s'", portType, FabricConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN), ObjectiveError.UNSUPPORTED);
        }
    }
    resultBuilder.addFlowRule(flowRule(obj, FabricConstants.FABRIC_INGRESS_ACL_ACL, selectorBuilder.build()));
}
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) PortNumber(org.onosproject.net.PortNumber) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) PiAction(org.onosproject.net.pi.runtime.PiAction)

Example 20 with PiActionParam

use of org.onosproject.net.pi.runtime.PiActionParam in project onos by opennetworkinglab.

the class PiGroupTranslatorImplTest method selectOutputBucket.

private static GroupBucket selectOutputBucket(int portNum) {
    ImmutableByteSequence paramVal = copyFrom(portNum);
    PiActionParam param = new PiActionParam(PORT, paramVal);
    PiTableAction action = PiAction.builder().withId(INGRESS_WCMP_CONTROL_SET_EGRESS_PORT).withParameter(param).build();
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().add(Instructions.piTableAction(action)).build();
    return DefaultGroupBucket.createSelectGroupBucket(treatment);
}
Also used : PiTableAction(org.onosproject.net.pi.runtime.PiTableAction) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ImmutableByteSequence(org.onlab.util.ImmutableByteSequence)

Aggregations

PiActionParam (org.onosproject.net.pi.runtime.PiActionParam)52 PiAction (org.onosproject.net.pi.runtime.PiAction)45 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)32 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)32 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)24 TrafficSelector (org.onosproject.net.flow.TrafficSelector)24 Test (org.junit.Test)21 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)11 FlowRule (org.onosproject.net.flow.FlowRule)11 PiCriterion (org.onosproject.net.flow.criteria.PiCriterion)11 DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)7 GroupDescription (org.onosproject.net.group.GroupDescription)6 DefaultNextObjective (org.onosproject.net.flowobjective.DefaultNextObjective)5 NextObjective (org.onosproject.net.flowobjective.NextObjective)5 PiActionProfileGroupId (org.onosproject.net.pi.runtime.PiActionProfileGroupId)5 PortNumber (org.onosproject.net.PortNumber)4 PiInstruction (org.onosproject.net.flow.instructions.PiInstruction)4 DefaultGroupBucket (org.onosproject.net.group.DefaultGroupBucket)4 GroupBucket (org.onosproject.net.group.GroupBucket)4 GroupBuckets (org.onosproject.net.group.GroupBuckets)4