use of org.onosproject.net.flowobjective.ForwardingObjective in project onos by opennetworkinglab.
the class PacketManager method removeRule.
/**
* Removes packet intercept flow rules from the device.
*
* @param device the device to remove the rules deom
* @param request the packet request
*/
private void removeRule(Device device, PacketRequest request) {
if (!device.type().equals(Device.Type.SWITCH)) {
return;
}
ForwardingObjective forwarding = createBuilder(request).remove(new ObjectiveContext() {
@Override
public void onError(Objective objective, ObjectiveError error) {
log.warn("Failed to withdraw packet request {} from {}: {}", request, device.id(), error);
}
});
objectiveService.forward(device.id(), forwarding);
}
use of org.onosproject.net.flowobjective.ForwardingObjective in project onos by opennetworkinglab.
the class PacketManager 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.SWITCH)) {
return;
}
if (!deviceService.isAvailable(device.id())) {
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 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, FabricConstants.FABRIC_INGRESS_FORWARDING_ROUTING_V4, selector));
}
use of org.onosproject.net.flowobjective.ForwardingObjective in project onos by opennetworkinglab.
the class ForwardingFunctionTypeTest method testFft.
private void testFft(TrafficSelector selector, ForwardingFunctionType expectedFft) {
ForwardingObjective fwd = DefaultForwardingObjective.builder().withSelector(selector).withFlag(ForwardingObjective.Flag.SPECIFIC).nextStep(0).fromApp(APP_ID).add();
assertEquals(expectedFft, ForwardingFunctionType.getForwardingFunctionType(fwd));
}
use of org.onosproject.net.flowobjective.ForwardingObjective 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));
}
Aggregations