Search in sources :

Example 1 with TsReturn

use of org.onosproject.fnl.base.TsReturn in project onos by opennetworkinglab.

the class DefaultCheckLoop method matchDeviceFlows.

/**
 * Iterate one by one at switch hops.
 * Return whether we discover a Loop now or not.
 *
 * When flows form a loop,
 * pkt is also a return value indicating the loop header.
 *
 * @param deviceId the device needed to be checked
 * @param pkt virtual packet forwarded by switches
 * @return true if a loop is discovered
 */
private boolean matchDeviceFlows(DeviceId deviceId, TsLoopPacket pkt) {
    if (pkt.isPassedDevice(deviceId)) {
        // Attention: pkt should be held outside
        return true;
    }
    List<FlowEntry> availableFlowEntries = new ArrayList<>();
    flowEntryInfo.get(deviceId).forEach(flowEntry -> {
        if (flowEntry.state() == ADDED) {
            availableFlowEntries.add(flowEntry);
        }
    });
    List<FlowEntry> sortedFlowEntries = sortFlowTable(availableFlowEntries);
    for (FlowEntry flowEntry : sortedFlowEntries) {
        TsReturn<Boolean> isBigger = new TsReturn<>();
        TsLoopPacket newPkt = pkt.copyPacketMatch();
        if (!matchAndAddFlowEntry(flowEntry, newPkt, isBigger)) {
            continue;
        }
        newPkt.pushPathFlow(flowEntry);
        for (Instruction instOne : flowEntry.treatment().immediate()) {
            // the relationship of params which are passed in and out.
            if (processOneInstruction(instOne, deviceId, pkt, newPkt, false, null)) {
                return true;
            }
        }
        newPkt.popPathFlow();
        if (!isBigger.getValue()) {
            break;
        }
    }
    return false;
}
Also used : ArrayList(java.util.ArrayList) OutputInstruction(org.onosproject.net.flow.instructions.Instructions.OutputInstruction) Instruction(org.onosproject.net.flow.instructions.Instruction) FlowEntry(org.onosproject.net.flow.FlowEntry) TsReturn(org.onosproject.fnl.base.TsReturn) TsLoopPacket(org.onosproject.fnl.base.TsLoopPacket)

Aggregations

ArrayList (java.util.ArrayList)1 TsLoopPacket (org.onosproject.fnl.base.TsLoopPacket)1 TsReturn (org.onosproject.fnl.base.TsReturn)1 FlowEntry (org.onosproject.net.flow.FlowEntry)1 Instruction (org.onosproject.net.flow.instructions.Instruction)1 OutputInstruction (org.onosproject.net.flow.instructions.Instructions.OutputInstruction)1