Search in sources :

Example 86 with ForwardingObjective

use of org.onosproject.net.flowobjective.ForwardingObjective in project fabric-tna by stratum.

the class ForwardingObjectiveTranslatorTest method testAclNextWithPortType.

/**
 * Test versatile flag of forwarding objective with next step and port type.
 */
@Test
public void testAclNextWithPortType() {
    // ACL 8-tuples
    TrafficSelector selector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPDst(IPV4_UNICAST_ADDR).build();
    TrafficSelector metaSelector = DefaultTrafficSelector.builder().matchMetadata(EDGE_PORT).build();
    ForwardingObjective fwd = DefaultForwardingObjective.builder().withSelector(selector).withPriority(PRIORITY).fromApp(APP_ID).makePermanent().withFlag(ForwardingObjective.Flag.VERSATILE).nextStep(NEXT_ID_1).withMeta(metaSelector).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(P4InfoConstants.FABRIC_INGRESS_ACL_SET_NEXT_ID_ACL).withParameter(new PiActionParam(P4InfoConstants.NEXT_ID, NEXT_ID_1)).build();
    TrafficSelector expectedSelector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPDst(IPV4_UNICAST_ADDR).matchPi(PiCriterion.builder().matchTernary(P4InfoConstants.HDR_IG_PORT_TYPE, PORT_TYPE_EDGE, PORT_TYPE_MASK).build()).build();
    FlowRule expectedFlowRule = DefaultFlowRule.builder().forDevice(DEVICE_ID).forTable(P4InfoConstants.FABRIC_INGRESS_ACL_ACL).withPriority(PRIORITY).makePermanent().withSelector(expectedSelector).withTreatment(DefaultTrafficTreatment.builder().piTableAction(piAction).build()).fromApp(APP_ID).build();
    assertTrue(expectedFlowRule.exactMatch(actualFlowRule));
    metaSelector = DefaultTrafficSelector.builder().matchMetadata(INFRA_PORT).build();
    fwd = DefaultForwardingObjective.builder().withSelector(selector).withPriority(PRIORITY).fromApp(APP_ID).makePermanent().withFlag(ForwardingObjective.Flag.VERSATILE).nextStep(NEXT_ID_1).withMeta(metaSelector).add();
    result = translator.translate(fwd);
    flowRulesInstalled = (List<FlowRule>) result.flowRules();
    groupsInstalled = (List<GroupDescription>) result.groups();
    assertEquals(1, flowRulesInstalled.size());
    assertTrue(groupsInstalled.isEmpty());
    actualFlowRule = flowRulesInstalled.get(0);
    expectedSelector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPDst(IPV4_UNICAST_ADDR).matchPi(PiCriterion.builder().matchTernary(P4InfoConstants.HDR_IG_PORT_TYPE, PORT_TYPE_INFRA, PORT_TYPE_MASK).build()).build();
    expectedFlowRule = DefaultFlowRule.builder().forDevice(DEVICE_ID).forTable(P4InfoConstants.FABRIC_INGRESS_ACL_ACL).withPriority(PRIORITY).makePermanent().withSelector(expectedSelector).withTreatment(DefaultTrafficTreatment.builder().piTableAction(piAction).build()).fromApp(APP_ID).build();
    assertTrue(expectedFlowRule.exactMatch(actualFlowRule));
}
Also used : GroupDescription(org.onosproject.net.group.GroupDescription) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) 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 87 with ForwardingObjective

use of org.onosproject.net.flowobjective.ForwardingObjective in project fabric-tna by stratum.

the class ForwardingObjectiveTranslatorTest method testAclNop.

/**
 * Test versatile flag of forwarding objective with acl nop.
 */
@Test
public void testAclNop() {
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
    // ACL 8-tuples like
    TrafficSelector selector = DefaultTrafficSelector.builder().matchIPDst(IPV4_UNICAST_ADDR).build();
    ForwardingObjective fwd = DefaultForwardingObjective.builder().withSelector(selector).withPriority(PRIORITY).fromApp(APP_ID).makePermanent().withFlag(ForwardingObjective.Flag.VERSATILE).withTreatment(treatment).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(P4InfoConstants.FABRIC_INGRESS_ACL_NOP_ACL).build();
    FlowRule expectedFlowRule = DefaultFlowRule.builder().forDevice(DEVICE_ID).forTable(P4InfoConstants.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 : GroupDescription(org.onosproject.net.group.GroupDescription) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) 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) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PiAction(org.onosproject.net.pi.runtime.PiAction) Test(org.junit.Test)

Example 88 with ForwardingObjective

use of org.onosproject.net.flowobjective.ForwardingObjective in project fabric-tna by stratum.

the class ForwardingObjectiveTranslatorTest method testAclDhcp.

/**
 * Test versatile flag of forwarding objective with DHCP match.
 */
@Test
public void testAclDhcp() {
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().wipeDeferred().punt().build();
    // DHCP
    TrafficSelector selector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPProtocol(IPv4.PROTOCOL_UDP).matchUdpSrc(TpPort.tpPort(UDP.DHCP_CLIENT_PORT)).matchUdpDst(TpPort.tpPort(UDP.DHCP_SERVER_PORT)).build();
    ForwardingObjective fwd = DefaultForwardingObjective.builder().withSelector(selector).withPriority(PRIORITY).fromApp(APP_ID).makePermanent().withFlag(ForwardingObjective.Flag.VERSATILE).withTreatment(treatment).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(P4InfoConstants.FABRIC_INGRESS_ACL_PUNT_TO_CPU).build();
    FlowRule expectedFlowRule = DefaultFlowRule.builder().forDevice(DEVICE_ID).forTable(P4InfoConstants.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 : GroupDescription(org.onosproject.net.group.GroupDescription) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) 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) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PiAction(org.onosproject.net.pi.runtime.PiAction) Test(org.junit.Test)

Aggregations

ForwardingObjective (org.onosproject.net.flowobjective.ForwardingObjective)88 DefaultForwardingObjective (org.onosproject.net.flowobjective.DefaultForwardingObjective)57 TrafficSelector (org.onosproject.net.flow.TrafficSelector)50 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)48 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)38 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)37 Test (org.junit.Test)33 NextObjective (org.onosproject.net.flowobjective.NextObjective)32 Objective (org.onosproject.net.flowobjective.Objective)32 FilteringObjective (org.onosproject.net.flowobjective.FilteringObjective)28 List (java.util.List)24 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)20 FlowRule (org.onosproject.net.flow.FlowRule)20 DeviceId (org.onosproject.net.DeviceId)18 ObjectiveContext (org.onosproject.net.flowobjective.ObjectiveContext)18 ObjectiveError (org.onosproject.net.flowobjective.ObjectiveError)16 DefaultNextObjective (org.onosproject.net.flowobjective.DefaultNextObjective)15 GroupDescription (org.onosproject.net.group.GroupDescription)15 PiAction (org.onosproject.net.pi.runtime.PiAction)14 ArrayList (java.util.ArrayList)13