Search in sources :

Example 1 with SetQueueInstruction

use of org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction in project onos by opennetworkinglab.

the class InstructionJsonMatcher method matchSetQueueInstruction.

/**
 * Matches the contents of a set queue instruction.
 *
 * @param instructionJson JSON instruction to match
 * @param description Description object used for recording errors
 * @return true if contents match, false otherwise
 */
private boolean matchSetQueueInstruction(JsonNode instructionJson, Description description) {
    final String jsonType = instructionJson.get("type").textValue();
    SetQueueInstruction instructionToMatch = (SetQueueInstruction) instruction;
    if (!instructionToMatch.type().name().equals(jsonType)) {
        description.appendText("type was " + jsonType);
        return false;
    }
    final long jsonQueueId = instructionJson.get("queueId").longValue();
    if (instructionToMatch.queueId() != jsonQueueId) {
        description.appendText("queueId was " + jsonQueueId);
        return false;
    }
    if (instructionJson.get("port").isLong() || instructionJson.get("port").isInt()) {
        final long jsonPort = instructionJson.get("port").asLong();
        if (instructionToMatch.port().toLong() != (jsonPort)) {
            description.appendText("port was " + jsonPort);
            return false;
        }
    } else if (instructionJson.get("port").isTextual()) {
        final String jsonPort = instructionJson.get("port").textValue();
        if (!instructionToMatch.port().toString().equals(jsonPort)) {
            description.appendText("port was " + jsonPort);
            return false;
        }
    } else {
        final String jsonPort = instructionJson.get("port").toString();
        description.appendText("Unmatching types ");
        description.appendText("instructionToMatch " + instructionToMatch.port().toString());
        description.appendText("jsonPort " + jsonPort);
    }
    return true;
}
Also used : SetQueueInstruction(org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction) HexString(org.onlab.util.HexString)

Example 2 with SetQueueInstruction

use of org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction in project onos by opennetworkinglab.

the class InstructionJsonMatcher method matchesSafely.

@Override
public boolean matchesSafely(JsonNode jsonInstruction, Description description) {
    // check type
    final JsonNode jsonTypeNode = jsonInstruction.get("type");
    final String jsonType = jsonTypeNode.textValue();
    final String type = instruction.type().name();
    if (!jsonType.equals(type)) {
        description.appendText("type was " + type);
        return false;
    }
    if (instruction instanceof ModMplsHeaderInstruction) {
        return matchModMplsHeaderInstruction(jsonInstruction, description);
    } else if (instruction instanceof OutputInstruction) {
        return matchOutputInstruction(jsonInstruction, description);
    } else if (instruction instanceof GroupInstruction) {
        return matchGroupInstruction(jsonInstruction, description);
    } else if (instruction instanceof MeterInstruction) {
        return matchMeterInstruction(jsonInstruction, description);
    } else if (instruction instanceof SetQueueInstruction) {
        return matchSetQueueInstruction(jsonInstruction, description);
    } else if (instruction instanceof ModOchSignalInstruction) {
        return matchModOchSingalInstruction(jsonInstruction, description);
    } else if (instruction instanceof ModEtherInstruction) {
        return matchModEtherInstruction(jsonInstruction, description);
    } else if (instruction instanceof ModVlanIdInstruction) {
        return matchModVlanIdInstruction(jsonInstruction, description);
    } else if (instruction instanceof ModVlanPcpInstruction) {
        return matchModVlanPcpInstruction(jsonInstruction, description);
    } else if (instruction instanceof ModIPInstruction) {
        return matchModIpInstruction(jsonInstruction, description);
    } else if (instruction instanceof ModIPv6FlowLabelInstruction) {
        return matchModIPv6FlowLabelInstruction(jsonInstruction, description);
    } else if (instruction instanceof ModMplsLabelInstruction) {
        return matchModMplsLabelInstruction(jsonInstruction, description);
    } else if (instruction instanceof ModOduSignalIdInstruction) {
        return matchModOduSingalIdInstruction(jsonInstruction, description);
    } else if (instruction instanceof PiInstruction) {
        return matchPiInstruction(jsonInstruction, description);
    } else if (instruction instanceof NoActionInstruction) {
        return true;
    }
    return false;
}
Also used : OutputInstruction(org.onosproject.net.flow.instructions.Instructions.OutputInstruction) ModOchSignalInstruction(org.onosproject.net.flow.instructions.L0ModificationInstruction.ModOchSignalInstruction) PiInstruction(org.onosproject.net.flow.instructions.PiInstruction) JsonNode(com.fasterxml.jackson.databind.JsonNode) HexString(org.onlab.util.HexString) ModEtherInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction) ModMplsHeaderInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsHeaderInstruction) ModIPInstruction(org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction) ModOduSignalIdInstruction(org.onosproject.net.flow.instructions.L1ModificationInstruction.ModOduSignalIdInstruction) SetQueueInstruction(org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction) ModMplsLabelInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsLabelInstruction) ModVlanIdInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction) NoActionInstruction(org.onosproject.net.flow.instructions.Instructions.NoActionInstruction) MeterInstruction(org.onosproject.net.flow.instructions.Instructions.MeterInstruction) ModIPv6FlowLabelInstruction(org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6FlowLabelInstruction) GroupInstruction(org.onosproject.net.flow.instructions.Instructions.GroupInstruction) ModVlanPcpInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction)

Example 3 with SetQueueInstruction

use of org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction in project onos by opennetworkinglab.

the class DefaultNicFlowRule method populate.

/**
 * Parses FlowRule's traffic selector and treatment
 * and keeps relevant information for this NIC rule.
 */
private void populate() {
    this.ethTypeCriterion = (EthTypeCriterion) this.selector().getCriterion(ETH_TYPE);
    this.ethSrcAddrCriterion = (EthCriterion) this.selector().getCriterion(ETH_SRC);
    this.ethDstAddrCriterion = (EthCriterion) this.selector().getCriterion(ETH_DST);
    this.ipv4ProtoCriterion = (IPProtocolCriterion) this.selector().getCriterion(IP_PROTO);
    this.ipv4SrcAddrCriterion = (IPCriterion) this.selector().getCriterion(IPV4_SRC);
    this.ipv4DstAddrCriterion = (IPCriterion) this.selector().getCriterion(IPV4_DST);
    this.ipv4SrcMaskCriterion = (IPCriterion) this.selector().getCriterion(IPV4_SRC);
    this.ipv4DstMaskCriterion = (IPCriterion) this.selector().getCriterion(IPV4_DST);
    this.udpSrcPortCriterion = (UdpPortCriterion) this.selector().getCriterion(UDP_SRC);
    this.udpDstPortCriterion = (UdpPortCriterion) this.selector().getCriterion(UDP_DST);
    this.tcpSrcPortCriterion = (TcpPortCriterion) this.selector().getCriterion(TCP_SRC);
    this.tcpDstPortCriterion = (TcpPortCriterion) this.selector().getCriterion(TCP_DST);
    this.actions = new HashSet<NicRuleAction>();
    // TODO: Expand this translator with more actions
    for (Instruction instr : this.treatment().allInstructions()) {
        if (instr.type() == NOACTION) {
            this.actions.add(new NicRuleAction(NicRuleAction.Action.DROP));
        } else if (instr.type() == QUEUE) {
            SetQueueInstruction queueInstruction = (SetQueueInstruction) instr;
            this.actions.add(new NicRuleAction(NicRuleAction.Action.QUEUE, queueInstruction.queueId()));
            this.interfaceNumber = queueInstruction.port().toLong();
        } else if (instr.type() == METER) {
            MeterInstruction meterInstruction = (MeterInstruction) instr;
            this.actions.add(new NicRuleAction(NicRuleAction.Action.METER, meterInstruction.meterId().id()));
        }
    }
    // This action provides basic rule match counters
    this.actions.add(new NicRuleAction(NicRuleAction.Action.COUNT));
}
Also used : SetQueueInstruction(org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction) MeterInstruction(org.onosproject.net.flow.instructions.Instructions.MeterInstruction) MeterInstruction(org.onosproject.net.flow.instructions.Instructions.MeterInstruction) Instruction(org.onosproject.net.flow.instructions.Instruction) SetQueueInstruction(org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction)

Example 4 with SetQueueInstruction

use of org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction in project onos by opennetworkinglab.

the class FlowModBuilderVer13 method buildActions.

private List<OFAction> buildActions(List<Instruction> treatments) {
    if (treatment == null) {
        return Collections.emptyList();
    }
    boolean tableFound = false;
    List<OFAction> actions = new LinkedList<>();
    for (Instruction i : treatments) {
        switch(i.type()) {
            case NOACTION:
                return Collections.emptyList();
            case L0MODIFICATION:
                actions.add(buildL0Modification(i));
                break;
            case L1MODIFICATION:
                actions.add(buildL1Modification(i));
                break;
            case L2MODIFICATION:
                actions.add(buildL2Modification(i));
                break;
            case L3MODIFICATION:
                actions.add(buildL3Modification(i));
                break;
            case L4MODIFICATION:
                actions.add(buildL4Modification(i));
                break;
            case OUTPUT:
                OutputInstruction out = (OutputInstruction) i;
                OFActionOutput.Builder action = factory().actions().buildOutput().setPort(OFPort.of((int) out.port().toLong()));
                if (out.port().equals(PortNumber.CONTROLLER)) {
                    action.setMaxLen(OFPCML_NO_BUFFER);
                }
                actions.add(action.build());
                break;
            case GROUP:
                GroupInstruction group = (GroupInstruction) i;
                OFActionGroup.Builder groupBuilder = factory().actions().buildGroup().setGroup(OFGroup.of(group.groupId().id()));
                actions.add(groupBuilder.build());
                break;
            case QUEUE:
                SetQueueInstruction queue = (SetQueueInstruction) i;
                OFActionSetQueue.Builder queueBuilder = factory().actions().buildSetQueue().setQueueId(queue.queueId());
                actions.add(queueBuilder.build());
                break;
            case TABLE:
                // FIXME: should not occur here.
                tableFound = true;
                break;
            case EXTENSION:
                actions.add(buildExtensionAction(((Instructions.ExtensionInstructionWrapper) i).extensionInstruction()));
                break;
            default:
                log.warn("Instruction type {} not yet implemented.", i.type());
        }
    }
    if (tableFound && actions.isEmpty()) {
        // a goto instruction for the next table
        return Collections.emptyList();
    }
    return actions;
}
Also used : OutputInstruction(org.onosproject.net.flow.instructions.Instructions.OutputInstruction) OFActionOutput(org.projectfloodlight.openflow.protocol.action.OFActionOutput) OFActionSetQueue(org.projectfloodlight.openflow.protocol.action.OFActionSetQueue) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) ModIPv6FlowLabelInstruction(org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6FlowLabelInstruction) ModOchSignalInstruction(org.onosproject.net.flow.instructions.L0ModificationInstruction.ModOchSignalInstruction) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction) OutputInstruction(org.onosproject.net.flow.instructions.Instructions.OutputInstruction) OFInstruction(org.projectfloodlight.openflow.protocol.instruction.OFInstruction) L3ModificationInstruction(org.onosproject.net.flow.instructions.L3ModificationInstruction) ModVlanIdInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction) ModOduSignalIdInstruction(org.onosproject.net.flow.instructions.L1ModificationInstruction.ModOduSignalIdInstruction) ModTransportPortInstruction(org.onosproject.net.flow.instructions.L4ModificationInstruction.ModTransportPortInstruction) ModEtherInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction) ModTunnelIdInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModTunnelIdInstruction) L4ModificationInstruction(org.onosproject.net.flow.instructions.L4ModificationInstruction) ModMplsLabelInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsLabelInstruction) ModIPInstruction(org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction) ModArpIPInstruction(org.onosproject.net.flow.instructions.L3ModificationInstruction.ModArpIPInstruction) ModVlanPcpInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction) L0ModificationInstruction(org.onosproject.net.flow.instructions.L0ModificationInstruction) ModVlanHeaderInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanHeaderInstruction) ModMplsBosInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsBosInstruction) Instruction(org.onosproject.net.flow.instructions.Instruction) ModArpEthInstruction(org.onosproject.net.flow.instructions.L3ModificationInstruction.ModArpEthInstruction) ModMplsHeaderInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsHeaderInstruction) GroupInstruction(org.onosproject.net.flow.instructions.Instructions.GroupInstruction) L1ModificationInstruction(org.onosproject.net.flow.instructions.L1ModificationInstruction) ModArpOpInstruction(org.onosproject.net.flow.instructions.L3ModificationInstruction.ModArpOpInstruction) SetQueueInstruction(org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction) OFActionGroup(org.projectfloodlight.openflow.protocol.action.OFActionGroup) LinkedList(java.util.LinkedList) SetQueueInstruction(org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction) GroupInstruction(org.onosproject.net.flow.instructions.Instructions.GroupInstruction)

Example 5 with SetQueueInstruction

use of org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction in project onos by opennetworkinglab.

the class FlowModBuilderVer10 method buildActions.

private List<OFAction> buildActions() {
    List<OFAction> acts = new LinkedList<>();
    OFAction act;
    if (treatment == null) {
        return acts;
    }
    for (Instruction i : treatment.immediate()) {
        switch(i.type()) {
            case NOACTION:
                return Collections.emptyList();
            case L2MODIFICATION:
                act = buildL2Modification(i);
                if (act != null) {
                    acts.add(buildL2Modification(i));
                }
                break;
            case L3MODIFICATION:
                act = buildL3Modification(i);
                if (act != null) {
                    acts.add(buildL3Modification(i));
                }
                break;
            case OUTPUT:
                OutputInstruction out = (OutputInstruction) i;
                OFActionOutput.Builder action = factory().actions().buildOutput().setPort(OFPort.of((int) out.port().toLong()));
                if (out.port().equals(PortNumber.CONTROLLER)) {
                    action.setMaxLen(OFPCML_NO_BUFFER);
                }
                acts.add(action.build());
                break;
            case QUEUE:
                SetQueueInstruction queue = (SetQueueInstruction) i;
                if (queue.port() == null) {
                    log.warn("Required argument 'port' undefined for OFActionEnqueue");
                }
                OFActionEnqueue.Builder queueBuilder = factory().actions().buildEnqueue().setQueueId(queue.queueId()).setPort(OFPort.ofInt((int) queue.port().toLong()));
                acts.add(queueBuilder.build());
                break;
            case L0MODIFICATION:
            case L1MODIFICATION:
            case GROUP:
            case TABLE:
            case METADATA:
                log.warn("Instruction type {} not supported with protocol version {}", i.type(), factory().getVersion());
                break;
            default:
                log.warn("Instruction type {} not yet implemented.", i.type());
        }
    }
    return acts;
}
Also used : OutputInstruction(org.onosproject.net.flow.instructions.Instructions.OutputInstruction) OFActionOutput(org.projectfloodlight.openflow.protocol.action.OFActionOutput) SetQueueInstruction(org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) OFActionEnqueue(org.projectfloodlight.openflow.protocol.action.OFActionEnqueue) ModIPInstruction(org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction) ModVlanPcpInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction) OutputInstruction(org.onosproject.net.flow.instructions.Instructions.OutputInstruction) L3ModificationInstruction(org.onosproject.net.flow.instructions.L3ModificationInstruction) Instruction(org.onosproject.net.flow.instructions.Instruction) ModVlanIdInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction) ModEtherInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction) SetQueueInstruction(org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction) LinkedList(java.util.LinkedList)

Aggregations

SetQueueInstruction (org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction)5 Instruction (org.onosproject.net.flow.instructions.Instruction)3 OutputInstruction (org.onosproject.net.flow.instructions.Instructions.OutputInstruction)3 ModEtherInstruction (org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction)3 ModVlanIdInstruction (org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction)3 ModVlanPcpInstruction (org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction)3 ModIPInstruction (org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction)3 LinkedList (java.util.LinkedList)2 HexString (org.onlab.util.HexString)2 GroupInstruction (org.onosproject.net.flow.instructions.Instructions.GroupInstruction)2 MeterInstruction (org.onosproject.net.flow.instructions.Instructions.MeterInstruction)2 ModOchSignalInstruction (org.onosproject.net.flow.instructions.L0ModificationInstruction.ModOchSignalInstruction)2 ModOduSignalIdInstruction (org.onosproject.net.flow.instructions.L1ModificationInstruction.ModOduSignalIdInstruction)2 L2ModificationInstruction (org.onosproject.net.flow.instructions.L2ModificationInstruction)2 ModMplsHeaderInstruction (org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsHeaderInstruction)2 ModMplsLabelInstruction (org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsLabelInstruction)2 L3ModificationInstruction (org.onosproject.net.flow.instructions.L3ModificationInstruction)2 ModIPv6FlowLabelInstruction (org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6FlowLabelInstruction)2 OFAction (org.projectfloodlight.openflow.protocol.action.OFAction)2 OFActionOutput (org.projectfloodlight.openflow.protocol.action.OFActionOutput)2