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;
}
Aggregations