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));
}
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));
}
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));
}
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));
}
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);
});
}
Aggregations