Skip to content
Snippets Groups Projects
Commit de9a560f authored by Alex Reimers's avatar Alex Reimers
Browse files

Fix an issue with static flow entry pusher where it was not correctly computing the wildcard.

parent a842b011
No related branches found
No related tags found
No related merge requests found
...@@ -149,7 +149,7 @@ public class FloodlightModuleLoader { ...@@ -149,7 +149,7 @@ public class FloodlightModuleLoader {
prop.load(is); prop.load(is);
} catch (IOException e) { } catch (IOException e) {
logger.error("Error, could not load default modules"); logger.error("Error, could not load default modules");
e.printStackTrace(); logger.error(e.getMessage());
System.exit(1); System.exit(1);
} }
} }
......
...@@ -11,7 +11,7 @@ public interface IStaticFlowEntryPusherService extends IFloodlightService { ...@@ -11,7 +11,7 @@ public interface IStaticFlowEntryPusherService extends IFloodlightService {
* Adds a static flow. * Adds a static flow.
* @param name Name of the flow mod. Must be unique. * @param name Name of the flow mod. Must be unique.
* @param fm The flow to push. * @param fm The flow to push.
* @param swDpid The switch DPID to push it to. * @param swDpid The switch DPID to push it to, in 00:00:00:00:00:00:00:01 notation.
*/ */
public void addFlow(String name, OFFlowMod fm, String swDpid); public void addFlow(String name, OFFlowMod fm, String swDpid);
......
package net.floodlightcontroller.staticflowentry; package net.floodlightcontroller.staticflowentry;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
...@@ -46,6 +47,7 @@ public class StaticFlowEntries { ...@@ -46,6 +47,7 @@ public class StaticFlowEntries {
int len; int len;
} }
private static byte[] zeroMac = new byte[] {0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
/** /**
* 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
...@@ -131,22 +133,49 @@ public class StaticFlowEntries { ...@@ -131,22 +133,49 @@ public class StaticFlowEntries {
OFMatch match = fm.getMatch(); OFMatch match = fm.getMatch();
entry.put(StaticFlowEntryPusher.COLUMN_NAME, name); entry.put(StaticFlowEntryPusher.COLUMN_NAME, name);
entry.put(StaticFlowEntryPusher.COLUMN_SWITCH, sw); entry.put(StaticFlowEntryPusher.COLUMN_SWITCH, sw);
entry.put(StaticFlowEntryPusher.COLUMN_ACTIONS, StaticFlowEntries.flowModActionsToString(fm.getActions()));
entry.put(StaticFlowEntryPusher.COLUMN_PRIORITY, Short.toString(fm.getPriority()));
entry.put(StaticFlowEntryPusher.COLUMN_ACTIVE, Boolean.toString(true)); entry.put(StaticFlowEntryPusher.COLUMN_ACTIVE, Boolean.toString(true));
entry.put(StaticFlowEntryPusher.COLUMN_PRIORITY, Short.toString(fm.getPriority()));
entry.put(StaticFlowEntryPusher.COLUMN_WILDCARD, Integer.toString(match.getWildcards())); entry.put(StaticFlowEntryPusher.COLUMN_WILDCARD, Integer.toString(match.getWildcards()));
entry.put(StaticFlowEntryPusher.COLUMN_IN_PORT, Short.toString(match.getInputPort()));
entry.put(StaticFlowEntryPusher.COLUMN_DL_SRC, HexString.toHexString(match.getDataLayerSource())); if ((fm.getActions() != null) && (fm.getActions().size() > 0))
entry.put(StaticFlowEntryPusher.COLUMN_DL_DST, HexString.toHexString(match.getDataLayerDestination())); entry.put(StaticFlowEntryPusher.COLUMN_ACTIONS, StaticFlowEntries.flowModActionsToString(fm.getActions()));
entry.put(StaticFlowEntryPusher.COLUMN_DL_VLAN, Short.toString(match.getDataLayerVirtualLan()));
entry.put(StaticFlowEntryPusher.COLUMN_DL_VLAN_PCP, Short.toString(match.getDataLayerVirtualLanPriorityCodePoint())); if (match.getInputPort() != 0)
entry.put(StaticFlowEntryPusher.COLUMN_DL_TYPE, Short.toString(match.getDataLayerType())); entry.put(StaticFlowEntryPusher.COLUMN_IN_PORT, Short.toString(match.getInputPort()));
entry.put(StaticFlowEntryPusher.COLUMN_NW_TOS, Short.toString(match.getNetworkTypeOfService()));
entry.put(StaticFlowEntryPusher.COLUMN_NW_PROTO, Short.toString(match.getNetworkProtocol())); if (!Arrays.equals(match.getDataLayerSource(), zeroMac))
entry.put(StaticFlowEntryPusher.COLUMN_NW_SRC, IPv4.fromIPv4Address(match.getNetworkSource())); entry.put(StaticFlowEntryPusher.COLUMN_DL_SRC, HexString.toHexString(match.getDataLayerSource()));
entry.put(StaticFlowEntryPusher.COLUMN_NW_DST, IPv4.fromIPv4Address(match.getNetworkDestination()));
entry.put(StaticFlowEntryPusher.COLUMN_TP_SRC, Short.toString(match.getTransportSource())); if (!Arrays.equals(match.getDataLayerDestination(), zeroMac))
entry.put(StaticFlowEntryPusher.COLUMN_TP_DST, Short.toString(match.getTransportDestination())); entry.put(StaticFlowEntryPusher.COLUMN_DL_DST, HexString.toHexString(match.getDataLayerDestination()));
if (match.getDataLayerVirtualLan() != -1)
entry.put(StaticFlowEntryPusher.COLUMN_DL_VLAN, Short.toString(match.getDataLayerVirtualLan()));
if (match.getDataLayerVirtualLanPriorityCodePoint() != 0)
entry.put(StaticFlowEntryPusher.COLUMN_DL_VLAN_PCP, Short.toString(match.getDataLayerVirtualLanPriorityCodePoint()));
if (match.getDataLayerType() != 0)
entry.put(StaticFlowEntryPusher.COLUMN_DL_TYPE, Short.toString(match.getDataLayerType()));
if (match.getNetworkTypeOfService() != 0)
entry.put(StaticFlowEntryPusher.COLUMN_NW_TOS, Short.toString(match.getNetworkTypeOfService()));
if (match.getNetworkProtocol() != 0)
entry.put(StaticFlowEntryPusher.COLUMN_NW_PROTO, Short.toString(match.getNetworkProtocol()));
if (match.getNetworkSource() != 0)
entry.put(StaticFlowEntryPusher.COLUMN_NW_SRC, IPv4.fromIPv4Address(match.getNetworkSource()));
if (match.getNetworkDestination() != 0)
entry.put(StaticFlowEntryPusher.COLUMN_NW_DST, IPv4.fromIPv4Address(match.getNetworkDestination()));
if (match.getTransportSource() != 0)
entry.put(StaticFlowEntryPusher.COLUMN_TP_SRC, Short.toString(match.getTransportSource()));
if (match.getTransportDestination() != 0)
entry.put(StaticFlowEntryPusher.COLUMN_TP_DST, Short.toString(match.getTransportDestination()));
return entry; return entry;
} }
......
...@@ -115,9 +115,18 @@ public class OFMatch implements Cloneable, Serializable { ...@@ -115,9 +115,18 @@ public class OFMatch implements Cloneable, Serializable {
*/ */
public OFMatch() { public OFMatch() {
this.wildcards = OFPFW_ALL; this.wildcards = OFPFW_ALL;
this.dataLayerDestination = new byte[6]; this.dataLayerDestination = new byte[] {0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
this.dataLayerSource = new byte[6]; this.dataLayerSource = new byte[] {0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
this.dataLayerVirtualLan = -1; this.dataLayerVirtualLan = -1;
this.dataLayerVirtualLanPriorityCodePoint = 0;
this.dataLayerType = 0;
this.inputPort = 0;
this.networkProtocol = 0;
this.networkTypeOfService = 0;
this.networkSource = 0;
this.networkDestination = 0;
this.transportDestination = 0;
this.transportSource = 0;
} }
/** /**
...@@ -840,16 +849,13 @@ public class OFMatch implements Cloneable, Serializable { ...@@ -840,16 +849,13 @@ public class OFMatch implements Cloneable, Serializable {
if (values[0].equals(STR_IN_PORT) || values[0].equals("input_port")) { if (values[0].equals(STR_IN_PORT) || values[0].equals("input_port")) {
this.inputPort = U16.t(Integer.valueOf(values[1])); this.inputPort = U16.t(Integer.valueOf(values[1]));
this.wildcards &= ~OFPFW_IN_PORT; this.wildcards &= ~OFPFW_IN_PORT;
} else if (values[0].equals(STR_DL_DST) } else if (values[0].equals(STR_DL_DST) || values[0].equals("eth_dst")) {
|| values[0].equals("eth_dst")) {
this.dataLayerDestination = HexString.fromHexString(values[1]); this.dataLayerDestination = HexString.fromHexString(values[1]);
this.wildcards &= ~OFPFW_DL_DST; this.wildcards &= ~OFPFW_DL_DST;
} else if (values[0].equals(STR_DL_SRC) } else if (values[0].equals(STR_DL_SRC) || values[0].equals("eth_src")) {
|| values[0].equals("eth_src")) {
this.dataLayerSource = HexString.fromHexString(values[1]); this.dataLayerSource = HexString.fromHexString(values[1]);
this.wildcards &= ~OFPFW_DL_SRC; this.wildcards &= ~OFPFW_DL_SRC;
} else if (values[0].equals(STR_DL_TYPE) } else if (values[0].equals(STR_DL_TYPE) || values[0].equals("eth_type")) {
|| values[0].equals("eth_type")) {
if (values[1].startsWith("0x")) if (values[1].startsWith("0x"))
this.dataLayerType = U16.t(Integer.valueOf( this.dataLayerType = U16.t(Integer.valueOf(
values[1].replaceFirst("0x", ""), 16)); values[1].replaceFirst("0x", ""), 16));
...@@ -867,12 +873,11 @@ public class OFMatch implements Cloneable, Serializable { ...@@ -867,12 +873,11 @@ public class OFMatch implements Cloneable, Serializable {
this.dataLayerVirtualLanPriorityCodePoint = U8.t(Short this.dataLayerVirtualLanPriorityCodePoint = U8.t(Short
.valueOf(values[1])); .valueOf(values[1]));
this.wildcards &= ~OFPFW_DL_VLAN_PCP; this.wildcards &= ~OFPFW_DL_VLAN_PCP;
} else if (values[0].equals(STR_NW_DST) } else if (values[0].equals(STR_NW_DST) || values[0].equals("ip_dst")) {
|| values[0].equals("ip_dst"))
setFromCIDR(values[1], STR_NW_DST); setFromCIDR(values[1], STR_NW_DST);
else if (values[0].equals(STR_NW_SRC) || values[0].equals("ip_src")) } else if (values[0].equals(STR_NW_SRC) || values[0].equals("ip_src")) {
setFromCIDR(values[1], STR_NW_SRC); setFromCIDR(values[1], STR_NW_SRC);
else if (values[0].equals(STR_NW_PROTO)) { } else if (values[0].equals(STR_NW_PROTO)) {
this.networkProtocol = U8.t(Short.valueOf(values[1])); this.networkProtocol = U8.t(Short.valueOf(values[1]));
this.wildcards &= ~OFPFW_NW_PROTO; this.wildcards &= ~OFPFW_NW_PROTO;
} else if (values[0].equals(STR_NW_TOS)) { } else if (values[0].equals(STR_NW_TOS)) {
...@@ -884,9 +889,10 @@ public class OFMatch implements Cloneable, Serializable { ...@@ -884,9 +889,10 @@ public class OFMatch implements Cloneable, Serializable {
} else if (values[0].equals(STR_TP_SRC)) { } else if (values[0].equals(STR_TP_SRC)) {
this.transportSource = U16.t(Integer.valueOf(values[1])); this.transportSource = U16.t(Integer.valueOf(values[1]));
this.wildcards &= ~OFPFW_TP_SRC; this.wildcards &= ~OFPFW_TP_SRC;
} else } else {
throw new IllegalArgumentException("unknown token " + tokens[i] throw new IllegalArgumentException("unknown token " + tokens[i]
+ " parsing " + match); + " parsing " + match);
}
} }
} }
......
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