use of org.onosproject.net.flow.instructions.Instruction in project fabric-tna by stratum.
the class NextObjectiveTranslator method nextMpls.
private void nextMpls(NextObjective obj, ObjectiveTranslation.Builder resultBuilder) throws FabricPipelinerException {
// Next objective can contain only one mpls push and one mpls label
// instruction. Pipeliner does not support other configurations.
final List<List<ModMplsLabelInstruction>> mplsInstructions = defaultNextTreatments(obj.nextTreatments(), false).stream().map(defaultNextTreatment -> l2Instructions(defaultNextTreatment.treatment(), MPLS_LABEL).stream().map(v -> (ModMplsLabelInstruction) v).collect(Collectors.toList())).filter(l -> !l.isEmpty()).collect(Collectors.toList());
if (mplsInstructions.isEmpty()) {
// No need to apply next mpls table
return;
}
// We expect one mpls label for each treatment and the label has to be the same
final Set<MplsLabel> mplsLabels = mplsInstructions.stream().flatMap(Collection::stream).map(ModMplsLabelInstruction::label).collect(Collectors.toSet());
if (obj.nextTreatments().size() != mplsInstructions.size() || mplsLabels.size() != 1) {
throw new FabricPipelinerException("Inconsistent MPLS_LABEL instructions, cannot process " + "next_mpls rule. It is required that all " + "treatments have the same MPLS_LABEL instructions.");
}
final TrafficSelector selector = nextIdSelector(obj.id());
final TrafficTreatment treatment = DefaultTrafficTreatment.builder().setMpls(mplsLabels.iterator().next()).build();
resultBuilder.addFlowRule(flowRule(obj, P4InfoConstants.FABRIC_INGRESS_PRE_NEXT_NEXT_MPLS, selector, treatment));
}
use of org.onosproject.net.flow.instructions.Instruction in project fabric-tna by stratum.
the class NextObjectiveTranslator method handleEgress.
private void handleEgress(NextObjective obj, TrafficTreatment treatment, ObjectiveTranslation.Builder resultBuilder, boolean strict) throws FabricPipelinerException {
final PortNumber outPort = outputPort(treatment);
final Instruction popVlanInst = l2Instruction(treatment, VLAN_POP);
if (outPort != null) {
if (strict && treatment.allInstructions().size() > 2) {
throw new FabricPipelinerException("Treatment contains instructions other " + "than OUTPUT and VLAN_POP, cannot generate " + "egress rules");
}
// We cannot program if there are no proper metadata in the objective
if (obj.meta() != null && obj.meta().getCriterion(Criterion.Type.VLAN_VID) != null) {
egressVlan(outPort, obj, popVlanInst, resultBuilder);
} else {
log.debug("NextObjective is trying to program {} without {} information [{}]", P4InfoConstants.FABRIC_EGRESS_EGRESS_NEXT_EGRESS_VLAN, obj.meta() == null ? "metadata" : "vlanId", obj);
}
}
}
use of org.onosproject.net.flow.instructions.Instruction in project onos by opennetworkinglab.
the class HPPipelineV3800 method tableIdForForwardingObjective.
@Override
protected int tableIdForForwardingObjective(TrafficSelector selector, TrafficTreatment treatment) {
boolean hardwareProcess = true;
log.debug("HP V3800 Driver - Evaluating the ForwardingObjective for proper TableID");
// Check criteria supported in hardware
for (Criterion criterion : selector.criteria()) {
if (!this.hardwareCriteria.contains(criterion.type())) {
log.warn("HP V3800 Driver - criterion {} only supported in SOFTWARE", criterion.type());
hardwareProcess = false;
break;
}
// HP3800 does not support hardware match on ETH_TYPE of value TYPE_VLAN
if (criterion.type() == Criterion.Type.ETH_TYPE) {
if (((EthTypeCriterion) criterion).ethType().toShort() == Ethernet.TYPE_VLAN) {
log.warn("HP V3800 Driver - ETH_TYPE == VLAN (0x8100) is only supported in software");
hardwareProcess = false;
break;
}
}
}
// Check if a CLEAR action is included
if (treatment.clearedDeferred()) {
log.warn("HP V3800 Driver - CLEAR action only supported in SOFTWARE");
hardwareProcess = false;
}
// If criteria can be processed in hardware, then check treatment
if (hardwareProcess) {
for (Instruction instruction : treatment.allInstructions()) {
// Check if the instruction type is contained in the hardware instruction
if (!this.hardwareInstructions.contains(instruction.type())) {
log.warn("HP V3800 Driver - instruction {} only supported in SOFTWARE", instruction.type());
hardwareProcess = false;
break;
}
/**
* If output is CONTROLLER_PORT the flow entry could be installed in hardware
* but is anyway processed in software because OPENFLOW header has to be added
*/
if (instruction.type() == Instruction.Type.OUTPUT) {
if (((Instructions.OutputInstruction) instruction).port() == PortNumber.CONTROLLER) {
log.warn("HP V3800 Driver - Forwarding to CONTROLLER only supported in software");
hardwareProcess = false;
break;
}
}
// Check if the specific L2MODIFICATION.subtype is supported in hardware
if (instruction.type() == Instruction.Type.L2MODIFICATION) {
if (!this.hardwareInstructionsL2mod.contains(((L2ModificationInstruction) instruction).subtype())) {
log.warn("HP V3800 Driver - L2MODIFICATION.subtype {} only supported in SOFTWARE", ((L2ModificationInstruction) instruction).subtype());
hardwareProcess = false;
break;
}
}
// TODO --- check if all the buckets contains one and only one output action
if (instruction.type() == Instruction.Type.GROUP) {
boolean groupInstalled = false;
GroupId groupId = ((Instructions.GroupInstruction) instruction).groupId();
Iterable<Group> groupsOnDevice = groupService.getGroups(deviceId);
for (Group group : groupsOnDevice) {
if ((group.state() == Group.GroupState.ADDED) && (group.id().equals(groupId))) {
groupInstalled = true;
if (group.type() != Group.Type.ALL) {
log.warn("HP V3800 Driver - group type {} only supported in SOFTWARE", group.type().toString());
hardwareProcess = false;
}
break;
}
}
if (!groupInstalled) {
log.warn("HP V3800 Driver - referenced group is not installed on the device.");
hardwareProcess = false;
}
}
}
}
if (hardwareProcess) {
log.warn("HP V3800 Driver - This flow rule is supported in HARDWARE");
return HP_HARDWARE_TABLE;
} else {
// TODO: create a specific flow in table 100 to redirect selected traffic on table 200
log.warn("HP V3800 Driver - This flow rule is only supported in SOFTWARE");
return HP_SOFTWARE_TABLE;
}
}
use of org.onosproject.net.flow.instructions.Instruction in project onos by opennetworkinglab.
the class FlowRuleJuniperImpl method getStaticRoute.
/**
* Helper method to convert FlowRule into an abstraction of static route
* {@link StaticRoute}.
*
* @param devId the device id
* @param criteria the IP destination criteria
* @param output the output instruction
* @return optional of Static Route
*/
private Optional<StaticRoute> getStaticRoute(DeviceId devId, IPCriterion criteria, OutputInstruction output, int priority) {
DeviceService deviceService = this.handler().get(DeviceService.class);
Collection<Port> ports = deviceService.getPorts(devId);
Optional<Port> port = ports.stream().filter(x -> x.number().equals(output.port())).findAny();
if (!port.isPresent()) {
log.error("The port {} does not exist in the device", output.port());
return Optional.empty();
}
// Find if the route refers to a local interface.
Optional<Port> local = deviceService.getPorts(devId).stream().filter(this::isIp).filter(p -> criteria.ip().getIp4Prefix().contains(Ip4Address.valueOf(p.annotations().value(JuniperUtils.AK_IP)))).findAny();
if (local.isPresent()) {
return Optional.of(new StaticRoute(criteria.ip().getIp4Prefix(), criteria.ip().getIp4Prefix().address(), true, priority));
}
Optional<Ip4Address> nextHop = findIpDst(devId, port.get());
if (nextHop.isPresent()) {
return Optional.of(new StaticRoute(criteria.ip().getIp4Prefix(), nextHop.get(), false, priority));
} else {
log.error("The destination interface has not an IP {}", port.get());
return Optional.empty();
}
}
use of org.onosproject.net.flow.instructions.Instruction in project onos by opennetworkinglab.
the class HPPipelineV1 method tableIdForForwardingObjective.
@Override
protected int tableIdForForwardingObjective(TrafficSelector selector, TrafficTreatment treatment) {
boolean hardwareProcess = true;
log.debug("HP V1 Driver - Evaluating the ForwardingObjective for proper TableID");
// Check criteria supported in hardware
for (Criterion criterion : selector.criteria()) {
if (!this.hardwareCriteria.contains(criterion.type())) {
log.warn("HP V1 Driver - criterion {} only supported in SOFTWARE", criterion.type());
hardwareProcess = false;
break;
}
// HP3500 supports hardware match on ETH_TYPE only with value TYPE_IPV4
if (criterion.type() == Criterion.Type.ETH_TYPE) {
if (((EthTypeCriterion) criterion).ethType().toShort() != Ethernet.TYPE_IPV4) {
log.warn("HP V1 Driver - only ETH_TYPE == IPv4 (0x0800) is supported in hardware");
hardwareProcess = false;
break;
}
}
// HP3500 supports IN_PORT criterion in hardware only if associated with ETH_TYPE criterion
if (criterion.type() == Criterion.Type.IN_PORT) {
hardwareProcess = false;
for (Criterion requiredCriterion : selector.criteria()) {
if (requiredCriterion.type() == Criterion.Type.ETH_TYPE) {
hardwareProcess = true;
}
}
if (!hardwareProcess) {
log.warn("HP V1 Driver - IN_PORT criterion without ETH_TYPE is not supported in hardware");
break;
}
}
}
// Check if a CLEAR action is included
if (treatment.clearedDeferred()) {
log.warn("HP V1 Driver - CLEAR action only supported in SOFTWARE");
hardwareProcess = false;
}
// If criteria can be processed in hardware, then check treatment
if (hardwareProcess) {
for (Instruction instruction : treatment.allInstructions()) {
// Check if the instruction type is contained in the hardware instruction
if (!this.hardwareInstructions.contains(instruction.type())) {
log.warn("HP V1 Driver - instruction {} only supported in SOFTWARE", instruction.type());
hardwareProcess = false;
break;
}
/**
* If output is CONTROLLER_PORT the flow entry could be installed in hardware
* but is anyway processed in software because openflow header has to be added
*/
if (instruction.type() == Instruction.Type.OUTPUT) {
if (((Instructions.OutputInstruction) instruction).port() == PortNumber.CONTROLLER) {
log.warn("HP V1 Driver - Forwarding to CONTROLLER only supported in software");
hardwareProcess = false;
break;
}
}
/**
* Only L2MODIFICATION supported in hardware is MODIFY VLAN_PRIORITY.
* Check if the specific L2MODIFICATION.subtype is supported in hardware
*/
if (instruction.type() == Instruction.Type.L2MODIFICATION) {
if (!this.hardwareInstructionsL2mod.contains(((L2ModificationInstruction) instruction).subtype())) {
log.warn("HP V1 Driver - L2MODIFICATION.subtype {} only supported in SOFTWARE", ((L2ModificationInstruction) instruction).subtype());
hardwareProcess = false;
break;
}
}
}
}
if (hardwareProcess) {
log.warn("HP V1 Driver - This flow rule is supported in HARDWARE");
return HP_HARDWARE_TABLE;
} else {
// TODO: create a specific flow in table 100 to redirect selected traffic on table 200
log.warn("HP V1 Driver - This flow rule is only supported in SOFTWARE");
return HP_SOFTWARE_TABLE;
}
}
Aggregations