use of org.onosproject.net.flowobjective.ForwardingObjective in project onos by opennetworkinglab.
the class ForwardingObjectiveTranslatorTest method testAclArp.
/**
* Test versatile flag of forwarding objective with ARP match.
*/
@Test
public void testAclArp() {
TrafficTreatment treatment = DefaultTrafficTreatment.builder().punt().build();
// ARP
TrafficSelector selector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_ARP).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());
assertEquals(1, groupsInstalled.size());
FlowRule actualFlowRule = flowRulesInstalled.get(0);
PiAction piAction = PiAction.builder().withId(FabricConstants.FABRIC_INGRESS_ACL_SET_CLONE_SESSION_ID).withParameter(new PiActionParam(FabricConstants.CLONE_ID, ForwardingObjectiveTranslator.CLONE_TO_CPU_ID)).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();
GroupDescription actualCloneGroup = groupsInstalled.get(0);
TrafficTreatment cloneGroupTreatment = DefaultTrafficTreatment.builder().setOutput(PortNumber.CONTROLLER).build();
List<GroupBucket> cloneBuckets = ImmutableList.of(DefaultGroupBucket.createCloneGroupBucket(cloneGroupTreatment));
GroupBuckets cloneGroupBuckets = new GroupBuckets(cloneBuckets);
GroupKey cloneGroupKey = new DefaultGroupKey(FabricPipeliner.KRYO.serialize(ForwardingObjectiveTranslator.CLONE_TO_CPU_ID));
GroupDescription expectedCloneGroup = new DefaultGroupDescription(DEVICE_ID, GroupDescription.Type.CLONE, cloneGroupBuckets, cloneGroupKey, ForwardingObjectiveTranslator.CLONE_TO_CPU_ID, APP_ID);
assertTrue(expectedFlowRule.exactMatch(actualFlowRule));
assertTrue(expectedCloneGroup.equals(actualCloneGroup));
}
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 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 AristaPipeliner method forward.
@Override
public void forward(ForwardingObjective forwardObjective) {
ForwardingObjective newFwd = forwardObjective;
Device device = deviceService.getDevice(deviceId);
if (forwardObjective.treatment() != null && forwardObjective.treatment().clearedDeferred()) {
log.warn("Using 'clear actions' instruction which is not supported by {} {} {} Switch" + " removing the clear deferred from the forwarding objective", device.id(), device.manufacturer(), device.hwVersion());
newFwd = forwardingObjectiveWithoutCleardDef(forwardObjective).orElse(forwardObjective);
}
super.forward(newFwd);
}
use of org.onosproject.net.flowobjective.ForwardingObjective in project onos by opennetworkinglab.
the class JuniperQfx5100Pipeliner method forward.
@Override
public void forward(ForwardingObjective forwardObjective) {
FlowRule rule;
FlowRuleOperations.Builder flowOpsBuilder = FlowRuleOperations.builder();
ForwardingObjective newFwd = forwardObjective;
Device device = deviceService.getDevice(deviceId);
if (forwardObjective.treatment() != null && forwardObjective.treatment().clearedDeferred()) {
log.warn("Using 'clear actions' instruction which is not supported by {} {} {} Switch", device.id(), device.manufacturer(), device.hwVersion());
newFwd = forwardingObjectiveWithoutCleardDef(forwardObjective).orElse(forwardObjective);
}
rule = processForward(newFwd);
switch(forwardObjective.op()) {
case ADD:
flowOpsBuilder.add(rule);
break;
case REMOVE:
flowOpsBuilder.remove(rule);
break;
default:
fail(forwardObjective, ObjectiveError.UNKNOWN);
log.warn("Unknown forwarding type {}", forwardObjective.op());
}
flowRuleService.apply(flowOpsBuilder.build(new FlowRuleOperationsContext() {
@Override
public void onSuccess(FlowRuleOperations ops) {
pass(forwardObjective);
}
@Override
public void onError(FlowRuleOperations ops) {
fail(forwardObjective, ObjectiveError.FLOWINSTALLATIONFAILED);
}
}));
}
Aggregations