use of org.onosproject.net.pi.runtime.PiAction in project onos by opennetworkinglab.
the class FabricInterpreterTest method testRoutingV4TreatmentEmpty.
/* Forwarding control block */
/**
* Map empty treatment for routing v4 table.
*/
@Test
public void testRoutingV4TreatmentEmpty() throws Exception {
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
PiAction mappedAction = interpreter.mapTreatment(treatment, FabricConstants.FABRIC_INGRESS_FORWARDING_ROUTING_V4);
PiAction expectedAction = PiAction.builder().withId(FabricConstants.FABRIC_INGRESS_FORWARDING_NOP_ROUTING_V4).build();
assertEquals(expectedAction, mappedAction);
}
use of org.onosproject.net.pi.runtime.PiAction in project onos by opennetworkinglab.
the class FilteringObjectiveTranslatorTest method testDenyObjective.
/**
* Test DENY objective.
*/
@Test
public void testDenyObjective() throws FabricPipelinerException {
FilteringObjective filteringObjective = DefaultFilteringObjective.builder().deny().withKey(Criteria.matchInPort(PORT_1)).addCondition(Criteria.matchVlanId(VlanId.NONE)).fromApp(APP_ID).makePermanent().withPriority(PRIORITY).add();
ObjectiveTranslation actualTranslation = translator.translate(filteringObjective);
TrafficSelector.Builder selector = DefaultTrafficSelector.builder().matchInPort(PORT_1).matchPi(buildPiCriterionVlan(null, null));
PiAction piAction = PiAction.builder().withId(FabricConstants.FABRIC_INGRESS_FILTERING_DENY).build();
FlowRule expectedFlowRule = DefaultFlowRule.builder().withPriority(PRIORITY).withSelector(selector.build()).withTreatment(DefaultTrafficTreatment.builder().piTableAction(piAction).build()).fromApp(APP_ID).forDevice(DEVICE_ID).makePermanent().forTable(FabricConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN).build();
ObjectiveTranslation expectedTranslation = ObjectiveTranslation.builder().addFlowRule(expectedFlowRule).build();
assertEquals(expectedTranslation, actualTranslation);
}
use of org.onosproject.net.pi.runtime.PiAction in project onos by opennetworkinglab.
the class FilteringObjectiveTranslatorTest method buildExpectedVlanInPortRule.
private FlowRule buildExpectedVlanInPortRule(PortNumber inPort, VlanId vlanId, VlanId innerVlanId, VlanId internalVlan, byte portType, TableId tableId) {
TrafficSelector.Builder selector = DefaultTrafficSelector.builder().matchInPort(inPort);
PiAction piAction;
selector.matchPi(buildPiCriterionVlan(vlanId, innerVlanId));
if (!vlanValid(vlanId)) {
piAction = PiAction.builder().withId(FabricConstants.FABRIC_INGRESS_FILTERING_PERMIT_WITH_INTERNAL_VLAN).withParameter(new PiActionParam(FabricConstants.VLAN_ID, internalVlan.toShort())).withParameter(new PiActionParam(FabricConstants.PORT_TYPE, portType)).build();
} else {
selector.matchVlanId(vlanId);
if (vlanValid(innerVlanId)) {
selector.matchInnerVlanId(innerVlanId);
}
piAction = PiAction.builder().withId(FabricConstants.FABRIC_INGRESS_FILTERING_PERMIT).withParameter(new PiActionParam(FabricConstants.PORT_TYPE, portType)).build();
}
return DefaultFlowRule.builder().withPriority(PRIORITY).withSelector(selector.build()).withTreatment(DefaultTrafficTreatment.builder().piTableAction(piAction).build()).fromApp(APP_ID).forDevice(DEVICE_ID).makePermanent().forTable(tableId).build();
}
use of org.onosproject.net.pi.runtime.PiAction in project onos by opennetworkinglab.
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(FabricConstants.FABRIC_INGRESS_ACL_NOP_ACL).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));
}
use of org.onosproject.net.pi.runtime.PiAction in project onos by opennetworkinglab.
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(FabricConstants.FABRIC_INGRESS_ACL_DROP).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));
}
Aggregations