Skip to content
Snippets Groups Projects
Commit 72a5a556 authored by sanjivininaikar's avatar sanjivininaikar
Browse files

Update StaticFlowEntries.java

Bugs fixed
parent b8f84411
No related branches found
No related tags found
No related merge requests found
...@@ -24,7 +24,6 @@ import java.util.Map; ...@@ -24,7 +24,6 @@ import java.util.Map;
import net.floodlightcontroller.core.annotations.LogMessageCategory; import net.floodlightcontroller.core.annotations.LogMessageCategory;
import net.floodlightcontroller.core.util.AppCookie; import net.floodlightcontroller.core.util.AppCookie;
import net.floodlightcontroller.staticflowentry.web.StaticFlowEntryPusherResource;
import net.floodlightcontroller.util.ActionUtils; import net.floodlightcontroller.util.ActionUtils;
import net.floodlightcontroller.util.InstructionUtils; import net.floodlightcontroller.util.InstructionUtils;
import net.floodlightcontroller.util.MatchUtils; import net.floodlightcontroller.util.MatchUtils;
...@@ -60,6 +59,9 @@ import org.projectfloodlight.openflow.types.U64; ...@@ -60,6 +59,9 @@ import org.projectfloodlight.openflow.types.U64;
public class StaticFlowEntries { public class StaticFlowEntries {
protected static Logger log = LoggerFactory.getLogger(StaticFlowEntries.class); protected static Logger log = LoggerFactory.getLogger(StaticFlowEntries.class);
private static final int INFINITE_TIMEOUT = 0; private static final int INFINITE_TIMEOUT = 0;
public static boolean ip6 = false;
public static boolean ip4 = false;
/** /**
* This function generates a random hash for the bottom half of the cookie * This function generates a random hash for the bottom half of the cookie
...@@ -341,7 +343,7 @@ public class StaticFlowEntries { ...@@ -341,7 +343,7 @@ public class StaticFlowEntries {
* @return The map of the storage entry * @return The map of the storage entry
* @throws IOException If there was an error parsing the JSON * @throws IOException If there was an error parsing the JSON
*/ */
public static Map<String, Object> jsonToStorageEntry(String fmJson) throws IOException, Exception { public static Map<String, Object> jsonToStorageEntry(String fmJson) throws IOException {
Map<String, Object> entry = new HashMap<String, Object>(); Map<String, Object> entry = new HashMap<String, Object>();
MappingJsonFactory f = new MappingJsonFactory(); MappingJsonFactory f = new MappingJsonFactory();
JsonParser jp; JsonParser jp;
...@@ -600,9 +602,7 @@ public class StaticFlowEntries { ...@@ -600,9 +602,7 @@ public class StaticFlowEntries {
} else { } else {
log.debug("Got IP protocol of '{}' and tp-src of '{}' and tp-dst of '" + tpDstPort + "' via SFP REST API", ipProto, tpSrcPort); log.debug("Got IP protocol of '{}' and tp-src of '{}' and tp-dst of '" + tpDstPort + "' via SFP REST API", ipProto, tpSrcPort);
} }
checkActions(entry);
if (!(checkActions(entry)))
throw new Exception("Invalid action/instructions");
return entry; return entry;
} }
...@@ -612,8 +612,11 @@ public class StaticFlowEntries { ...@@ -612,8 +612,11 @@ public class StaticFlowEntries {
* @return state indicating whether a flow is valid or not * @return state indicating whether a flow is valid or not
*/ */
private static boolean checkActions(Map<String, Object> entry) { private static boolean checkActions(Map<String, Object> entry) {
ip6 = false;
ip4 = false;
String actions = null; String actions = null;
if (entry.containsKey(StaticFlowEntryPusher.COLUMN_ACTIONS) || if (entry.containsKey(StaticFlowEntryPusher.COLUMN_ACTIONS) ||
entry.containsKey(StaticFlowEntryPusher.COLUMN_INSTR_APPLY_ACTIONS) || entry.containsKey(StaticFlowEntryPusher.COLUMN_INSTR_APPLY_ACTIONS) ||
entry.containsKey(StaticFlowEntryPusher.COLUMN_INSTR_WRITE_ACTIONS)) { entry.containsKey(StaticFlowEntryPusher.COLUMN_INSTR_WRITE_ACTIONS)) {
...@@ -630,17 +633,17 @@ public class StaticFlowEntries { ...@@ -630,17 +633,17 @@ public class StaticFlowEntries {
actions.contains(MatchUtils.STR_IPV6_DST) || actions.contains(MatchUtils.STR_IPV6_SRC) || actions.contains(MatchUtils.STR_IPV6_DST) || actions.contains(MatchUtils.STR_IPV6_SRC) ||
actions.contains(MatchUtils.STR_IPV6_FLOW_LABEL) || actions.contains(MatchUtils.STR_IPV6_ND_SSL) || actions.contains(MatchUtils.STR_IPV6_FLOW_LABEL) || actions.contains(MatchUtils.STR_IPV6_ND_SSL) ||
actions.contains(MatchUtils.STR_IPV6_ND_TARGET) || actions.contains(MatchUtils.STR_IPV6_ND_TTL)) { actions.contains(MatchUtils.STR_IPV6_ND_TARGET) || actions.contains(MatchUtils.STR_IPV6_ND_TTL)) {
StaticFlowEntryPusherResource.ip6 = true; ip6 = true;
} }
if (actions.contains(MatchUtils.STR_NW_SRC) || actions.contains(MatchUtils.STR_NW_DST) || if (actions.contains(MatchUtils.STR_NW_SRC) || actions.contains(MatchUtils.STR_NW_DST) ||
actions.contains(MatchUtils.STR_ARP_OPCODE) || actions.contains(MatchUtils.STR_ARP_SHA) || actions.contains(MatchUtils.STR_ARP_OPCODE) || actions.contains(MatchUtils.STR_ARP_SHA) ||
actions.contains(MatchUtils.STR_ARP_DHA) || actions.contains(MatchUtils.STR_ARP_SPA) || actions.contains(MatchUtils.STR_ARP_DHA) || actions.contains(MatchUtils.STR_ARP_SPA) ||
actions.contains(MatchUtils.STR_ARP_DPA) || actions.contains(MatchUtils.STR_ICMP_CODE) || actions.contains(MatchUtils.STR_ARP_DPA) || actions.contains(MatchUtils.STR_ICMP_CODE) ||
actions.contains(MatchUtils.STR_ICMP_TYPE)) { actions.contains(MatchUtils.STR_ICMP_TYPE)) {
StaticFlowEntryPusherResource.ip4 = true; ip4 = true;
} }
} }
if (StaticFlowEntryPusherResource.ip4 == true && StaticFlowEntryPusherResource.ip6 == true) { if (ip6 == true && ip4 == true) {
return false; return false;
} }
return true; return true;
......
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