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

Last-minute SFP additions to catch some exceptions. Still have more to go, but...

Last-minute SFP additions to catch some exceptions. Still have more to go, but they can wait, since it'd be from user error.
parent 8fe916f9
No related branches found
No related tags found
No related merge requests found
...@@ -64,6 +64,7 @@ import org.projectfloodlight.openflow.protocol.OFFlowRemovedReason; ...@@ -64,6 +64,7 @@ import org.projectfloodlight.openflow.protocol.OFFlowRemovedReason;
import org.projectfloodlight.openflow.protocol.OFPortDesc; import org.projectfloodlight.openflow.protocol.OFPortDesc;
import org.projectfloodlight.openflow.protocol.OFMessage; import org.projectfloodlight.openflow.protocol.OFMessage;
import org.projectfloodlight.openflow.protocol.OFType; import org.projectfloodlight.openflow.protocol.OFType;
import org.projectfloodlight.openflow.protocol.OFVersion;
import org.projectfloodlight.openflow.types.DatapathId; import org.projectfloodlight.openflow.types.DatapathId;
import org.projectfloodlight.openflow.types.TableId; import org.projectfloodlight.openflow.types.TableId;
import org.projectfloodlight.openflow.types.U16; import org.projectfloodlight.openflow.types.U16;
...@@ -383,7 +384,11 @@ implements IOFSwitchListener, IFloodlightModule, IStaticFlowEntryPusherService, ...@@ -383,7 +384,11 @@ implements IOFSwitchListener, IFloodlightModule, IStaticFlowEntryPusherService,
return; return;
} }
} else if (key.equals(COLUMN_TABLE_ID)) { } 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)) { } else if (key.equals(COLUMN_ACTIONS)) {
ActionUtils.fromString(fmb, (String) row.get(COLUMN_ACTIONS), log); ActionUtils.fromString(fmb, (String) row.get(COLUMN_ACTIONS), log);
} else if (key.equals(COLUMN_COOKIE)) { } else if (key.equals(COLUMN_COOKIE)) {
...@@ -424,7 +429,7 @@ implements IOFSwitchListener, IFloodlightModule, IStaticFlowEntryPusherService, ...@@ -424,7 +429,7 @@ implements IOFSwitchListener, IFloodlightModule, IStaticFlowEntryPusherService,
try { try {
fmb.setMatch(MatchUtils.fromString(match, fmb.getVersion())); fmb.setMatch(MatchUtils.fromString(match, fmb.getVersion()));
} catch (IllegalArgumentException e) { } 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; return;
} }
//sanjivini //sanjivini
......
...@@ -5,6 +5,7 @@ import java.util.List; ...@@ -5,6 +5,7 @@ import java.util.List;
import org.projectfloodlight.openflow.protocol.OFFactories; import org.projectfloodlight.openflow.protocol.OFFactories;
import org.projectfloodlight.openflow.protocol.OFFlowMod; 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.OFInstruction;
import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions; import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions;
import org.projectfloodlight.openflow.protocol.instruction.OFInstructionClearActions; import org.projectfloodlight.openflow.protocol.instruction.OFInstructionClearActions;
...@@ -88,6 +89,12 @@ public class InstructionUtils { ...@@ -88,6 +89,12 @@ public class InstructionUtils {
if (instStr == null || instStr.equals("")) { if (instStr == null || instStr.equals("")) {
return; 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 // Split into pairs of key=value
String[] keyValue = instStr.split("="); String[] keyValue = instStr.split("=");
if (keyValue.length != 2) { if (keyValue.length != 2) {
...@@ -129,6 +136,12 @@ public class InstructionUtils { ...@@ -129,6 +136,12 @@ public class InstructionUtils {
if (inst == null || inst.equals("")) { if (inst == null || inst.equals("")) {
return; 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 // Split into pairs of key=value
String[] tokens = inst.split(","); String[] tokens = inst.split(",");
if (tokens.length != 2) { if (tokens.length != 2) {
...@@ -181,6 +194,12 @@ public class InstructionUtils { ...@@ -181,6 +194,12 @@ public class InstructionUtils {
* @param log * @param log
*/ */
public static void writeActionsFromString(OFFlowMod.Builder fmb, String inst, Logger 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 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(); OFInstructionWriteActions.Builder ib = OFFactories.getFactory(fmb.getVersion()).instructions().buildWriteActions();
ActionUtils.fromString(tmpFmb, inst, log); ActionUtils.fromString(tmpFmb, inst, log);
...@@ -212,6 +231,12 @@ public class InstructionUtils { ...@@ -212,6 +231,12 @@ public class InstructionUtils {
* @param log * @param log
*/ */
public static void applyActionsFromString(OFFlowMod.Builder fmb, String inst, Logger 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(); OFFlowMod.Builder tmpFmb = OFFactories.getFactory(fmb.getVersion()).buildFlowModify();
OFInstructionApplyActions.Builder ib = OFFactories.getFactory(fmb.getVersion()).instructions().buildApplyActions(); OFInstructionApplyActions.Builder ib = OFFactories.getFactory(fmb.getVersion()).instructions().buildApplyActions();
ActionUtils.fromString(tmpFmb, inst, log); ActionUtils.fromString(tmpFmb, inst, log);
...@@ -243,6 +268,12 @@ public class InstructionUtils { ...@@ -243,6 +268,12 @@ public class InstructionUtils {
* @param log * @param log
*/ */
public static void clearActionsFromString(OFFlowMod.Builder fmb, String inst, Logger 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()) { if (inst != null && inst.isEmpty()) {
OFInstructionClearActions i = OFFactories.getFactory(fmb.getVersion()).instructions().clearActions(); OFInstructionClearActions i = OFFactories.getFactory(fmb.getVersion()).instructions().clearActions();
log.debug("Appending ClearActions instruction: {}", i); log.debug("Appending ClearActions instruction: {}", i);
...@@ -279,6 +310,11 @@ public class InstructionUtils { ...@@ -279,6 +310,11 @@ public class InstructionUtils {
if (inst == null || inst.isEmpty()) { if (inst == null || inst.isEmpty()) {
return; 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(); 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