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 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 onos by opennetworkinglab.
the class VirtualNetworkPacketManager method pushRule.
/**
* Pushes packet intercept flow rules to the device.
*
* @param device the device to push the rules to
* @param request the packet request
*/
private void pushRule(Device device, PacketRequest request) {
if (!device.type().equals(Device.Type.VIRTUAL)) {
return;
}
ForwardingObjective forwarding = createBuilder(request).add(new ObjectiveContext() {
@Override
public void onError(Objective objective, ObjectiveError error) {
log.warn("Failed to install packet request {} to {}: {}", request, device.id(), error);
}
});
objectiveService.forward(device.id(), forwarding);
}
use of org.onosproject.net.flowobjective.ForwardingObjective in project onos by opennetworkinglab.
the class FlowObjectiveManagerTest method forwardingObjective.
/**
* Tests adding a forwarding objective.
*/
@Test
public void forwardingObjective() {
TrafficSelector selector = DefaultTrafficSelector.emptySelector();
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
ForwardingObjective forward = DefaultForwardingObjective.builder().fromApp(NetTestTools.APP_ID).withFlag(ForwardingObjective.Flag.SPECIFIC).withSelector(selector).withTreatment(treatment).makePermanent().add();
manager.forward(id1, forward);
TestTools.assertAfter(RETRY_MS, () -> assertThat(forwardingObjectives, hasSize(1)));
assertThat(forwardingObjectives, hasItem("of:d1"));
assertThat(filteringObjectives, hasSize(0));
assertThat(nextObjectives, hasSize(0));
}
use of org.onosproject.net.flowobjective.ForwardingObjective in project onos by opennetworkinglab.
the class FlowObjectiveManagerTest method deviceUpEvent.
/**
* Tests receipt of a device up event.
*
* @throws TestUtilsException if lookup of a field fails
*/
@Test
public void deviceUpEvent() throws TestUtilsException {
TrafficSelector selector = DefaultTrafficSelector.emptySelector();
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
DeviceEvent event = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, d2);
DeviceListener listener = TestUtils.getField(manager, "deviceListener");
assertThat(listener, notNullValue());
listener.event(event);
ForwardingObjective forward = DefaultForwardingObjective.builder().fromApp(NetTestTools.APP_ID).withFlag(ForwardingObjective.Flag.SPECIFIC).withSelector(selector).withTreatment(treatment).makePermanent().add();
manager.forward(id2, forward);
// new device should have an objective now
TestTools.assertAfter(RETRY_MS, () -> assertThat(forwardingObjectives, hasSize(1)));
assertThat(forwardingObjectives, hasItem("of:d2"));
assertThat(filteringObjectives, hasSize(0));
assertThat(nextObjectives, hasSize(0));
}
Aggregations