Search in sources :

Example 21 with ForwardingObjective

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

the class ForwardingObjectiveTranslator method defaultIpv4Route.

private void defaultIpv4Route(ForwardingObjective obj, ObjectiveTranslation.Builder resultBuilder) throws FabricPipelinerException {
    ForwardingObjective defaultObj = obj.copy().withPriority(0).add();
    final TrafficSelector selector = DefaultTrafficSelector.emptySelector();
    resultBuilder.addFlowRule(flowRule(defaultObj, P4InfoConstants.FABRIC_INGRESS_FORWARDING_ROUTING_V4, selector));
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective)

Example 22 with ForwardingObjective

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

the class ForwardingObjectiveTranslatorTest method testAclDrop.

/**
 * Test versatile flag of forwarding objective with acl drop.
 */
@Test
public void testAclDrop() {
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().wipeDeferred().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_DROP).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 23 with ForwardingObjective

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

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(P4InfoConstants.FABRIC_INGRESS_ACL_SET_NEXT_ID_ACL).withParameter(new PiActionParam(P4InfoConstants.NEXT_ID, NEXT_ID_1)).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) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) PiAction(org.onosproject.net.pi.runtime.PiAction) Test(org.junit.Test)

Example 24 with ForwardingObjective

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

the class ForwardingObjectiveTranslatorTest method testIPv4Drop.

@Test
public void testIPv4Drop() throws FabricPipelinerException {
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().wipeDeferred().build();
    TrafficSelector selector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPDst(IPV4_UNICAST_ADDR).build();
    TrafficSelector expectedSelector = DefaultTrafficSelector.builder().matchIPDst(IPV4_UNICAST_ADDR).build();
    ForwardingObjective fwd = DefaultForwardingObjective.builder().withSelector(selector).withPriority(PRIORITY).fromApp(APP_ID).makePermanent().withFlag(ForwardingObjective.Flag.SPECIFIC).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_FORWARDING_DROP_ROUTING_V4).build();
    FlowRule expectedFlowRule = DefaultFlowRule.builder().forDevice(DEVICE_ID).forTable(P4InfoConstants.FABRIC_INGRESS_FORWARDING_ROUTING_V4).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) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PiAction(org.onosproject.net.pi.runtime.PiAction) Test(org.junit.Test)

Example 25 with ForwardingObjective

use of org.onosproject.net.flowobjective.ForwardingObjective in project onos by opennetworkinglab.

the class ArtemisDeaggregatorImpl method installClientRules.

/**
 * Rules to be installed on MOAS Client.
 */
private void installClientRules() {
    log.info("installClientRules");
    artemisService.getConfig().ifPresent(config -> {
        // selector
        TrafficSelector selector = DefaultTrafficSelector.builder().matchEthType(TYPE_IPV4).matchIPSrc(remoteTunnelIp.toIpPrefix()).matchIPDst(config.moasInfo().getTunnelPoint().getLocalIp().toIpPrefix()).build();
        // treatment
        TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(PortNumber.LOCAL).build();
        // forwarding objective builder
        ForwardingObjective forwardingObjective = DefaultForwardingObjective.builder().withSelector(selector).withTreatment(treatment).withPriority(PRIORITY).withFlag(ForwardingObjective.Flag.VERSATILE).fromApp(appId).add();
        // send flow objective to specified switch
        flowObjectiveService.forward(DeviceId.deviceId(tunnelPort.element().id().toString()), forwardingObjective);
        log.info("Installing flow rule = {}", forwardingObjective);
    });
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Aggregations

ForwardingObjective (org.onosproject.net.flowobjective.ForwardingObjective)75 DefaultForwardingObjective (org.onosproject.net.flowobjective.DefaultForwardingObjective)50 TrafficSelector (org.onosproject.net.flow.TrafficSelector)44 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)43 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)34 Test (org.junit.Test)33 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)32 Objective (org.onosproject.net.flowobjective.Objective)26 NextObjective (org.onosproject.net.flowobjective.NextObjective)25 FilteringObjective (org.onosproject.net.flowobjective.FilteringObjective)23 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)20 FlowRule (org.onosproject.net.flow.FlowRule)20 List (java.util.List)19 GroupDescription (org.onosproject.net.group.GroupDescription)15 PiAction (org.onosproject.net.pi.runtime.PiAction)14 DeviceId (org.onosproject.net.DeviceId)12 ObjectiveError (org.onosproject.net.flowobjective.ObjectiveError)12 DefaultNextObjective (org.onosproject.net.flowobjective.DefaultNextObjective)11 ImmutableList (com.google.common.collect.ImmutableList)10 PortCriterion (org.onosproject.net.flow.criteria.PortCriterion)9