Skip to content

Commit

Permalink
Merge branch 'sanjivininaikar-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Izard committed Dec 23, 2014
2 parents 70a1426 + 4dce73e commit 579469c
Show file tree
Hide file tree
Showing 7 changed files with 735 additions and 325 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,21 @@
import org.projectfloodlight.openflow.protocol.oxm.OFOxmEthType;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmIcmpv4Code;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmIcmpv4Type;

import org.projectfloodlight.openflow.protocol.oxm.OFOxmIcmpv6Code;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmIcmpv6Type;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpDscp;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpEcn;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpProto;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpv4Dst;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpv4Src;

import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpv6Dst;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpv6Flabel;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpv6NdSll;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpv6NdTarget;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpv6NdTll;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpv6Src;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmMetadata;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmMplsBos;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmMplsLabel;
Expand Down Expand Up @@ -203,7 +213,13 @@ public static void serializeActions(JsonGenerator jsonGenerator, List<OFAction>
jsonGenerator.writeStringField(MatchUtils.STR_ARP_SPA, ((OFOxmArpSpa) ((OFActionSetField) a).getField()).getValue().toString()); // ipaddress formats string already
} else if (((OFActionSetField)a).getField() instanceof OFOxmArpTpa) {
jsonGenerator.writeStringField(MatchUtils.STR_ARP_DPA, ((OFOxmArpTpa) ((OFActionSetField) a).getField()).getValue().toString());
}
} else if (((OFActionSetField)a).getField() instanceof OFOxmIpv6NdSll) {
jsonGenerator.writeStringField(MatchUtils.STR_IPV6_ND_SSL, ((OFOxmIpv6NdSll) ((OFActionSetField) a).getField()).getValue().toString());
} else if (((OFActionSetField)a).getField() instanceof OFOxmIpv6NdTll) {
jsonGenerator.writeStringField(MatchUtils.STR_IPV6_ND_TTL, ((OFOxmIpv6NdTll) ((OFActionSetField) a).getField()).getValue().toString());
} else if (((OFActionSetField)a).getField() instanceof OFOxmIpv6NdTarget) {
jsonGenerator.writeStringField(MatchUtils.STR_IPV6_ND_TARGET, ((OFOxmIpv6NdTarget) ((OFActionSetField) a).getField()).getValue().toString());
}
/* DATA LAYER */
else if (((OFActionSetField)a).getField() instanceof OFOxmEthType) {
jsonGenerator.writeNumberField(MatchUtils.STR_DL_TYPE, ((OFOxmEthType) ((OFActionSetField) a).getField()).getValue().getValue());
Expand All @@ -220,15 +236,25 @@ else if (((OFActionSetField)a).getField() instanceof OFOxmIcmpv4Code) {
jsonGenerator.writeNumberField(MatchUtils.STR_ICMP_CODE, ((OFOxmIcmpv4Code) ((OFActionSetField) a).getField()).getValue().getCode());
} else if (((OFActionSetField)a).getField() instanceof OFOxmIcmpv4Type) {
jsonGenerator.writeNumberField(MatchUtils.STR_ICMP_TYPE, ((OFOxmIcmpv4Type) ((OFActionSetField) a).getField()).getValue().getType());
}
} else if (((OFActionSetField)a).getField() instanceof OFOxmIcmpv6Code) {
jsonGenerator.writeNumberField(MatchUtils.STR_ICMPV6_CODE, ((OFOxmIcmpv6Code) ((OFActionSetField) a).getField()).getValue().getRaw());
} else if (((OFActionSetField)a).getField() instanceof OFOxmIcmpv6Type) {
jsonGenerator.writeNumberField(MatchUtils.STR_ICMPV6_TYPE, ((OFOxmIcmpv6Type) ((OFActionSetField) a).getField()).getValue().getRaw());
}
/* NETWORK LAYER */
else if (((OFActionSetField)a).getField() instanceof OFOxmIpProto) {
jsonGenerator.writeNumberField(MatchUtils.STR_NW_PROTO, ((OFOxmIpProto) ((OFActionSetField) a).getField()).getValue().getIpProtocolNumber());
} else if (((OFActionSetField)a).getField() instanceof OFOxmIpv4Src) {
jsonGenerator.writeStringField(MatchUtils.STR_NW_SRC, ((OFOxmIpv4Src) ((OFActionSetField) a).getField()).getValue().toString());
} else if (((OFActionSetField)a).getField() instanceof OFOxmIpv4Dst) {
jsonGenerator.writeStringField(MatchUtils.STR_NW_DST, ((OFOxmIpv4Dst) ((OFActionSetField) a).getField()).getValue().toString());
} else if (((OFActionSetField)a).getField() instanceof OFOxmIpEcn) {
} else if (((OFActionSetField)a).getField() instanceof OFOxmIpv6Src) {
jsonGenerator.writeStringField(MatchUtils.STR_IPV6_SRC, ((OFOxmIpv6Src) ((OFActionSetField) a).getField()).getValue().toString());
} else if (((OFActionSetField)a).getField() instanceof OFOxmIpv6Dst) {
jsonGenerator.writeStringField(MatchUtils.STR_IPV6_DST, ((OFOxmIpv6Dst) ((OFActionSetField) a).getField()).getValue().toString());
} else if (((OFActionSetField)a).getField() instanceof OFOxmIpv6Flabel) {
jsonGenerator.writeStringField(MatchUtils.STR_IPV6_FLOW_LABEL, ((OFOxmIpv6Flabel) ((OFActionSetField) a).getField()).getValue().toString());
} else if (((OFActionSetField)a).getField() instanceof OFOxmIpEcn) {
jsonGenerator.writeNumberField(MatchUtils.STR_NW_ECN, ((OFOxmIpEcn) ((OFActionSetField) a).getField()).getValue().getEcnValue());
} else if (((OFActionSetField)a).getField() instanceof OFOxmIpDscp) {
jsonGenerator.writeNumberField(MatchUtils.STR_NW_DSCP, ((OFOxmIpDscp) ((OFActionSetField) a).getField()).getValue().getDscpValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import net.floodlightcontroller.core.annotations.LogMessageCategory;
import net.floodlightcontroller.core.util.AppCookie;
import net.floodlightcontroller.staticflowentry.web.StaticFlowEntryPusherResource;
import net.floodlightcontroller.util.ActionUtils;
import net.floodlightcontroller.util.InstructionUtils;

Expand Down Expand Up @@ -137,7 +138,7 @@ public static String getEntryNameFromJson(String fmJson) throws IOException{
* @param name The name of this static flow entry
* @return A Map representation of the storage entry
*/
public static Map<String, Object> flowModToStorageEntry(OFFlowMod fm, String sw, String name) {
public static Map<String, Object> flowModToStorageEntry(OFFlowMod fm, String sw, String name) throws Exception {
Map<String, Object> entry = new HashMap<String, Object>();
entry.put(StaticFlowEntryPusher.COLUMN_NAME, name);
entry.put(StaticFlowEntryPusher.COLUMN_SWITCH, sw);
Expand Down Expand Up @@ -271,6 +272,35 @@ public static Map<String, Object> flowModToStorageEntry(OFFlowMod fm, String sw,
case ARP_TPA:
entry.put(StaticFlowEntryPusher.COLUMN_ARP_DPA, match.get(MatchField.ARP_TPA).toString());
break;

//sanjivini
case IPV6_SRC:
entry.put(StaticFlowEntryPusher.COLUMN_NW6_SRC, match.get(MatchField.IPV6_SRC).toString());
break;
case IPV6_DST:
entry.put(StaticFlowEntryPusher.COLUMN_NW6_DST, match.get(MatchField.IPV6_DST).toString());
break;
case IPV6_FLABEL:
entry.put(StaticFlowEntryPusher.COLUMN_IPV6_FLOW_LABEL, match.get(MatchField.IPV6_FLABEL).toString());
break;
case ICMPV6_TYPE:
entry.put(StaticFlowEntryPusher.COLUMN_ICMP6_TYPE, String.valueOf(match.get(MatchField.ICMPV6_TYPE).getValue()));
break;
case ICMPV6_CODE:
entry.put(StaticFlowEntryPusher.COLUMN_ICMP6_CODE, match.get(MatchField.ICMPV6_CODE).getValue());
break;
case IPV6_ND_SLL:
entry.put(StaticFlowEntryPusher.COLUMN_ND_SLL, match.get(MatchField.IPV6_ND_SLL).toString());
break;
case IPV6_ND_TLL:
entry.put(StaticFlowEntryPusher.COLUMN_ND_TLL, match.get(MatchField.IPV6_ND_TLL).toString());
break;
case IPV6_ND_TARGET:
entry.put(StaticFlowEntryPusher.COLUMN_ND_TARGET, match.get(MatchField.IPV6_ND_TARGET).toString());
break;

//sanjivini

case MPLS_LABEL:
entry.put(StaticFlowEntryPusher.COLUMN_MPLS_LABEL, match.get(MatchField.MPLS_LABEL).getValue());
break;
Expand All @@ -293,6 +323,10 @@ public static Map<String, Object> flowModToStorageEntry(OFFlowMod fm, String sw,
} // end switch-case
} // end while

int result = StaticFlowEntryPusherResource.checkActions(entry);
if (result == -1)
throw new Exception("Invalid action/instructions");

return entry;
}

Expand Down Expand Up @@ -458,6 +492,34 @@ public static Map<String, Object> jsonToStorageEntry(String fmJson) throws IOExc
case StaticFlowEntryPusher.COLUMN_ARP_DPA:
entry.put(StaticFlowEntryPusher.COLUMN_ARP_DPA, jp.getText());
break;

//sanjivini
case StaticFlowEntryPusher.COLUMN_NW6_SRC:
entry.put(StaticFlowEntryPusher.COLUMN_NW6_SRC, jp.getText());
break;
case StaticFlowEntryPusher.COLUMN_NW6_DST:
entry.put(StaticFlowEntryPusher.COLUMN_NW6_DST, jp.getText());
break;
case StaticFlowEntryPusher.COLUMN_IPV6_FLOW_LABEL:
entry.put(StaticFlowEntryPusher.COLUMN_IPV6_FLOW_LABEL, jp.getText());
break;
case StaticFlowEntryPusher.COLUMN_ICMP6_TYPE:
entry.put(StaticFlowEntryPusher.COLUMN_ICMP6_TYPE, jp.getText());
break;
case StaticFlowEntryPusher.COLUMN_ICMP6_CODE:
entry.put(StaticFlowEntryPusher.COLUMN_ICMP6_CODE, jp.getText());
break;
case StaticFlowEntryPusher.COLUMN_ND_SLL:
entry.put(StaticFlowEntryPusher.COLUMN_ND_SLL, jp.getText());
break;
case StaticFlowEntryPusher.COLUMN_ND_TLL:
entry.put(StaticFlowEntryPusher.COLUMN_ND_TLL, jp.getText());
break;
case StaticFlowEntryPusher.COLUMN_ND_TARGET:
entry.put(StaticFlowEntryPusher.COLUMN_ND_TARGET, jp.getText());
break;
//sanjivini

case StaticFlowEntryPusher.COLUMN_MPLS_LABEL:
entry.put(StaticFlowEntryPusher.COLUMN_MPLS_LABEL, jp.getText());
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,18 @@ public class StaticFlowEntryPusher
public static final String COLUMN_ARP_DHA = MatchUtils.STR_ARP_DHA;
public static final String COLUMN_ARP_SPA = MatchUtils.STR_ARP_SPA;
public static final String COLUMN_ARP_DPA = MatchUtils.STR_ARP_DPA;

//sanjivini
//IPv6 related columns
public static final String COLUMN_NW6_SRC = MatchUtils.STR_IPV6_SRC;
public static final String COLUMN_NW6_DST = MatchUtils.STR_IPV6_DST;
public static final String COLUMN_IPV6_FLOW_LABEL = MatchUtils.STR_IPV6_FLOW_LABEL;
public static final String COLUMN_ICMP6_TYPE = MatchUtils.STR_ICMPV6_TYPE;
public static final String COLUMN_ICMP6_CODE = MatchUtils.STR_ICMPV6_CODE;
public static final String COLUMN_ND_SLL = MatchUtils.STR_IPV6_ND_SSL;
public static final String COLUMN_ND_TLL = MatchUtils.STR_IPV6_ND_TTL;
public static final String COLUMN_ND_TARGET = MatchUtils.STR_IPV6_ND_TARGET;
//sanjivini

public static final String COLUMN_MPLS_LABEL = MatchUtils.STR_MPLS_LABEL;
public static final String COLUMN_MPLS_TC = MatchUtils.STR_MPLS_TC;
Expand Down Expand Up @@ -164,6 +176,13 @@ public class StaticFlowEntryPusher
COLUMN_ICMP_TYPE, COLUMN_ICMP_CODE,
COLUMN_ARP_OPCODE, COLUMN_ARP_SHA, COLUMN_ARP_DHA,
COLUMN_ARP_SPA, COLUMN_ARP_DPA,

//sanjivini
//IPv6 related matches
COLUMN_NW6_SRC, COLUMN_NW6_DST, COLUMN_ICMP6_TYPE, COLUMN_ICMP6_CODE,
COLUMN_IPV6_FLOW_LABEL, COLUMN_ND_SLL, COLUMN_ND_TLL, COLUMN_ND_TARGET,
//sanjivini

COLUMN_MPLS_LABEL, COLUMN_MPLS_TC, COLUMN_MPLS_BOS,
COLUMN_METADATA, COLUMN_TUNNEL_ID, COLUMN_PBB_ISID,
/* end newly added matches */
Expand Down Expand Up @@ -408,6 +427,13 @@ void parseRow(Map<String, Object> row, Map<String, Map<String, OFFlowMod>> entri
log.debug("ignoring flow entry {} on switch {} with illegal OFMatch() key: " + match, entryName, switchName);
return;
}
//sanjivini
catch (Exception e) {
log.error("OF version incompatible for the match: " + match);
e.printStackTrace();
return;
}
//sanjivini

entries.get(switchName).put(entryName, fmb.build()); // add the FlowMod message to the table
}
Expand Down Expand Up @@ -754,8 +780,13 @@ public void startUp(FloodlightModuleContext context) {

@Override
public void addFlow(String name, OFFlowMod fm, DatapathId swDpid) {
Map<String, Object> fmMap = StaticFlowEntries.flowModToStorageEntry(fm, swDpid.toString(), name);
storageSourceService.insertRowAsync(TABLE_NAME, fmMap);
try {
Map<String, Object> fmMap = StaticFlowEntries.flowModToStorageEntry(fm, swDpid.toString(), name);
storageSourceService.insertRowAsync(TABLE_NAME, fmMap);
} catch (Exception e) {
log.error("Error! Check the fields specified for the flow.Make sure IPv4 fields are not mixed with IPv6 fields or all "
+ "mandatory fields are specified. ");
}
}

@Override
Expand Down
Loading

0 comments on commit 579469c

Please sign in to comment.