Skip to content
Snippets Groups Projects
Commit ef259134 authored by Ryan Izard's avatar Ryan Izard
Browse files

Merge pull request #478 from rizard/v1.0

Last-minute SFP additions to catch some exceptions.
parents 8fe916f9 46936a40
No related branches found
No related tags found
No related merge requests found
......@@ -64,6 +64,7 @@ import org.projectfloodlight.openflow.protocol.OFFlowRemovedReason;
import org.projectfloodlight.openflow.protocol.OFPortDesc;
import org.projectfloodlight.openflow.protocol.OFMessage;
import org.projectfloodlight.openflow.protocol.OFType;
import org.projectfloodlight.openflow.protocol.OFVersion;
import org.projectfloodlight.openflow.types.DatapathId;
import org.projectfloodlight.openflow.types.TableId;
import org.projectfloodlight.openflow.types.U16;
......@@ -383,7 +384,11 @@ implements IOFSwitchListener, IFloodlightModule, IStaticFlowEntryPusherService,
return;
}
} else if (key.equals(COLUMN_TABLE_ID)) {
fmb.setTableId(TableId.of(Integer.parseInt((String) row.get(key)))); // support multiple flow tables for OF1.1+
if (fmb.getVersion().compareTo(OFVersion.OF_10) > 0) {
fmb.setTableId(TableId.of(Integer.parseInt((String) row.get(key)))); // support multiple flow tables for OF1.1+
} else {
log.error("Table not supported in OpenFlow 1.0");
}
} else if (key.equals(COLUMN_ACTIONS)) {
ActionUtils.fromString(fmb, (String) row.get(COLUMN_ACTIONS), log);
} else if (key.equals(COLUMN_COOKIE)) {
......@@ -424,7 +429,7 @@ implements IOFSwitchListener, IFloodlightModule, IStaticFlowEntryPusherService,
try {
fmb.setMatch(MatchUtils.fromString(match, fmb.getVersion()));
} catch (IllegalArgumentException e) {
log.debug("ignoring flow entry {} on switch {} with illegal OFMatch() key: " + match, entryName, switchName);
log.debug("Ignoring flow entry {} on switch {} with illegal OFMatch() key: " + match, entryName, switchName);
return;
}
//sanjivini
......
......@@ -5,6 +5,7 @@ import java.util.List;
import org.projectfloodlight.openflow.protocol.OFFactories;
import org.projectfloodlight.openflow.protocol.OFFlowMod;
import org.projectfloodlight.openflow.protocol.OFVersion;
import org.projectfloodlight.openflow.protocol.instruction.OFInstruction;
import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions;
import org.projectfloodlight.openflow.protocol.instruction.OFInstructionClearActions;
......@@ -88,6 +89,12 @@ public class InstructionUtils {
if (instStr == null || instStr.equals("")) {
return;
}
if (fmb.getVersion().compareTo(OFVersion.OF_11) < 0) {
log.error("Goto Table Instruction not supported in OpenFlow 1.0");
return;
}
// Split into pairs of key=value
String[] keyValue = instStr.split("=");
if (keyValue.length != 2) {
......@@ -129,6 +136,12 @@ public class InstructionUtils {
if (inst == null || inst.equals("")) {
return;
}
if (fmb.getVersion().compareTo(OFVersion.OF_11) < 0) {
log.error("Write Metadata Instruction not supported in OpenFlow 1.0");
return;
}
// Split into pairs of key=value
String[] tokens = inst.split(",");
if (tokens.length != 2) {
......@@ -181,6 +194,12 @@ public class InstructionUtils {
* @param log
*/
public static void writeActionsFromString(OFFlowMod.Builder fmb, String inst, Logger log) {
if (fmb.getVersion().compareTo(OFVersion.OF_11) < 0) {
log.error("Write Actions Instruction not supported in OpenFlow 1.0");
return;
}
OFFlowMod.Builder tmpFmb = OFFactories.getFactory(fmb.getVersion()).buildFlowModify(); // ActionUtils.fromString() will use setActions(), which should not be used for OF1.3; use temp to avoid overwriting any applyActions data
OFInstructionWriteActions.Builder ib = OFFactories.getFactory(fmb.getVersion()).instructions().buildWriteActions();
ActionUtils.fromString(tmpFmb, inst, log);
......@@ -212,6 +231,12 @@ public class InstructionUtils {
* @param log
*/
public static void applyActionsFromString(OFFlowMod.Builder fmb, String inst, Logger log) {
if (fmb.getVersion().compareTo(OFVersion.OF_11) < 0) {
log.error("Apply Actions Instruction not supported in OpenFlow 1.0");
return;
}
OFFlowMod.Builder tmpFmb = OFFactories.getFactory(fmb.getVersion()).buildFlowModify();
OFInstructionApplyActions.Builder ib = OFFactories.getFactory(fmb.getVersion()).instructions().buildApplyActions();
ActionUtils.fromString(tmpFmb, inst, log);
......@@ -243,6 +268,12 @@ public class InstructionUtils {
* @param log
*/
public static void clearActionsFromString(OFFlowMod.Builder fmb, String inst, Logger log) {
if (fmb.getVersion().compareTo(OFVersion.OF_11) < 0) {
log.error("Clear Actions Instruction not supported in OpenFlow 1.0");
return;
}
if (inst != null && inst.isEmpty()) {
OFInstructionClearActions i = OFFactories.getFactory(fmb.getVersion()).instructions().clearActions();
log.debug("Appending ClearActions instruction: {}", i);
......@@ -279,6 +310,11 @@ public class InstructionUtils {
if (inst == null || inst.isEmpty()) {
return;
}
if (fmb.getVersion().compareTo(OFVersion.OF_13) < 0) {
log.error("Goto Meter Instruction not supported in OpenFlow 1.0, 1.1, or 1.2");
return;
}
OFInstructionMeter.Builder ib = OFFactories.getFactory(fmb.getVersion()).instructions().buildMeter();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment